manicanldes-backend/test/purchase-order-money.spec.ts

14 lines
520 B
TypeScript

import { lineTotal, totalOf } from '../src/procurement/purchase-order-money';
describe('purchase order money bounds', () => {
it('rounds the third fractional minor unit only once per line', () => {
expect(lineTotal('1.005', '1.01')).toBe('1.02');
});
it('rejects totals exceeding the database decimal precision', () => {
expect(() => lineTotal('999999999.999', '999999999.99')).toThrow();
expect(() =>
totalOf([{ lineTotal: '9999999999.99' }, { lineTotal: '0.01' }]),
).toThrow();
});
});