test(accounting): update tax-report CSV tests for the unified ledger format

The CSV rework (unified, typed ledger) replaced the 'Rechnung' column with
'Referenz' (+ a 'Typ' column) and dropped the separate cancelled 0/1 column in
favour of a localised '(Cancelled)' suffix on the Reference cell. Update the
two assertions in taxReportPdf.test.js accordingly. All 11 cases pass.
This commit is contained in:
Luca
2026-06-15 19:54:18 +02:00
parent 7e586cd3a1
commit b584aaf7a6
@@ -193,8 +193,11 @@ describe('renderTaxReportCsv', () => {
expect(contentType).toMatch(/text\/csv/);
expect(filename).toBe('tax_report_2026-01-01_to_2026-03-31_CHF.csv');
const lines = content.split('\r\n');
expect(lines[0]).toContain('Rechnung'); // de header for tax_col_invoice
expect(lines[0]).toContain('Kunde');
// Unified ledger CSV: Typ / Referenz / Kunde-Lieferant columns replace the
// old Rechnung/Kunde split.
expect(lines[0]).toContain('Typ'); // de header for tax_col_type
expect(lines[0]).toContain('Referenz'); // de header for tax_col_reference
expect(lines[0]).toContain('Kunde'); // "Kunde / Lieferant"
expect(lines[0]).toContain('Netto');
});
@@ -234,19 +237,17 @@ describe('renderTaxReportCsv', () => {
expect(content).toMatch(/"161\.55"/);
});
it('marks cancelled rows with a 1 in the cancelled column', async () => {
it('flags a cancelled row with a "(Cancelled)" suffix on its Reference cell', async () => {
invoiceRowsForRun = [
SAMPLE_ROW({ status: 'cancelled' }),
];
const { content } = await taxReportService.renderTaxReportCsv({
from: '2026-01-01', to: '2026-03-31', currency: 'CHF', locale: 'en',
});
// Migration 126 added a trailing Skonto column. The cancelled
// marker is now second-to-last; the Skonto cell is empty for
// non-Skonto rows. Asserting on a regex keeps the test stable
// against future trailing-column additions.
// Unified ledger CSV has no separate cancelled column — a cancelled row is
// flagged by appending the localised "(Cancelled)" tag to its Reference.
const dataRow = content.split('\r\n')[1];
expect(/"1","[^"]*"$/.test(dataRow)).toBe(true);
expect(dataRow).toContain('R-2026-0001 (Cancelled)');
});
it('uses CRLF line endings (RFC 4180) and BOM-free body', async () => {