sales
This commit is contained in:
@@ -119,6 +119,8 @@ model InventoryItem {
|
||||
bomLines InventoryBomLine[] @relation("InventoryBomParent")
|
||||
usedInBomLines InventoryBomLine[] @relation("InventoryBomComponent")
|
||||
inventoryTransactions InventoryTransaction[]
|
||||
salesQuoteLines SalesQuoteLine[]
|
||||
salesOrderLines SalesOrderLine[]
|
||||
}
|
||||
|
||||
model Warehouse {
|
||||
@@ -163,6 +165,8 @@ model Customer {
|
||||
contacts CrmContact[]
|
||||
parentCustomer Customer? @relation("CustomerHierarchy", fields: [parentCustomerId], references: [id], onDelete: SetNull)
|
||||
childCustomers Customer[] @relation("CustomerHierarchy")
|
||||
salesQuotes SalesQuote[]
|
||||
salesOrders SalesOrder[]
|
||||
}
|
||||
|
||||
model InventoryBomLine {
|
||||
@@ -277,3 +281,64 @@ model CrmContact {
|
||||
customer Customer? @relation(fields: [customerId], references: [id], onDelete: Cascade)
|
||||
vendor Vendor? @relation(fields: [vendorId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
||||
model SalesQuote {
|
||||
id String @id @default(cuid())
|
||||
documentNumber String @unique
|
||||
customerId String
|
||||
status String
|
||||
issueDate DateTime
|
||||
expiresAt DateTime?
|
||||
notes String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
customer Customer @relation(fields: [customerId], references: [id], onDelete: Restrict)
|
||||
lines SalesQuoteLine[]
|
||||
}
|
||||
|
||||
model SalesQuoteLine {
|
||||
id String @id @default(cuid())
|
||||
quoteId String
|
||||
itemId String
|
||||
description String
|
||||
quantity Int
|
||||
unitOfMeasure String
|
||||
unitPrice Float
|
||||
position Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
quote SalesQuote @relation(fields: [quoteId], references: [id], onDelete: Cascade)
|
||||
item InventoryItem @relation(fields: [itemId], references: [id], onDelete: Restrict)
|
||||
|
||||
@@index([quoteId, position])
|
||||
}
|
||||
|
||||
model SalesOrder {
|
||||
id String @id @default(cuid())
|
||||
documentNumber String @unique
|
||||
customerId String
|
||||
status String
|
||||
issueDate DateTime
|
||||
notes String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
customer Customer @relation(fields: [customerId], references: [id], onDelete: Restrict)
|
||||
lines SalesOrderLine[]
|
||||
}
|
||||
|
||||
model SalesOrderLine {
|
||||
id String @id @default(cuid())
|
||||
orderId String
|
||||
itemId String
|
||||
description String
|
||||
quantity Int
|
||||
unitOfMeasure String
|
||||
unitPrice Float
|
||||
position Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
order SalesOrder @relation(fields: [orderId], references: [id], onDelete: Cascade)
|
||||
item InventoryItem @relation(fields: [itemId], references: [id], onDelete: Restrict)
|
||||
|
||||
@@index([orderId, position])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user