Invoice details endpoint for the invoice page

C# · ASP.NET Core · beginner · modification

Adds the invoice details endpoint the new invoice page calls. `InvoicesController` gets `GET /api/invoices/{id}`, which loads the invoice and projects it straight into the new `InvoiceDetailsDto`, with its lines as `InvoiceLineDto` records in position order, so only the columns the page needs are read; an id with no invoice answers 404. Both records live next to the existing summary record in `InvoiceDtos.cs`. `InvoiceDetailsTests.cs` adds endpoint tests on the existing `BillingApiFactory`.

ASP.NET Core 10 Web API on .NET 10 (C# 14, nullable reference types enabled), controllers with `[ApiController]`. EF Core 10 with Npgsql in production; `BillingDbContext` is unchanged: `Invoice` has `Id` (int identity, sequential), `CompanyId`, `Number`, `IssuedOn` and `DueOn` (`DateOnly`), `Status` (`draft`, `sent`, `paid` or `void`), `TotalCents` (long) and `Lines`; `InvoiceLine` has `InvoiceId`, `Position` (int), `Description`, `Quantity` (int), `UnitPriceCents` and `AmountCents` (long), at most 200 lines per invoice. Amounts are stored when the invoice is issued and are never recomputed by this API. Authentication is unchanged in `Program.cs`: JWT bearer tokens from the company's identity provider, and every token carries a `company_id` claim, read by `User.GetCompanyId()` (`Billing.Api.Auth.ClaimsPrincipalExtensions`, existing). Each company's users may see all of that company's invoices; there are no finer roles. Tests use xUnit and the existing `BillingApiFactory` (`WebApplicationFactory<Program>` over an in-memory SQLite database): `CreateClientFor(companyId)` signs requests in as a user of that company, and `SeedInvoiceAsync(companyId, number, lines...)` inserts a `sent` invoice dated 2026-10-01, due 2026-10-31. The invoice page itself ships separately in the web app.

Requirements

Files touched

Review this PR

C# practice