Chart of Accounts Mapper
Component Detail
Description
Maps internal expense claim field names and expense types to the target accounting system's chart of accounts codes. Maintains per-org mapping configurations so that the same claim fields resolve to different account codes depending on whether the target is Xledger or Dynamics. Flags unmapped fields as validation errors.
chart-of-accounts-mapper
Summaries
The Chart of Accounts Mapper is the translation layer that ensures every expense claim is coded to the correct account in the target accounting system — whether that is Xledger or Microsoft Dynamics. Incorrect account coding leads to misclassified expenses, failed reconciliations, and potentially non-compliant financial reporting. By centralizing mapping configurations per organization and flagging unmapped fields before export, this component prevents costly post-export corrections and gives finance teams confidence that exported data will integrate cleanly into their general ledger without manual intervention.
The Chart of Accounts Mapper is a medium-complexity shared backend service used by both the Dynamics Exporter and any Xledger exporter, making it a cross-cutting dependency that must be delivered and stable before either export path can be tested end-to-end. The per-org configuration model introduces ongoing operational scope: new organizations or new expense categories will require mapping configuration updates, so a lightweight admin interface or configuration file process should be planned. Validate the initial mapping configurations with the HLF finance team early — late-discovered unmapped expense types will surface as export failures in UAT.
mapField() performs a two-key lookup — (fieldName, expenseType) — against the org-specific AccountingFieldMap, returning the target account code or throwing a ValidationError if no mapping exists. getOrgMapping() should cache configurations in memory with an invalidation hook tied to updateMappingConfig() to avoid repeated database reads on every claim. validateMappingCompleteness() runs mapField() across all fields on a claim and aggregates errors, enabling pre-flight validation before the export pipeline begins. listSupportedExpenseTypes() provides a discovery endpoint for UI-driven configuration tools.
Store mapping configs as JSON documents keyed by orgId with schema versioning to support non-breaking config evolution as new expense categories are added.
Responsibilities
- Load org-specific field-to-account-code mapping configurations
- Resolve expense type to the correct account code for the target system
- Return validation errors for claim fields with no defined mapping
- Support runtime configuration updates for new expense categories
Interfaces
mapField(fieldName, expenseType, orgType): AccountCode
validateMappingCompleteness(claim, orgType): ValidationResult
getOrgMapping(orgId): AccountingFieldMap
updateMappingConfig(orgId, config)
listSupportedExpenseTypes(orgType): string[]
Relationships
Dependents (2)
Components that depend on this component
Related Data Entities (1)
Data entities managed by this component