Skip to main content
You send the line amounts and the API stores them as sent: it does not calculate them, but it checks that they add up according to Noyax’s rules. The header totals and AverageExchangeRate are not sent; the API fills them from the lines. The same rules apply to quotes, orders, despatches and invoices.

Line checks

Every line is checked with the rules below. A difference of up to 0.05 is accepted. UnitPrice must be excluding VAT. VatIncluded is no longer used: it is still accepted so that existing requests keep working, but it is ignored. A line that fails a check rejects the request with the module’s code (quote 5118, order 6120, despatch 7124, invoice 3126). The message names the line, the field, the rule and the expected value, for example: Line 2: VatAmount (18.00) does not match VatBase × VatRate / 100 (20.00).

Header totals

The header totals are filled from the lines; values sent in the request are ignored.
  • DiscountTotal = sum of DiscountAmount.
  • SubTotal = sum of AmountExcludingTax.
  • WithholdingTotal = sum of WithheldVatAmount.
  • VatTotal = sum of VatAmount − WithholdingTotal. It is net of withholding.
  • AdditionalTaxTotal = sum of the additional tax amounts of all lines.
  • GrandTotal = sum of AmountIncludingTax − WithholdingTotal.

Currencies

Line amounts are in the line’s own currency.
  • When every line has the same currency, the document is in that currency and the totals are plain sums of the lines.
  • When the lines have different currencies, the document is in the company’s default currency and each line amount is converted to it with the line’s ExchangeRate before it is added to the totals.
AverageExchangeRate is filled from the lines as well (a value sent in the request is ignored):
  • Every line has the same currency: the amount-weighted average of the line exchange rates, that is the sum of AmountExcludingTax × ExchangeRate divided by the sum of AmountExcludingTax, with 6 decimals (the first line’s ExchangeRate when the sum of AmountExcludingTax is 0).
  • The lines have different currencies: 1.

Calculating a line in your system

The checks above fix how the amounts of a line relate to each other. The rules below describe how Noyax arrives at the other values; follow them so that documents created through the API look like documents created in Noyax. Amounts are rounded to 2 decimals. Price. UnitPrice must exclude VAT. If your prices include VAT (and additional taxes added on top of the price), divide them by (1 + additional tax rate/100) × (1 + VatRate/100) before sending. For withholding-type additional taxes (such as income tax or corporate tax withholding) the divisor is 1 + additional tax rate/100 + VatRate/100. Discount rate. The discounts of a line are applied one after another, so the line’s DiscountRate is the combined rate: DiscountRate = 100 × (1 − (1 − rate₁/100) × (1 − rate₂/100) × …) 10, 10 and 10 give 27.1. If the user entered a discount amount instead of rates, the rate is derived from it: DiscountAmount / GrossAmount × 100. Additional taxes (each entry of AdditionalTaxes): Amount = AmountExcludingTax × Rate / 100. Base is the amount the tax was calculated on. VAT base (VatBase): AmountExcludingTax plus the additional tax amounts that are taxed with VAT, such as special consumption tax. Withholding-type additional taxes are not part of the VAT base. Withholding (tevkifat): the line’s WithholdingCode, WithholdingNumerator and WithholdingDenominator give the withheld share of the VAT, and WithheldVatAmount is calculated as in the checks above. Withholding does not reduce the line amount including tax; it is deducted from the document’s VatTotal and GrandTotal.