This project parses a Comarch ERP Optima accounting report (Excel export) and converts it to JSON.
The output JSON contains:
- a list of accounting postings (journal entry blocks),
- optional report totals from the footer section.
- Loads a legacy
.xlsreport file. - Converts it to an
openpyxlworkbook in memory. - Parses Optima report blocks (header + posting lines + totals).
- Exports structured data to
result.json.
In short: it is an Optima report to JSON parser for a bookkeeping postings list.
main.py- entry point, runs conversion and parsing, writesresult.json.xls_to_xlsx.py- converts.xlsfiles toopenpyxlworkbook objects.optima_report.py- parsing logic for document blocks and footer totals.xlregex.py- lightweight row/block pattern-matching helpers for Excel sheets.
- Python
3.13+ - Poetry (recommended)
Dependencies:
openpyxlxlrd
poetry install- Put your Optima export file in the project directory (default name in current script:
excel.xls). - Run:
poetry run python main.py- Parsed output will be saved to:
result.json
Top-level output includes:
blocks: list of accounting postings (journal entries),- footer aggregate fields when present (turnover/balance values).
Each block typically contains:
- entry metadata (
entry_id,journal_number,document_number,operator, etc.), items: detailed debit/credit posting lines,debit_totalandcredit_total.
Example (shortened):
{
"blocks": [
{
"entry_id": "1",
"journal_number": "ZAKUP/2024/02/1",
"items": [
{
"line_id": "1/1",
"debit_account": "503",
"debit_amount": 11932.49,
"credit_account": "",
"credit_amount": 0.0
}
],
"debit_total": 11932.49,
"credit_total": 11932.49
}
]
}If your report sheet name or file name is different, update main.py:
- input file passed to
cvt_xls_to_xlsx(...), - worksheet name (currently
"Arkusz2"), - output file path if needed.
- Parser patterns are tailored to the Optima report layout used in this project.
- If your export format differs, adjust row/block patterns in
optima_report.py.