Handles generating unique and consecutive numbers for invoices.

interface InvoiceNumberServiceInterface<AddressData extends InvoiceAddress> {
    generateInvoiceNumber: (
        recipientId: string,
        invoiceAddress: AddressData,
        transaction?: Transaction,
        nameAbbreviation?: string,
    ) => string | Promise<string>;
    generateTemporaryInvoiceNumber: (
        recipientId: string,
        invoiceAddress: InvoiceAddress,
        nameAbbreviation?: string,
    ) => string | Promise<string>;
}

Type Parameters

Implemented by

Properties

generateInvoiceNumber: (
    recipientId: string,
    invoiceAddress: AddressData,
    transaction?: Transaction,
    nameAbbreviation?: string,
) => string | Promise<string>

Generates a new invoice number.

Type declaration

    • (
          recipientId: string,
          invoiceAddress: AddressData,
          transaction?: Transaction,
          nameAbbreviation?: string,
      ): string | Promise<string>
    • Parameters

      • recipientId: string

        The id of the recipient of the invoice.

      • invoiceAddress: AddressData

        The address data of the recipient of the invoice.

      • Optionaltransaction: Transaction

        An optional transaction from outside to make sure any changes only apply when the transaction is committed.

      • OptionalnameAbbreviation: string

        An optional name abbreviation if you don't want to generate one.

      Returns string | Promise<string>

      A promise of the new invoice number.

generateTemporaryInvoiceNumber: (
    recipientId: string,
    invoiceAddress: InvoiceAddress,
    nameAbbreviation?: string,
) => string | Promise<string>

Generates a temporary invoice number with the prefix "TEMP". This does not increase the number of invoices which can be helpful if you create an invoice that might not be sent out.

Type declaration

    • (
          recipientId: string,
          invoiceAddress: InvoiceAddress,
          nameAbbreviation?: string,
      ): string | Promise<string>
    • Parameters

      • recipientId: string

        The id of the recipient of the invoice.

      • invoiceAddress: InvoiceAddress

        The address data of the customer.

      • OptionalnameAbbreviation: string

        An optional name abbreviation if you don't want to generate one.

      Returns string | Promise<string>

      A promise of the new temporary invoice number.