Compliance Matrix
This matrix tracks implementation coverage against the official e-Fatura v11 manual and the XML-XSD package published at efatura.cv/docs/xsd.
| Reference | Rule | Type | Status | Implementation | Test | Notes |
|---|---|---|---|---|---|---|
| Manual 6.2 | DFE XML must follow the official XSD. | xsd | done | XmllintXsdValidator | tests/xsd.test.ts | Uses bundled 2024-05-27 XSD package. |
| Manual 6.2 | XML must be UTF-8 and compact. | local | done | buildDfeXml | tests/xml.test.ts | Generates XML without pretty-print whitespace. |
| Manual 6.2 | DFE root has Version, Id, and DocumentTypeCode. | xsd | done | buildDfeXml | tests/xml.test.ts | Root namespace is urn:cv:efatura:xsd:v1.0. |
| Manual 6.2.2 | IUD has 45 characters and Luhn check digit. | local | done | buildIud, validateIud | tests/iud.test.ts | Luhn is for IUD, not NIF. |
| Manual 6.3.1 | CV NIF format is [1-9][0-9]{8}. | local | done | tax-id value object | tests/validation.test.ts | Existence is PE and DNRE external validation. |
| Manual 6.3 | Party, address, contacts, payments, references, transport and rent receipt are structured fields. | local | done | domain value objects, reserved ExtraFields names | tests/validation.test.ts | Known official fields are first-class schemas and cannot be injected through ExtraFields. |
| Manual 7.2 | Emitter party is mandatory and must include CV NIF, name, address, email and phone/mobile. | local | done | invoice-fiscal-rules, dfe-party-xml | tests/official-rules.test.ts, tests/xml.test.ts | Registry existence is external. |
| Manual 7.2 | Receiver party rules vary by DFE type and threshold. | local | done | documents, invoice-data | tests/validation.test.ts | External NIF existence is separate. |
| Manual 7.2 | Payment party and transport service provider use the same TaxId format rules. | local | done | party-data, tax-id | tests/validation.test.ts | Registry existence is external. |
| Manual 7.9 | Software code, name and version are required. | local | done | resolveConfig, transmissionXml | tests/config.test.ts, tests/xml.test.ts | Registered software validation is external. |
| Manual 7.18 | Transmission includes IssueMode, TransmitterTaxId and Software. | xsd | done | transmissionXml | tests/xml.test.ts, tests/xsd.test.ts | IssueMode enum preserves Online, Offline and Off. |
| Manual 7.19 | Contingency is required when IssueMode is not Online. | local | done | assertContingencyMatchesEmissionMode | tests/official-rules.test.ts | Off requires IUC. |
| Manual 7.21 | Online date/time tolerance and contingency tolerance must be validated. | local | done | validateIssueDateTolerance | tests/event.test.ts, tests/official-rules.test.ts | Uses injectable clock. |
| Manual 7 | Tax type NA requires exemption reason. | local | done | tax-data | tests/validation.test.ts | Tax code enum is exported. |
| Manual 7 | Totals must match line amounts and tax totals. | local | done | invoice-fiscal-rules | tests/official-rules.test.ts | Uses money tolerance of 0.01. |
| Manual 7 | Corrective notes require valid references and reason codes. | local | done | documents, invoice-field-compatibility | tests/validation.test.ts | Includes credit, debit and return notes. |
| Manual 7 | Transport documents require transport type, route and service provider rules. | local | done | documents, transport-structures | tests/validation.test.ts | Recipient activity checks are external. |
| Manual 7 | Receipt type renda requires rent receipt structure. | local | done | documents, document-structures | tests/validation.test.ts | XSD validates generated XML. |
| Manual 8 | XML signature must be XAdES-BES with SHA-256/RSA. | local | done | XadesBesSigner | tests/signing.test.ts | Signature bytes are not compared to official vectors because none are published. |
| Manual 10 | Middleware submission sends Deflate ZIP with {IUD}.xml filenames. | local | done | buildDfeZip, FetchMiddlewareTransport | tests/middleware.test.ts | Internal ZIP baseline fixture exists. |
| Manual 10 | PE/middleware responses must preserve documents, errors and metadata. | local | done | response-parser | tests/response-parser.test.ts | Handles JSON/XML and Portuguese keys. |
| Manual 11 | Transmitter and emitter authorization are configured in middleware/PE. | pe | done | fiscal authority contracts and fetch clients | tests/fiscal-readiness.test.ts, tests/fiscal-readiness-live.test.ts | Live checks require EFATURA_LIVE_TESTS=1 and credentials. |
| Manual 12 | DFA includes QR Code URL and contingency notice. | local | done | PdfDfaRenderer, dfaQrCodeUrl | tests/middleware.test.ts | Base URL is configurable. |
Manual 7, Totals PayableAlternativeAmount; embedded XML Fields Map.txt lines 207-212 | A foreign payable amount is represented as an alternative amount while fiscal values remain in CVE. | local and xsd | done | prepareInvoiceToCve, convertInvoiceToCve, buildDfeXml | tests/currency/currency-xml-dfa.test.ts, tests/xsd.test.ts | The converted CVE payable amount is primary; the original amount is evidence. |
Embedded common/CV_EFatura_Elements_v1.0.xsd, PayableAlternativeAmount@CurrencyCode; embedded common/ISO_ISO3AlphaCurrencyCode_2012-08-31.xsd | Alternative currency uses the schema’s ISO 4217 alphabetic code list. | local and xsd | done | checked-in schema currency set, normalizeCurrencyCode, payableAlternativeAmountSchema, quote validation, XSD validation | tests/currency/schema-currency-codes.test.ts, tests/currency/payable-alternative-currency.test.ts, tests/currency/exchange-rate-quote.test.ts, tests/xsd.test.ts | Provider and low-level invoice validation use the same 178 canonical codes. IDR, IdR, and unknown values fail before XML; XAU, XTS, and XXX remain valid. |
Manual 7, PayableAlternativeAmount@ExchangeRate; embedded XML Fields Map.txt lines 209-212 | Exchange rate is the multiplier from the alternative currency to the CVE payable amount. | local and xsd | done | provider normalization and decimal conversion | tests/currency/convert-invoice-to-cve.test.ts, tests/currency/currency-xml-dfa.test.ts | Direction is amountInTarget = amountInSource * rate. |
Embedded common/CV_EFatura_Elements_v1.0.xsd, ExchangeRate; embedded common/CV_EFatura_Types_v1.0.xsd, stDecimal5MinExc0 | Exchange rate is positive with at most five fractional digits. | xsd | done | validateExchangeRateQuote, XML number formatting | tests/currency/exchange-rate-quote.test.ts, tests/xsd.test.ts | The active XSD governs despite an earlier three-decimal artifact note. |
| Manual 12 DFA rules and Manual 7 fiscal totals | DFA primary monetary values remain in CVE and conversion evidence is supplementary. | local | done | dfaRenderInputFrom, PdfDfaRenderer | tests/currency/currency-xml-dfa.test.ts, tests/dfa-pdf-renderer.test.ts | Foreign currency labels are rejected for IUD-only rendering and ignored in favor of CVE when an invoice is present. |
| Manual 7 fiscal totals and audit consistency | Conversion metadata cannot claim payable values absent from or inconsistent with the invoice. | local | done | prepareInvoiceToCve, dfaRenderInputFrom | tests/currency/prepare-invoice-to-cve.test.ts, tests/currency/convert-invoice-to-cve.test.ts, tests/currency/currency-xml-dfa.test.ts | Preparation rejects documents without totals. DFA metadata must target CVE and agree with invoice and alternative payable values. |
| Artifacts | Official XML examples are validated against XSD. | artifact | done | bundled XML-XSD package | tests/xsd.test.ts | Source is official XML-XSD package. |
| Artifacts | Official golden vectors for IUD, ZIP and signature. | artifact | not published | FileSystemGoldenVectorRepository | tests/golden-vectors.test.ts | Internal fixtures are package baselines, not DNRE vectors. |