GrossPriceConverter
in package
FinalYes
Gross price mode for B2C and shops.
Shops calculate with prices including VAT, EN 16931 calculates net. Per VAT group:
- G = Σ g_i with g_i = round2(quantity × price incl. VAT)
- N = round2(G / (1 + rate / 100)); a partial cancellation aligned with the earlier ones declares its N (Corrections\CancellationHistory), which is used within 0.01
- T = round2(N × rate / 100) (BR-CO-17)
- Every line gets n_i = round2(g_i / (1 + rate / 100)); the few cents N − Σ n_i are added to the lines with the largest rounding remainders. Each line keeps the sign of its gross amount (returns and vouchers stay negative). Net prices are derived with the precision needed so that the line formula yields the line amount.
- G − (N + T) is returned as rounding amount for BT-114, so that the amount due equals the gross amount the customer saw. The calculator takes BT-114 from the total G and the amounts it finally uses, so that it also holds when declared amounts are kept (e.g. the aligned VAT of a partial cancellation).
Limits: all lines must use gross prices, and gross lines must not have line or document allowances or charges. Model shipping costs and discounts as lines; a discount line needs a negative quantity, because prices must not be negative (BR-27).
Table of Contents
Methods
- appliesTo() : bool
- convert() : BigDecimal}
- netOf() : BigDecimal
- N = round2(G / (1 + rate / 100)), step 2.
Methods
appliesTo()
public
appliesTo(InvoiceData $invoice) : bool
Parameters
- $invoice : InvoiceData
Return values
boolconvert()
public
convert(InvoiceData $invoice[, array<string, BigDecimal> $nets = [] ]) : BigDecimal}
Parameters
- $invoice : InvoiceData
- $nets : array<string, BigDecimal> = []
-
declared net amounts N per VAT group (key: DeclaredAmounts::breakdownKey()), e.g. of a partial cancellation aligned with the earlier ones (Corrections\CancellationHistory); used instead of step 2 within 0.01
Return values
BigDecimal} —gross: G of all groups
netOf()
N = round2(G / (1 + rate / 100)), step 2.
public
static netOf(BigDecimal $gross, BigDecimal $rate) : BigDecimal
Parameters
- $gross : BigDecimal
- $rate : BigDecimal