feat(web): cada documento de ventas y compras puede elegir sus columnas de línea y su cabecera
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c5368c7ad0
commit
1f212e2b30
5 files changed
+91
-14
No files matched your search
@@ -5,9 +5,10 @@ import { ActivatedRoute, Router, convertToParamMap, provideRouter } from '@angul
|
||||
import { of } from 'rxjs';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { purchaseRequestLayout } from './compras/compras.layouts';
|
||||
import { hasFolio, headerKeysOf } from './document-layouts';
|
||||
import { hasFolio, headerKeysOf, marketingLayout } from './document-layouts';
|
||||
import { LINE_COLUMNS, lineFieldsOf } from './line-columns';
|
||||
import { transferRequestLayout } from './inventario/inventario.layouts';
|
||||
import { createPayload, updatePayload, validateLayout } from './document-model';
|
||||
import { MARKETING_LINES, createPayload, updatePayload, validateLayout } from './document-model';
|
||||
import { DocumentFormPage } from './document-form.page';
|
||||
import { DOCUMENT_SCREENS } from './document-screens';
|
||||
|
||||
@@ -198,3 +199,40 @@ describe('DocumentFormPage de inventario', () => {
|
||||
ctrl.expectOne('/api/sl/InventoryTransferRequests/471').flush({});
|
||||
});
|
||||
});
|
||||
|
||||
describe('columnas de línea por documento', () => {
|
||||
const base = { partnerLabel: 'Cliente', taxResource: 'SalesTaxCodes' };
|
||||
|
||||
it('sin elegir, el documento lleva todas las columnas y envía los mismos campos de siempre', () => {
|
||||
const l = marketingLayout(base);
|
||||
expect(l.columns.map((c) => c.key)).toEqual([
|
||||
'ItemCode', 'ItemDescription', 'Quantity', 'WarehouseCode', 'Price', 'DiscountPercent', 'TaxCode', 'LineTotal',
|
||||
]);
|
||||
expect(l.lines.fields).toEqual(MARKETING_LINES.fields);
|
||||
});
|
||||
|
||||
it('un documento elige sus columnas y el orden; los campos enviados salen de ellas', () => {
|
||||
const { item, description, quantity, warehouse } = LINE_COLUMNS;
|
||||
const l = marketingLayout({ ...base, lineColumns: [item, description, quantity, warehouse] });
|
||||
expect(l.columns.map((c) => c.key)).toEqual(['ItemCode', 'ItemDescription', 'Quantity', 'WarehouseCode']);
|
||||
expect(l.lines.fields).toEqual(['ItemCode', 'ItemDescription', 'Quantity', 'WarehouseCode']);
|
||||
const body = createPayload({ CardCode: 'C1' }, [{ ItemCode: 'A', Quantity: 1, WarehouseCode: '01', Price: 9, TaxCode: 'IVA' }], l.lines);
|
||||
expect(body['DocumentLines']).toEqual([{ ItemCode: 'A', Quantity: 1, WarehouseCode: '01' }]);
|
||||
});
|
||||
|
||||
it('el total y los campos calculados no se envían', () => {
|
||||
expect(lineFieldsOf([LINE_COLUMNS.price, LINE_COLUMNS.total])).toEqual(['Price']);
|
||||
});
|
||||
|
||||
it('un documento puede traer su cabecera completa en lugar de la base', () => {
|
||||
const l = marketingLayout({ ...base, header: { left: [], right: [] } });
|
||||
expect(headerKeysOf(l)).toEqual(['Comments', 'DiscountPercent']);
|
||||
});
|
||||
|
||||
it('los demás documentos no cambian cuando uno elige columnas', () => {
|
||||
const custom = marketingLayout({ ...base, lineColumns: [LINE_COLUMNS.item] });
|
||||
const other = marketingLayout(base);
|
||||
expect(custom.columns).toHaveLength(1);
|
||||
expect(other.columns).toHaveLength(8);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user