feat: base de bancos (recursos de pagos recibidos y efectuados, acción Cancel, menú Bancos, tabla con ventana de selección)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
GeorgeandClaude Sonnet 5.5 committed 2026-10-16 13:23:27 -05:00
1 parent 08977741de
commit 369be317ab
13 files changed
+304 -10

No files matched your search

+33
View File
@@ -80,4 +80,37 @@ describe('SlProxyService: auditoría', () => {
await service.get(user, 'Orders', '5', {});
expect(record).not.toHaveBeenCalled();
});
describe('acciones sobre un registro (anular un pago)', () => {
it('anular un pago llama a Entidad(clave)/Cancel y queda registrado', async () => {
request.mockResolvedValueOnce({ data: undefined });
await service.action(user, 'IncomingPayments', '512', 'Cancel', '10.0.0.5');
expect(request).toHaveBeenCalledWith(expect.objectContaining({ method: 'POST', path: 'IncomingPayments(512)/Cancel' }));
expect(record).toHaveBeenCalledWith({ action: 'sl_action', webUser: 'ana', ip: '10.0.0.5', resource: 'IncomingPayments', key: '512', detail: { action: 'Cancel' } });
});
it('una acción que no está en la lista blanca del recurso no llega a SAP', async () => {
await expect(service.action(user, 'IncomingPayments', '512', 'Delete', '10.0.0.5')).rejects.toThrow(/no disponible/i);
await expect(service.action(user, 'Orders', '5', 'Cancel', '10.0.0.5')).rejects.toThrow(/no disponible/i);
expect(request).not.toHaveBeenCalled();
});
it('sin permiso de escritura queda denegado y no llega a SAP', async () => {
paths = ['/bancos/pagos-efectuados'];
await expect(service.action(user, 'IncomingPayments', '512', 'Cancel', '10.0.0.5')).rejects.toBeInstanceOf(ForbiddenException);
expect(request).not.toHaveBeenCalled();
expect(record).toHaveBeenCalledWith(expect.objectContaining({ action: 'sl_denied', resource: 'IncomingPayments', outcome: 'denied' }));
});
it('si SAP rechaza la anulación queda registrada como error y el error sigue su camino', async () => {
request.mockRejectedValueOnce(new Error('ya está anulado'));
await expect(service.action(user, 'VendorPayments', '9', 'Cancel', '10.0.0.5')).rejects.toThrow('ya está anulado');
expect(record).toHaveBeenCalledWith(expect.objectContaining({ action: 'sl_action', resource: 'VendorPayments', key: '9', outcome: 'error', detail: { action: 'Cancel', error: 'ya está anulado' } }));
});
it('la clave del registro se valida (solo números en los pagos)', async () => {
await expect(service.action(user, 'IncomingPayments', "1);DROP", 'Cancel', '10.0.0.5')).rejects.toThrow();
expect(request).not.toHaveBeenCalled();
});
});
});