@ekwo-ai/fec

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

The French FEC — fichier des ecritures comptables — in TypeScript: the eighteen columns of the arrete du 29 juillet 2013, from plain ledger rows, and read back into accounts, parties and entries. Zero dependencies.

原始使用文档

@ekwo-ai/fec

The French FEC — fichier des écritures comptables — in TypeScript, with no dependencies.

Eighteen columns, in the order fixed by the arrêté du 29 juillet 2013 (art. A. 47 A-1 du Livre des procédures fiscales). Give it ledger rows and it gives you the file, the name the administration expects, and the list of what does not add up.

import { checkFec, fecFileName, fromQueryRow, generateFec } from '@ekwo-ai/fec';

const lines = rows.map(fromQueryRow); // rows of a `fec_lines(...)` query
const violations = checkFec(lines);   // empty, or what an inspector reads first
const file = generateFec(lines);      // `|` separated, comma decimals, CRLF
const name = fecFileName('123456789', '2026-12-31'); // 123456789FEC20261231.txt

FecQueryRow is the row shape of the fec_lines(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.

The opening lines

A file that covers a whole financial year starts with its à-nouveaux: one line per balance-sheet account, at the balance it carried on the last day of the year before, on the opening journal and dated on the first day of the year. This package does nothing special with them — they arrive as ordinary rows, they carry one entry number of their own, and checkFec balances them like any other entry.

Where they come from is the producer's business. In Ekwo OS they are computed from the ledger rather than posted, and two of their properties are worth knowing when you read a file:

  • An unclosed year still carries its result. When the year before has not been closed, the difference between the balance-sheet lines is the result nobody has allocated yet, and it arrives as one more opening line on the balance-sheet account the close would have put it on. The file balances whether or not the meeting has happened.
  • The entries of a year-end close are not in the file of the year they close. They would show the result twice — once in the ordinary movements, once on the balance sheet — so the income statement reads from the movements as it always did, and the result reaches the balance sheet in the opening lines of the year that follows.

An extract that is not a whole financial year gets no opening lines: it is an extract of movements, and fecFileName is built from a year end.

Reading one back

readFec() goes the other way: the file this package writes, and the one any package that keeps books in France hands over when asked for a year, into the plain shape every reader of an accounting export in this repository declares — accounts, parties, entries, violations.

import { readFec } from '@ekwo-ai/fec';

const books = readFec(bytesOrString);                            // UTF-8, fatally
const latin = readFec(bytes, { encoding: 'iso-8859-15' });       // said, never guessed

books.entries;    // [{ journal: 'VE', number: '1', date: '2025-01-15', reference: 'F-001', lines: […] }, …]
books.contacts;   // one per CompAuxNum, named by CompAuxLib
books.violations; // an entry that does not balance, a line with two sides, an entry on two dates
  • The columns are found by their names in the header, which the arrêté makes mandatory: the variants of the text add columns (a cash-basis taxpayer's four) or write Montant and Sens instead of Debit and Credit, and all of them read.
  • The separator is the one the header uses, a tab or a vertical bar. Dates are AAAAMMJJ, refused otherwise; an amount has a comma or a point as its decimal mark and nothing else.
  • An entry is the lines that share a JournalCode and an EcritureNum. Each line keeps its party (CompAuxNum), its currency amount (Montantdevise, Idevise) and its reconciliation mark (EcritureLet).
  • A FEC is kept in the currency of the books and never says which, so currency is null. The à-nouveaux arrive as the entries of their journal, like any other: saying that journal is the opening is the importer's business.

What does not add up comes back in violations, the entry as written beside it; what is not a FEC is thrown as a BooksFileError with a code. In Ekwo OS this is ekwo import fec <file>.

The separators are options: decimalSeparator, fieldSeparator, newline, header. The defaults are what the French tooling expects.

MIT.

版本与发布记录

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

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

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

@ekwo-ai/fec 是什么?

The French FEC — fichier des ecritures comptables — in TypeScript: the eighteen columns of the arrete du 29 juillet 2013, from plain ledger rows, and read back into accounts, parties and entries. Zero dependencies.

如何安装 @ekwo-ai/fec?

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

@ekwo-ai/fec 支持 TypeScript 吗?

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

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

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

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

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

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

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

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

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

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

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