yavsc/src/Yavsc.Server/Models
Lum f4eb14d083 feat(api): POST /api/bill/estimate/{id}/sign — JSON signature capture
Adds a new JSON-bodied signature endpoint as a sibling of the
legacy PNG-based prosign/clisign routes. The legacy flow stays
intact: the TeX invoice templates (Bill_tex.cshtml,
Estimate_tex.cshtml) still consume the sign-{billingCode}-{id}.png
files the old endpoints write, and the new endpoint writes to a
distinct /signatures/ tree under UserFilesDirName. A future
migration commit will regenerate PNGs from the JSON payload and
decommission the PNG flow.

Scope
- New Signature entity (Yavsc.Server/Models/Billing/Signature.cs)
  with FK to Estimate, FK to ApplicationUser (Signer), Type
  (Pro/Client) enum, CoordinateMax (default 10_000), int[] Strokes
  (native Npgsql mapping), CapturedAtUtc, FilePath. Multiple
  versions per (EstimateId, Type) are allowed; the controller
  reads the most recent.
- New Estimate.Signatures nav collection (InverseProperty) so the
  composite index covers both sides of the relation.
- New DbSet<Signature> Signatures + composite index
  (EstimateId, Type, CapturedAtUtc DESC) in ApplicationDbContext
  OnModelCreating. DeleteBehavior.Cascade on Estimate deletion
  cleans up signatures automatically.
- New EstimateSignatureFileHelper (Server/Helpers) with
  ReceiveEstimateSignatureAsync(user, estimateId, type, payload).
  Writes a yavsc.signature/v1 JSON envelope to
  UserFilesDirName/{user}/signatures/sign-{type}-{estimateId}-{ticks}.json.
  Quota update lives in the controller, not the helper, because
  the helper has no DbContext access.
- New endpoint POST /api/bill/estimate/{id:long}/sign on
  BillingController. Authz is body-driven (the bearer token is the
  PostIt OAuth client, not the end user, so signerUserId is in
  the JSON body, validated against Estimate.OwnerId/ClientId).
  Returns 201 Created with the new Signature's metadata.

Plumbing
- SignatureSubmission (body type) lives next to BillingController
  in the same file — small enough to keep colocated.
- The legacy prosign/clisign routes are untouched. They keep
  the IFormFile PNG contract; the new endpoint is the JSON
  counterpart.

Tests
- New EstimateSignatureFileHelperTests in Yavsc.Org.Tests
  (8 tests, all green): filename format incl. lowercase type and
  ticks, envelope v1 round-trip (parsed via JsonDocument, not
  text matching), null payload rejected, non-positive
  estimateId rejected. Disk side effects are isolated to a
  per-test temp root via AbstractFileSystemHelpers.UserFilesDirName.
- Yavsc.Org.Tests full suite: 29/29 green.
- PostIt.Tests: 57/57 green (untouched by this commit).
- Builds: Yavsc.Server, Yavsc.Api, Yavsc.Org, Yavsc.Org.Tests
  all compile clean.

Out of scope
- EF migration: the Signatures table doesn't exist in the
  database yet. The migration is intentionally a separate
  commit so the generated SQL can be reviewed against the
  composite index and the int[] column type before it touches
  any prod database. Until the migration lands, the new
  endpoint will 500 on SaveChanges; the [DEV] button in
  PostIt is the only call site, so this is acceptable.
- SignalR handler that opens the signature page on a
  'devis received' push — commit 4.
2026-07-04 15:47:55 +01:00
..
Access reorg 2026-02-28 21:17:54 +00:00
Auth reorg 2026-02-28 21:17:54 +00:00
Bank reorg 2026-02-28 21:17:54 +00:00
Billing feat(api): POST /api/bill/estimate/{id}/sign — JSON signature capture 2026-07-04 15:47:55 +01:00
Blog postit and them also 2026-06-10 00:23:17 +01:00
Calendar reorg 2026-02-28 21:17:54 +00:00
Chat reorg 2026-02-28 21:17:54 +00:00
Cratie reorg 2026-02-28 21:17:54 +00:00
Drawing reorg 2026-02-28 21:17:54 +00:00
Edition reorg 2026-02-28 21:17:54 +00:00
EMailing reorg 2026-02-28 21:17:54 +00:00
FileSystem Login settings 2026-06-10 16:59:23 +01:00
Forms reorg 2026-02-28 21:17:54 +00:00
HairCut Blog Files model 2026-03-01 02:13:26 +00:00
IT refact and login 2026-03-09 02:07:42 +00:00
Kyc a scoring model 2026-05-24 19:35:35 +01:00
Market reorg 2026-02-28 21:17:54 +00:00
Messaging refact and login 2026-03-09 02:07:42 +00:00
Musical fixes and renaming 2026-06-30 23:32:05 +01:00
Payment refact and login 2026-03-09 02:07:42 +00:00
Relationship refact and login 2026-03-09 02:07:42 +00:00
societe.com reorg 2026-02-28 21:17:54 +00:00
Workflow refact and login 2026-03-09 02:07:42 +00:00
ApplicationDbContext.cs feat(api): POST /api/bill/estimate/{id}/sign — JSON signature capture 2026-07-04 15:47:55 +01:00
ApplicationUser.cs reorg 2026-02-28 21:17:54 +00:00
ConsentOptions.cs reorg 2026-02-28 21:17:54 +00:00
ErrorViewModel.cs reorg 2026-02-28 21:17:54 +00:00
FormFile.cs reorg 2026-02-28 21:17:54 +00:00
IdentityUserLogin.cs reorg 2026-02-28 21:17:54 +00:00
IUnit.cs reorg 2026-02-28 21:17:54 +00:00
YavscApiResource.cs APi Scopes 2026-03-16 23:16:12 +00:00
YavscApiResourceClaim.cs APi Scopes 2026-03-16 23:16:12 +00:00
YavscApiResourceProperty.cs APi Scopes 2026-03-16 23:16:12 +00:00
YavscApiResourceScope.cs APi Scopes 2026-03-16 23:16:12 +00:00
YavscApiResourceSecret.cs APi Scopes 2026-03-16 23:16:12 +00:00
YavscApiScope.cs APi Scopes 2026-03-16 23:16:12 +00:00
YavscApiScopeClaim.cs APi Scopes 2026-03-16 23:16:12 +00:00
YavscApiScopeProperty.cs APi Scopes 2026-03-16 23:16:12 +00:00
YavscDeviceFlowCodes.cs APi Scopes 2026-03-16 23:16:12 +00:00
YavscPersistedGrant.cs APi Scopes 2026-03-16 23:16:12 +00:00