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:
@@ -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)));
|
||||
|
||||
Reference in New Issue
Block a user