fix(inventory): serialise unknown units as null, not 0 (iOS shows unknown, no phantom negatives)

This commit is contained in:
Marc-André Bombeck committed 2026-06-17 14:09:42 +02:00
commit fcd498d252
12 files changed
+146 -30

No files matched your search

+4 -2
View File
@@ -296,13 +296,15 @@ const medicationInventoryItemResource = z
),
unitsTotal: z
.number()
.nullable()
.describe(
"Units the container shipped with (tablets / ampoules / puffs; 1–1000). v1.16.12 — fractional, so a split-pill remainder reads cleanly. Dose-derived readouts divide by the medication's `unitsPerDose`.",
"Units the container shipped with (tablets / ampoules / puffs; 1–1000). v1.16.12 — fractional, so a split-pill remainder reads cleanly. Dose-derived readouts divide by the medication's `unitsPerDose`. v1.18.3 (iOS#31) — NULL when the unit count is unknown (a corrupt or legacy row); the client renders \"unknown\", never a fabricated 0.",
),
unitsRemaining: z
.number()
.nullable()
.describe(
"Units left in the container. v1.16.12 — fractional (a ½-tablet dose leaves 29.5 of 30). Decremented by the intake consumption hook (FEFO with spillover across containers); refunded when a taken dose is skipped, edited away, or deleted.",
"Units left in the container. v1.16.12 — fractional (a ½-tablet dose leaves 29.5 of 30). Decremented by the intake consumption hook (FEFO with spillover across containers); refunded when a taken dose is skipped, edited away, or deleted. v1.18.3 (iOS#31) — NULL when the count is unknown (a corrupt or legacy row); the client renders \"unknown\", never a fabricated 0 it could decrement into negatives.",
),
firstUseAt: z.iso
.datetime({ offset: true })