@ekwo-ai/fec 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ekwo AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # `@ekwo-ai/fec`
2
+
3
+ The French **FEC** — *fichier des écritures comptables* — in TypeScript, with
4
+ no dependencies.
5
+
6
+ Eighteen columns, in the order fixed by the arrêté du 29 juillet 2013 (art.
7
+ A. 47 A-1 du Livre des procédures fiscales). Give it ledger rows and it gives
8
+ you the file, the name the administration expects, and the list of what does
9
+ not add up.
10
+
11
+ ```ts
12
+ import { checkFec, fecFileName, fromQueryRow, generateFec } from '@ekwo-ai/fec';
13
+
14
+ const lines = rows.map(fromQueryRow); // rows of a `fec_lines(...)` query
15
+ const violations = checkFec(lines); // empty, or what an inspector reads first
16
+ const file = generateFec(lines); // `|` separated, comma decimals, CRLF
17
+ const name = fecFileName('123456789', '2026-12-31'); // 123456789FEC20261231.txt
18
+ ```
19
+
20
+ `FecQueryRow` is the row shape of the `fec_lines(company, from, to)` function of
21
+ [Ekwo OS](https://github.com/Ekwo-ai/ekwo-os), declared here so that nothing is
22
+ imported from it. Any book-keeping system that can produce those columns can
23
+ use this package; it reads no database and knows no accounting.
24
+
25
+ ## The opening lines
26
+
27
+ A file that covers a whole financial year starts with its *à-nouveaux*: one
28
+ line per balance-sheet account, at the balance it carried on the last day of
29
+ the year before, on the opening journal and dated on the first day of the year.
30
+ This package does nothing special with them — they arrive as ordinary rows,
31
+ they carry one entry number of their own, and `checkFec` balances them like any
32
+ other entry.
33
+
34
+ Where they come from is the producer's business. In Ekwo OS they are computed
35
+ from the ledger rather than posted, and two of their properties are worth
36
+ knowing when you read a file:
37
+
38
+ - **An unclosed year still carries its result.** When the year before has not
39
+ been closed, the difference between the balance-sheet lines is the result
40
+ nobody has allocated yet, and it arrives as one more opening line on the
41
+ balance-sheet account the close would have put it on. The file balances
42
+ whether or not the meeting has happened.
43
+ - **The entries of a year-end close are not in the file of the year they
44
+ close.** They would show the result twice — once in the ordinary movements,
45
+ once on the balance sheet — so the income statement reads from the movements
46
+ as it always did, and the result reaches the balance sheet in the opening
47
+ lines of the year that follows.
48
+
49
+ An extract that is not a whole financial year gets no opening lines: it is an
50
+ extract of movements, and `fecFileName` is built from a year end.
51
+
52
+ The separators are options: `decimalSeparator`, `fieldSeparator`, `newline`,
53
+ `header`. The defaults are what the French tooling expects.
54
+
55
+ MIT.
@@ -0,0 +1,108 @@
1
+ /**
2
+ * The French FEC — *fichier des ecritures comptables*.
3
+ *
4
+ * Eighteen columns fixed by the arrete du 29 juillet 2013 (art. A. 47 A-1 du
5
+ * Livre des procedures fiscales). Feed it the rows of a `fec_lines(company,
6
+ * from, to)` query — {@link FecQueryRow} is that shape — and it writes the
7
+ * file.
8
+ *
9
+ * It depends on nothing, reads no database and knows no accounting: the rows
10
+ * come from wherever the books are kept.
11
+ */
12
+ /** ISO-8601 calendar date, `YYYY-MM-DD`. */
13
+ export type IsoDate = string;
14
+ /**
15
+ * A fixed-point number as Postgres returns `numeric`: a string, because a
16
+ * double would lose cents on the way in.
17
+ */
18
+ export type Decimal = string;
19
+ /** The eighteen column headers, in the order the specification fixes. */
20
+ export declare const FEC_COLUMNS: readonly ["JournalCode", "JournalLib", "EcritureNum", "EcritureDate", "CompteNum", "CompteLib", "CompAuxNum", "CompAuxLib", "PieceRef", "PieceDate", "EcritureLib", "Debit", "Credit", "EcritureLet", "DateLet", "ValidDate", "Montantdevise", "Idevise"];
21
+ export type FecColumn = (typeof FEC_COLUMNS)[number];
22
+ /**
23
+ * One line of the file. Field names match the columns; dates are ISO
24
+ * (`YYYY-MM-DD`) and converted to `YYYYMMDD` on output. Amounts accept a
25
+ * number or the string Postgres returns for `numeric`.
26
+ */
27
+ export interface FecLine {
28
+ journalCode: string;
29
+ journalLib: string;
30
+ ecritureNum: string;
31
+ ecritureDate: IsoDate | Date;
32
+ compteNum: string;
33
+ compteLib: string;
34
+ compAuxNum?: string | null;
35
+ compAuxLib?: string | null;
36
+ pieceRef: string;
37
+ pieceDate: IsoDate | Date;
38
+ ecritureLib: string;
39
+ debit: number | Decimal;
40
+ credit: number | Decimal;
41
+ ecritureLet?: string | null;
42
+ dateLet?: IsoDate | Date | null;
43
+ validDate: IsoDate | Date;
44
+ montantDevise?: number | Decimal | null;
45
+ idevise?: string | null;
46
+ }
47
+ export interface FecOptions {
48
+ /**
49
+ * Decimal separator. The administration accepts both; a comma is what the
50
+ * French tooling expects and is the default.
51
+ */
52
+ decimalSeparator?: ',' | '.';
53
+ /** Field separator. `|` is the usual choice and the default. */
54
+ fieldSeparator?: '|' | '\t';
55
+ /** Line ending. Default `\r\n`. */
56
+ newline?: '\r\n' | '\n';
57
+ /** Emit the header row. Default true; the specification requires it. */
58
+ header?: boolean;
59
+ }
60
+ /** `2026-08-31` or a Date becomes `20260831`. Empty input becomes ''. */
61
+ export declare function formatFecDate(value: IsoDate | Date | null | undefined): string;
62
+ /** Two decimals, no thousands separator, with the chosen decimal mark. */
63
+ export declare function formatFecAmount(value: number | Decimal | null | undefined, separator?: ',' | '.'): string;
64
+ export declare class FecError extends Error {
65
+ name: string;
66
+ }
67
+ export interface FecViolation {
68
+ /** Zero-based index in the input, or `null` for a whole-file rule. */
69
+ line: number | null;
70
+ rule: string;
71
+ message: string;
72
+ }
73
+ /**
74
+ * Checks the file-level rules a tax inspector applies first: mandatory
75
+ * fields, one side per line, and each entry balancing to zero.
76
+ */
77
+ export declare function checkFec(lines: readonly FecLine[]): FecViolation[];
78
+ /** The whole file as a string. Write it out as UTF-8 or ISO-8859-15. */
79
+ export declare function generateFec(lines: readonly FecLine[], options?: FecOptions): string;
80
+ /**
81
+ * The file name the administration expects: SIREN, the literal `FEC`, the
82
+ * closing date of the financial year, `.txt`.
83
+ */
84
+ export declare function fecFileName(siren: string, fiscalYearEnd: IsoDate | Date): string;
85
+ /** Row shape returned by the `fec_lines()` database function. */
86
+ export interface FecQueryRow {
87
+ journal_code: string;
88
+ journal_lib: string;
89
+ ecriture_num: string;
90
+ ecriture_date: string | Date;
91
+ compte_num: string;
92
+ compte_lib: string;
93
+ comp_aux_num: string | null;
94
+ comp_aux_lib: string | null;
95
+ piece_ref: string;
96
+ piece_date: string | Date;
97
+ ecriture_lib: string;
98
+ debit: string;
99
+ credit: string;
100
+ ecriture_let: string | null;
101
+ date_let: string | Date | null;
102
+ valid_date: string | Date;
103
+ montant_devise: string | null;
104
+ idevise: string | null;
105
+ }
106
+ /** Maps a `fec_lines()` row onto a {@link FecLine}. */
107
+ export declare function fromQueryRow(row: FecQueryRow): FecLine;
108
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;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U,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,uDAAuD;AACvD,wBAAgB,YAAY,CAAC,GAAG,EAAE,WAAW,GAAG,OAAO,CAqBtD"}
package/dist/index.js ADDED
@@ -0,0 +1,192 @@
1
+ /**
2
+ * The French FEC — *fichier des ecritures comptables*.
3
+ *
4
+ * Eighteen columns fixed by the arrete du 29 juillet 2013 (art. A. 47 A-1 du
5
+ * Livre des procedures fiscales). Feed it the rows of a `fec_lines(company,
6
+ * from, to)` query — {@link FecQueryRow} is that shape — and it writes the
7
+ * file.
8
+ *
9
+ * It depends on nothing, reads no database and knows no accounting: the rows
10
+ * come from wherever the books are kept.
11
+ */
12
+ /** The eighteen column headers, in the order the specification fixes. */
13
+ export const FEC_COLUMNS = [
14
+ 'JournalCode',
15
+ 'JournalLib',
16
+ 'EcritureNum',
17
+ 'EcritureDate',
18
+ 'CompteNum',
19
+ 'CompteLib',
20
+ 'CompAuxNum',
21
+ 'CompAuxLib',
22
+ 'PieceRef',
23
+ 'PieceDate',
24
+ 'EcritureLib',
25
+ 'Debit',
26
+ 'Credit',
27
+ 'EcritureLet',
28
+ 'DateLet',
29
+ 'ValidDate',
30
+ 'Montantdevise',
31
+ 'Idevise',
32
+ ];
33
+ const DEFAULTS = {
34
+ decimalSeparator: ',',
35
+ fieldSeparator: '|',
36
+ newline: '\r\n',
37
+ header: true,
38
+ };
39
+ /** `2026-08-31` or a Date becomes `20260831`. Empty input becomes ''. */
40
+ export function formatFecDate(value) {
41
+ if (value === null || value === undefined || value === '')
42
+ return '';
43
+ if (value instanceof Date) {
44
+ const y = value.getUTCFullYear().toString().padStart(4, '0');
45
+ const m = (value.getUTCMonth() + 1).toString().padStart(2, '0');
46
+ const d = value.getUTCDate().toString().padStart(2, '0');
47
+ return `${y}${m}${d}`;
48
+ }
49
+ const match = /^(\d{4})-(\d{2})-(\d{2})/.exec(value);
50
+ if (match === null)
51
+ throw new FecError(`invalid date: ${value}`);
52
+ return `${match[1]}${match[2]}${match[3]}`;
53
+ }
54
+ /** Two decimals, no thousands separator, with the chosen decimal mark. */
55
+ export function formatFecAmount(value, separator = ',') {
56
+ if (value === null || value === undefined || value === '')
57
+ return '';
58
+ const n = typeof value === 'number' ? value : Number(value);
59
+ if (!Number.isFinite(n))
60
+ throw new FecError(`invalid amount: ${String(value)}`);
61
+ return n.toFixed(2).replace('.', separator);
62
+ }
63
+ export class FecError extends Error {
64
+ name = 'FecError';
65
+ }
66
+ /**
67
+ * Checks the file-level rules a tax inspector applies first: mandatory
68
+ * fields, one side per line, and each entry balancing to zero.
69
+ */
70
+ export function checkFec(lines) {
71
+ const violations = [];
72
+ const perEntry = new Map();
73
+ lines.forEach((line, index) => {
74
+ for (const field of ['journalCode', 'ecritureNum', 'compteNum', 'ecritureLib']) {
75
+ if (line[field] === undefined || line[field] === null || line[field] === '') {
76
+ violations.push({ line: index, rule: 'required', message: `${field} is empty` });
77
+ }
78
+ }
79
+ const debit = Number(line.debit ?? 0);
80
+ const credit = Number(line.credit ?? 0);
81
+ if (debit !== 0 && credit !== 0) {
82
+ violations.push({
83
+ line: index,
84
+ rule: 'one-side',
85
+ message: 'a line carries both a debit and a credit',
86
+ });
87
+ }
88
+ if (debit < 0 || credit < 0) {
89
+ violations.push({
90
+ line: index,
91
+ rule: 'sign',
92
+ message: 'amounts must be positive; a reversal flips the side',
93
+ });
94
+ }
95
+ if ((line.ecritureLet ?? '') !== '' && (line.dateLet ?? '') === '') {
96
+ violations.push({
97
+ line: index,
98
+ rule: 'letter',
99
+ message: 'EcritureLet is set but DateLet is empty',
100
+ });
101
+ }
102
+ const key = `${line.journalCode}/${line.ecritureNum}`;
103
+ const bucket = perEntry.get(key) ?? { debit: 0, credit: 0, first: index };
104
+ bucket.debit += debit;
105
+ bucket.credit += credit;
106
+ perEntry.set(key, bucket);
107
+ });
108
+ for (const [key, bucket] of perEntry) {
109
+ if (Math.abs(bucket.debit - bucket.credit) > 0.005) {
110
+ violations.push({
111
+ line: bucket.first,
112
+ rule: 'balance',
113
+ message: `entry ${key} has debit ${bucket.debit.toFixed(2)} and credit ${bucket.credit.toFixed(2)}`,
114
+ });
115
+ }
116
+ }
117
+ return violations;
118
+ }
119
+ /** The whole file as a string. Write it out as UTF-8 or ISO-8859-15. */
120
+ export function generateFec(lines, options = {}) {
121
+ const opts = { ...DEFAULTS, ...options };
122
+ const sep = opts.fieldSeparator;
123
+ const clean = (value) => {
124
+ if (value === null || value === undefined)
125
+ return '';
126
+ // A separator or a newline inside a field would shift every column after
127
+ // it; the format has no quoting, so they become a space and runs of
128
+ // whitespace are collapsed.
129
+ return value.replace(/[\r\n\t|]+/g, ' ').replace(/\s+/g, ' ').trim();
130
+ };
131
+ const out = [];
132
+ if (opts.header)
133
+ out.push(FEC_COLUMNS.join(sep));
134
+ for (const line of lines) {
135
+ out.push([
136
+ clean(line.journalCode),
137
+ clean(line.journalLib),
138
+ clean(line.ecritureNum),
139
+ formatFecDate(line.ecritureDate),
140
+ clean(line.compteNum),
141
+ clean(line.compteLib),
142
+ clean(line.compAuxNum),
143
+ clean(line.compAuxLib),
144
+ clean(line.pieceRef),
145
+ formatFecDate(line.pieceDate),
146
+ clean(line.ecritureLib),
147
+ formatFecAmount(line.debit, opts.decimalSeparator),
148
+ formatFecAmount(line.credit, opts.decimalSeparator),
149
+ clean(line.ecritureLet),
150
+ formatFecDate(line.dateLet),
151
+ formatFecDate(line.validDate),
152
+ formatFecAmount(line.montantDevise, opts.decimalSeparator),
153
+ clean(line.idevise),
154
+ ].join(sep));
155
+ }
156
+ return out.join(opts.newline) + opts.newline;
157
+ }
158
+ /**
159
+ * The file name the administration expects: SIREN, the literal `FEC`, the
160
+ * closing date of the financial year, `.txt`.
161
+ */
162
+ export function fecFileName(siren, fiscalYearEnd) {
163
+ const digits = siren.replace(/\D/g, '');
164
+ if (digits.length !== 9) {
165
+ throw new FecError(`a SIREN has nine digits, got "${siren}"`);
166
+ }
167
+ return `${digits}FEC${formatFecDate(fiscalYearEnd)}.txt`;
168
+ }
169
+ /** Maps a `fec_lines()` row onto a {@link FecLine}. */
170
+ export function fromQueryRow(row) {
171
+ return {
172
+ journalCode: row.journal_code,
173
+ journalLib: row.journal_lib,
174
+ ecritureNum: row.ecriture_num,
175
+ ecritureDate: row.ecriture_date,
176
+ compteNum: row.compte_num,
177
+ compteLib: row.compte_lib,
178
+ compAuxNum: row.comp_aux_num,
179
+ compAuxLib: row.comp_aux_lib,
180
+ pieceRef: row.piece_ref,
181
+ pieceDate: row.piece_date,
182
+ ecritureLib: row.ecriture_lib,
183
+ debit: row.debit,
184
+ credit: row.credit,
185
+ ecritureLet: row.ecriture_let,
186
+ dateLet: row.date_let,
187
+ validDate: row.valid_date,
188
+ montantDevise: row.montant_devise,
189
+ idevise: row.idevise,
190
+ };
191
+ }
192
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAWH,yEAAyE;AACzE,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,aAAa;IACb,YAAY;IACZ,aAAa;IACb,cAAc;IACd,WAAW;IACX,WAAW;IACX,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,WAAW;IACX,aAAa;IACb,OAAO;IACP,QAAQ;IACR,aAAa;IACb,SAAS;IACT,WAAW;IACX,eAAe;IACf,SAAS;CACD,CAAC;AA4CX,MAAM,QAAQ,GAAyB;IACrC,gBAA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AC,YAAY;QAC7B,UAAU,EAAE,GAAG,CAAC,WAAW;QAC3B,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,YAAY,EAAE,GAAG,CAAC,aAAwB;QAC1C,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,UAAU,EAAE,GAAG,CAAC,YAAY;QAC5B,UAAU,EAAE,GAAG,CAAC,YAAY;QAC5B,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,SAAS,EAAE,GAAG,CAAC,UAAqB;QACpC,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,OAAO,EAAE,GAAG,CAAC,QAA0B;QACvC,SAAS,EAAE,GAAG,CAAC,UAAqB;QACpC,aAAa,EAAE,GAAG,CAAC,cAAc;QACjC,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@ekwo-ai/fec",
3
+ "version": "0.4.0",
4
+ "description": "The French FEC — fichier des ecritures comptables — in TypeScript: the eighteen columns of the arrete du 29 juillet 2013, from plain ledger rows. Zero dependencies.",
5
+ "keywords": [
6
+ "fec",
7
+ "fichier-des-ecritures-comptables",
8
+ "france",
9
+ "dgfip",
10
+ "accounting",
11
+ "bookkeeping",
12
+ "ledger",
13
+ "export"
14
+ ],
15
+ "license": "MIT",
16
+ "author": "Ekwo AI",
17
+ "homepage": "https://github.com/Ekwo-ai/ekwo-os/tree/main/packages/formats/fec#readme",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/Ekwo-ai/ekwo-os.git",
21
+ "directory": "packages/formats/fec"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/Ekwo-ai/ekwo-os/issues"
25
+ },
26
+ "type": "module",
27
+ "sideEffects": false,
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "README.md",
34
+ "LICENSE"
35
+ ],
36
+ "main": "./dist/index.js",
37
+ "types": "./dist/index.d.ts",
38
+ "exports": {
39
+ ".": {
40
+ "types": "./dist/index.d.ts",
41
+ "import": "./dist/index.js"
42
+ }
43
+ },
44
+ "scripts": {
45
+ "build": "tsc -p tsconfig.build.json",
46
+ "typecheck": "tsc -p tsconfig.json --noEmit",
47
+ "test": "vitest run"
48
+ },
49
+ "devDependencies": {
50
+ "@types/node": "^24.0.0",
51
+ "typescript": "^5.9.0",
52
+ "vitest": "^3.2.0"
53
+ }
54
+ }