Net price from gross price and allowance

Error PEPPOL-EN16931-R046 Peppol

Item net price MUST equal (Gross price - Allowance amount) when gross price is provided.

Mandatory rule: As long as it is violated, the invoice is invalid and will be rejected by validators.
What is wrong

If ram:ChargeAmount is provided for the gross price, the net price’s ram:ChargeAmount does not equal the gross price less the first available allowance ram:ActualAmount. If no allowance amount is present, the calculation uses zero.

What the rule means

The net price is derived from the gross price less the allowance on the price. Matching values ensure that the stated net price follows arithmetically from the price details.

Please align the net price and allowance with the gross price

The net price does not equal the gross price less the allowance stated at price level. Make sure these price amounts agree mathematically.

What to do
  1. Compare ram:ChargeAmount in ram:GrossPriceProductTradePrice with ram:ChargeAmount in ram:NetPriceProductTradePrice.
  2. Account for the first available allowance ram:ActualAmount.
  3. Make sure the net price equals the gross price less that allowance.
  4. Generate the invoice again and validate it.
What it looks like
✗ Triggers the message
<ram:GrossPriceProductTradePrice>
  <ram:ChargeAmount>100</ram:ChargeAmount>
  <ram:AppliedTradeAllowanceCharge>
    <ram:ActualAmount>10</ram:ActualAmount>
  </ram:AppliedTradeAllowanceCharge>
</ram:GrossPriceProductTradePrice>
<ram:NetPriceProductTradePrice>
  <ram:ChargeAmount>95</ram:ChargeAmount>
</ram:NetPriceProductTradePrice>
✓ Correct
<ram:GrossPriceProductTradePrice>
  <ram:ChargeAmount>100</ram:ChargeAmount>
  <ram:AppliedTradeAllowanceCharge>
    <ram:ActualAmount>10</ram:ActualAmount>
  </ram:AppliedTradeAllowanceCharge>
</ram:GrossPriceProductTradePrice>
<ram:NetPriceProductTradePrice>
  <ram:ChargeAmount>90</ram:ChargeAmount>
</ram:NetPriceProductTradePrice>
Technical details

If ram:ChargeAmount is absent from the gross price, the test passes. Otherwise, it compares the net price ram:ChargeAmount with the gross price less the first ram:ActualAmount; u:decimalOrZero treats a missing allowance amount as zero.

Where the rule applies

The rule applies to ram:GrossPriceProductTradePrice on an invoice line and compares its ram:ChargeAmount with ram:ChargeAmount in the adjacent ram:NetPriceProductTradePrice.

Context (rule/@context)
rsm:SupplyChainTradeTransaction/ram:IncludedSupplyChainTradeLineItem/ram:SpecifiedLineTradeAgreement/ ram:GrossPriceProductTradePrice
Test expression (assert/@test)
not(ram:ChargeAmount) or xs:decimal(../ram:NetPriceProductTradePrice/ram:ChargeAmount) = xs:decimal(ram:ChargeAmount) - u:decimalOrZero(ram:AppliedTradeAllowanceCharge/ ram:ActualAmount[1])