feat: integrate invoice-master-poc-v2 inference API

Rewrite OcrService to match the actual inference API response format
(nested status/result structure with PascalCase/snake_case field names).
Register IOcrService in DI with typed HttpClient and Polly v8 resilience
(retry, timeout, circuit breaker via AddStandardResilienceHandler).

Key changes:
- Fix response model to match real API (InferenceApiResponse)
- Map correct field names (InvoiceNumber, InvoiceDueDate, OCR, Amount, etc.)
- Add extract_line_items=true for VAT summary extraction
- Copy stream before sending to avoid disposal conflicts with retries
- Add JsonException handling for malformed responses
- Remove sensitive data from error logs
- Add 35 unit tests covering field mapping, VAT parsing, error handling,
  decimal/date formats, and content type detection
This commit is contained in:
Yaojia Wang
2026-02-13 10:30:50 +01:00
parent 041e54196a
commit 26d0c41203
6 changed files with 1044 additions and 78 deletions

View File

@@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.0">
@@ -22,6 +23,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\FiscalFlow.Application\FiscalFlow.Application.csproj" />
<ProjectReference Include="..\..\src\FiscalFlow.Core\FiscalFlow.Core.csproj" />
<ProjectReference Include="..\..\src\FiscalFlow.Infrastructure\FiscalFlow.Infrastructure.csproj" />
</ItemGroup>
</Project>