Commit graph

29 commits

Author SHA1 Message Date
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
0965caaf40 fixes and renaming 2026-06-30 23:32:05 +01:00
fa7d6242f1 postit and them also 2026-06-10 00:23:17 +01:00
e24208e77b refact 2026-05-30 19:34:22 +01:00
8a46341755 a scoring model 2026-05-24 19:35:35 +01:00
5620213cf5 better 2026-04-19 20:36:03 +01:00
65db349c0a fixes the current date at testing phase 2026-04-19 19:17:34 +01:00
Paul Schneider
be7df3d054 APi Scopes 2026-03-16 23:16:12 +00:00
Paul Schneider
e042e34bf7 refact and login 2026-03-09 02:07:42 +00:00
Paul Schneider
acc34aeee4 cleanup db migrations 2026-03-01 20:14:54 +00:00
Paul Schneider
cbd5822fa2 diable nullable 2026-03-01 17:25:25 +00:00
Paul Schneider
93f0c2d25e cleanup 2026-03-01 14:09:10 +00:00
Paul Schneider
bfb37bc214 Blog Files model 2026-03-01 02:13:26 +00:00
Paul Schneider
40e8e08690 reorg 2026-02-28 21:17:54 +00:00
Paul Schneider
45514010f2 REORG 2026-02-14 16:54:27 +00:00
Paul Schneider
8d68ee380a id server db resources 2026-02-09 01:03:33 +00:00
Paul Schneider
e5fa31c9cb using AscDocCsharp, and fixing the tag helper 2025-09-14 17:47:11 +01:00
Paul Schneider
03161bbfb6 Id Stores from db 2025-08-24 16:07:53 +01:00
Paul Schneider
b3d565b6d9 Refactoring
The main server owns the migrations, it's the server part,
it's simpler.

It's Yavsc, not one of its lib.
2025-07-15 20:17:39 +01:00
Paul Schneider
52edbff231 a client store 2025-07-15 17:35:14 +01:00
Paul Schneider
fc15e42efe db cleanup 2025-07-15 15:49:48 +01:00
Paul Schneider
72bae76c75 null paiment id 2025-07-15 15:42:30 +01:00
Paul Schneider
8fc1153e59 testing 2025-07-14 20:35:13 +01:00
Paul Schneider
0cfc1dc95a External Login 2025-07-10 19:14:17 +01:00
Paul Schneider
6c175783a9 Externl Login 2025-07-10 15:19:28 +01:00
Paul Schneider
9b7a6c0125 refact 2025-06-29 18:44:35 +01:00
Paul Schneider
4941f3bdef Implémentation de la publication d'un billet 2025-06-28 16:14:52 +01:00
Paul Schneider
39788f46f9 migration net9.0 2025-06-16 02:30:32 +01:00
Paul Schneider
8e8f4d3896 refactoring 2025-02-14 22:44:33 +00:00
Renamed from src/Yavsc/Models/ApplicationDbContext.cs (Browse further)