fix: require open drawer to complete transactions, fix product price field
- Backend enforces open drawer at location before completing any transaction - Frontend disables payment buttons when drawer is closed with warning message - Fix product price field name (price, not sellingPrice) in POS API types - Fix seed UUIDs to use valid UUID v4 format (version nibble must be 1-8) - Fix Vite allowedHosts for dev.lunarfront.tech access - Add e2e test for drawer enforcement (39 POS tests now pass) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
import postgres from 'postgres'
|
||||
|
||||
const DB_URL = process.env.DATABASE_URL ?? 'postgresql://lunarfront:lunarfront@localhost:5432/lunarfront'
|
||||
const COMPANY_ID = 'a0000000-0000-0000-0000-000000000001'
|
||||
const COMPANY_ID = 'a0000000-0000-4000-8000-000000000001'
|
||||
|
||||
const sql = postgres(DB_URL)
|
||||
|
||||
@@ -18,7 +18,7 @@ async function seed() {
|
||||
const [company] = await sql`SELECT id FROM company WHERE id = ${COMPANY_ID}`
|
||||
if (!company) {
|
||||
await sql`INSERT INTO company (id, name, timezone) VALUES (${COMPANY_ID}, 'Demo Store', 'America/Chicago')`
|
||||
await sql`INSERT INTO location (id, name) VALUES ('a0000000-0000-0000-0000-000000000002', 'Main Store')`
|
||||
await sql`INSERT INTO location (id, name, tax_rate, service_tax_rate) VALUES ('a0000000-0000-4000-8000-000000000002', 'Main Store', '0.0825', '0.0825')`
|
||||
console.log(' Created company and location')
|
||||
|
||||
// Seed RBAC
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import postgres from 'postgres'
|
||||
|
||||
const DB_URL = process.env.DATABASE_URL ?? 'postgresql://lunarfront:lunarfront@localhost:5432/lunarfront'
|
||||
const COMPANY_ID = 'a0000000-0000-0000-0000-000000000001'
|
||||
const COMPANY_ID = 'a0000000-0000-4000-8000-000000000001'
|
||||
|
||||
const sql = postgres(DB_URL)
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
transactionLineItems,
|
||||
discountAudits,
|
||||
discounts,
|
||||
drawerSessions,
|
||||
} from '../db/schema/pos.js'
|
||||
import { products, inventoryUnits } from '../db/schema/inventory.js'
|
||||
import { companies, locations } from '../db/schema/stores.js'
|
||||
@@ -231,6 +232,18 @@ export const TransactionService = {
|
||||
if (!txn) throw new NotFoundError('Transaction')
|
||||
if (txn.status !== 'pending') throw new ConflictError('Transaction is not pending')
|
||||
|
||||
// Require an open drawer session at the transaction's location
|
||||
if (txn.locationId) {
|
||||
const [openDrawer] = await db
|
||||
.select({ id: drawerSessions.id })
|
||||
.from(drawerSessions)
|
||||
.where(and(eq(drawerSessions.locationId, txn.locationId), eq(drawerSessions.status, 'open')))
|
||||
.limit(1)
|
||||
if (!openDrawer) {
|
||||
throw new ValidationError('Cannot complete transaction without an open drawer at this location')
|
||||
}
|
||||
}
|
||||
|
||||
// Validate cash payment (with optional nickel rounding)
|
||||
let changeGiven: string | undefined
|
||||
let roundingAdjustment = 0
|
||||
|
||||
Reference in New Issue
Block a user