KSEF-PL-P15-SUM: KSeF Total Gross Amount Due (Fa/P_15) must equal sum of net rate buckets (P_13_1..P_13_7) plus VAT (P_14_1..P_14_5)
This rule enforces the arithmetic consistency of the Polish KSeF FA(2) invoice total gross amount (BT-112 / P_15). The context XPath `/Faktura/Fa/P_15` selects the gross total element. The assertion compares `xs:decimal(P_15)` against the sum of the net amount of the first VAT rate bucket (`P_13_1`, BT-116) and its corresponding VAT amount (`P_14_1`, BT-117). In the full KSeF FA(2) schema, P_15 must equal the sum of all net rate buckets P_13_1 through P_13_7 plus all VAT amounts P_14_1 through P_14_5. The raw test shown only covers the first bucket, so it triggers when the invoice contains multiple VAT rate buckets or when P_15 is not equal to P_13_1 + P_14_1. The rule is fatal because an incorrect total gross amount invalidates the invoice for tax and clearing purposes. The XPath evaluation context is the `P_15` element, and the test uses `xs:decimal()` to cast the string values to decimals for numeric comparison. Missing or non-numeric values will also cause the assertion to fail.
1. Ensure that the invoice contains all applicable VAT rate buckets (P_13_1..P_13_7 and P_14_1..P_14_5) with correct net and VAT amounts. 2. Calculate the total gross amount (P_15) as the sum of all net amounts (P_13_1 through P_13_7) plus all VAT amounts (P_14_1 through P_14_5). 3. Verify that the value of P_15 matches this sum exactly, using decimal arithmetic to avoid rounding errors. 4. If the invoice has only one VAT rate bucket, ensure that P_15 equals P_13_1 + P_14_1. 5. Update the P_15 element with the correct total gross amount. 6. Re-run the Schematron validation to confirm the rule passes.
KSeF XSD rejects NIP "MISSING". Country prefixes ("PL") and hyphens are forbidden.
fix: Normalize <NIP> to 10 digits: <NIP>1111111111</NIP>.
P_15 reports 177.00 PLN, but P_13_1 + P_14_1 equals 123.00 PLN.
fix: Set <P_15>123.00</P_15>.