Fix CII schema violation: emit an empty ApplicableHeaderTradeDelivery element
Validate e-invoices / mustang (push) Failing after 19s

Mustang's Phase 4 CI check (validate-einvoice.yml) caught this on its very first real run: @e-invoice-eu/core's UBL->CII conversion silently drops the whole Delivery container when cac:Delivery is absent from the UBL input, breaking CII's fixed Agreement/Delivery/Settlement element order and failing schema validation on every generated e-invoice (original, Storno, and Gutschrift alike).
This commit is contained in:
Marco
2026-07-23 12:23:03 +00:00
parent 29ea9fafd8
commit ffd4c40d92
+15
View File
@@ -69,6 +69,19 @@ function isoDate(iso: string): string {
return iso.slice(0, 10);
}
// Empty on purpose — this shop doesn't track a separate delivery date/
// location distinct from the invoice itself (and a Storno never shipped at
// all, so asserting one would be factually wrong). The *element* still has
// to exist, though: CII's SupplyChainTradeTransaction is a fixed
// Agreement/Delivery/Settlement sequence, and @e-invoice-eu/core's UBL→CII
// conversion drops the whole `ram:ApplicableHeaderTradeDelivery` container
// when `cac:Delivery` is absent from the UBL input — which then fails
// schema validation (Mustang: "Invalid content ... ApplicableHeaderTrade
// Settlement. One of ApplicableHeaderTradeDelivery is expected", caught by
// the Phase 4 CI check on the very first real run). An empty object here
// still emits the required empty `<ram:ApplicableHeaderTradeDelivery/>`.
const DELIVERY: UblInvoice["cac:Delivery"] = {};
function paymentMeans(seller: InvoiceSeller, paymentMethodTitle: string): UblInvoice["cac:PaymentMeans"] {
if (!seller.iban) return undefined;
return [
@@ -180,6 +193,7 @@ export function buildEInvoiceData(order: InvoiceOrder, seller: InvoiceSeller): I
order.city,
order.country,
),
"cac:Delivery": DELIVERY,
"cac:PaymentMeans": paymentMeans(seller, order.paymentMethodTitle),
"cac:TaxTotal": taxTotal(rateGroups),
"cac:LegalMonetaryTotal": {
@@ -243,6 +257,7 @@ export function buildCorrectionEInvoiceData(kind: CorrectionInvoiceKind, order:
order.city,
order.country,
),
"cac:Delivery": DELIVERY,
"cac:PaymentMeans": paymentMeans(seller, "Überweisung"),
"cac:TaxTotal": taxTotal(rateGroups),
"cac:LegalMonetaryTotal": {