Credit notes and corrections
A credit note (UBL CreditNote) reduces or cancels an invoice. It has the same parts as an invoice, with credit note names, and refers to the invoice it corrects in a preceding invoice reference (BG-3).
Create a credit note
createCreditNote() takes a CreditNoteInput: creditNoteTypeCode (BT-3) instead of invoiceTypeCode, creditNoteLine with creditedQuantity instead of invoiceLine with invoicedQuantity. Amounts are positive: the type code says they are credited.
const creditNote = createCreditNote({
id: 'CN-1',
issueDate: '2017-11-20',
creditNoteTypeCode: '381', // credit note
documentCurrencyCode: 'EUR',
buyerReference: '0150abc',
billingReference: [
{ invoiceDocumentReference: { id: 'Snippet1', issueDate: '2017-11-13' } }, // the invoice it credits
],
accountingSupplierParty: baseInvoice.accountingSupplierParty,
accountingCustomerParty: baseInvoice.accountingCustomerParty,
creditNoteLine: [
{
id: '1',
creditedQuantity: { value: 2, unitCode: 'DAY' },
item: { name: 'Consulting', classifiedTaxCategory: { id: 'S', percent: 25 } },
price: { priceAmount: 400 },
},
],
});
const credited = creditNote.legalMonetaryTotal.payableAmount.value; // '1000.00'Defaulted and computed exactly as for an invoice. A credit note has no dueDate; put a due date in paymentMeans[].paymentDueDate instead.
Type codes
Peppol allows five credit note type codes (81, 83, 381, 396 and 532) and invoice type codes such as 380 (commercial invoice) and 383 (debit note); the lists are in invoice types and credit note types. Code 384, a corrected invoice, is accepted only when both the seller and the buyer are in Germany (PEPPOL-EN16931-P0112):
const german = (name: string) => ({
endpointId: { schemeId: '0088', value: '7300010000001' },
postalAddress: { cityName: 'Berlin', country: { identificationCode: 'DE' } },
partyLegalEntity: { registrationName: name },
});
const corrected = createInvoice({
...baseInvoice,
id: 'Snippet1-C',
invoiceTypeCode: '384', // corrected invoice: Peppol allows it only between German parties
billingReference: [{ invoiceDocumentReference: { id: 'Snippet1', issueDate: '2017-11-13' } }],
accountingSupplierParty: {
party: { ...german('Lieferant GmbH'), partyTaxScheme: [{ companyId: 'DE123456789' }] },
},
accountingCustomerParty: { party: german('Kunde GmbH') },
});Everywhere else, correct an invoice with a credit note and, if needed, a new invoice.