inventory

This commit is contained in:
2026-03-14 22:37:09 -05:00
parent 6589581908
commit 10b47da724
14 changed files with 651 additions and 43 deletions

View File

@@ -19,6 +19,7 @@ model User {
updatedAt DateTime @updatedAt
userRoles UserRole[]
contactEntries CrmContactEntry[]
inventoryTransactions InventoryTransaction[]
}
model Role {
@@ -117,6 +118,7 @@ model InventoryItem {
updatedAt DateTime @updatedAt
bomLines InventoryBomLine[] @relation("InventoryBomParent")
usedInBomLines InventoryBomLine[] @relation("InventoryBomComponent")
inventoryTransactions InventoryTransaction[]
}
model Warehouse {
@@ -127,6 +129,7 @@ model Warehouse {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
locations WarehouseLocation[]
inventoryTransactions InventoryTransaction[]
}
model Customer {
@@ -188,11 +191,34 @@ model WarehouseLocation {
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
warehouse Warehouse @relation(fields: [warehouseId], references: [id], onDelete: Cascade)
inventoryTransactions InventoryTransaction[]
@@unique([warehouseId, code])
@@index([warehouseId])
}
model InventoryTransaction {
id String @id @default(cuid())
itemId String
warehouseId String
locationId String
transactionType String
quantity Int
reference String
notes String
createdById String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
item InventoryItem @relation(fields: [itemId], references: [id], onDelete: Cascade)
warehouse Warehouse @relation(fields: [warehouseId], references: [id], onDelete: Restrict)
location WarehouseLocation @relation(fields: [locationId], references: [id], onDelete: Restrict)
createdBy User? @relation(fields: [createdById], references: [id], onDelete: SetNull)
@@index([itemId, createdAt])
@@index([warehouseId, createdAt])
@@index([locationId, createdAt])
}
model Vendor {
id String @id @default(cuid())
name String