3c-fix: partial consumption now deducts eaten + leftovers

- consumptionPortions = min(planned, actualPortionsEaten + leftoverEstimatePortions).
  Meal boxes are a subset of leftovers; raw inventory is only retained for
  portions that were never cooked.
- Added validation leftoverEstimatePortions >= mealBoxPortions with localized
  400 error (cooked.leftoverLessThanBox) in server i18n + all 12 locales.
- Removed unused COOKING_SESSION_STATUSES / MEAL_BOX_STATUSES imports from
  apps/api/src/lib/cooking.ts.
- Hardened test cleanup to delete mealBoxes/meals/recipeCooks/cookingSessions
  by household before dropping storageLocations.
- New regression tests: meal-box double-counting, eaten+leftover split, and
  leftover < box rejection.
- Updated FAS3-COOKING-SESSIONS-AUDIT.md with corrected physics semantics.
This commit is contained in:
Sven (AAMOS AI)
2026-08-07 15:35:25 +07:00
parent cb493010d0
commit 8637eaa6c3
16 changed files with 257 additions and 25 deletions
+2 -1
View File
@@ -384,5 +384,6 @@
"scan.diff.undo": "Annulla",
"scan.diff.undoHint": "Ogni modifica può essere annullata dalla vista dettaglio dell'articolo.",
"cooked.portionsSumExceedsPlanned": "Le porzioni mangiate e gli avanzi non possono superare il numero totale di porzioni.",
"cooked.undoWindowExpired": "Non è più possibile annullare questa sessione di cucina. La finestra di 24 ore è scaduta."
"cooked.undoWindowExpired": "Non è più possibile annullare questa sessione di cucina. La finestra di 24 ore è scaduta.",
"cooked.leftoverLessThanBox": "Gli avanzi devono essere almeno tanti quanto il numero di porzioni dei contenitori per il pranzo."
}