fix(pdf): adjust spacing to stop L and Rand text overlapping

increase vertical spacing before subtotal line from 6 to 10 points, widen horizontal gap between quantity and pricing text, and add an explanatory comment
This commit is contained in:
SJCoetz 2026-07-21 13:26:13 +02:00
parent ae2950c7a0
commit 6f5108ca63

View file

@ -108,15 +108,17 @@ async function customerDelivery(ctx: ReportContext): Promise<Uint8Array> {
return r;
});
drawTable(pdf, cols, rows);
moveDown(pdf, 6);
// Subtotal on a single line, right-aligned to the last column
moveDown(pdf, 10);
// Subtotal on a single line, right-aligned to the last column.
// The qty and value are separated by a wide gap so the "L" (litres)
// and "R" (Rand) don't visually run into each other.
const subtotalRight = 40 + cols.reduce((a, c) => a + c.width, 0);
if (ctx.includePricing) {
const totalValStr = formatCurrency(totalValue);
const valW = pdf.font.widthOfTextAtSize(totalValStr, 10);
const subtotalStr = `Subtotal: ${formatNumber(totalQty)} L`;
const subW = pdf.font.widthOfTextAtSize(subtotalStr, 10);
drawText(pdf, subtotalStr, { x: subtotalRight - valW - 12 - subW, y: pdf.y, size: 10, bold: true });
drawText(pdf, subtotalStr, { x: subtotalRight - valW - 32 - subW, y: pdf.y, size: 10, bold: true });
drawText(pdf, totalValStr, { x: subtotalRight - 8 - valW, y: pdf.y, size: 10, bold: true });
} else {
const subtotalStr = `Subtotal: ${formatNumber(totalQty)} L`;