efaturaefatura
Beta

Beta documentation. APIs may change before the stable release.

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.

ReferenceRuleTypeStatusImplementationTestNotes
Manual 6.2DFE XML must follow the official XSD.xsddoneXmllintXsdValidatortests/xsd.test.tsUses bundled 2024-05-27 XSD package.
Manual 6.2XML must be UTF-8 and compact.localdonebuildDfeXmltests/xml.test.tsGenerates XML without pretty-print whitespace.
Manual 6.2DFE root has Version, Id, and DocumentTypeCode.xsddonebuildDfeXmltests/xml.test.tsRoot namespace is urn:cv:efatura:xsd:v1.0.
Manual 6.2.2IUD has 45 characters and Luhn check digit.localdonebuildIud, validateIudtests/iud.test.tsLuhn is for IUD, not NIF.
Manual 6.3.1CV NIF format is [1-9][0-9]{8}.localdonetax-id value objecttests/validation.test.tsExistence is PE and DNRE external validation.
Manual 6.3Party, address, contacts, payments, references, transport and rent receipt are structured fields.localdonedomain value objects, reserved ExtraFields namestests/validation.test.tsKnown official fields are first-class schemas and cannot be injected through ExtraFields.
Manual 7.2Emitter party is mandatory and must include CV NIF, name, address, email and phone/mobile.localdoneinvoice-fiscal-rules, dfe-party-xmltests/official-rules.test.ts, tests/xml.test.tsRegistry existence is external.
Manual 7.2Receiver party rules vary by DFE type and threshold.localdonedocuments, invoice-datatests/validation.test.tsExternal NIF existence is separate.
Manual 7.2Payment party and transport service provider use the same TaxId format rules.localdoneparty-data, tax-idtests/validation.test.tsRegistry existence is external.
Manual 7.9Software code, name and version are required.localdoneresolveConfig, transmissionXmltests/config.test.ts, tests/xml.test.tsRegistered software validation is external.
Manual 7.18Transmission includes IssueMode, TransmitterTaxId and Software.xsddonetransmissionXmltests/xml.test.ts, tests/xsd.test.tsIssueMode enum preserves Online, Offline and Off.
Manual 7.19Contingency is required when IssueMode is not Online.localdoneassertContingencyMatchesEmissionModetests/official-rules.test.tsOff requires IUC.
Manual 7.21Online date/time tolerance and contingency tolerance must be validated.localdonevalidateIssueDateTolerancetests/event.test.ts, tests/official-rules.test.tsUses injectable clock.
Manual 7Tax type NA requires exemption reason.localdonetax-datatests/validation.test.tsTax code enum is exported.
Manual 7Totals must match line amounts and tax totals.localdoneinvoice-fiscal-rulestests/official-rules.test.tsUses money tolerance of 0.01.
Manual 7Corrective notes require valid references and reason codes.localdonedocuments, invoice-field-compatibilitytests/validation.test.tsIncludes credit, debit and return notes.
Manual 7Transport documents require transport type, route and service provider rules.localdonedocuments, transport-structurestests/validation.test.tsRecipient activity checks are external.
Manual 7Receipt type renda requires rent receipt structure.localdonedocuments, document-structurestests/validation.test.tsXSD validates generated XML.
Manual 8XML signature must be XAdES-BES with SHA-256/RSA.localdoneXadesBesSignertests/signing.test.tsSignature bytes are not compared to official vectors because none are published.
Manual 10Middleware submission sends Deflate ZIP with {IUD}.xml filenames.localdonebuildDfeZip, FetchMiddlewareTransporttests/middleware.test.tsInternal ZIP baseline fixture exists.
Manual 10PE/middleware responses must preserve documents, errors and metadata.localdoneresponse-parsertests/response-parser.test.tsHandles JSON/XML and Portuguese keys.
Manual 11Transmitter and emitter authorization are configured in middleware/PE.pedonefiscal authority contracts and fetch clientstests/fiscal-readiness.test.ts, tests/fiscal-readiness-live.test.tsLive checks require EFATURA_LIVE_TESTS=1 and credentials.
Manual 12DFA includes QR Code URL and contingency notice.localdonePdfDfaRenderer, dfaQrCodeUrltests/middleware.test.tsBase URL is configurable.
Manual 7, Totals PayableAlternativeAmount; embedded XML Fields Map.txt lines 207-212A foreign payable amount is represented as an alternative amount while fiscal values remain in CVE.local and xsddoneprepareInvoiceToCve, convertInvoiceToCve, buildDfeXmltests/currency/currency-xml-dfa.test.ts, tests/xsd.test.tsThe 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.xsdAlternative currency uses the schema’s ISO 4217 alphabetic code list.local and xsddonechecked-in schema currency set, normalizeCurrencyCode, payableAlternativeAmountSchema, quote validation, XSD validationtests/currency/schema-currency-codes.test.ts, tests/currency/payable-alternative-currency.test.ts, tests/currency/exchange-rate-quote.test.ts, tests/xsd.test.tsProvider 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-212Exchange rate is the multiplier from the alternative currency to the CVE payable amount.local and xsddoneprovider normalization and decimal conversiontests/currency/convert-invoice-to-cve.test.ts, tests/currency/currency-xml-dfa.test.tsDirection is amountInTarget = amountInSource * rate.
Embedded common/CV_EFatura_Elements_v1.0.xsd, ExchangeRate; embedded common/CV_EFatura_Types_v1.0.xsd, stDecimal5MinExc0Exchange rate is positive with at most five fractional digits.xsddonevalidateExchangeRateQuote, XML number formattingtests/currency/exchange-rate-quote.test.ts, tests/xsd.test.tsThe active XSD governs despite an earlier three-decimal artifact note.
Manual 12 DFA rules and Manual 7 fiscal totalsDFA primary monetary values remain in CVE and conversion evidence is supplementary.localdonedfaRenderInputFrom, PdfDfaRenderertests/currency/currency-xml-dfa.test.ts, tests/dfa-pdf-renderer.test.tsForeign 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 consistencyConversion metadata cannot claim payable values absent from or inconsistent with the invoice.localdoneprepareInvoiceToCve, dfaRenderInputFromtests/currency/prepare-invoice-to-cve.test.ts, tests/currency/convert-invoice-to-cve.test.ts, tests/currency/currency-xml-dfa.test.tsPreparation rejects documents without totals. DFA metadata must target CVE and agree with invoice and alternative payable values.
ArtifactsOfficial XML examples are validated against XSD.artifactdonebundled XML-XSD packagetests/xsd.test.tsSource is official XML-XSD package.
ArtifactsOfficial golden vectors for IUD, ZIP and signature.artifactnot publishedFileSystemGoldenVectorRepositorytests/golden-vectors.test.tsInternal fixtures are package baselines, not DNRE vectors.