The FEC handed to the tax auditor: two entries do not balance
Goal Read the FEC as the accountant hands it over, set aside the line with an unreadable amount, and learn which entries do not balance, with the query that proves it.
Every French company that keeps its accounts on a computer hands its FEC to the tax auditor: 18 fields in a fixed order, one file per fiscal year. A missing or non-compliant file costs €5,000, once per audit.
- decimal comma and YYYYMMDD dates declared in the connector
- a line with an unreadable debit set aside, with its reason
- one question in natural language: two unbalanced entries, and the SQL
JournalCode|JournalLib|EcritureNum|EcritureDate|CompteNum|CompteLib|CompAuxNum|CompAuxLib|PieceRef|PieceDate|EcritureLib|Debit|Credit|EcritureLet|DateLet|ValidDate|Montantdevise|Idevise VE|Ventes|VE000001|20250115|411000|Clients|C001|Durand SAS|F2025-001|20250115|Facture Durand|1200,00|0,00|||20260115|| VE|Ventes|VE000001|20250115|706000|Prestations de services|||F2025-001|20250115|Facture Durand|0,00|1000,00|||20260115|| VE|Ventes|VE000001|20250115|445710|TVA collectée|||F2025-001|20250115|Facture Durand|0,00|200,00|||20260115|| AC|Achats|AC000001|20250120|613200|Locations immobilières|||FA-7781|20250120|Loyer janvier|1500,00|0,00|||20260115|| AC|Achats|AC000001|20250120|445660|TVA déductible|||FA-7781|20250120|Loyer janvier|300,00|0,00|||20260115|| AC|Achats|AC000001|20250120|401000|Fournisseurs|F010|SCI des Tilleuls|FA-7781|20250120|Loyer janvier|0,00|1800,00|||20260115|| BQ|Banque|BQ000001|20250205|512000|Banque|||REL-02|20250205|Règlement Durand|1200,00|0,00|||20260115|| BQ|Banque|BQ000001|20250205|411000|Clients|C001|Durand SAS|REL-02|20250205|Règlement Durand|0,00|1200,00|||20260115|| VE|Ventes|VE000002|20250310|411000|Clients|C002|Petit et fils|F2025-002|20250310|Facture Petit|3600,00|0,00|||20260115|| VE|Ventes|VE000002|20250310|706000|Prestations de services|||F2025-002|20250310|Facture Petit|0,00|3000,00|||20260115|| VE|Ventes|VE000002|20250310|445710|TVA collectée|||F2025-002|20250310|Facture Petit|0,00|600,00|||20260115|| AC|Achats|AC000002|20250318|606400|Fournitures administratives|||FA-0412|20250318|Fournitures|250,00|0,00|||20260115|| AC|Achats|AC000002|20250318|445660|TVA déductible|||FA-0412|20250318|Fournitures|50,00|0,00|||20260115|| AC|Achats|AC000002|20250318|401000|Fournisseurs|F020|Bureau Plus|FA-0412|20250318|Fournitures|0,00|300,00|||20260115|| BQ|Banque|BQ000002|20250402|401000|Fournisseurs|F010|SCI des Tilleuls|VIR-04|20250402|Règlement SCI|1800,00|0,00|||20260115|| BQ|Banque|BQ000002|20250402|512000|Banque|||VIR-04|20250402|Règlement SCI|0,00|1800,00|||20260115|| VE|Ventes|VE000003|20250512|411000|Clients|C003|Lambert SARL|F2025-003|20250512|Facture Lambert|960,00|0,00|||20260115|| VE|Ventes|VE000003|20250512|706000|Prestations de services|||F2025-003|20250512|Facture Lambert|0,00|800,00|||20260115|| VE|Ventes|VE000003|20250512|445710|TVA collectée|||F2025-003|20250512|Facture Lambert|0,00|160,00|||20260115||
… 19 more lines
manifests/10-fec.yaml
apiVersion: connectors.lumnik.io/v1kind: Connectormetadata: name: scenario-fec-a connector_type: csv-file scopes: [compta-a]spec: transport: kind: sftp host: host.docker.internal port: 2224 user: compta path: /fec/*FEC*.txt password_env: SCENARIO_FEC_A_SFTP # The fingerprint the accountant's server presents, read out of band (ssh-keyscan | ssh-keygen -lf -). host_key_fingerprint: "SHA256:FINGERPRINT_READ_AT_REPLAY" parser: has_header: true delimiter: "|" encoding: UTF-8 after_process: none mapping: on-error: fields: { Debit: dlq, Credit: dlq } # an amount written but unreadable: the line is set aside default: soft dataset: # The 18 fields of art. A47 A-1 LPF: a file without one of them is not a FEC. - require-headers: columns: [JournalCode, JournalLib, EcritureNum, EcritureDate, CompteNum, CompteLib, CompAuxNum, CompAuxLib, PieceRef, PieceDate, EcritureLib, Debit, Credit, EcritureLet, DateLet, ValidDate, Montantdevise, Idevise] cell: - parse-number: { column: Debit, decimal-separator: "," } - parse-number: { column: Credit, decimal-separator: "," } - parse-date: { column: EcritureDate, formats: ["yyyyMMdd"] } - parse-date: { column: PieceDate, formats: ["yyyyMMdd"] } - parse-date: { column: ValidDate, formats: ["yyyyMMdd"] }manifests/20-ecriture.yaml
kind: Entityname: ecriture_alabel: Ligne d'écrituredescription: "One line of a FEC accounting entry: the entry it belongs to (EcritureNum), its account, its debit and its credit. An entry is balanced when the sum of its debits equals the sum of its credits."# A FEC line has no identifier of its own; in this file an account appears once per entry.match: [entry, account]scopes: [compta-a]columns: entry: { label: "Numéro d'écriture" } journal: { label: "Journal" } entry_date: { label: "Date d'écriture" } account: { label: "Numéro de compte" } account_label: { label: "Libellé du compte" } piece: { label: "Pièce" } label: { label: "Libellé de l'écriture" } debit: { label: "Débit" } credit: { label: "Crédit" }sources: - table: t_scenario_fec_a map: EcritureNum: entry JournalCode: journal EcritureDate: entry_date CompteNum: account CompteLib: account_label PieceRef: piece EcritureLib: label Debit: debit Credit: credit$ lm apply -f 10-fec.yaml
Applied connector "scenario-fec-c" — 1 endpoint
$ lm connector run scenario-fec-c
run scheduled: 7db19892-de30-489b-8497-64977c371b4d
$ lm run get 7db19892-de30-489b-8497-64977c371b4d --wait-evaluated
ID CONNECTOR ENDPOINT STATUS IN OUT SKIPPED DEAD-LETTERS STARTED ENDED EVALUATED
7db19892 scenario-fec-c default Completed 38 37 1 1 2026-11-21 10:15 2026-11-21 10:15 yes
⚠ 1 rows quarantined — see: lm dlq list --run 7db19892-de30-489b-8497-64977c371b4d
$ lm entity apply -f 20-ecriture.yaml
Applied entity "ecriture_c" → connector."v_ecriture_c"- run
- IN 38 · OUT 37 · SKIPPED 1
- ecriture_c
- v_ecriture_c
evidence: replay.log, check_fec.txt, 01-run.json, 02-dead-letter.txt, 03-unbalanced.json · transform v1
$ lm dlq get d6f352db-6905-40cc-b7e2-a04436ce16da
ID: d6f352db-6905-40cc-b7e2-a04436ce16da
Connector: scenario-fec-c (7a61b304-e296-4b85-a9aa-fa0199f3619d)
Run: 7db19892-de30-489b-8497-64977c371b4d
Reason: MappingFailed
Attempts: 1
Message: Debit: parse-number could not read the value
Detail: {"field":"Debit","message":"parse-number could not read the value"}
Payload: {"Debit":"12O,00","Credit":"0,00","DateLet":null,"Idevise":null,"PieceRef":"FA-1188","CompteLib":"Petit équipement","CompteNum":"606300","PieceDate":"20250714","ValidDate":"20260115","CompAuxLib":null,"CompAuxNum":null,"JournalLib":"Achats","EcritureLet":null,"EcritureLib":"Petit outillage","EcritureNum":"AC000004","JournalCode":"AC","EcritureDate":"20250714","Montantdevise":null}
Resolution: open- reason
- Debit: parse-number could not read the value
- line
- AC000004 · 606300 Petit équipement · Debit «12O,00»
evidence: replay.log, check_fec.txt, 01-run.json, 02-dead-letter.txt, 03-unbalanced.json · transform v1
$ lm ask --scope compta-c --lang fr "Quelles écritures ne sont pas équilibrées ?"
Il y a 2 écritures qui ne sont pas équilibrées. Les totaux sont les suivants :
1. Écriture : AC000004
Débit : 24
Crédit : 144
2. Écriture : VE000007
Débit : 1440
Crédit : 1404
data as of: 2026-11-21T09:15:56.448333Z (last completed run)
ENTRY SUM SUM_2
AC000004 24 144
VE000007 1440 1404
2 rows returned
SQL: SELECT "entry", SUM("debit"), SUM("credit")
FROM "connector"."v_ecriture_c"
GROUP BY "entry"
HAVING SUM("debit") <> SUM("credit")
LIMIT 500- answer
- Il y a 2 écritures qui ne sont pas équilibrées. Les totaux sont les suivants :
- AC000004
- debit 24 · credit 144
- VE000007
- debit 1440 · credit 1404
- check_fec.py
- AC000004 VE000007
evidence: replay.log, check_fec.txt, 01-run.json, 02-dead-letter.txt, 03-unbalanced.json · transform v1
Limits
- Debit = credit is a check over several lines: it is a question, not an inbox decision.
- The two totals come back named sum and sum_2: the sentence says which is the debit.
- A FEC line has no identifier of its own: the Entity keys it by entry and account, which holds in this file.
- lumnik does not check the other A47 A-1 rules (continuous numbering, validation date, file name) and does not certify a FEC.
- Fictitious company, SIREN 999999999, synthetic data.
This scenario needs lumnik Pro.
See the editions →