UPO 4.3, fixes for invoices

This commit is contained in:
Michał Chudy
2026-01-16 08:35:43 +01:00
parent 1912b5b48d
commit 5fb5a624b8
64 changed files with 1044 additions and 1444 deletions

View File

@@ -12,7 +12,8 @@ vi.mock('../../../shared/PDF-functions', () => ({
formatText: vi.fn(),
getContentTable: vi.fn(),
getTable: vi.fn(),
getValue: vi.fn(),
getValue: vi.fn((v) => v?._text || v),
getTStawkaPodatku: vi.fn()
}));
describe(generateWiersze.name, () => {
@@ -27,6 +28,7 @@ describe(generateWiersze.name, () => {
P_7: { _text: 'Product 1' },
P_9A: { _text: '100' },
P_8B: { _text: '2' },
P_12: { _text: '23' },
},
],
KodWaluty: { _text: 'PLN' },
@@ -59,6 +61,8 @@ describe(generateWiersze.name, () => {
vi.mocked(PDFFunctions.createHeader).mockReturnValue(['Header'] as any);
vi.mocked(PDFFunctions.createSection).mockReturnValue({ section: 'content' } as any);
vi.mocked(PDFFunctions.createLabelTextArray).mockReturnValue(['Label', 'Value'] as any);
vi.mocked(PDFFunctions.getTStawkaPodatku).mockReturnValue('0' as any);
};
describe('when no invoice lines exist', () => {
@@ -106,11 +110,11 @@ describe(generateWiersze.name, () => {
});
it('should display "brutto" when P_11 is not in fieldsWithValue', () => {
vi.mocked(PDFFunctions.getTable).mockReturnValue([{ NrWierszaFa: { _text: '1' } }] as any);
vi.mocked(PDFFunctions.getTable).mockReturnValue([{ NrWierszaFa: { _text: '1' }, P_12: {_text: '23'} }] as any);
vi.mocked(PDFFunctions.getContentTable).mockReturnValue({
content: { table: {} } as any,
fieldsWithValue: ['P_11A', 'P_7'],
fieldsWithValue: ['P_11A', 'P_7', 'P12'],
});
vi.mocked(PDFFunctions.getValue).mockReturnValue('0');
@@ -148,7 +152,7 @@ describe(generateWiersze.name, () => {
});
it('should generate two tables when fieldsWithValue.length > 8', () => {
vi.mocked(PDFFunctions.getTable).mockReturnValue([{ NrWierszaFa: { _text: '1' } }] as any);
vi.mocked(PDFFunctions.getTable).mockReturnValue([{ NrWierszaFa: { _text: '1' }, P_12: {_text: '23'} }] as any);
vi.mocked(PDFFunctions.getContentTable)
.mockReturnValueOnce({
@@ -175,7 +179,7 @@ describe(generateWiersze.name, () => {
});
it('should not add second table if it has only 1 field with value', () => {
vi.mocked(PDFFunctions.getTable).mockReturnValue([{ NrWierszaFa: { _text: '1' } }] as any);
vi.mocked(PDFFunctions.getTable).mockReturnValue([{ NrWierszaFa: { _text: '1' }, P_12: {_text: '23'} }] as any);
vi.mocked(PDFFunctions.getContentTable)
.mockReturnValueOnce({