fix(web): ventas y compras envían la unidad de medida del artículo (UoMEntry)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0d5a3074c8
commit
d3ab97cd2e
7 files changed
+71
-20
No files matched your search
@@ -201,21 +201,21 @@ describe('DocumentFormPage de inventario', () => {
|
||||
});
|
||||
|
||||
describe('columnas de línea por documento', () => {
|
||||
const base = { partnerLabel: 'Cliente', taxResource: 'SalesTaxCodes' };
|
||||
const base = { partnerLabel: 'Cliente', taxResource: 'SalesTaxCodes', uom: 'sales' } as const;
|
||||
|
||||
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);
|
||||
expect(l.lines.fields).toEqual([...MARKETING_LINES.fields, 'UoMEntry']);
|
||||
});
|
||||
|
||||
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']);
|
||||
expect(l.lines.fields).toEqual(['ItemCode', 'ItemDescription', 'Quantity', 'WarehouseCode', 'UoMEntry']);
|
||||
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' }]);
|
||||
});
|
||||
@@ -236,3 +236,36 @@ describe('columnas de línea por documento', () => {
|
||||
expect(other.columns).toHaveLength(8);
|
||||
});
|
||||
});
|
||||
|
||||
describe('unidad de medida en ventas y compras', () => {
|
||||
const item = { ItemCode: 'SU01', ItemName: 'Sutura', UoMGroupEntry: 1, InventoryUoMEntry: 1, DefaultPurchasingUoMEntry: null, DefaultSalesUoMEntry: 2 };
|
||||
const pick = (uom: 'sales' | 'purchase', picked: Record<string, unknown>, line: Record<string, unknown> = {}) =>
|
||||
marketingLayout({ partnerLabel: 'Cliente', taxResource: 'SalesTaxCodes', uom })
|
||||
.columns.find((c) => c.key === 'ItemCode')!
|
||||
.lookup!.apply(picked, line);
|
||||
|
||||
it('al elegir un artículo la línea toma su unidad: la de venta en ventas, la de compra en compras', () => {
|
||||
expect(pick('sales', item)).toMatchObject({ ItemCode: 'SU01', UoMEntry: 2 });
|
||||
expect(pick('purchase', item)).toMatchObject({ ItemCode: 'SU01', UoMEntry: 1 }); // sin unidad de compra: la de inventario
|
||||
});
|
||||
|
||||
it('un artículo de unidad manual no lleva unidad, y al cambiar de artículo no arrastra la anterior', () => {
|
||||
const manual = { ItemCode: 'M1', UoMGroupEntry: -1, InventoryUoMEntry: -1 };
|
||||
expect(pick('purchase', manual, { ItemCode: 'SU01', UoMEntry: 1 })['UoMEntry']).toBeUndefined();
|
||||
});
|
||||
|
||||
it('la unidad se envía a SAP solo si es válida (la manual, -1, no)', () => {
|
||||
const l = marketingLayout({ partnerLabel: 'Cliente', taxResource: 'SalesTaxCodes', uom: 'purchase' });
|
||||
const body = createPayload({}, [{ ItemCode: 'A', Quantity: 1, UoMEntry: 3 }, { ItemCode: 'B', Quantity: 1, UoMEntry: -1 }], l.lines);
|
||||
expect(body['DocumentLines']).toEqual([
|
||||
{ ItemCode: 'A', Quantity: 1, UoMEntry: 3 },
|
||||
{ ItemCode: 'B', Quantity: 1 },
|
||||
]);
|
||||
});
|
||||
|
||||
it('cada pantalla toma la unidad de su lado', () => {
|
||||
const ap = (path: string) => DOCUMENT_SCREENS.find((s) => s.path === path)!.layout.columns.find((c) => c.key === 'ItemCode')!.lookup!.apply(item, {});
|
||||
expect(ap('/ventas/ordenes')['UoMEntry']).toBe(2);
|
||||
expect(ap('/compras/ordenes')['UoMEntry']).toBe(1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user