Service Layer high complexity backend
2
Dependencies
1
Dependents
5
Entities
0
Integrations

Description

Backend service implementing the connector pattern that bridges Meander approved expense records to external accounting systems. Exposes a single AccountingConnector interface with concrete XledgerConnector and DynamicsConnector implementations; tenant configuration from organization_settings selects the active connector at runtime with no hardcoded org checks in business logic.

Feature: Accounting API

accounting-api-adapter

Sources & reasoning

This is the central service for the feature - it abstracts two incompatible accounting APIs behind a single interface, delegates connector selection to tenant configuration, and owns all retry and error-surfacing logic, making accounting integration a pure configuration concern.

No source references — this artifact was included based on reasoning alone (see above).

Responsibilities

  • Expose a unified AccountingConnector interface abstracting Xledger and Dynamics backends
  • Select the active connector at runtime from organization_settings tenant configuration
  • Submit approved expense records to the active accounting system
  • Retry failed submissions with exponential backoff up to five attempts before marking permanently failed
  • Emit a log entry to accounting_sync_logs for every submission attempt and outcome

Interfaces

submitExpense(expenseId: string): Promise<AccountingSyncResult>
retryFailed(): Promise<void>
getConnectorForTenant(orgId: string): AccountingConnector
markPermanentlyFailed(logId: string, reason: string): Promise<void>

Relationships

Dependencies (2)

Components this component depends on

Dependents (1)

Components that depend on this component

Sub-Components (2)

Xledger Connector
component medium

Concrete AccountingConnector implementation for Blindeforbundet, authenticating with API key plus company ID request header to submit expense records to Xledger's REST API. Handles Xledger-specific request mapping, idempotency tokens, and error codes.

  • Authenticate against Xledger with API key and company ID header
  • Map Meander expense fields to Xledger request payload format
  • Interpret Xledger-specific error codes and surface retry vs permanent failure signals
Dynamics Connector
component medium

Concrete AccountingConnector implementation for HLF, acquiring OAuth2 client credentials from HLF's Azure AD tenant to submit expense records to the Dynamics portal. Manages token lifecycle, refresh, and Dynamics-specific payload mapping.

  • Acquire and refresh OAuth2 client credentials from HLF's Azure AD tenant
  • Map Meander expense fields to Dynamics portal request format
  • Interpret Dynamics error codes and surface retry vs permanent failure signals