feat: redondeo en el pie de los documentos de ventas y compras (visible según OADM.RoundMthd) y endpoint /api/company/settings

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
GeorgeandClaude Sonnet 5.5 committed 2026-10-19 12:53:23 -05:00
1 parent 6c2cb30d63
commit e9e3ba03e5
19 files changed
+270 -17

No files matched your search

@@ -0,0 +1,31 @@
import { vi } from 'vitest';
import type { SapClientService } from '../sap/sap-client.service.js';
import { CompanyService } from './company.service.js';
describe('CompanyService', () => {
const make = (data: unknown) => {
const request = vi.fn(async () => ({ data }));
return { service: new CompanyService({ request } as unknown as SapClientService), request };
};
it('entrega solo el redondeo y el separador, sin el resto de la información de la empresa', async () => {
const { service, request } = make({ RoundingMethod: 'tYES', AccountSegmentsSeparator: '.', DefaultBankAccount: '192-1153365-0-50' });
const settings = await service.settings();
expect(settings).toEqual({ roundingEnabled: true, accountSegmentsSeparator: '.' });
expect(request).toHaveBeenCalledWith({ method: 'POST', path: 'CompanyService_GetAdminInfo', body: {} });
});
it('sin redondeo ni separador usa los valores por defecto', async () => {
const { service } = make({ RoundingMethod: 'tNO', AccountSegmentsSeparator: null });
expect(await service.settings()).toEqual({ roundingEnabled: false, accountSegmentsSeparator: '-' });
});
it('recuerda la respuesta un rato y luego la vuelve a pedir', async () => {
const { service, request } = make({ RoundingMethod: 'tYES' });
await service.settings(1000);
await service.settings(1000 + 60_000);
expect(request).toHaveBeenCalledTimes(1);
await service.settings(1000 + 11 * 60_000);
expect(request).toHaveBeenCalledTimes(2);
});
});