model Customer { id Int @id @default(autoincrement()) firstName String @db.VarChar(255) lastName String @db.VarChar(255) email String? @db.VarChar(255) mobileNumber String @unique @db.Char(11) address String? @db.Text city String? @db.VarChar(100) state String? @db.VarChar(100) country String? @db.VarChar(100) isActive Boolean @default(true) createdAt DateTime @default(now()) @db.Timestamp(0) updatedAt DateTime @updatedAt @db.Timestamp(0) deletedAt DateTime? @db.Timestamp(0) orders Order[] @relation("Customer_Orders") salesInvoices SalesInvoice[] @relation("Customer_Sales_Invoices") stockMovements StockMovement[] @relation("StockMovement_Customer") @@map("Customers") } model Order { id Int @id @default(autoincrement()) orderNumber String @unique @db.VarChar(100) status OrderStatus @default(PENDING) paymentMethod PaymentMethodType @default(CARD) totalAmount Decimal @db.Decimal(15, 2) description String? @db.Text createdAt DateTime @default(now()) @db.Timestamp(0) updatedAt DateTime @updatedAt @db.Timestamp(0) deletedAt DateTime? @db.Timestamp(0) customerId Int customer Customer @relation("Customer_Orders", fields: [customerId], references: [id], onUpdate: NoAction) @@index([customerId], map: "Orders_customerId_fkey") @@map("Orders") } model SalesInvoice { id Int @id @default(autoincrement()) code String @unique @db.VarChar(100) totalAmount Decimal @db.Decimal(15, 2) description String? @db.Text createdAt DateTime @default(now()) @db.Timestamp(0) updatedAt DateTime @updatedAt @db.Timestamp(0) customerId Int? inventoryId Int items SalesInvoiceItem[] @relation("SalesInvoice_Items") customer Customer? @relation("Customer_Sales_Invoices", fields: [customerId], references: [id]) inventory Inventory @relation("Inventory_SalesInvoices", fields: [inventoryId], references: [id]) @@index([inventoryId], map: "Sales_Invoices_inventoryId_fkey") @@index([customerId], map: "Sales_Invoices_customerId_fkey") @@map("Sales_Invoices") } model SalesInvoiceItem { id Int @id @default(autoincrement()) count Decimal @db.Decimal(10, 0) fee Decimal @db.Decimal(15, 2) total Decimal @db.Decimal(15, 2) createdAt DateTime @default(now()) @db.Timestamp(0) invoiceId Int productId Int invoice SalesInvoice @relation("SalesInvoice_Items", fields: [invoiceId], references: [id]) product Product @relation("Product_SalesInvoiceItems", fields: [productId], references: [id]) @@index([invoiceId], map: "Sales_Invoice_Items_invoiceId_fkey") @@index([productId], map: "Sales_Invoice_Items_productId_fkey") @@map("Sales_Invoice_Items") } model TriggerLog { id Int @id @default(autoincrement()) message String @db.Text createdAt DateTime @default(now()) @db.Timestamp(0) name String @db.Text @@map("Trigger_Logs") }