feat: add drawer cash in/out adjustments with balance reconciliation
- New drawer_adjustment table (type: cash_in/cash_out, amount, reason) - POST/GET /drawer/:id/adjustments endpoints - Drawer close calculation now includes adjustments: expected = opening + sales + cash_in - cash_out - DrawerAdjustmentSchema for input validation - 5 new tests (44 total POS tests passing) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -68,6 +68,8 @@ export const discounts = pgTable('discount', {
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
})
|
||||
|
||||
export const adjustmentTypeEnum = pgEnum('adjustment_type', ['cash_in', 'cash_out'])
|
||||
|
||||
export const drawerSessions = pgTable('drawer_session', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
locationId: uuid('location_id').references(() => locations.id),
|
||||
@@ -86,6 +88,20 @@ export const drawerSessions = pgTable('drawer_session', {
|
||||
closedAt: timestamp('closed_at', { withTimezone: true }),
|
||||
})
|
||||
|
||||
export const drawerAdjustments = pgTable('drawer_adjustment', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
drawerSessionId: uuid('drawer_session_id')
|
||||
.notNull()
|
||||
.references(() => drawerSessions.id),
|
||||
type: adjustmentTypeEnum('type').notNull(),
|
||||
amount: numeric('amount', { precision: 10, scale: 2 }).notNull(),
|
||||
reason: text('reason').notNull(),
|
||||
createdBy: uuid('created_by')
|
||||
.notNull()
|
||||
.references(() => users.id),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
})
|
||||
|
||||
export const transactions = pgTable('transaction', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
locationId: uuid('location_id').references(() => locations.id),
|
||||
|
||||
Reference in New Issue
Block a user