finance
This commit is contained in:
@@ -29,6 +29,7 @@ model User {
|
||||
workOrderOperationLaborEntries WorkOrderOperationLaborEntry[]
|
||||
assignedWorkOrderOperations WorkOrderOperation[]
|
||||
shipmentPicks ShipmentPick[]
|
||||
financeCustomerPayments FinanceCustomerPayment[]
|
||||
approvedSalesQuotes SalesQuote[] @relation("SalesQuoteApprovedBy")
|
||||
approvedSalesOrders SalesOrder[] @relation("SalesOrderApprovedBy")
|
||||
salesQuoteRevisionsCreated SalesQuoteRevision[] @relation("SalesQuoteRevisionCreatedBy")
|
||||
@@ -401,6 +402,7 @@ model Vendor {
|
||||
contactEntries CrmContactEntry[]
|
||||
contacts CrmContact[]
|
||||
purchaseOrders PurchaseOrder[]
|
||||
capexEntries CapexEntry[]
|
||||
preferredSupplyItems InventoryItem[]
|
||||
}
|
||||
|
||||
@@ -496,6 +498,7 @@ model SalesOrder {
|
||||
revisions SalesOrderRevision[]
|
||||
workOrders WorkOrder[]
|
||||
purchaseOrderLines PurchaseOrderLine[]
|
||||
customerPayments FinanceCustomerPayment[]
|
||||
}
|
||||
|
||||
model SalesOrderLine {
|
||||
@@ -665,6 +668,7 @@ model WorkOrder {
|
||||
materialIssues WorkOrderMaterialIssue[]
|
||||
completions WorkOrderCompletion[]
|
||||
reservations InventoryReservation[]
|
||||
financeCostSnapshot FinanceManufacturingCostSnapshot?
|
||||
|
||||
@@index([itemId, createdAt])
|
||||
@@index([projectId, dueDate])
|
||||
@@ -788,6 +792,74 @@ model WorkOrderCompletion {
|
||||
@@index([workOrderId, createdAt])
|
||||
}
|
||||
|
||||
model FinanceProfile {
|
||||
id String @id @default(cuid())
|
||||
currencyCode String @default("USD")
|
||||
standardLaborRatePerHour Float @default(45)
|
||||
overheadRatePerHour Float @default(18)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model FinanceCustomerPayment {
|
||||
id String @id @default(cuid())
|
||||
salesOrderId String
|
||||
paymentType String
|
||||
paymentMethod String
|
||||
paymentDate DateTime
|
||||
amount Float
|
||||
reference String
|
||||
notes String
|
||||
createdById String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
salesOrder SalesOrder @relation(fields: [salesOrderId], references: [id], onDelete: Cascade)
|
||||
createdBy User? @relation(fields: [createdById], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([salesOrderId, paymentDate])
|
||||
@@index([createdAt])
|
||||
}
|
||||
|
||||
model FinanceManufacturingCostSnapshot {
|
||||
id String @id @default(cuid())
|
||||
workOrderId String @unique
|
||||
materialCost Float @default(0)
|
||||
laborCost Float @default(0)
|
||||
overheadCost Float @default(0)
|
||||
totalCost Float @default(0)
|
||||
materialIssueCount Int @default(0)
|
||||
laborEntryCount Int @default(0)
|
||||
calculatedAt DateTime @default(now())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
workOrder WorkOrder @relation(fields: [workOrderId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([calculatedAt])
|
||||
}
|
||||
|
||||
model CapexEntry {
|
||||
id String @id @default(cuid())
|
||||
title String
|
||||
category String
|
||||
status String
|
||||
vendorId String?
|
||||
purchaseOrderId String?
|
||||
plannedAmount Float
|
||||
actualAmount Float
|
||||
requestDate DateTime
|
||||
targetInServiceDate DateTime?
|
||||
purchasedAt DateTime?
|
||||
notes String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
vendor Vendor? @relation(fields: [vendorId], references: [id], onDelete: SetNull)
|
||||
purchaseOrder PurchaseOrder? @relation(fields: [purchaseOrderId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([status, requestDate])
|
||||
@@index([vendorId, createdAt])
|
||||
@@index([purchaseOrderId, createdAt])
|
||||
}
|
||||
|
||||
model PurchaseOrder {
|
||||
id String @id @default(cuid())
|
||||
documentNumber String @unique
|
||||
@@ -803,6 +875,7 @@ model PurchaseOrder {
|
||||
lines PurchaseOrderLine[]
|
||||
receipts PurchaseReceipt[]
|
||||
revisions PurchaseOrderRevision[]
|
||||
capexEntries CapexEntry[]
|
||||
}
|
||||
|
||||
model PurchaseOrderLine {
|
||||
|
||||
Reference in New Issue
Block a user