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:
@@ -10,7 +10,6 @@ model Inventory {
|
||||
inventoryTransfersFrom InventoryTransfer[] @relation("Inventory_From")
|
||||
inventoryTransfersTo InventoryTransfer[] @relation("Inventory_To")
|
||||
purchaseReceipts PurchaseReceipt[]
|
||||
salesInvoices SalesInvoice[] @relation("Inventory_SalesInvoices")
|
||||
stockAdjustments StockAdjustment[] @relation("Inventory_Stock_Adjustments")
|
||||
stockBalances StockBalance[] @relation("StockBalance_inventory")
|
||||
counterStockMovements StockMovement[] @relation("StockMovement_CounterInventory")
|
||||
@@ -24,9 +23,10 @@ model InventoryBankAccount {
|
||||
inventoryId Int
|
||||
bankAccountId Int
|
||||
|
||||
inventory Inventory @relation(fields: [inventoryId], references: [id])
|
||||
bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])
|
||||
posAccounts PosAccount[]
|
||||
inventory Inventory @relation(fields: [inventoryId], references: [id])
|
||||
bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])
|
||||
posAccounts PosAccount[]
|
||||
purchaseReceiptPayments PurchaseReceiptPayments[]
|
||||
|
||||
@@id([inventoryId, bankAccountId])
|
||||
@@index([bankAccountId])
|
||||
@@ -45,6 +45,7 @@ model PosAccount {
|
||||
deletedAt DateTime? @db.Timestamp(0)
|
||||
|
||||
inventoryBankAccount InventoryBankAccount @relation(fields: [inventoryId, bankAccountId], references: [inventoryId, bankAccountId])
|
||||
salesInvoices SalesInvoice[]
|
||||
|
||||
@@index([inventoryId])
|
||||
@@map("Pos_Accounts")
|
||||
|
||||
+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")
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ model ProductVariant {
|
||||
basePrice Decimal @db.Decimal(15, 2)
|
||||
salePrice Decimal @db.Decimal(15, 2)
|
||||
description String? @db.Text
|
||||
barcode String? @unique(map: "products_barcode_unique") @db.VarChar(100)
|
||||
barcode String? @unique() @db.VarChar(100)
|
||||
imageUrl String? @db.VarChar(255)
|
||||
unit String? @db.VarChar(10)
|
||||
quantity Decimal? @default(0.00) @db.Decimal(10, 0)
|
||||
@@ -25,24 +25,24 @@ model Product {
|
||||
id Int @id @default(autoincrement())
|
||||
name String @db.VarChar(255)
|
||||
description String? @db.Text
|
||||
sku String? @unique(map: "products_sku_unique") @db.VarChar(100)
|
||||
barcode String? @unique(map: "products_barcode_unique") @db.VarChar(100)
|
||||
sku String? @unique() @db.VarChar(100)
|
||||
barcode String? @unique() @db.VarChar(100)
|
||||
createdAt DateTime @default(now()) @db.Timestamp(0)
|
||||
updatedAt DateTime @updatedAt @db.Timestamp(0)
|
||||
deletedAt DateTime? @db.Timestamp(0)
|
||||
brandId Int?
|
||||
categoryId Int?
|
||||
salePrice Decimal @default(0.00) @db.Decimal(15, 0)
|
||||
minimumStockAlertLevel Decimal @default(1.00) @db.Decimal(10, 0)
|
||||
inventoryTransferItems InventoryTransferItem[] @relation("InventoryTransferItem_Product")
|
||||
// productCharges ProductCharge[] @relation("Product_Charges")
|
||||
variants ProductVariant[] @relation("Product_Variant")
|
||||
brand ProductBrand? @relation("Product_Brand", fields: [brandId], references: [id], onUpdate: NoAction)
|
||||
category ProductCategory? @relation("Product_Category", fields: [categoryId], references: [id], onUpdate: NoAction)
|
||||
purchaseReceiptItems PurchaseReceiptItem[] @relation("Product_PurchaseReceiptItems")
|
||||
salesInvoiceItems SalesInvoiceItem[] @relation("Product_SalesInvoiceItems")
|
||||
stockAdjustments StockAdjustment[] @relation("Product_Stock_Adjustments")
|
||||
stockBalances StockBalance[] @relation("StockBalance_Product")
|
||||
stockMovements StockMovement[] @relation("StockMovement_Product")
|
||||
salesInvoiceItems SalesInvoiceItem[]
|
||||
|
||||
@@index([brandId], map: "Products_brandId_fkey")
|
||||
@@index([categoryId], map: "Products_categoryId_fkey")
|
||||
|
||||
@@ -47,8 +47,11 @@ model PurchaseReceiptPayments {
|
||||
description String? @db.Text
|
||||
createdAt DateTime @default(now()) @db.Timestamp(0)
|
||||
|
||||
receipt PurchaseReceipt @relation(fields: [receiptId], references: [id])
|
||||
bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])
|
||||
receipt PurchaseReceipt @relation(fields: [receiptId], references: [id])
|
||||
bankAccount BankAccount @relation(fields: [bankAccountId], references: [id])
|
||||
inventoryBankAccount InventoryBankAccount? @relation(fields: [inventoryBankAccountInventoryId, inventoryBankAccountBankAccountId], references: [inventoryId, bankAccountId])
|
||||
inventoryBankAccountInventoryId Int?
|
||||
inventoryBankAccountBankAccountId Int?
|
||||
|
||||
@@index([receiptId], map: "Purchase_Receipt_Payments_receiptId_fkey")
|
||||
@@map("Purchase_Receipt_Payments")
|
||||
|
||||
@@ -15,7 +15,7 @@ model StockMovement {
|
||||
counterInventoryId Int?
|
||||
customerId Int?
|
||||
counterInventory Inventory? @relation("StockMovement_CounterInventory", fields: [counterInventoryId], references: [id])
|
||||
customer Customer? @relation("StockMovement_Customer", fields: [customerId], references: [id])
|
||||
customer Customer? @relation(fields: [customerId], references: [id])
|
||||
inventory Inventory @relation("StockMovement_Inventory", fields: [inventoryId], references: [id])
|
||||
product Product @relation("StockMovement_Product", fields: [productId], references: [id])
|
||||
supplier Supplier? @relation("StockMovement_Supplier", fields: [supplierId], references: [id])
|
||||
|
||||
Reference in New Issue
Block a user