Allowances and charges
Allowances lower the amount due, charges raise it. At document level they are BG-20 and BG-21 and carry a VAT category; at line level (BG-27, BG-28) they change the line's net amount. The snippets extend the base invoice.
Document level
chargeIndicator is 'false' for an allowance and 'true' for a charge. Give a reason as text, as a code (UNCL5189 for allowances, UNCL7161 for charges), or both. State the amount, or a percentage and the base amount it applies to.
const allowanceCharge: InvoiceInput['allowanceCharge'] = [
{
chargeIndicator: 'false', // an allowance
allowanceChargeReasonCode: '95', // UNCL5189: discount
allowanceChargeReason: 'Loyalty discount',
amount: 100,
taxCategory: { id: 'S', percent: 25 },
},
{
chargeIndicator: 'true', // a charge
allowanceChargeReasonCode: 'FC', // UNCL7161: freight service
allowanceChargeReason: 'Freight',
multiplierFactorNumeric: 2.5, // 2.5 % ...
baseAmount: 2800, // ... of 2800.00: the builder computes amount = 70.00
taxCategory: { id: 'S', percent: 25 },
},
];Computed: amount from multiplierFactorNumeric and baseAmount when you leave it out.
Line level
A line allowance or charge has no VAT category of its own: it takes the line's.
const [line] = baseInvoice.invoiceLine;
if (line === undefined) {
throw new Error('baseInvoice has a line');
}
const invoiceLine: InvoiceInput['invoiceLine'] = [
{
...line,
allowanceCharge: [
{
chargeIndicator: 'false',
allowanceChargeReasonCode: '95',
allowanceChargeReason: 'Volume discount',
amount: 300,
},
],
},
];
// lineExtensionAmount: 7 × 400.00 − 300.00 = 2500.00Computed: the line's lineExtensionAmount includes them.
Effect on the totals
const invoice = createInvoice({ ...baseInvoice, allowanceCharge, invoiceLine });
const totals = invoice.legalMonetaryTotal;
// lineExtensionAmount 2500.00 Σ line net amounts (BT-106)
// allowanceTotalAmount 100.00 Σ document allowances (BT-107)
// chargeTotalAmount 70.00 Σ document charges (BT-108)
// taxExclusiveAmount 2470.00 2500.00 − 100.00 + 70.00 (BT-109)
// taxInclusiveAmount 3087.50 plus 25 % VAT on 2470.00 (BT-112)
// payableAmount 3087.50 (BT-115)Computed: every total above, and the VAT breakdown, where each document level allowance or charge counts in its VAT category.