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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user