fix: stock correction not working for bottle type and manual calculation mode (#133)
- Fix bottle type: submitStockCorrection used blister formula for baseTotal but getMedTotal uses only looseTablets for bottles. Now uses getPackageSize() which handles both types correctly. - Fix manual mode: same-day taken doses were counted as consumed after a stock correction (>= comparison with date-only timestamps). Changed to > so doses on the correction day are excluded. - Add agent instruction: only release-manager may create PRs/push/merge.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useState } from "react";
|
||||
import type { Coverage, FormState, Medication, RefillEntry } from "../types";
|
||||
import { getMedTotal } from "../types";
|
||||
import { getMedTotal, getPackageSize } from "../types";
|
||||
|
||||
export interface UseRefillReturn {
|
||||
// Refill state
|
||||
@@ -146,8 +146,8 @@ export function useRefill(): UseRefillReturn {
|
||||
const desiredTotal = finalFullBlisters * selectedMed.pillsPerBlister + finalPartialPills;
|
||||
|
||||
// The "base" from DB structure (without any stockAdjustment)
|
||||
const baseTotal =
|
||||
selectedMed.packCount * selectedMed.blistersPerPack * selectedMed.pillsPerBlister + selectedMed.looseTablets;
|
||||
// Use getPackageSize() which handles both blister and bottle types correctly
|
||||
const baseTotal = getPackageSize(selectedMed);
|
||||
|
||||
// stockAdjustment = what we need to make getMedTotal() return desiredTotal
|
||||
const newStockAdjustment = desiredTotal - baseTotal;
|
||||
|
||||
Reference in New Issue
Block a user