InvoiceSpec / Rules Registry / ksef-fa-2 / KSEF-PL-P15-SUM
fatal ASSERTION · KSEF-PL-P15-SUM KSeF FA(2) / FA(3) (Polish Mandate) (FA-2-XML) Jurisdiction: PL

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)

Official KSeF FA(2) / FA(3) (Polish Mandate) Spec ↗
01. Technical Specification & XPath Evaluation Context

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.

Evaluated XPath Location:
/Faktura/Fa/P_15
Deterministic Remediation Steps

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.

02. Side-by-Side FA-2-XML Payload Diff (Rejected vs. Compliant)
--- a/invoice-rejected.xml (KSEF-PL-P15-SUM) FAIL
1 <Faktura>
2 <Fa>
3 <P_13_1>100.00</P_13_1>
4 <P_14_1>23.00</P_14_1>
5 <P_13_2>50.00</P_13_2>
6 <P_14_2>4.00</P_14_2>
7 - <!-- ERROR: P_15 (177.00) does not equal P_13_1 + P_14_1 (123.00) because the second bucket is omitted in the test -->
8 <P_15>177.00</P_15>
9 </Fa>
10 </Faktura>
+++ b/invoice-compliant.xml (EN 16931 VALID)
PASS
1 <Faktura>
2 <Fa>
3 <P_13_1>100.00</P_13_1>
4 <P_14_1>23.00</P_14_1>
5 <P_13_2>50.00</P_13_2>
6 <P_14_2>4.00</P_14_2>
7 <P_15>177.00</P_15>
8 </Fa>
9 </Faktura>
03. Interactive KSeF FA(2) / FA(3) (Polish Mandate) Validation & Auto-Fix Workbench
3 CREDITS
invoice.xmlFA-2-XML
DETECTED SOURCECustom ERP / Billing Engine
BT-131 LINE SUM100.00 EUR
BT-106 HEADER100.00 EUR
SCHEMATRON: 2 FATAL· 1ms
KSeF FA(2) / FA(3) (Poland)
KSEF-PL-NIP-01Polish Seller NIP ("MISSING") must be an exact 10-digit tax identifier without PL prefix
Spec & Diff
xpath: /Faktura/Podmiot1/DaneIdentyfikacyjne/NIP

KSeF XSD rejects NIP "MISSING". Country prefixes ("PL") and hyphens are forbidden.

fix: Normalize <NIP> to 10 digits: <NIP>1111111111</NIP>.

KSEF-PL-P15-SUMKSeF Total Gross P_15 (177.00) != Net P_13_1 (100.00) + VAT P_14_1 (23.00)
Spec & Diff
xpath: /Faktura/Fa/P_15

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>.

Automate Custom ERP / Billing Engine → KSeF FA(2) / FA(3) (Poland) AP Delivery

Deploy certified Peppol Access Point & ZUGFeRD ERP connector

04. Adjacent KSeF FA(2) / FA(3) (Polish Mandate) Assertions Browse All Rules →