fix: correct stock calculation for both manual and automatic modes (#136)
Manual mode: Use takenAt timestamp instead of dose date-only comparison to correctly distinguish doses taken before vs after stock correction on the same day. Add polling race condition guard (mutationInFlightRef) so Take/Undo immediately reflects in dashboard stock. Automatic mode: Grid-align effectiveStart to the medication schedule and use hybrid consumed calculation (time-based + early-taken doses) for accurate stock counting.
This commit is contained in:
@@ -278,7 +278,8 @@ export function AppProvider({ children }: { children: React.ReactNode }) {
|
||||
systemLocale,
|
||||
settingsHook.settings.reminderDaysBefore,
|
||||
settingsHook.settings.stockCalculationMode,
|
||||
doses.takenDoses
|
||||
doses.takenDoses,
|
||||
doses.takenDoseTimestamps
|
||||
),
|
||||
[
|
||||
medications.meds,
|
||||
@@ -287,6 +288,7 @@ export function AppProvider({ children }: { children: React.ReactNode }) {
|
||||
settingsHook.settings.reminderDaysBefore,
|
||||
settingsHook.settings.stockCalculationMode,
|
||||
doses.takenDoses,
|
||||
doses.takenDoseTimestamps,
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user