purchase slice 1
This commit is contained in:
@@ -20,6 +20,7 @@ model User {
|
||||
userRoles UserRole[]
|
||||
contactEntries CrmContactEntry[]
|
||||
inventoryTransactions InventoryTransaction[]
|
||||
purchaseReceipts PurchaseReceipt[]
|
||||
}
|
||||
|
||||
model Role {
|
||||
@@ -134,6 +135,7 @@ model Warehouse {
|
||||
updatedAt DateTime @updatedAt
|
||||
locations WarehouseLocation[]
|
||||
inventoryTransactions InventoryTransaction[]
|
||||
purchaseReceipts PurchaseReceipt[]
|
||||
}
|
||||
|
||||
model Customer {
|
||||
@@ -198,6 +200,7 @@ model WarehouseLocation {
|
||||
updatedAt DateTime @updatedAt
|
||||
warehouse Warehouse @relation(fields: [warehouseId], references: [id], onDelete: Cascade)
|
||||
inventoryTransactions InventoryTransaction[]
|
||||
purchaseReceipts PurchaseReceipt[]
|
||||
|
||||
@@unique([warehouseId, code])
|
||||
@@index([warehouseId])
|
||||
@@ -384,6 +387,7 @@ model PurchaseOrder {
|
||||
updatedAt DateTime @updatedAt
|
||||
vendor Vendor @relation(fields: [vendorId], references: [id], onDelete: Restrict)
|
||||
lines PurchaseOrderLine[]
|
||||
receipts PurchaseReceipt[]
|
||||
}
|
||||
|
||||
model PurchaseOrderLine {
|
||||
@@ -399,6 +403,43 @@ model PurchaseOrderLine {
|
||||
updatedAt DateTime @updatedAt
|
||||
purchaseOrder PurchaseOrder @relation(fields: [purchaseOrderId], references: [id], onDelete: Cascade)
|
||||
item InventoryItem @relation(fields: [itemId], references: [id], onDelete: Restrict)
|
||||
receiptLines PurchaseReceiptLine[]
|
||||
|
||||
@@index([purchaseOrderId, position])
|
||||
}
|
||||
|
||||
model PurchaseReceipt {
|
||||
id String @id @default(cuid())
|
||||
receiptNumber String @unique
|
||||
purchaseOrderId String
|
||||
warehouseId String
|
||||
locationId String
|
||||
receivedAt DateTime
|
||||
notes String
|
||||
createdById String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
purchaseOrder PurchaseOrder @relation(fields: [purchaseOrderId], 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)
|
||||
lines PurchaseReceiptLine[]
|
||||
|
||||
@@index([purchaseOrderId, createdAt])
|
||||
@@index([warehouseId, createdAt])
|
||||
@@index([locationId, createdAt])
|
||||
}
|
||||
|
||||
model PurchaseReceiptLine {
|
||||
id String @id @default(cuid())
|
||||
purchaseReceiptId String
|
||||
purchaseOrderLineId String
|
||||
quantity Int
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
purchaseReceipt PurchaseReceipt @relation(fields: [purchaseReceiptId], references: [id], onDelete: Cascade)
|
||||
purchaseOrderLine PurchaseOrderLine @relation(fields: [purchaseOrderLineId], references: [id], onDelete: Restrict)
|
||||
|
||||
@@index([purchaseReceiptId])
|
||||
@@index([purchaseOrderLineId])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user