import policy from "./invoice-booking-policy.json"; // Single source of truth for the amount an invoice line contributes to a machine's // income. The flag itself lives in ./invoice-booking-policy.json because the CLI // booking script must obey exactly the same rule — two copies of a financial // constant will eventually disagree. // // Client ruling, 2026-10-01: amounts are booked VAT-INCLUSIVE, i.e. the figure the // debtor actually pays. Set `bookInclusiveVat: false` in the JSON to book ex-VAT // instead, then re-run `npm run seed && node scripts/book-invoice.mjs`. export const BOOK_INCLUSIVE_VAT = policy.bookInclusiveVat; // The amount to post to monthly_income for one invoice line. export function bookedAmount(amountExcl: number, vat: number): number { const r = (n: number) => Math.round((n || 0) * 100) / 100; return BOOK_INCLUSIVE_VAT ? r(amountExcl) + r(vat) : r(amountExcl); } // Label for whichever mode is active, so the UI never says "ex VAT" while booking // the inclusive figure (or the reverse). export const BOOKED_LABEL = BOOK_INCLUSIVE_VAT ? "incl VAT" : "ex VAT"; export const BOOKED_LONG_LABEL = BOOK_INCLUSIVE_VAT ? "Booked to income (incl VAT)" : "Booked to income (ex VAT)";