Add consignment_detail table for consignment inventory
Separate table linked to product — keeps product table clean when most items are not consignment. Tracks consignor (account), commission percentage, min price, and agreement date. 33 tests passing.
This commit is contained in:
@@ -166,6 +166,26 @@ export type PriceHistory = typeof priceHistory.$inferSelect
|
||||
export type StockReceipt = typeof stockReceipts.$inferSelect
|
||||
export type StockReceiptInsert = typeof stockReceipts.$inferInsert
|
||||
|
||||
export const consignmentDetails = pgTable('consignment_detail', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
productId: uuid('product_id')
|
||||
.notNull()
|
||||
.references(() => products.id),
|
||||
companyId: uuid('company_id')
|
||||
.notNull()
|
||||
.references(() => companies.id),
|
||||
consignorAccountId: uuid('consignor_account_id').notNull(),
|
||||
commissionPercent: numeric('commission_percent', { precision: 5, scale: 2 }).notNull(),
|
||||
minPrice: numeric('min_price', { precision: 10, scale: 2 }),
|
||||
agreementDate: date('agreement_date'),
|
||||
notes: text('notes'),
|
||||
isActive: boolean('is_active').notNull().default(true),
|
||||
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
|
||||
})
|
||||
|
||||
export type ConsignmentDetail = typeof consignmentDetails.$inferSelect
|
||||
export type ConsignmentDetailInsert = typeof consignmentDetails.$inferInsert
|
||||
|
||||
export type Product = typeof products.$inferSelect
|
||||
export type ProductInsert = typeof products.$inferInsert
|
||||
export type InventoryUnit = typeof inventoryUnits.$inferSelect
|
||||
|
||||
Reference in New Issue
Block a user