feat(web): documentos de ventas y compras con tipo Artículo / Servicio (columnas de línea, validación, guardado y copiado)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
68d2cfe6d0
commit
2e74bccd65
11 files changed
+260
-25
No files matched your search
@@ -190,3 +190,28 @@ describe('flete (gastos adicionales)', () => {
|
||||
expect(freightPayload({ FreightAmount: 0 }, { FreightAmount: 0 }, '2', 'update', false).body).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe('documentos de servicio', () => {
|
||||
const service = { key: 'DocumentLines', fields: ['AccountCode', 'ItemDescription', 'TaxCode', 'LineTotal'], base: true, service: true };
|
||||
|
||||
it('una línea de servicio vacía no tiene cuenta, descripción ni total', () => {
|
||||
expect(isBlankLine({ AccountCode: '', ItemDescription: '', LineTotal: 0 }, true)).toBe(true);
|
||||
expect(isBlankLine({ AccountCode: '_SYS1', LineTotal: 0 }, true)).toBe(false);
|
||||
expect(isBlankLine({ ItemDescription: 'Alquiler', LineTotal: 0 }, true)).toBe(false);
|
||||
expect(isBlankLine({ ItemCode: '', LineTotal: 0 }, false)).toBe(true);
|
||||
});
|
||||
|
||||
it('exige al menos una línea con cuenta y que cada una tenga cuenta y total', () => {
|
||||
expect(validateLayout({}, [], [], [], true)).toEqual(['Agregue al menos una línea con cuenta contable.']);
|
||||
expect(validateLayout({}, [{ ItemDescription: 'x', LineTotal: 0 }], [], [], true)).toEqual([
|
||||
'Línea 1: indique la cuenta contable.',
|
||||
'Línea 1: el total debe ser mayor que cero.',
|
||||
]);
|
||||
expect(validateLayout({}, [{ AccountCode: '_SYS1', LineTotal: 50 }], [], [], true)).toEqual([]);
|
||||
});
|
||||
|
||||
it('envía solo los campos de servicio, sin cantidad ni artículo', () => {
|
||||
const body = createPayload({ DocType: 'dDocument_Service', CardCode: 'P1' }, [{ AccountCode: '_SYS1', ItemDescription: 'Alquiler', TaxCode: 'IGV', LineTotal: 100, Quantity: 1, ItemCode: '' }, { AccountCode: '', LineTotal: 0 }], service);
|
||||
expect(body['DocumentLines']).toEqual([{ AccountCode: '_SYS1', ItemDescription: 'Alquiler', TaxCode: 'IGV', LineTotal: 100 }]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user