feat(web): copiar de / a entre documentos de ventas y compras
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cafe4bc035
commit
29e80181fe
8 files changed
+383
-6
No files matched your search
@@ -0,0 +1,62 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { COPY_FLOWS, OBJECT_TYPES, copyFromDocument, copySources, copyTargets } from './document-copy';
|
||||
import { DOCUMENT_SCREENS } from './document-screens';
|
||||
|
||||
describe('flujos de copiado', () => {
|
||||
it('cada documento del flujo existe como pantalla y tiene tipo de objeto', () => {
|
||||
const paths = new Set(DOCUMENT_SCREENS.map((s) => s.path));
|
||||
for (const [from, to] of Object.entries(COPY_FLOWS)) {
|
||||
for (const p of [from, ...to]) {
|
||||
expect(paths.has(p), p).toBe(true);
|
||||
expect(OBJECT_TYPES[p], p).toBeGreaterThan(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('solo ventas con ventas y compras con compras', () => {
|
||||
for (const [from, to] of Object.entries(COPY_FLOWS)) {
|
||||
for (const p of to) expect(p.split('/')[1], `${from} → ${p}`).toBe(from.split('/')[1]);
|
||||
}
|
||||
});
|
||||
|
||||
it('copiar a / copiar de son los dos lados del mismo flujo', () => {
|
||||
expect(copyTargets('/ventas/ordenes')).toEqual(['/ventas/entrega', '/ventas/facturas']);
|
||||
expect(copySources('/ventas/facturas')).toEqual(['/ventas/ofertas', '/ventas/ordenes', '/ventas/entrega']);
|
||||
expect(copyTargets('/ventas/notas-credito')).toEqual([]);
|
||||
expect(copySources('/ventas/ofertas')).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('copyFromDocument', () => {
|
||||
const source = {
|
||||
DocEntry: 315,
|
||||
DocNum: 1315,
|
||||
CardCode: 'C1',
|
||||
NumAtCard: 'REF',
|
||||
DiscountPercent: 5,
|
||||
DocumentLines: [
|
||||
{ LineNum: 0, ItemCode: 'A1', ItemDescription: 'Pieza', Quantity: 5, RemainingOpenQuantity: 3, WarehouseCode: '01', Price: 100, DiscountPercent: 0, TaxCode: 'IVA', LineStatus: 'bost_Open' },
|
||||
{ LineNum: 1, ItemCode: 'B2', Quantity: 2, RemainingOpenQuantity: 0, LineStatus: 'bost_Close' },
|
||||
{ LineNum: 2, ItemCode: 'C3', ItemDescription: 'Otra', Quantity: 1, Price: 10, LineStatus: 'bost_Open' },
|
||||
],
|
||||
};
|
||||
|
||||
it('copia las líneas abiertas con la cantidad pendiente y la referencia al origen', () => {
|
||||
const c = copyFromDocument(source, '/ventas/ordenes', 'Órdenes de venta');
|
||||
expect(c.skipped).toBe(1);
|
||||
expect(c.lines).toHaveLength(2);
|
||||
expect(c.lines[0]).toMatchObject({
|
||||
ItemCode: 'A1', Quantity: 3, Price: 100, LineTotal: 300, BaseType: 17, BaseEntry: 315, BaseLine: 0,
|
||||
});
|
||||
expect(c.lines[1]).toMatchObject({ ItemCode: 'C3', Quantity: 1, BaseLine: 2 });
|
||||
});
|
||||
|
||||
it('copia socio, referencia y descuento, y deja el origen en el comentario', () => {
|
||||
expect(copyFromDocument(source, '/ventas/ordenes', 'Órdenes de venta').header).toEqual({
|
||||
CardCode: 'C1',
|
||||
NumAtCard: 'REF',
|
||||
DiscountPercent: 5,
|
||||
Comments: 'Basado en órdenes de venta 1315.',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user