fix: negate expense amounts and stop blank trailing pages in cashbox PDF export
Expenses were stored as positive amounts (DB convention) and buildRows() never negated them, so they were added to the running budget total instead of subtracted. Negate expense amounts for team-wallet transactions, mirroring the existing signedFlowAmount() convention in teams.service.ts. Separately, addFooters() placed footer text inside the reserved bottom margin without an explicit height option, which made pdfkit's LineWrapper treat every footer draw as overflowing the page and call continueOnNewPage() twice per page - inflating page counts 3x with blank trailing pages. Bounding the footer text to its own small height box prevents pdfkit's automatic pagination from firing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,12 +26,13 @@ export function buildRows(team: Team, from: string, to: string): CashboxExportRo
|
||||
|
||||
for (const transaction of team.transactions ?? []) {
|
||||
if (!transaction.type) continue;
|
||||
const amount = Number(transaction.amount);
|
||||
raw.push({
|
||||
date: transaction.date,
|
||||
type: transaction.type.name,
|
||||
who: 'Teamkasse',
|
||||
note: transaction.note,
|
||||
amount: Number(transaction.amount),
|
||||
amount: transaction.type.name === 'expense' ? -amount : amount,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -318,6 +319,7 @@ function addFooters(doc: PDFKit.PDFDocument, teamName: string): void {
|
||||
.fillColor(COLORS.footerText)
|
||||
.text(`${teamName} – Kassenbuch-Report, erstellt am ${generatedAt}`, PAGE_MARGIN, footerY, {
|
||||
width: doc.page.width - PAGE_MARGIN * 2 - 60,
|
||||
height: 20,
|
||||
lineBreak: false,
|
||||
});
|
||||
doc
|
||||
@@ -325,6 +327,7 @@ function addFooters(doc: PDFKit.PDFDocument, teamName: string): void {
|
||||
.fillColor(COLORS.footerText)
|
||||
.text(`Seite ${i - range.start + 1} von ${range.count}`, doc.page.width - PAGE_MARGIN - 60, footerY, {
|
||||
width: 60,
|
||||
height: 20,
|
||||
align: 'right',
|
||||
lineBreak: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user