Skip to content

Documentation / @facturometro/core / createCreditNote

Function: createCreditNote() ​

createCreditNote(input): CreditNote

Defined in: packages/core/src/create/index.ts:131

Creates a canonical credit note from what the caller knows about it.

The credit note counterpart of createInvoice: same defaults, same calculations, same way of stating a VAT exemption reason, on credited quantities. Amounts stay positive - a credit note credits what it states.

Parameters ​

input ​

CreditNoteInput

The credit note, without the amounts that follow from its lines.

Returns ​

CreditNote

The canonical credit note.

Throws ​

When a number the caller wrote is not finite.

Throws ​

When a line states a price base quantity (BT-149) of zero.

Throws ​

When an allowance or charge of the document or of a line states no amount and not both a multiplierFactorNumeric and a baseAmount to compute it from, or when a tax total other than the first states no taxAmount, or one of its tax subtotals no taxableAmount or taxAmount: the builder computes only the first tax total (the VAT total in the document currency, BT-110).

Example ​

ts
import { createCreditNote } from '@facturometro/core';

const creditNote = createCreditNote({
  id: 'CN-1',
  issueDate: '2026-09-10',
  creditNoteTypeCode: '381',
  documentCurrencyCode: 'EUR',
  accountingSupplierParty: supplier,
  accountingCustomerParty: customer,
  billingReference: [{ invoiceDocumentReference: { id: 'INV-1' } }],
  creditNoteLine: [
    {
      id: '1',
      creditedQuantity: { value: 1, unitCode: 'C62' },
      item: { name: 'Widget', classifiedTaxCategory: { id: 'S', percent: 25 } },
      price: { priceAmount: 41 },
    },
  ],
});

creditNote.legalMonetaryTotal.payableAmount; // { value: '51.25', currencyId: 'EUR' }

MIT licensed. Specification artefacts belong to OpenPEPPOL, CEN and OASIS.