Refactor GL period and entry date handling to use BusinessClock for accurate date resolution; add GlAccountCodeValidator for startup validation of configured account codes.

This commit is contained in:
2026-10-07 11:27:12 +05:30
parent ea8c8210e5
commit f753cae82d
17 changed files with 389 additions and 25 deletions
+12 -2
View File
@@ -77,12 +77,22 @@ builder.Services.AddScoped<IAuthAltService, AuthAltService>();
// General Ledger service proxy → external GL microservice (docs/12-GENERAL-LEDGER-INTEGRATION.md)
builder.Services.AddHttpClient<IGeneralLedgerClient, GeneralLedgerClient>(c =>
{
var baseUrl = builder.Configuration["GeneralLedgerService:BaseUrl"]
?? throw new InvalidOperationException("GeneralLedgerService:BaseUrl is not configured.");
var baseUrl = builder.Configuration["GeneralLedgerService:BaseUrl"];
if (string.IsNullOrWhiteSpace(baseUrl))
throw new InvalidOperationException("GeneralLedgerService:BaseUrl is not configured.");
// GeneralLedgerClient builds *relative* URIs ("journal-entries", "accounts", …), so the base
// address must keep its full path — including /api/v1/ — and end in '/'. Without the trailing
// slash, Uri resolution replaces the last segment and every call lands on /api/journal-entries.
if (!baseUrl.EndsWith('/')) baseUrl += "/";
c.BaseAddress = new Uri(baseUrl);
});
builder.Services.AddScoped<IGeneralLedgerService, GeneralLedgerService>();
// Fail fast on a misconfigured chart of accounts: every Gl*Code in configuration must exist in GL,
// otherwise the first user to touch that flow eats a 404 mid-transaction.
builder.Services.AddHostedService<GlAccountCodeValidator>();
// Current-user (audit actor). AuthHex has no sub/nameid → a claims transformation
// JIT-provisions a local shadow user and injects the local `int` id as `nameid`.
builder.Services.AddHttpContextAccessor();