Factur-X EN 16931 E-Invoicing, 27-State EU VAT Validation & DGFiP FEC Export: Production Engineering Guide
How SMEs, ERP developers, and Shopify B2B teams generate hybrid PDF/A-3B + UN/CEFACT XML CII invoices, validate French SIREN/SIRET and 27-state EU VIES VAT numbers with outage fallback, bridge accredited PA/PDP platforms, and produce audit-ready 18-column FEC ledgers.
Direct answer
Factur-X EN 16931 embeds a structured UN/CEFACT CrossIndustryInvoice XML file inside a PDF/A-3B visual invoice container. To satisfy France's 2026 reception and 2027 SME issuance deadlines, validate buyer SIREN and 27-state EU VIES VAT numbers before invoicing, calculate totals in integer cents by VAT bucket, dispatch signed bundles to an accredited platform, and export balanced 18-column DGFiP FEC journals.
1. France 2026-2027 e-invoicing calendar and PA/PDP architecture
Electronic invoicing across France and Germany is no longer a distant roadmap item. Since September 1, 2026, every French VAT-registered company (large enterprises, mid-caps, SMEs, micro-businesses, and sole traders) has been legally required to receive structured electronic invoices via an accredited platform, while large enterprises (GE) and mid-caps (ETI) have already moved to mandatory structured issuance and e-reporting. On September 1, 2027, mandatory structured issuance and e-reporting extend to all French SMEs, TPEs, and micro-entreprises, including businesses operating under VAT franchise thresholds (article 293 B CGI).
In parallel, the French tax authority (DGFiP) refocused the Portail Public de Facturation (PPF) onto two core national services: the central recipient directory (annuaire) mapping SIREN/SIRET routing codes to receiving platforms, and the tax data concentrator. Actual invoice exchange flows through DGFiP-accredited private platforms known as Plateformes Agreees (PA), formerly referred to as PDP (Plateformes de Dematerialisation Partenaires). Sending a flat PDF attachment by email no longer fulfills domestic B2B compliance and triggers automated rejection by corporate accounts payable gateways.
Engineering teams building billing pipelines for e-commerce stores, SaaS back offices, or SMB ERPs must separate two distinct regulatory flows:
- Domestic French B2B e-invoicing: Every invoice between two VAT-liable French entities must travel through accredited platforms in one of the three official structured syntaxes: Factur-X (hybrid PDF/A-3B + XML CII), UBL 2.1, or pure UN/CEFACT CII, carrying the buyer SIREN (
schemeID="0002"), mandatory legal mentions, and transaction category codes (goods, services, or mixed). - B2C and international / intra-EU e-reporting: Retail orders, cross-border B2B deliveries to the other 26 EU Member States, and extra-EU exports are not routed through the French recipient directory as domestic e-invoices, yet their transaction summaries and service payment dates must still be reported to the administration via your PA/PDP while issuing valid EN 16931 invoices for European buyers (for example German ZUGFeRD 2.x recipients).
If your wholesale workflow runs on Shopify Basic, Grow, or Advanced alongside deferred Net 30 billing, combine this compliance architecture with our companion blueprint on Shopify B2B purchase orders and Net 30 without Shopify Plus so purchase order numbers (BT-13) and due dates flow directly from cart submission into the Factur-X payload.
2. Factur-X profiles compared: MINIMUM, BASIC WL, BASIC, EN 16931, EXTENDED
Co-authored by FNFE-MPE in France and FeRD in Germany (where it is technically identical to ZUGFeRD 2.x), Factur-X defines five progressive XML profiles. Picking the wrong profile is the single most frequent integration mistake: teams generate a MINIMUM or BASIC WL file to ship faster, only to discover that B2B buyers and PA/PDP validators reject missing line items, unit codes, or allowance breakdowns.
The table below compares the five official Factur-X 1.0 profiles across Guideline URN, line-item support, regulatory acceptance, and real-world engineering tradeoffs.
| Factur-X Profile | Official Guideline URN (BT-24) | Line-level XML | PA/PDP & Chorus Pro | Recommended production use |
|---|---|---|---|---|
| MINIMUM | urn:factur-x.eu:1p0:minimum |
No (header totals only) | Not accepted as full B2B e-invoice | Legacy indexing metadata only; avoid for 2026-2027 compliance |
| BASIC WL | urn:factur-x.eu:1p0:basicwl |
No (header + VAT buckets) | Accepted for header accounting automation only | Simple single-summary accounting ingest without SKU lines |
| BASIC | urn:cen.eu:en16931:2017#compliant#urn:factur-x.eu:1p0:basic |
Yes (subset of EN 16931) | Accepted on standard B2B flows | Simple line-item invoices without complex buyer/delivery metadata |
| EN 16931 (Comfort) | urn:cen.eu:en16931:2017 |
Yes (100% EU core semantic model) | Universally accepted (France PA/PDP, Chorus Pro, EU/DE) | Default target for SMEs, Shopify B2B, SaaS and ERP connectors |
| EXTENDED | urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended |
Yes (EN 16931 + supply-chain extensions) | Accepted where trading partner supports extensions | Automotive, EDI logistics, multi-delivery-note enterprise supply chains |
Targeting EN 16931 from day one eliminates rework. In production accounting pipelines, manual PDF re-keying averages 3 to 5 minutes per supplier invoice with a 1.5% to 3% line-item or VAT transcription error rate, whereas a strict EN 16931 XML CII attachment parses deterministically in under 15 milliseconds with zero OCR ambiguity.
3. Anatomy of a compliant PDF/A-3B + XML CII Factur-X EN 16931 invoice
A valid Factur-X document is not simply a standard PDF with an XML file stapled onto it. Automated validators such as veraPDF and PA/PDP gateways enforce four strict structural invariants on the binary PDF container:
- ISO 19005-3 (PDF/A-3B) archival conformance: Every font must be embedded, no external color profile references or JavaScript actions are permitted, an sRGB ICC
OutputIntentdictionary must be present, and the file trailer must include a deterministic/IDarray. - Embedded attachment naming and MIME type: The XML stream must be attached inside the PDF
/Names/EmbeddedFilescatalog under the exact filenamefactur-x.xmlwith MIME subtypetext/xml(orapplication/xmldepending on validator profile, withtext/xmlrecommended by FNFE-MPE) and an/AF(Associated Files) array on the root catalog declaring/AFRelationship /Alternative(or/Datafor non-EN16931 profiles). - XMP extension schema metadata: The PDF
/MetadataXMP packet must declare both PDF/A-3B identification (pdfaid:part=3,pdfaid:conformance=B) and the Factur-X extension schema properties:fx:DocumentType=INVOICE,fx:DocumentFileName=factur-x.xml,fx:Version=1.0, andfx:ConformanceLevel=EN 16931. - UN/CEFACT CII XML validity against XSD and Schematron: The embedded
factur-x.xmlmust validate cleanly against the UN/CEFACT CrossIndustryInvoice D16B XSD schema and all EN 16931 Schematron business rules (BR-*,BR-CO-*,BR-S-*,BR-AE-*).
Production XML CII payload (EN 16931 profile)
Below is a verified minimal-complete UN/CEFACT CrossIndustryInvoice XML structure carrying the required namespaces, guideline URN, document type code (380 for commercial invoice, 381 for credit note), SIREN schemeID="0002", EU VAT schemeID="VA", Purchase Order reference (BT-13), line item, VAT bucket, and header monetary summation:
<?xml version="1.0" encoding="UTF-8"?>
<rsm:CrossIndustryInvoice
xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"
xmlns:qdt="urn:un:unece:uncefact:data:standard:QualifiedDataType:100"
xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100">
<rsm:ExchangedDocumentContext>
<ram:GuidelineSpecifiedDocumentContextParameter>
<ram:ID>urn:cen.eu:en16931:2017</ram:ID>
</ram:GuidelineSpecifiedDocumentContextParameter>
</rsm:ExchangedDocumentContext>
<rsm:ExchangedDocument>
<ram:ID>FAC-2026-0412</ram:ID>
<ram:TypeCode>380</ram:TypeCode>
<ram:IssueDateTime>
<udt:DateTimeString format="102">20261202</udt:DateTimeString>
</ram:IssueDateTime>
</rsm:ExchangedDocument>
<rsm:SupplyChainTradeTransaction>
<ram:IncludedSupplyChainTradeLineItem>
<ram:AssociatedDocumentLineDocument>
<ram:LineID>1</ram:LineID>
</ram:AssociatedDocumentLineDocument>
<ram:SpecifiedTradeProduct>
<ram:SellerAssignedID>SKU-IND-400</ram:SellerAssignedID>
<ram:Name>Industrial Valve Kit DN40</ram:Name>
</ram:SpecifiedTradeProduct>
<ram:SpecifiedLineTradeAgreement>
<ram:NetPriceProductTradePrice>
<ram:ChargeAmount>250.0000</ram:ChargeAmount>
</ram:NetPriceProductTradePrice>
</ram:SpecifiedLineTradeAgreement>
<ram:SpecifiedLineTradeDelivery>
<ram:BilledQuantity unitCode="C62">4.0000</ram:BilledQuantity>
</ram:SpecifiedLineTradeDelivery>
<ram:SpecifiedLineTradeSettlement>
<ram:ApplicableTradeTax>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>20.00</ram:RateApplicablePercent>
</ram:ApplicableTradeTax>
<ram:SpecifiedTradeSettlementLineMonetarySummation>
<ram:LineTotalAmount>1000.00</ram:LineTotalAmount>
</ram:SpecifiedTradeSettlementLineMonetarySummation>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>PO-2026-8841</ram:BuyerReference>
<ram:SellerTradeParty>
<ram:Name>Atelier Mecanique Loire SAS</ram:Name>
<ram:SpecifiedLegalOrganization>
<ram:ID schemeID="0002">842195304</ram:ID>
</ram:SpecifiedLegalOrganization>
<ram:PostalTradeAddress>
<ram:PostcodeCode>44000</ram:PostcodeCode>
<ram:LineOne>14 Rue de l Industrie</ram:LineOne>
<ram:CityName>Nantes</ram:CityName>
<ram:CountryID>FR</ram:CountryID>
</ram:PostalTradeAddress>
<ram:SpecifiedTaxRegistration>
<ram:ID schemeID="VA">FR58842195304</ram:ID>
</ram:SpecifiedTaxRegistration>
</ram:SellerTradeParty>
<ram:BuyerTradeParty>
<ram:Name>Distributeur Nord Pro SAS</ram:Name>
<ram:SpecifiedLegalOrganization>
<ram:ID schemeID="0002">519304821</ram:ID>
</ram:SpecifiedLegalOrganization>
<ram:PostalTradeAddress>
<ram:PostcodeCode>59000</ram:PostcodeCode>
<ram:LineOne>82 Avenue Faidherbe</ram:LineOne>
<ram:CityName>Lille</ram:CityName>
<ram:CountryID>FR</ram:CountryID>
</ram:PostalTradeAddress>
<ram:SpecifiedTaxRegistration>
<ram:ID schemeID="VA">FR24519304821</ram:ID>
</ram:SpecifiedTaxRegistration>
</ram:BuyerTradeParty>
<ram:BuyerOrderReferencedDocument>
<ram:IssuerAssignedID>PO-2026-8841</ram:IssuerAssignedID>
</ram:BuyerOrderReferencedDocument>
</ram:ApplicableHeaderTradeAgreement>
<ram:ApplicableHeaderTradeDelivery>
<ram:ActualDeliverySupplyChainEvent>
<ram:OccurrenceDateTime>
<udt:DateTimeString format="102">20261202</udt:DateTimeString>
</ram:OccurrenceDateTime>
</ram:ActualDeliverySupplyChainEvent>
</ram:ApplicableHeaderTradeDelivery>
<ram:ApplicableHeaderTradeSettlement>
<ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
<ram:SpecifiedTradeSettlementPaymentMeans>
<ram:TypeCode>58</ram:TypeCode>
<ram:PayeePartyCreditorFinancialAccount>
<ram:IBANID>FR7630006000011234567890189</ram:IBANID>
</ram:PayeePartyCreditorFinancialAccount>
</ram:SpecifiedTradeSettlementPaymentMeans>
<ram:ApplicableTradeTax>
<ram:CalculatedAmount>200.00</ram:CalculatedAmount>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:BasisAmount>1000.00</ram:BasisAmount>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>20.00</ram:RateApplicablePercent>
</ram:ApplicableTradeTax>
<ram:SpecifiedTradePaymentTerms>
<ram:Description>Net 30 SEPA transfer</ram:Description>
<ram:DueDateDateTime>
<udt:DateTimeString format="102">20270101</udt:DateTimeString>
</ram:DueDateDateTime>
</ram:SpecifiedTradePaymentTerms>
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
<ram:LineTotalAmount>1000.00</ram:LineTotalAmount>
<ram:TaxBasisTotalAmount>1000.00</ram:TaxBasisTotalAmount>
<ram:TaxTotalAmount currencyID="EUR">200.00</ram:TaxTotalAmount>
<ram:GrandTotalAmount>1200.00</ram:GrandTotalAmount>
<ram:DuePayableAmount>1200.00</ram:DuePayableAmount>
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
</ram:ApplicableHeaderTradeSettlement>
</rsm:SupplyChainTradeTransaction>
</rsm:CrossIndustryInvoice>
Automated CLI verification in CI/CD before deploying a generator
Never ship a PDF/A-3B generator based solely on visual inspection in a browser PDF viewer. Wire four deterministic CLI checks into your CI pipeline so every generated test invoice is verified for PDF/A-3B compliance, attachment extraction, XSD syntax, and XMP conformance:
# 1. Verify factur-x.xml is embedded inside the PDF container
pdfdetach -list FAC-2026-0412.pdf
# 2. Extract the embedded XML stream without altering bytes
pdfdetach -savefile factur-x.xml -o /tmp/factur-x.xml FAC-2026-0412.pdf
# 3. Validate XML CII structure against the official UN/CEFACT D16B XSD
xmllint --noout --schema Factur-X_1.0.07_EN16931.xsd /tmp/factur-x.xml
# 4. Run veraPDF PDF/A-3B archival verification (flavour 3b)
verapdf --flavour 3b --format text FAC-2026-0412.pdf
# 5. Inspect XMP metadata packet for fx:ConformanceLevel
qpdf --qdf --object-streams=disable FAC-2026-0412.pdf - | grep -E "pdfaid:|fx:ConformanceLevel|AFRelationship"
4. 27-state EU VIES VAT validation, French SIREN/SIRET and reverse charge
Generating clean XML is only half of compliance. If an e-commerce store or ERP applies 0% intra-EU B2B reverse charge (Article 138 of EU Directive 2006/112/EC and Article 262 ter I of the French CGI) on an invalid or unregistered VAT ID, the seller remains liable for the uncollected 20% domestic VAT during a tax audit, plus penalties. Conversely, rejecting valid French or European corporate orders whenever a national VIES server flakes out costs immediate B2B conversion.
A resilient validation layer combines three deterministic stages: local normalization and regex validation across all 27 EU Member States plus Northern Ireland (XI), mathematical checksum verification, and live calls to the European Commission VIES REST API with a 24-hour TTL cache.
Calling the official European Commission VIES REST API
Unlike legacy SOAP wrappers, the European Commission exposes a clean JSON REST endpoint. Pay attention to Greece: ISO 3166 uses GR on shipping addresses, while VIES strictly requires the prefix EL in both the URL path and VAT identifier:
curl -fsS --max-time 5 -H "Accept: application/json" "https://ec.europa.eu/taxation_customs/vies/rest-api/ms/DE/vat/123456789"
# Expected response fields to archive for tax audit evidence:
# {
# "isValid": true,
# "requestDate": "2026-12-02T14:22:10.412Z",
# "userError": "VALID",
# "name": "MUSTERWERK GMBH",
# "address": "INDUSTRIESTR. 12, 80331 MUENCHEN",
# "requestIdentifier": "WAPIAAAAZ9x..."
# }
Always archive the returned requestIdentifier, requestDate, and normalized VAT number on the invoice record. During a French or EU VAT control, that consultation token proves you verified the buyer's active VAT status on the date of supply.
Validating French SIREN, SIRET and VIES fallback offline
On French domestic orders, the buyer's 9-digit SIREN (or 14-digit SIRET) is mandatory in SpecifiedLegalOrganization. Standard Luhn catches typos instantaneously at checkout, but remember the official INSEE exception for La Poste (SIREN 356000000), whose SIRET checksum is divisible by 5 when standard Luhn fails:
import re
def luhn_valid(digits: str) -> bool:
if not digits.isdigit():
return False
total = 0
for idx, ch in enumerate(reversed(digits)):
n = int(ch)
if idx % 2 == 1:
n *= 2
if n > 9:
n -= 9
total += n
return total % 10 == 0
def validate_french_siret(raw: str) -> tuple[bool, str]:
clean = re.sub(r"[\s.\-_/]+", "", raw or "")
if not re.fullmatch(r"\d{14}", clean):
return False, "SIRET must contain 14 digits"
siren = clean[:9]
if siren == "000000000" or not luhn_valid(siren):
return False, "Invalid 9-digit SIREN prefix"
if siren == "356000000" and not luhn_valid(clean):
return (sum(int(c) for c in clean) % 5 == 0), clean
return luhn_valid(clean), clean
When VIES returns MS_UNAVAILABLE, MS_MAX_CONCURRENT_REQ, or times out after 5 seconds, serve a cached verified result if one exists within the last 24 hours. If no cache entry exists, fall back to country regex plus national check-digit math (for example ISO 7064 Mod 11-10 for Germany DE, modulo 10 weighted sum for Italy IT, weights [6,5,7,2,3,4,5,6,7] mod 11 for Poland PL, and (12 + 3 * (siren % 97)) % 97 for France FR), mark the invoice as UNAVAILABLE_FALLBACK, and enqueue a background retry job before final PA/PDP transmission.
| Transaction scenario (FR Seller) | EN 16931 CategoryCode | VAT rate | ExemptionReasonCode | Mandatory legal mention & FEC revenue account |
|---|---|---|---|---|
| Domestic French B2B | S (Standard) |
20.00% (or reduced) |
None | Standard VAT breakdown; FEC credit 707000 + 445710 |
| Intra-EU B2B (valid VIES VAT) | AE (Reverse Charge) |
0.00% |
VATEX-EU-AE |
Autoliquidation, Art. 262 ter I CGI / Art. 138 Dir. 2006/112/EC; FEC credit 707100 |
| Extra-EU Export (US, CH, UK, CA) | G (Export outside EU) |
0.00% |
VATEX-EU-G |
Exoneration TVA exportation, Art. 262 I CGI; FEC credit 707200 |
| French VAT franchise (Art. 293 B) | E (Exempt) |
0.00% |
VATEX-EU-O or VATEX-FR-FRANCHISE |
TVA non applicable, art. 293 B du CGI; FEC credit 706000 / 707000 |
5. Zero-cent monetary invariants, credit notes (381) and signed PA/PDP webhooks
The top cause of live PA/PDP rejections on e-commerce invoices is a 1-cent mismatch between the sum of rounded line taxes and the document-level VAT total. EN 16931 business rules BR-CO-10, BR-CO-15, and BR-S-08 require strict algebraic consistency across all summation fields:
LineTotalAmount(BT-106) must equal the exact sum of every line net total (BT-131).TaxBasisTotalAmount(BT-109) must equalBT-106 - AllowanceTotalAmount + ChargeTotalAmount.- Each
ApplicableTradeTaxbucket calculatesCalculatedAmount = round_half_up(BasisAmount * Rate / 100)once per distinct(CategoryCode, Rate)pair. GrandTotalAmount(BT-112) must equalTaxBasisTotalAmount + TaxTotalAmountto the exact cent, andDuePayableAmount(BT-115) must equalGrandTotalAmount - TotalPrepaidAmount.
For refunds or price corrections, never edit or overwrite an issued invoice. Emit an immutable credit note carrying TypeCode set to 381, a distinct chronological sequence (for example AV-2026-0014), and the mandatory InvoiceReferencedDocument/IssuerAssignedID (BT-25) referencing the original invoice number.
Signed PA/PDP webhook bridge security: When forwarding the generated Factur-X bundle (PDF/A-3B base64, raw XML, and SHA-256 digests of both artifacts) from your store or ERP to an accredited platform or middleware connector, reject private/loopback IP ranges to prevent SSRF, enforce HTTPS with an 8-second timeout, and sign the raw JSON body with HMAC-SHA256(timestamp + "." + raw_body, signing_secret) so your receiving gateway verifies authenticity and prevents replay attacks.
If your team also maintains self-hosted document infrastructure alongside e-invoicing archives, make sure storage deduplication never corrupts metadata indices: see our engineering runbook on deduplicating Nextcloud libraries safely without breaking oc_filecache or Memories.
6. Audit-ready 18-column DGFiP FEC export and automated pre-close validation
Compliance does not end when the Factur-X PDF leaves your server. Every French company keeping computerized books must be able to hand the tax inspector a valid Fichier des Ecritures Comptables (FEC) under Article L.47 A-I and Article A.47 A-1 of the Livre des Procedures Fiscales. Generating the FEC directly from the same immutable invoice ledger that produced your Factur-X XML guarantees zero drift between sent invoices, credit notes, and general ledger entries.
Every FEC file contains strictly 18 mandatory columns in exact order: JournalCode, JournalLib, EcritureNum, EcritureDate, CompteNum, CompteLib, CompAuxNum, CompAuxLib, PieceRef, PieceDate, EcritureLib, Debit, Credit, EcritureLet, DateLet, ValidDate, Montantdevise, and Idevise. Below is a balanced excerpt for one domestic B2B invoice (FAC-2026-0412, 1 000,00 EUR HT + 200,00 EUR VAT) and one intra-EU reverse-charge invoice (FAC-2026-0413, 850,00 EUR HT, 0% VAT):
| JournalCode | EcritureNum | EcritureDate | CompteNum | PieceRef | EcritureLib | Debit | Credit |
|---|---|---|---|---|---|---|---|
VT |
VT000412 |
20261202 |
411000 |
FAC-2026-0412 |
Facture Factur-X FAC-2026-0412 Distributeur Nord Pro SAS | 1200,00 |
0,00 |
VT |
VT000412 |
20261202 |
707000 |
FAC-2026-0412 |
Facture Factur-X FAC-2026-0412 Distributeur Nord Pro SAS | 0,00 |
1000,00 |
VT |
VT000412 |
20261202 |
445710 |
FAC-2026-0412 |
Facture Factur-X FAC-2026-0412 Distributeur Nord Pro SAS | 0,00 |
200,00 |
VT |
VT000413 |
20261202 |
411000 |
FAC-2026-0413 |
Facture Factur-X FAC-2026-0413 Musterwerk GmbH (UE AE) | 850,00 |
0,00 |
VT |
VT000413 |
20261202 |
707100 |
FAC-2026-0413 |
Facture Factur-X FAC-2026-0413 Musterwerk GmbH (UE AE) | 0,00 |
850,00 |
Automated Python FEC pre-close validator
Before delivering a monthly export to your accountant (Pennylane, Sage, Cegid, or ACD) or archiving for DGFiP Test Compta Demat, run an automated validator that checks header order, column count, date formatting, per-entry zero-cent balance, and CWE-1236 spreadsheet formula injection:
from collections import defaultdict
from decimal import Decimal
from pathlib import Path
import re
EXPECTED_HEADERS = [
"JournalCode", "JournalLib", "EcritureNum", "EcritureDate",
"CompteNum", "CompteLib", "CompAuxNum", "CompAuxLib",
"PieceRef", "PieceDate", "EcritureLib", "Debit", "Credit",
"EcritureLet", "DateLet", "ValidDate", "Montantdevise", "Idevise",
]
def verify_fec(path: Path, delimiter: str = "|") -> list[str]:
errors: list[str] = []
lines = path.read_text(encoding="utf-8").splitlines()
if not lines or lines[0].split(delimiter) != EXPECTED_HEADERS:
return ["Invalid or missing 18-column DGFiP FEC header row"]
balances: dict[str, Decimal] = defaultdict(lambda: Decimal("0.00"))
for line_no, raw in enumerate(lines[1:], start=2):
cols = raw.split(delimiter)
if len(cols) != 18:
errors.append(f"Line {line_no}: expected 18 columns, got {len(cols)}")
continue
if not re.fullmatch(r"\d{8}", cols[3]) or not re.fullmatch(r"\d{8}", cols[9]):
errors.append(f"Line {line_no}: EcritureDate/PieceDate must be YYYYMMDD")
if re.match(r"^[=+\-@]", cols[10]):
errors.append(f"Line {line_no}: unsanitized formula prefix in EcritureLib (CWE-1236)")
debit = Decimal(cols[11].replace(",", "."))
credit = Decimal(cols[12].replace(",", "."))
balances[cols[2]] += debit - credit
for entry_num, delta in balances.items():
if delta != Decimal("0.00"):
errors.append(f"Entry {entry_num}: unbalanced Debit/Credit delta={delta}")
return errors
7. Frequently asked questions
Is a plain PDF invoice still valid under France's 2026 and 2027 e-invoicing mandate?
No. Since September 1, 2026, all French VAT-registered businesses must receive structured electronic invoices through an accredited platform (PA/PDP), while large enterprises and mid-caps already issue them. From September 1, 2027, SMEs, micro-businesses, and sole traders must also emit structured domestic B2B invoices in Factur-X (PDF/A-3B + XML CII), UBL, or UN/CEFACT CII rather than unstructured PDFs.
Which Factur-X profile should SMEs and Shopify B2B merchants generate by default?
Generate the EN 16931 (Comfort) profile identified by the URN urn:cen.eu:en16931:2017. Unlike MINIMUM or BASIC WL, EN 16931 carries complete line-level quantities, unit prices, VAT category breakdowns, SIREN identifiers (schemeID 0002), and purchase order references, so every French accredited platform (PA/PDP), Chorus Pro, and German ZUGFeRD 2.x receiver parses it without rejection.
How should a checkout handle EU VIES downtime when validating B2B VAT numbers?
National tax gateways behind the European Commission VIES REST API frequently return MS_UNAVAILABLE or MS_MAX_CONCURRENT_REQ during peak hours. Never block legitimate checkout indefinitely or blindly grant zero-rate reverse charge without verification. Cache confirmed VIES responses with a 24-hour TTL and fall back to strict country-specific regex plus mathematical checksum verification (Luhn, ISO 7064 Mod 11-10, or national weights) while flagging the order for asynchronous VIES re-check before dispatch.
How do you avoid EN 16931 Schematron BR-CO-15 and BR-S-08 rounding errors in XML CII?
Compute every monetary value in integer cents, never floating-point decimals. Round line net amounts (BT-131) to two decimals, aggregate taxable bases strictly per VAT category and rate bucket (BT-116), calculate VAT once per bucket rather than summing pre-rounded per-line taxes, and verify that TaxBasisTotalAmount + TaxTotalAmount equals GrandTotalAmount with zero cent discrepancy before embedding factur-x.xml.
What makes an 18-column DGFiP FEC export audit-ready alongside Factur-X invoices?
Under Article L.47 A-I of the French Livre des Procedures Fiscales, the FEC file must use pipe or tab delimiters, UTF-8 encoding, exact 18-column headers, YYYYMMDD dates, French decimal commas, strict Debit equal to Credit equilibrium on every EcritureNum, distinct revenue accounts for domestic (707000), intra-EU reverse charge (707100), and extra-EU export (707200), immutable reversing entries for 381 credit notes, and CWE-1236 formula sanitization.
Automate Factur-X EN 16931, EU VIES VAT and FEC exports in production
Need ready-to-run compliance on Shopify without building PDF/A-3B streams, VIES fallbacks, and PA/PDP webhooks from scratch? Eclipse Factur-X & EU VAT B2B starts free (up to 15 EN 16931 invoices/month), validates all 27 EU VAT jurisdictions plus French SIREN/SIRET, automates intra-EU reverse charge, and exports balanced 18-column FEC journals. For custom ERP or Python/n8n billing pipelines, explore our fixed-price SME automation packages.
Related Eclipse Technology engineering guides: Shopify B2B Purchase Orders & Net 30 Without Plus · Nextcloud Deduplicate Photos (HEIC, RAW & Memories) · All technical guides