Xledger Exporter
Component Detail
Description
Concrete implementation of AccountingExporter for Blindeforbundet's Xledger accounting system. Maps approved expense claim fields to Xledger's chart of accounts, produces a structured CSV or JSON file per Xledger's import specification, and validates that all required Xledger fields are present before including a claim in the export.
xledger-exporter
Summaries
The Xledger Exporter translates Blindeforbundet's approved expense claims into the exact format required by their Xledger accounting system, enabling direct import without manual data re-entry or reformatting. By automating field mapping against Xledger's chart of accounts and validating all required fields before export, it eliminates a significant source of finance team manual effort and reduces the risk of import rejections that delay reimbursements. Its design also supports a future direct API integration with Xledger, which would further reduce the manual file upload step and accelerate the overall reimbursement cycle, providing a clear path for operational efficiency gains.
High complexity due to the requirement to correctly map expense claim fields to Xledger's specific chart of accounts structure and produce a validated, import-ready output. Delivery depends on `chart-of-accounts-mapper` and `csv-json-file-generator` being available and correctly configured with Blindeforbundet's Xledger account codes. A key risk is obtaining and maintaining accurate chart-of-accounts mapping data — this is organisation-specific configuration that requires input from the finance team and will need updating if Xledger account structures change. The future `pushToXledgerApi` interface is in scope as a planned capability; ensure the architecture supports it without a full rewrite.
Thorough validation testing is essential: every required Xledger field must be covered, and skipped claim reasons must be clear enough for coordinators to act on.
Implements the `AccountingExporter` interface with `export(claims): ExportPayload` as the primary entry point. The pipeline is: `mapClaimToXledgerRecord(ExpenseClaim)` maps each claim using `chart-of-accounts-mapper`, then `validateXledgerFields(ExpenseClaim)` checks for required Xledger fields and collects failures as skipped claims with structured reasons. Valid records are passed to `generateCsv(records): Uint8List` via `csv-json-file-generator`. The `pushToXledgerApi(payload)` method is scaffolded for future direct API delivery.
Depends on `expense_claim` data model for source fields. Backend-only execution context. The chart-of-accounts mapping must be externalised as configuration (not hardcoded) to support account structure updates without code changes. Ensure `validateXledgerFields` returns typed `ValidationResult` objects so skipped claim reasons are machine-readable for the confirmation dialog display.
Responsibilities
- Map expense claim fields to Xledger chart-of-accounts columns
- Validate Xledger-required fields and collect skipped claims with reasons
- Produce Xledger-compatible CSV/JSON export payload
- Support future direct API push to Xledger endpoint
Interfaces
export(claims): ExportPayload
mapClaimToXledgerRecord(ExpenseClaim): XledgerRecord
validateXledgerFields(ExpenseClaim): ValidationResult
generateCsv(records): Uint8List
pushToXledgerApi(payload): ApiResponse
Relationships
Dependencies (2)
Components this component depends on
Related Data Entities (6)
Data entities managed by this component