Add lookup tables, payment methods, tax exemptions, and processor link APIs
Replace unit_status and item_condition pgEnums with company-scoped lookup tables that support custom values. Add account_payment_method table, tax_exemption table with approve/revoke workflow, and CRUD routes for processor links. Validate inventory unit status/condition against lookup tables at service layer.
This commit is contained in:
@@ -8,7 +8,6 @@ import {
|
||||
integer,
|
||||
numeric,
|
||||
date,
|
||||
pgEnum,
|
||||
} from 'drizzle-orm/pg-core'
|
||||
import { companies, locations } from './stores.js'
|
||||
|
||||
@@ -44,21 +43,9 @@ export const suppliers = pgTable('supplier', {
|
||||
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
})
|
||||
|
||||
export const conditionEnum = pgEnum('item_condition', [
|
||||
'new',
|
||||
'excellent',
|
||||
'good',
|
||||
'fair',
|
||||
'poor',
|
||||
])
|
||||
|
||||
export const unitStatusEnum = pgEnum('unit_status', [
|
||||
'available',
|
||||
'sold',
|
||||
'rented',
|
||||
'in_repair',
|
||||
'retired',
|
||||
])
|
||||
// NOTE: item_condition and unit_status pgEnums replaced by lookup tables.
|
||||
// See lookups.ts for inventory_unit_status and item_condition tables.
|
||||
// Columns below use varchar referencing the lookup slug.
|
||||
|
||||
export const products = pgTable('product', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
@@ -97,8 +84,8 @@ export const inventoryUnits = pgTable('inventory_unit', {
|
||||
.references(() => companies.id),
|
||||
locationId: uuid('location_id').references(() => locations.id),
|
||||
serialNumber: varchar('serial_number', { length: 255 }),
|
||||
condition: conditionEnum('condition').notNull().default('new'),
|
||||
status: unitStatusEnum('status').notNull().default('available'),
|
||||
condition: varchar('condition', { length: 100 }).notNull().default('new'),
|
||||
status: varchar('status', { length: 100 }).notNull().default('available'),
|
||||
purchaseDate: date('purchase_date'),
|
||||
purchaseCost: numeric('purchase_cost', { precision: 10, scale: 2 }),
|
||||
notes: text('notes'),
|
||||
|
||||
Reference in New Issue
Block a user