Comarch ERP Optima / XL to KSeF FA(2) / FA(3) (Polish Mandate) Schema Crosswalk & XML Compiler
Bridging Comarch ERP Optima & XL Invoices to Polish KSeF FA(2) / FA(3)
Polish B2B VAT invoices exported from Comarch ERP must conform to the Ministry of Finance **KSeF FA(2)** XSD schema before February 2026:
1. **Strict 10-Digit NIP Formatting (`KSEF-PL-NIP-01`):** Strip all `PL` country prefixes and hyphens from `Kontrahent.NIP` before populating `Podmiot2/DaneIdentyfikacyjne/NIP`.
2. **Rate Bucket Summation (`KSEF-PL-P15-SUM`):** Reconcile 23% VAT base (`P_13_1`) and 23% VAT amount (`P_14_1`) with the gross total `P_15`.
| Comarch ERP Optima / XL API Field | EN 16931 Business Term | Target FA-2-XML XPath | Card. | Normalization Rule | Assertion |
|---|---|---|---|---|---|
| Naglowek.NumerPelny VARCHAR(50) | P_2 (Numer Faktury) | /Faktura/Fa/P_2 | 1..1 | Direct string mapping of sequential Polish VAT invoice number | KSEF-PL-P1-DATE ↗ |
| Sprzedawca.NIP CHAR(10) | Podmiot1 NIP | /Faktura/Podmiot1/DaneIdentyfikacyjne/NIP | 1..1 | Remove PL prefix and dashes; enforce 10 digits | KSEF-PL-NIP-01 ↗ |
| Podsumowanie.RazemBrutto DECIMAL(18,2) | P_15 (Kwota Należności Ogółem) | /Faktura/Fa/P_15 | 1..1 | Must match exact sum of net rate buckets + VAT buckets | KSEF-PL-P15-SUM ↗ |
Missing <cbc:CustomizationID> or value does not declare EN 16931 CIUS compliance.
fix: Insert <cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0</cbc:CustomizationID>.
Found invalid or lowercase currency code "eur". Expected uppercase ISO 4217 (e.g. "EUR").
fix: Replace <cbc:DocumentCurrencyCode>eur</cbc:DocumentCurrencyCode> with uppercase "EUR".
Peppol Schematron forbids empty elements such as <cbc:AdditionalStreetName></cbc:AdditionalStreetName> serialized from null ERP fields.
fix: Strip empty <cbc:AdditionalStreetName> nodes prior to XML serialization.
Missing <cbc:EndpointID schemeID="..."> inside <cac:AccountingSupplierParty>/<cac:Party>.
fix: Add <cbc:EndpointID schemeID="9930">DE123456789</cbc:EndpointID> as the first child of Seller <cac:Party>.
Buyer <cbc:EndpointID> is either missing or lacks the mandatory EAS @schemeID attribute.
fix: Add schemeID="9930" (or "0088" for GLN / "0204" for Leitweg-ID) to Buyer <cbc:EndpointID>.
No <cbc:BuyerReference> (BT-10) found. Mandatory in XRechnung 3.0 (BR-DE-15) and required in Peppol BIS 3.0 (PEPPOL-EN16931-R003) when OrderReference is absent.
fix: Insert <cbc:BuyerReference>991-12849-74</cbc:BuyerReference> in the document header.
Mathematical discrepancy of 0.05 EUR between InvoiceLine sum (199.95) and LegalMonetaryTotal/LineExtensionAmount (200.00).
fix: Set cbc:LineExtensionAmount and cbc:TaxExclusiveAmount to 199.95.
TaxSubtotal/TaxableAmount reports 200.00, but Standard rated ("S") lines total 199.95.
fix: Recalculate BT-116 = 199.95, VAT BT-117 = 37.99, and PayableAmount BT-115 = 237.94.