This commit is contained in:
@@ -1319,15 +1319,29 @@ export async function computeCustomInvoiceTotals(params: {
|
|||||||
// (rappen precision). We carry the per-line amount on the row so
|
// (rappen precision). We carry the per-line amount on the row so
|
||||||
// the PDF doesn't need to recompute and any rounding remains
|
// the PDF doesn't need to recompute and any rounding remains
|
||||||
// identical between rendering passes.
|
// identical between rendering passes.
|
||||||
|
//
|
||||||
|
// tenantName=null because custom invoices aren't bound to a
|
||||||
|
// specific tenant. unitLabel=null because admin-entered lines are
|
||||||
|
// free-form (the auto-cron lines use "day" / "request" /
|
||||||
|
// "message" — for custom lines the quantity is just a number).
|
||||||
|
// metadata.description preserves the admin's input so
|
||||||
|
// formatLineDescription can read it via the metadata channel
|
||||||
|
// (the row's description column also has it, redundantly, for
|
||||||
|
// safety). displayOrder reflects the order the admin added the
|
||||||
|
// rows so the PDF renders them top-to-bottom unchanged.
|
||||||
const lines: Omit<InvoiceLine, "id" | "invoiceId">[] = payload.lines.map(
|
const lines: Omit<InvoiceLine, "id" | "invoiceId">[] = payload.lines.map(
|
||||||
(ln) => {
|
(ln, idx) => {
|
||||||
const amount = Math.round(ln.quantity * ln.unitPriceChf * 100) / 100;
|
const amount = Math.round(ln.quantity * ln.unitPriceChf * 100) / 100;
|
||||||
return {
|
return {
|
||||||
|
tenantName: null,
|
||||||
kind: "custom_line" as InvoiceLineKind,
|
kind: "custom_line" as InvoiceLineKind,
|
||||||
description: ln.description.trim(),
|
description: ln.description.trim(),
|
||||||
quantity: ln.quantity,
|
quantity: ln.quantity,
|
||||||
|
unitLabel: null,
|
||||||
unitPriceChf: ln.unitPriceChf,
|
unitPriceChf: ln.unitPriceChf,
|
||||||
amountChf: amount,
|
amountChf: amount,
|
||||||
|
metadata: { description: ln.description.trim() },
|
||||||
|
displayOrder: idx,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user