fix: reset stock adjustment offset on refill (#99)

- Reset stockAdjustment to 0 and lastStockCorrectionAt to now when
  a refill is added, so consumed-pill tracking restarts from the
  new base stock level
This commit is contained in:
Daniel Volz
2026-02-06 22:04:14 +01:00
committed by GitHub
parent 5818dcc00d
commit ae45054ab7
+2
View File
@@ -61,6 +61,8 @@ export async function refillRoutes(app: FastifyInstance) {
.set({
packCount: newPackCount,
looseTablets: newLooseTablets,
stockAdjustment: 0, // Reset offset since we're adding to base stock
lastStockCorrectionAt: new Date(), // Reset consumed counter to now
updatedAt: new Date(),
})
.where(and(eq(medications.id, medId), eq(medications.userId, userId)));