backoffice-ledger-service
Ledger API that imports nightly back-office ledger entries and creates purchase documents (invoices/credit notes for TC commission) in Dynamics 365, exporting files to SharePoint.
Health score
0 to 100 across seven weighted factors; nothing is hidden. Green is 75 and above, amber 50 to 74, red below 50. How scoring works.
Facts
| Languages | csharp, sql |
| Frameworks | ASP.NET Core 8, MediatR 12, FluentValidation 12, Polly 8, Swashbuckle 9 |
| Runtimes | .NET 8 |
| Tests / CI | some / CI in place |
| Last commit | 2026-02-09 |
| Owner | Owner unknown (mapping to be curated) |
| Domain | Payments and finance (system generated; curate in repo-owners.json to override) |
| Product area | Phenix |
| Hosted | On-prem Deployed to our own machines
|
| Releases | 2 release pipeline(s): \finance\backoffice\backoffice-ledger-service API; \finance\backoffice\backoffice-ledger-service Database |
| Integration | rest, wcf |
| Source | Open in Azure DevOps |
Dependencies in context
Entanglement
loosely attached Bound into the core by 1 mechanism(s).
- Speaks WCF (client)
Detaches when its WCF surface gains a modern interface or its WCF calls move to one.
Migration playbooks
Generated from this repo's assessment data: what is feasible, what blocks it, and the steps in order. Ratings: green means actionable now, amber means sequence other work first, red means blocked, grey means not applicable.
ZDD adoption
Ready with guardrailsClose: the deployment path exists, but specific checks are needed first, typically raising tests, auditing serialized data, or respecting a shared schema with expand and contract. Test coverage is thin; ZDD shifts the safety net onto automation.
- 3 system(s) depend on this repo; during a rolling deploy they will talk to old and new versions at once, so responses must stay compatible
- Consumes WCF contract packages: never take a breaking client bump mid-feature, and treat obsolete warnings as migration debt
- Adopt the four-stage discipline from the ZDD engineering standard: pre-deployment compatibility, deployment, feature activation behind a flag, post-release cleanup.
- Raise automated test coverage first: ZDD trades the end-of-sprint manual gate for continuous automated confidence, so the tests are the entry ticket.
- Make every change dual-version safe: backwards-compatible APIs (new major version for breaking wire changes), expand and contract for any schema change, and consumers tolerant of unknown fields.
- Audit serialized data: anything in Redis, queues or shared caches must deserialize cleanly across adjacent versions.
- Wrap behaviour changes in feature flags so code deploys dark and release becomes a business decision, not a deployment event.
- Route deployments through the Workflow Engine's automated drain, deploy, health-check, return cycle (the path proven by the first automated production run in mid-2026).
- Verify with area-scoped regression rather than the whole-platform cycle, and watch error rates after rollout with automated rollback on alert.
SQL Server exit
Feasible now (1 owned database)The database is solely owned by this system, so the migration is self-contained. Recommended target: PostgreSQL.
- Inventory the schema and query surface of sqlserver:Ledger: tables, stored procedures, triggers, cross-database joins and anything else engine-specific.
- Confirm the target: PostgreSQL (relational model; keep transactions and joins, swap the engine).
- Data access is not through an ORM, so port the SQL by hand: translate T-SQL constructs, replace stored procedures with application code or target-native equivalents, and add integration tests around the queries that matter first.
- Stand up the target alongside SQL Server, backfill with an ETL pass (pgloader or an export/import job), then dual-write or replicate until parity is proven.
- Move reads to the target, watch correctness and latency, then cut writes over and keep SQL Server read-only until confidence is earned.
- Decommission the SQL Server database and remove the connection strings and firewall paths that pointed at it.
Containerisation
Ready to containeriseModern runtime, no hosted legacy transport: this service can follow the estate's proven container path (Dockerfile, shared pipeline template, ECS via Terraform).
- Add a Dockerfile and make the app read all configuration from environment variables and the secrets manager, never from machine-local files.
- Log to stdout and expose a health check endpoint so ECS can supervise it.
- Adopt the shared ci.yml pipeline template with the container parameters (awsRegion, containerAfterBuild, ecsTerraformRepo), which is exactly how the estate's existing AWS services deploy.
- Define the service in the Terraform repo, deploy to a non-production environment, then shift traffic and disarm the deployment-group release pipeline.
Recommended actions
No specific actions for this repo. It either needs only normal maintenance, or its work is covered by an estate-level action. See the full programme.
Assessment notes
backoffice-ledger-service
Purpose
Main ledger service for interacting with Dynamics 365: imports ledger entries exported nightly from back office, and creates purchase documents (purchase invoices and credit notes) to pay commission to Travel Counsellors. Exports and commission files are written to SharePoint via OData with certificate-based OAuth.
Tech stack
- .NET 8 ASP.NET Core Web API (
TC.Ledger.Api) using MediatR, FluentValidation, Polly, Scrutor, Asp.Versioning, Swashbuckle/NSwag, PhenixAuth authentication and WebApi.Logger. - SQL Server data access through
TC.LedgerService.DataAccess.SqlClient(connection target "Ledger" via TC.ConnectionBroker); MongoDB used for request/response logging (ledger_logs). - XLSX export tooling (
TC.Spreadsheet.Xlsx.Export,ExcelDocumentCodeGen) for spreadsheet outputs. - Legacy WCF-style
[ServiceContract]interfaces retained inTC.Ledger.ServiceContractsfor back-office integration; TC.ConnectionBroker.Wcf referenced. - SQL database project
db/LedgerDatabase(Create/Change scripts) deployed by a dedicated pipeline.
Deployment
Prod application with 2 releases. Build pipelines "backoffice-ledger-service API" and "backoffice-ledger-service Database"; matching release pipelines under \finance\backoffice\. CI uses the shared azure-pipelines-templates (dotnet 8 SDK).
Dependencies
- Internal:
tc-connectionbroker(TC.ConnectionBroker.* including Mongo/Sql/Wcf),tc-exceptions(TC.Exceptions.WebApiClient.AspNetCore). Also PhenixAuth and TC.Diagnostics NuGet packages from the internal feed. Thejob-ledger-exportrepo is a likely consumer of this API. - External: Microsoft Dynamics 365 (ledger and purchase-document import, including Dynamics GP and Travel Operations Dynamics providers), SharePoint OData site for file storage.
Data stores
- SQL Server
Ledgerdatabase, including KeyHeader/KeyCertificate/KeyPair tables holding SharePoint access certificates. - MongoDB
ledger_logsdatabase for request/response logging.
Integration points
- REST/JSON API (versioned, Swagger) with generated client packages (
TC.Ledger.Api.Client,TC.Ledger.ServiceClient). - WCF service contracts for back-office ledger import integration.
- Outbound: Dynamics 365 and SharePoint (OAuth certificate flow).
Code health
- Unit tests present (
TC.Ledger.Api.UnitTests, InternalModels tests) plus apitests appsettings; no end-to-end suite in repo. - Modern CI, Nerdbank.GitVersioning; actively maintained (last commit 2026-02-09).
Modernisation risks
- SharePoint access certificates require manual periodic rotation (documented next expiry 26/03/2027) — operational risk if missed.
- Residual WCF contracts and multi-provider Dynamics logic add legacy coupling, but the runtime and tooling are current.