# Accounting Report Gap Analysis Workflow

Date: 2026-05-05
Purpose: reusable method for comparing Tradon/Tryton accounting reports with an
external target standard.

## Scope

Use this workflow when comparing one accounting report at a time, for example
General Ledger, Trial Balance, Aged Balance, Balance Sheet, Income Statement, or
tax reports.

The first completed example is:

- `general_ledger_gap_analysis.md`

## Source Priority

Read sources in this order:

1. Root `AGENTS.md`.
2. `notes/accounting/README.md`.
3. Existing accounting notes, especially `reporting.md`,
   `business_rules.md`, and `comparison_checklist.md`.
4. Target standard report definition.
5. Target standard shared docs, such as reporting standards, parameter rules,
   and field catalogues.
6. Tradon/Tryton report code, views, models, templates, and tests.

If the target standard lives outside this repository, request filesystem access
when needed and keep the resulting notes inside `notes/accounting/`.

## Extraction Steps

1. Identify the target report code and file.
   - Example: `GL-001 General Ledger`.
2. Read the target report definition completely.
3. Read shared target docs that define common rules:
   - parameters;
   - fields;
   - sorting;
   - grouping;
   - totals;
   - exports;
   - audit controls.
4. Locate the corresponding Tradon/Tryton implementation with `rg`:
   - `ir.action.report`;
   - `ir.action.act_window`;
   - `context_model`;
   - report model names;
   - `Report` classes;
   - `ModelSQL.table_query()`;
   - XML views;
   - `.fodt` templates.
5. Map parameters and filters.
6. Map sorting, grouping, and balance logic.
7. Map output columns field by field.
8. Compare calculation rules:
   - debit/credit sign convention;
   - opening balance;
   - closing balance;
   - running balance;
   - transaction currency;
   - base currency;
   - posted/draft behavior.
9. Compare export behavior:
   - UI view;
   - PDF/ODT;
   - CSV;
   - XLSX;
   - audit-ready flat extract.
10. Compare controls and reconciliation expectations.
11. Record open questions separately from confirmed gaps.

## Gap Classification

Use these labels consistently:

- `Covered`: current Tradon/Tryton behavior matches the target.
- `Partial`: current behavior exists but is incomplete or presented differently.
- `Gap`: target behavior is missing.
- `Different model`: both systems answer a similar need with different concepts.
- `Open question`: source evidence is not enough yet.

For priority, use:

- `High`: blocks audit, statutory reporting, reconciliation, or standard export.
- `Medium`: important reporting difference, but workaround exists.
- `Low`: presentation or convenience difference.
- `Trade-specific`: related to `purchase_trade` or commodity business rules.

## Output File Template

Create one file per report:

`notes/accounting/<report_name>_gap_analysis.md`

Recommended sections:

1. Executive summary.
2. Sources read.
3. Target report requirements.
4. Current Tradon/Tryton behavior.
5. Parameter and filter gaps.
6. Sorting and grouping gaps.
7. Column mapping.
8. Calculation and currency gaps.
9. Export and audit gaps.
10. Controls and reconciliation gaps.
11. Prioritized gaps.
12. Open questions.

## General Ledger Lessons Learned

For the first General Ledger comparison:

- Tryton exposes an account summary with drill-down lines, while the target
  standard expects a flat audit/export report.
- Tryton has date, period, fiscal year, company, posted, and journal filters,
  but the target also requires explicit account range, currency, entity,
  document, and voucher filters.
- Tryton carries second currency as `amount_second_currency`, but the target
  requires debit, credit, and balance in transaction currency plus base currency.
- Tryton computes running balance by account, with optional party cumulation,
  while the target requires account plus transaction currency grouping.
- The target expects opening and closing rows per account plus transaction
  currency.
- Audit metadata and export-oriented columns must be normalized explicitly.

## Maintenance Rule

After completing each report comparison:

1. Add the new analysis file to `notes/accounting/README.md`.
2. Add any reusable checklist item to `comparison_checklist.md`.
3. Keep report-specific conclusions in the report gap file, not in `AGENTS.md`.
4. Keep `AGENTS.md` pointing only to the accounting index and workflow.
