feat: add General Ledger integration and financial reporting features

- Implemented General Ledger client component for managing GL integration.
- Created a dedicated page for General Ledger configuration.
- Developed Finance Report client component for generating various financial reports.
- Added report blocks for structured display of financial data.
- Introduced API endpoints for fetching GL accounts and financial reports.
- Updated navigation to include links for GL integration and financial reports.
- Enhanced permissions to manage GL and view financial reports.
- Updated appsettings to include General Ledger API configuration.
This commit is contained in:
2026-10-20 18:54:30 +05:30
parent cc33ecdd54
commit ca81e9bc42
32 changed files with 8786 additions and 134 deletions
@@ -0,0 +1,48 @@
using System.Net.Http.Json;
using System.Text.Json;
namespace Distribution.Features.GeneralLedger;
public record GeneralLedgerResult(int StatusCode, bool Success, JsonElement? Body);
public interface IGeneralLedgerClient
{
Task<bool> IsHealthyAsync(CancellationToken ct = default);
Task<GeneralLedgerResult> SendAsync(HttpMethod method, string path, object? payload = null, CancellationToken ct = default);
}
/// <summary>
/// Service-to-service client for the General Ledger microservice. The GL service is not user-facing:
/// every request carries the shared X-Api-Key (GeneralLedger:ApiKey, must equal the GL service's ApiKey:Value).
/// <paramref name="path"/> is relative to GeneralLedger:BaseUrl and carries the API version (e.g. "v1/accounts", "v1/journal-entries"), so moving a call to v2 is a one-path change.
/// </summary>
public class GeneralLedgerClient(HttpClient http) : IGeneralLedgerClient
{
public async Task<bool> IsHealthyAsync(CancellationToken ct = default)
{
try
{
using var response = await http.GetAsync("/health", ct);
return response.IsSuccessStatusCode;
}
catch (HttpRequestException)
{
return false;
}
}
public async Task<GeneralLedgerResult> SendAsync(HttpMethod method, string path, object? payload = null, CancellationToken ct = default)
{
using var request = new HttpRequestMessage(method, path.TrimStart('/'));
if (payload is not null) request.Content = JsonContent.Create(payload);
using var response = await http.SendAsync(request, ct);
JsonElement? body = null;
if (response.Content.Headers.ContentLength != 0)
{
try { body = await response.Content.ReadFromJsonAsync<JsonElement>(cancellationToken: ct); }
catch (JsonException) { }
}
return new GeneralLedgerResult((int)response.StatusCode, response.IsSuccessStatusCode, body);
}
}