@ekwo-ai/ecdf

中文文档
0.25.2发布于 2026/11/13MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 2531

The Luxembourg eCDF XML interface file (v2.0) in TypeScript, with the four recapitulative statement forms it carries. Zero dependencies.

原始使用文档
文档目录6 节
  1. eCDF is an envelope, not a form
  2. The specification this was written from
  3. Amounts and numbers
  4. The file name
  5. What it refuses and what it reports
  6. What is out of scope, on purpose

@ekwo-ai/ecdf

The Luxembourg eCDF interface file, version 2.0, in TypeScript, with no dependencies — and the four forms it carries that are a recapitulative statement of European Union supplies.

import { generateEcdf } from '@ekwo-ai/ecdf';

const { file, filename, declarations, violations } = generateEcdf(rows, {
  prefix: '000000',
  interfaceId: 'DEMO',
  agent: { matrNbr: '19999999999', rcsNbr: 'B999999', vatNbr: '99999999' },
  declarer: { matrNbr: '19999999999', rcsNbr: 'B999999', vatNbr: '99999999' },
  cadence: 'quarter',
  year: 2026,
  period: 3,
});

StatementRow is the row shape of the ec_sales_list(company, from, to) function of Ekwo OS, declared here so that nothing is imported from it. Any book-keeping system that can produce those columns can use this package; it reads no database and knows no accounting.

eCDF is an envelope, not a form

One XML file carries any number of declarations, each named by a type and filled with fields identified by number. This package writes the envelope and knows the four types that carry a statement:

typeWhat it declaresFiled
TVA_LICMSupplies of goods and triangular operationsMonthly
TVA_LICTThe sameQuarterly
TVA_PSIMSupplies of servicesMonthly
TVA_PSITThe sameQuarterly

One call writes both forms where the period carries both natures: goods and services are separate filings in Luxembourg, and the envelope is made to hold several. A nature with nothing in it produces no declaration, because eCDF refuses a statement whose every table is empty — and generateEcdf says so in a violation rather than handing back a file that will be rejected.

The field identifiers are the ones the forms print: state I of the goods form is 01 country, 02 number, 03 amount, with 04 as its total; state II — the triangular operations — is 05, 06, 07 with total 08; the services form uses 01, 02, 03 with total 04. Field 16 is the total of the corrections, written as zero here because corrections are out of scope.

The specification this was written from

WhatWhere
The schema, eCDF_file_v2.0-XML_schema.xsdhttps://ecdf-developer.b2g.etat.lu/ecdf/formdocs/eCDF_file_v2.0-XML_documentation-01-EN.pdf
Documentation of the XML file, v2.0, CTIE, 24 November 2022https://ecdf-developer.b2g.etat.lu/ecdf/formdocs/eCDF_file_v2.0-XML_documentation-01-EN.pdf
A complete example, with TVA_LICM, TVA_LICT, TVA_PSIM and TVA_PSIThttps://ecdf.b2g.etat.lu/ecdf/formdocs/eCDF_XML_file_example-FR.pdf
The blank forms and the filing rules, 2026https://ecdf.b2g.etat.lu/ecdf/formdocs/2026/TVA_LICM/2026M1V001/ and the three siblings

The schema itself is at https://ecdf-developer.b2g.etat.lu/ecdf/formdocs/eCDF_file_v2.0-XML_schema.xsd.

The output of this package was checked against that schema with xmllint before it was committed, with one caveat worth writing down: libxml2 cannot evaluate the [\P{Cc}]+ pattern the schema puts on every TextField, and rejects DE against it. Replacing that one pattern with .+ makes the file validate. The schema is not shipped here — it belongs to the administration and it moves.

Three things about it that an example does not show:

  • Tables come last. Every simple field of a FormData is written before the first Table, and a file that interleaves them is refused.
  • id="352" is not id="0352". The identifier is a string, and a leading zero makes a different field.
  • There is no schema per form. The XSD accepts any id under FormData; which identifiers a given type allows is checked by the server. The validation-rules document that would state each field's type formally sits behind authentication, so the field types here come from the published example and the printed forms.

Amounts and numbers

A comma, never a point — not even as a thousands separator. Up to two decimals, and a minus sign where a credit note has taken the line below zero. Everything is in euro; the forms carry no currency field.

The customer's country and number are two separate fields, which is exactly the shape the statement rows already have. Do not concatenate them. The declarer's own VAT number is eight digits without LU, or NE.

The file name

eCDF fixes it: the file on disk is called <FileReference>.xml, where the reference is <prefix>X<yyyymmdd>T<hhmmss><nn> — the agent's six-character eCDF prefix, an X for an XML file, the moment it was built, and two digits that separate two files of the same second. A fresh reference is generated for every file. generateEcdf returns both the name and the reference.

What it refuses and what it reports

An exception, because it would make the whole file meaningless: a prefix that is not six characters, a missing interface identifier, a MatrNbr, VATNbr or RCSNbr the schema's own patterns reject, or a period that does not fit the cadence.

A violation, because one line is wrong and the rest of the file is not: whatever the producer flagged, unknown_nature, wrong_currency, no_vat_number, vat_number_is_the_declarer, nil_amount, and nothing_to_declare when no form came out at all.

What is out of scope, on purpose

  • Corrections. States III and V of the goods form and state II of the services form carry them, with the period being corrected and, on the goods side, a localised "Oui"/"Ja" in field 15. Producing one means knowing what was filed before, which is a question for the books.
  • Call-off stock, states IV and V of the goods form. The published example predates them and the type of their boolean fields could not be read from any document available without an account, so nothing is guessed at here.
  • Filing. Interface must hold an identifier the CTIE attributes after an access request and an interface validation. A file without one is refused. Writing valid XML is possible today; depositing it is not, until that agreement exists.

MIT.

版本与发布记录

@ekwo-ai/ecdf 共发布 33 个版本,首次发布于 2026/09/19;过去 12 个月发布了 33 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.25.2latest2026/11/13今天
0.25.12026/11/13今天
0.25.02026/11/076 天前
0.24.12026/11/059 天前
0.24.02026/10/2816 天前
0.23.02026/10/2816 天前

关于 @ekwo-ai/ecdf 的常见问题

@ekwo-ai/ecdf 是什么?

The Luxembourg eCDF XML interface file (v2.0) in TypeScript, with the four recapitulative statement forms it carries. Zero dependencies.

如何安装 @ekwo-ai/ecdf?

在项目目录运行 npm install @ekwo-ai/ecdf,或使用 pnpm add / yarn add / bun add。

@ekwo-ai/ecdf 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@ekwo-ai/ecdf 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@ekwo-ai/ecdf 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@ekwo-ai/ecdf 可以商用吗?

@ekwo-ai/ecdf 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@ekwo-ai/ecdf 的下载量有多少?

根据 npm 官方下载统计,@ekwo-ai/ecdf 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,531 次,日均约 84 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@ekwo-ai/ecdf 还在维护吗?

最新版本 0.25.2 发布于 2026/11/13(今天);至今共发布 33 个版本,其中过去 12 个月发布了 33 个;首次发布于 2026/09/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。