diff --git a/myteamwallet_backend/src/cashbox-export/cashbox-export.utils.spec.ts b/myteamwallet_backend/src/cashbox-export/cashbox-export.utils.spec.ts index 54d32a0..bd7b207 100644 --- a/myteamwallet_backend/src/cashbox-export/cashbox-export.utils.spec.ts +++ b/myteamwallet_backend/src/cashbox-export/cashbox-export.utils.spec.ts @@ -155,4 +155,15 @@ describe('buildCsv', () => { '2026-08-05;Zahlung;Alex Muster;Test;1,01;1,01', ); }); + + it('rounds negative half-cent boundaries correctly', () => { + const csv = buildCsv([ + { date: '2026-08-05T00:00:00.000Z', type: 'expense', who: 'Teamkasse', note: 'Test', amount: -1.005, runningTotal: -1.005 }, + ]); + + expect(csv).toBe( + 'Datum;Typ;Wer;Notiz;Betrag;Periodensaldo\r\n' + + '2026-08-05;Ausgabe;Teamkasse;Test;-1,01;-1,01', + ); + }); }); diff --git a/myteamwallet_backend/src/cashbox-export/cashbox-export.utils.ts b/myteamwallet_backend/src/cashbox-export/cashbox-export.utils.ts index f8ef725..96ad9df 100644 --- a/myteamwallet_backend/src/cashbox-export/cashbox-export.utils.ts +++ b/myteamwallet_backend/src/cashbox-export/cashbox-export.utils.ts @@ -68,7 +68,7 @@ const TYPE_LABELS: Record = { }; function formatGermanAmount(value: number): string { - const rounded = Math.round((value + Number.EPSILON) * 100) / 100; + const rounded = Math.sign(value) * Math.round((Math.abs(value) + Number.EPSILON) * 100) / 100; const normalized = rounded === 0 ? 0 : rounded; return normalized.toFixed(2).replace('.', ','); }