Handles calculating anything regarding invoices.

interface InvoiceCalcServiceInterface<Invoice extends Invoice> {
    getItemTotalPriceAfterTax: (
        item: InvoiceItem,
    ) => BigNumber | Promise<BigNumber>;
    getItemTotalPriceBeforeTax: (
        item: InvoiceItem,
    ) => BigNumber | Promise<BigNumber>;
    getItemTotalTax: (item: InvoiceItem) => BigNumber | Promise<BigNumber>;
    getTotalAfterTax: (invoice: Invoice) => BigNumber | Promise<BigNumber>;
    getTotalBeforeTax: (invoice: Invoice) => BigNumber | Promise<BigNumber>;
    getTotalBeforeTaxForTaxGroup: (
        invoice: Invoice,
        group: Vat,
        groupOnlyByRate: boolean,
    ) => BigNumber | Promise<BigNumber>;
    getTotalTax: (invoice: Invoice) => BigNumber | Promise<BigNumber>;
    getTotalTaxForTaxGroup: (
        invoice: Invoice,
        group: Vat,
        groupOnlyByRate: boolean,
    ) => BigNumber | Promise<BigNumber>;
}

Type Parameters

Implemented by

Properties

getItemTotalPriceAfterTax: (item: InvoiceItem) => BigNumber | Promise<BigNumber>

Gets the total price of an item after tax.

Type declaration

    • (item: InvoiceItem): BigNumber | Promise<BigNumber>
    • Parameters

      • item: InvoiceItem

        The invoice item to get the price from.

      Returns BigNumber | Promise<BigNumber>

      The total price before tax times 1 + tax/100.

getItemTotalPriceBeforeTax: (
    item: InvoiceItem,
) => BigNumber | Promise<BigNumber>

Gets the total price of an item before tax.

Type declaration

    • (item: InvoiceItem): BigNumber | Promise<BigNumber>
    • Parameters

      • item: InvoiceItem

        The invoice item to get the price from.

      Returns BigNumber | Promise<BigNumber>

      The amount of the item times its price.

getItemTotalTax: (item: InvoiceItem) => BigNumber | Promise<BigNumber>

Gets the total tax for the given item.

Type declaration

    • (item: InvoiceItem): BigNumber | Promise<BigNumber>
    • Parameters

      Returns BigNumber | Promise<BigNumber>

      The total price before tax times tax/100.

getTotalAfterTax: (invoice: Invoice) => BigNumber | Promise<BigNumber>

Gets the total price of an invoice after tax.

Type declaration

    • (invoice: Invoice): BigNumber | Promise<BigNumber>
    • Parameters

      • invoice: Invoice

        The invoice to get the price from.

      Returns BigNumber | Promise<BigNumber>

      The addition of the total price before tax and the total tax of the invoice.

getTotalBeforeTax: (invoice: Invoice) => BigNumber | Promise<BigNumber>

Gets the total price of an invoice before tax.

Type declaration

    • (invoice: Invoice): BigNumber | Promise<BigNumber>
    • Parameters

      • invoice: Invoice

        The invoice to get the price from.

      Returns BigNumber | Promise<BigNumber>

      The addition of the total price before tax of all items in the invoice. If this would be negative this returns 0.

getTotalBeforeTaxForTaxGroup: (
    invoice: Invoice,
    group: Vat,
    groupOnlyByRate: boolean,
) => BigNumber | Promise<BigNumber>

Gets the total price of an invoice before tax.

Type declaration

    • (
          invoice: Invoice,
          group: Vat,
          groupOnlyByRate: boolean,
      ): BigNumber | Promise<BigNumber>
    • Parameters

      • invoice: Invoice

        The invoice to get the price from.

      • group: Vat

        The tax group to get the total before from.

      • groupOnlyByRate: boolean

        Whether or not VAT groups are only determined by rate and not by category code.

      Returns BigNumber | Promise<BigNumber>

      The addition of the total price before tax of all items in the invoice. If this would be negative this returns 0.

getTotalTax: (invoice: Invoice) => BigNumber | Promise<BigNumber>

Gets the total tax of the invoice.

Type declaration

    • (invoice: Invoice): BigNumber | Promise<BigNumber>
    • Parameters

      • invoice: Invoice

        The invoice to get the total tax from.

      Returns BigNumber | Promise<BigNumber>

      The addition of the tax of all items of the invoice.

getTotalTaxForTaxGroup: (
    invoice: Invoice,
    group: Vat,
    groupOnlyByRate: boolean,
) => BigNumber | Promise<BigNumber>

Gets the total tax for a specific tax group (eg. 19%).

Type declaration

    • (
          invoice: Invoice,
          group: Vat,
          groupOnlyByRate: boolean,
      ): BigNumber | Promise<BigNumber>
    • Parameters

      • invoice: Invoice

        The invoice to get the total tax from.

      • group: Vat

        The tax group for which the total tax should be calculated.

      • groupOnlyByRate: boolean

        Whether or not VAT groups are only determined by rate and not by category code.

      Returns BigNumber | Promise<BigNumber>

      The addition of the tax of all items that are in the provided tax group.