feat(inventories): add cardex retrieval for inventory and product
feat(pos): update sale invoice creation to include customer and item details feat(pos): enhance POS account service to include today's sales information feat(pos): refactor order DTO to create sale invoice with detailed item structure feat(products): add minimum stock alert level to product creation and update DTOs fix(triggers): implement stock validation and movement logging for sales invoice items refactor(database): update sales invoices schema to include posAccountId and remove inventoryId
This commit is contained in:
+22
-22
@@ -12,9 +12,9 @@ model Customer {
|
||||
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")
|
||||
orders Order[] @relation()
|
||||
stockMovements StockMovement[] @relation()
|
||||
salesInvoices SalesInvoice[]
|
||||
|
||||
@@map("Customers")
|
||||
}
|
||||
@@ -30,27 +30,27 @@ model Order {
|
||||
updatedAt DateTime @updatedAt @db.Timestamp(0)
|
||||
deletedAt DateTime? @db.Timestamp(0)
|
||||
customerId Int
|
||||
customer Customer @relation("Customer_Orders", fields: [customerId], references: [id], onUpdate: NoAction)
|
||||
customer Customer @relation(fields: [customerId], references: [id], onUpdate: NoAction)
|
||||
|
||||
@@index([customerId], map: "Orders_customerId_fkey")
|
||||
@@index([customerId])
|
||||
@@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])
|
||||
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?
|
||||
posAccountId Int
|
||||
items SalesInvoiceItem[]
|
||||
customer Customer? @relation(fields: [customerId], references: [id])
|
||||
posAccount PosAccount @relation(fields: [posAccountId], references: [id])
|
||||
|
||||
@@index([inventoryId], map: "Sales_Invoices_inventoryId_fkey")
|
||||
@@index([customerId], map: "Sales_Invoices_customerId_fkey")
|
||||
@@index([customerId])
|
||||
@@index([posAccountId])
|
||||
@@map("Sales_Invoices")
|
||||
}
|
||||
|
||||
@@ -62,11 +62,11 @@ model SalesInvoiceItem {
|
||||
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])
|
||||
invoice SalesInvoice @relation(fields: [invoiceId], references: [id])
|
||||
product Product @relation(fields: [productId], references: [id])
|
||||
|
||||
@@index([invoiceId], map: "Sales_Invoice_Items_invoiceId_fkey")
|
||||
@@index([productId], map: "Sales_Invoice_Items_productId_fkey")
|
||||
@@index([invoiceId])
|
||||
@@index([productId])
|
||||
@@map("Sales_Invoice_Items")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user