fec-validator-excel 0.1.0__tar.gz
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.
- fec_validator_excel-0.1.0/LICENSE +13 -0
- fec_validator_excel-0.1.0/PKG-INFO +39 -0
- fec_validator_excel-0.1.0/README.md +21 -0
- fec_validator_excel-0.1.0/pyproject.toml +30 -0
- fec_validator_excel-0.1.0/setup.cfg +4 -0
- fec_validator_excel-0.1.0/src/fec_validator_excel/__init__.py +52 -0
- fec_validator_excel-0.1.0/src/fec_validator_excel/__main__.py +16 -0
- fec_validator_excel-0.1.0/src/fec_validator_excel.egg-info/PKG-INFO +39 -0
- fec_validator_excel-0.1.0/src/fec_validator_excel.egg-info/SOURCES.txt +10 -0
- fec_validator_excel-0.1.0/src/fec_validator_excel.egg-info/dependency_links.txt +1 -0
- fec_validator_excel-0.1.0/src/fec_validator_excel.egg-info/entry_points.txt +2 -0
- fec_validator_excel-0.1.0/src/fec_validator_excel.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 RadarBG (https://radarbg.com)
|
|
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.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fec-validator-excel
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Zero-dependency Python parser, DGFiP validator and CLI for French FEC (Fichier des Ecritures Comptables) accounting files.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://radarbg.com/instant/fec-to-excel?ref=pypi-fec
|
|
7
|
+
Project-URL: French FEC to Excel Online, https://radarbg.com/instant/fec-to-excel?ref=pypi-fec
|
|
8
|
+
Project-URL: RadarBG Accounting Tools, https://radarbg.com/instant?ref=pypi
|
|
9
|
+
Keywords: fec,dgfip,france,accounting,comptabilite,excel,csv,validator,parser
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Topic :: Office/Business :: Financial :: Accounting
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# fec-validator-excel
|
|
20
|
+
|
|
21
|
+
Zero-dependency Python parser, DGFiP validator, and CLI for French **FEC (Fichier des Écritures Comptables)** accounting files.
|
|
22
|
+
|
|
23
|
+
Need an instant browser tool to validate DGFiP rules and export formatted **Excel (.xlsx with Balance_Comptes & Controle_DGFiP tabs), Xero, or QuickBooks CSV**?
|
|
24
|
+
👉 Use **[radarbg.com/instant/fec-to-excel](https://radarbg.com/instant/fec-to-excel?ref=pypi-fec)**
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
```bash
|
|
28
|
+
pip install fec-validator-excel
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
```python
|
|
33
|
+
from fec_validator_excel import parse_fec
|
|
34
|
+
rows, issues, n_entries = parse_fec(open("123456789FEC20261115.txt", "rb").read())
|
|
35
|
+
print(len(rows), "lines,", n_entries, "entries, issues:", issues)
|
|
36
|
+
```
|
|
37
|
+
```bash
|
|
38
|
+
fec-validator-excel 123456789FEC20261115.txt --format json
|
|
39
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# fec-validator-excel
|
|
2
|
+
|
|
3
|
+
Zero-dependency Python parser, DGFiP validator, and CLI for French **FEC (Fichier des Écritures Comptables)** accounting files.
|
|
4
|
+
|
|
5
|
+
Need an instant browser tool to validate DGFiP rules and export formatted **Excel (.xlsx with Balance_Comptes & Controle_DGFiP tabs), Xero, or QuickBooks CSV**?
|
|
6
|
+
👉 Use **[radarbg.com/instant/fec-to-excel](https://radarbg.com/instant/fec-to-excel?ref=pypi-fec)**
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
```bash
|
|
10
|
+
pip install fec-validator-excel
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
```python
|
|
15
|
+
from fec_validator_excel import parse_fec
|
|
16
|
+
rows, issues, n_entries = parse_fec(open("123456789FEC20261115.txt", "rb").read())
|
|
17
|
+
print(len(rows), "lines,", n_entries, "entries, issues:", issues)
|
|
18
|
+
```
|
|
19
|
+
```bash
|
|
20
|
+
fec-validator-excel 123456789FEC20261115.txt --format json
|
|
21
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "fec-validator-excel"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Zero-dependency Python parser, DGFiP validator and CLI for French FEC (Fichier des Ecritures Comptables) accounting files."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.8"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
dependencies = []
|
|
13
|
+
keywords = ["fec", "dgfip", "france", "accounting", "comptabilite", "excel", "csv", "validator", "parser"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
"Topic :: Office/Business :: Financial :: Accounting",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[project.scripts]
|
|
22
|
+
fec-validator-excel = "fec_validator_excel.__main__:main"
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://radarbg.com/instant/fec-to-excel?ref=pypi-fec"
|
|
26
|
+
"French FEC to Excel Online" = "https://radarbg.com/instant/fec-to-excel?ref=pypi-fec"
|
|
27
|
+
"RadarBG Accounting Tools" = "https://radarbg.com/instant?ref=pypi"
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.packages.find]
|
|
30
|
+
where = ["src"]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Zero-dependency French FEC (Fichier des Ecritures Comptables) parser and DGFiP validator."""
|
|
2
|
+
import csv, datetime as dt, re
|
|
3
|
+
from collections import defaultdict
|
|
4
|
+
from decimal import Decimal, InvalidOperation
|
|
5
|
+
|
|
6
|
+
__version__ = "0.1.0"
|
|
7
|
+
__all__ = ["parse_fec", "FEC_REQUIRED"]
|
|
8
|
+
|
|
9
|
+
FEC_REQUIRED = [
|
|
10
|
+
"JournalCode", "JournalLib", "EcritureNum", "EcritureDate", "CompteNum",
|
|
11
|
+
"CompteLib", "CompAuxNum", "CompAuxLib", "PieceRef", "PieceDate",
|
|
12
|
+
"EcritureLib", "Debit", "Credit", "EcritureLet", "DateLet",
|
|
13
|
+
"ValidDate", "Montantdevise", "Idevise",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
def _dec(s):
|
|
17
|
+
s = (s or "").strip().strip('"').replace(" ", "")
|
|
18
|
+
if not s: return Decimal("0.00")
|
|
19
|
+
if "," in s and "." in s:
|
|
20
|
+
s = s.replace(".", "").replace(",", ".") if s.rfind(",") > s.rfind(".") else s.replace(",", "")
|
|
21
|
+
elif "," in s:
|
|
22
|
+
s = s.replace(",", ".")
|
|
23
|
+
try: return Decimal(s)
|
|
24
|
+
except InvalidOperation: return None
|
|
25
|
+
|
|
26
|
+
def parse_fec(data):
|
|
27
|
+
text = data.decode("utf-8-sig", errors="replace") if isinstance(data, (bytes, bytearray)) else str(data)
|
|
28
|
+
lines = [ln for ln in text.splitlines() if ln.strip()]
|
|
29
|
+
if len(lines) < 2: raise ValueError("FEC file must have a header and at least one entry.")
|
|
30
|
+
delim = max(("\t", "|", ";", ","), key=lambda d: lines[0].count(d))
|
|
31
|
+
reader = list(csv.reader(lines, delimiter=delim, quotechar='"'))
|
|
32
|
+
hdr = {c.strip().lower(): i for i, c in enumerate(reader[0])}
|
|
33
|
+
issues = []
|
|
34
|
+
miss = [c for c in FEC_REQUIRED if c.lower() not in hdr]
|
|
35
|
+
if miss: issues.append(f"Missing DGFiP columns ({len(miss)}): {', '.join(miss[:5])}")
|
|
36
|
+
rows, bal = [], defaultdict(lambda: [Decimal("0.00"), Decimal("0.00")])
|
|
37
|
+
for ln_no, raw in enumerate(reader[1:], start=2):
|
|
38
|
+
if not any(c.strip() for c in raw): continue
|
|
39
|
+
g = lambda col: raw[hdr[col.lower()]].strip() if col.lower() in hdr and hdr[col.lower()] < len(raw) else ""
|
|
40
|
+
deb, cred = _dec(g("Debit")), _dec(g("Credit"))
|
|
41
|
+
if deb is None or cred is None:
|
|
42
|
+
issues.append(f"Row {ln_no}: invalid Debit/Credit"); continue
|
|
43
|
+
ed = g("EcritureDate")
|
|
44
|
+
iso = f"{ed[:4]}-{ed[4:6]}-{ed[6:8]}" if re.fullmatch(r"\d{8}", ed) else ed
|
|
45
|
+
enum = g("EcritureNum")
|
|
46
|
+
bal[enum][0] += deb; bal[enum][1] += cred
|
|
47
|
+
rows.append({"journal": g("JournalCode"), "ecriture_num": enum, "date": iso, "compte": g("CompteNum"),
|
|
48
|
+
"compte_lib": g("CompteLib"), "piece_ref": g("PieceRef"), "libelle": g("EcritureLib"),
|
|
49
|
+
"debit": float(deb), "credit": float(cred), "net": float(deb - cred)})
|
|
50
|
+
unbal = [e for e, (d, c) in bal.items() if d != c]
|
|
51
|
+
if unbal: issues.append(f"{len(unbal)} unbalanced EcritureNum: {', '.join(unbal[:5])}")
|
|
52
|
+
return rows, issues, len(bal)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import argparse, csv, json, sys
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from . import parse_fec
|
|
4
|
+
|
|
5
|
+
def main(argv=None):
|
|
6
|
+
ap = argparse.ArgumentParser(description="Validate & convert French FEC accounting files.")
|
|
7
|
+
ap.add_argument("file"); ap.add_argument("--format", choices=["json", "csv"], default="json")
|
|
8
|
+
args = ap.parse_args(argv)
|
|
9
|
+
rows, issues, n = parse_fec(Path(args.file).read_bytes())
|
|
10
|
+
if args.format == "json":
|
|
11
|
+
print(json.dumps({"entries": n, "issues": issues, "rows": rows}, indent=2, ensure_ascii=False))
|
|
12
|
+
else:
|
|
13
|
+
w = csv.DictWriter(sys.stdout, fieldnames=["journal","ecriture_num","date","compte","compte_lib","piece_ref","libelle","debit","credit","net"])
|
|
14
|
+
w.writeheader(); w.writerows(rows)
|
|
15
|
+
|
|
16
|
+
if __name__ == "__main__": main()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fec-validator-excel
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Zero-dependency Python parser, DGFiP validator and CLI for French FEC (Fichier des Ecritures Comptables) accounting files.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://radarbg.com/instant/fec-to-excel?ref=pypi-fec
|
|
7
|
+
Project-URL: French FEC to Excel Online, https://radarbg.com/instant/fec-to-excel?ref=pypi-fec
|
|
8
|
+
Project-URL: RadarBG Accounting Tools, https://radarbg.com/instant?ref=pypi
|
|
9
|
+
Keywords: fec,dgfip,france,accounting,comptabilite,excel,csv,validator,parser
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Topic :: Office/Business :: Financial :: Accounting
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Requires-Python: >=3.8
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# fec-validator-excel
|
|
20
|
+
|
|
21
|
+
Zero-dependency Python parser, DGFiP validator, and CLI for French **FEC (Fichier des Écritures Comptables)** accounting files.
|
|
22
|
+
|
|
23
|
+
Need an instant browser tool to validate DGFiP rules and export formatted **Excel (.xlsx with Balance_Comptes & Controle_DGFiP tabs), Xero, or QuickBooks CSV**?
|
|
24
|
+
👉 Use **[radarbg.com/instant/fec-to-excel](https://radarbg.com/instant/fec-to-excel?ref=pypi-fec)**
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
```bash
|
|
28
|
+
pip install fec-validator-excel
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
```python
|
|
33
|
+
from fec_validator_excel import parse_fec
|
|
34
|
+
rows, issues, n_entries = parse_fec(open("123456789FEC20261115.txt", "rb").read())
|
|
35
|
+
print(len(rows), "lines,", n_entries, "entries, issues:", issues)
|
|
36
|
+
```
|
|
37
|
+
```bash
|
|
38
|
+
fec-validator-excel 123456789FEC20261115.txt --format json
|
|
39
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/fec_validator_excel/__init__.py
|
|
5
|
+
src/fec_validator_excel/__main__.py
|
|
6
|
+
src/fec_validator_excel.egg-info/PKG-INFO
|
|
7
|
+
src/fec_validator_excel.egg-info/SOURCES.txt
|
|
8
|
+
src/fec_validator_excel.egg-info/dependency_links.txt
|
|
9
|
+
src/fec_validator_excel.egg-info/entry_points.txt
|
|
10
|
+
src/fec_validator_excel.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fec_validator_excel
|