63 lines
2.9 KiB
Plaintext
63 lines
2.9 KiB
Plaintext
enum ProductionBatchStatus {
|
|
DRAFT
|
|
IN_PROGRESS
|
|
COMPLETED
|
|
CANCELLED
|
|
}
|
|
|
|
model ProductionBatch {
|
|
id String @id @default(uuid()) @db.Uuid
|
|
organizationId String @map("organization_id") @db.Uuid
|
|
bomId String @map("bom_id") @db.Uuid
|
|
createdById String @map("created_by_id") @db.Uuid
|
|
reference String @db.VarChar(32)
|
|
plannedQuantity Int @map("planned_quantity")
|
|
status ProductionBatchStatus @default(DRAFT)
|
|
scheduledDate DateTime? @map("scheduled_date") @db.Date
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3)
|
|
startedAt DateTime? @map("started_at") @db.Timestamptz(3)
|
|
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Restrict)
|
|
bom ProductBom @relation(fields: [bomId, organizationId], references: [id, organizationId], onDelete: Restrict)
|
|
createdBy User @relation(fields: [createdById, organizationId], references: [id, organizationId], onDelete: Restrict)
|
|
completion ProductionBatchCompletion?
|
|
cancellation ProductionBatchCancellation?
|
|
materialUsage ProductionMaterialUsage[]
|
|
packagingRun PackagingRun?
|
|
costSnapshot BatchCostSnapshot?
|
|
stockPosting ProductionStockPosting?
|
|
@@unique([organizationId, reference])
|
|
@@unique([id, organizationId])
|
|
@@unique([id, bomId, organizationId])
|
|
@@index([organizationId, status, createdAt, id])
|
|
@@index([organizationId, bomId])
|
|
@@map("production_batches")
|
|
}
|
|
|
|
model ProductionBatchCompletion {
|
|
batchId String @id @map("batch_id") @db.Uuid
|
|
organizationId String @map("organization_id") @db.Uuid
|
|
completedById String @map("completed_by_id") @db.Uuid
|
|
goodQuantity Int @map("good_quantity")
|
|
rejectedQuantity Int @map("rejected_quantity")
|
|
rejectionReason String? @map("rejection_reason") @db.VarChar(500)
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3)
|
|
batch ProductionBatch @relation(fields: [batchId, organizationId], references: [id, organizationId], onDelete: Restrict)
|
|
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Restrict)
|
|
completedBy User @relation(fields: [completedById, organizationId], references: [id, organizationId], onDelete: Restrict)
|
|
@@unique([batchId, organizationId])
|
|
@@map("production_batch_completions")
|
|
}
|
|
|
|
model ProductionBatchCancellation {
|
|
batchId String @id @map("batch_id") @db.Uuid
|
|
organizationId String @map("organization_id") @db.Uuid
|
|
cancelledById String @map("cancelled_by_id") @db.Uuid
|
|
reason String @db.VarChar(500)
|
|
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(3)
|
|
batch ProductionBatch @relation(fields: [batchId, organizationId], references: [id, organizationId], onDelete: Restrict)
|
|
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Restrict)
|
|
cancelledBy User @relation(fields: [cancelledById, organizationId], references: [id, organizationId], onDelete: Restrict)
|
|
@@unique([batchId, organizationId])
|
|
@@map("production_batch_cancellations")
|
|
}
|