UPO 4.3, fixes for invoices
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user