feat: add cash rounding, POS test suite, and fix test harness port cleanup
- Add Swedish rounding (nearest nickel) for cash payments at locations with cash_rounding enabled - Add rounding_adjustment column to transactions, cash_rounding to locations - Add POS schema to database plugin for relational query support - Complete/void routes now return full transaction with line items via getById - Test harness killPort falls back to fuser when lsof unavailable (fixes stale process bug) - Add 35-test POS API suite covering discounts, drawer, transactions, tax, rounding, e2e flow - Add unit tests for tax service and POS Zod schemas Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -32,8 +32,12 @@ export const DrawerService = {
|
||||
if (session.status === 'closed') throw new ConflictError('Drawer session is already closed')
|
||||
|
||||
// Calculate expected balance from cash transactions in this drawer session
|
||||
const [cashTotal] = await db
|
||||
.select({ total: sum(transactions.total) })
|
||||
// Net cash kept = total + rounding_adjustment (change is already accounted for)
|
||||
const [cashTotals] = await db
|
||||
.select({
|
||||
total: sum(transactions.total),
|
||||
rounding: sum(transactions.roundingAdjustment),
|
||||
})
|
||||
.from(transactions)
|
||||
.where(
|
||||
and(
|
||||
@@ -43,7 +47,7 @@ export const DrawerService = {
|
||||
)
|
||||
)
|
||||
|
||||
const cashIn = parseFloat(cashTotal?.total ?? '0')
|
||||
const cashIn = parseFloat(cashTotals?.total ?? '0') + parseFloat(cashTotals?.rounding ?? '0')
|
||||
const openingBalance = parseFloat(session.openingBalance)
|
||||
const expectedBalance = openingBalance + cashIn
|
||||
const closingBalance = input.closingBalance
|
||||
|
||||
Reference in New Issue
Block a user