fix: code review fixes + unit/API tests for repair-POS integration
Code review fixes: - Wrap createFromRepairTicket() in DB transaction for atomicity - Wrap complete() inventory + status updates in DB transaction - Repair ticket status update now atomic with transaction completion - Add Zod validation on from-repair route body - Fix requiresDiscountOverride: threshold and manual_discount are independent checks - Order discount distributes proportionally across line items (not first-only) - Extract shared receipt calculations into useReceiptData/useBarcode hooks - Add error handling for barcode generation Tests: - Unit: consumable tax category mapping, exempt rate short-circuit - API: ready-for-pickup listing + search, from-repair transaction creation, consumable exclusion from line items, tax rate verification (labor=service, part=goods), duplicate prevention, ticket auto-pickup on payment completion, isConsumable product filter Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -193,7 +193,9 @@ export function setDiscountThreshold(pct: number) {
|
||||
}
|
||||
|
||||
export function requiresDiscountOverride(discountPct: number): boolean {
|
||||
// Check percentage threshold first
|
||||
const threshold = getDiscountThreshold()
|
||||
if (threshold <= 0) return requiresOverride('manual_discount')
|
||||
return discountPct >= threshold
|
||||
if (threshold > 0 && discountPct >= threshold) return true
|
||||
// Fall back to the blanket manual_discount toggle
|
||||
return requiresOverride('manual_discount')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user