feat: T4b wave 7 - schema for phenology, honey movement ledger, shelf life
- Phenology reports, apiary phenology state and weather days with permissions for system roles - Honey movement ledger: BOTTLING movements and initialAmount backfilled from existing bottlings with the same gram rounding; the migration reports counts and aborts if the ledger invariant fails - Shelf life and event catalog columns; backup export/import of the new tables, old bundles keep importing, invariant check after imports - e2e: test timeout 20 s (app start in hooks exceeded 5 s under load) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
326b3d9cdd
commit
22382d53a2
17 files changed
+1213
-39
No files matched your search
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Honey ledger invariant (Spec 4.6): amount = initialAmount + sum(quantity)
|
||||
* / 1000, rounded to the gram. Returns the batches that break it (tolerance
|
||||
* 0.5 g); an empty result means the ledger is consistent. Batches without
|
||||
* initialAmount are not booked and therefore not checked.
|
||||
*/
|
||||
export const INVARIANT_SQL = `
|
||||
SELECT hb."id"
|
||||
FROM "HoneyBatch" hb
|
||||
LEFT JOIN (
|
||||
SELECT "honeyBatchId", sum("quantity") AS grams
|
||||
FROM "BatchMovement"
|
||||
WHERE "honeyBatchId" IS NOT NULL
|
||||
GROUP BY "honeyBatchId"
|
||||
) m ON m."honeyBatchId" = hb."id"
|
||||
WHERE hb."initialAmount" IS NOT NULL
|
||||
AND hb."amount" IS NOT NULL
|
||||
AND abs(hb."amount" - (hb."initialAmount" + coalesce(m.grams, 0) / 1000.0)) > 0.0005
|
||||
`;
|
||||
Reference in new issue
Block a user