feat(cardex): enhance stock movement retrieval with additional fields and optimized mapping
refactor(migration): update Stock_Movements table to include counterInventoryId and customerId, add foreign key constraints, and implement triggers for inventory management
This commit is contained in:
@@ -156,6 +156,7 @@ model Customer {
|
||||
salesInvoices SalesInvoice[] @relation("Customer_Sales_Invoices")
|
||||
|
||||
@@map("Customers")
|
||||
stockMovements StockMovement[] @relation("StockMovement_Customer")
|
||||
}
|
||||
|
||||
model Inventory {
|
||||
@@ -173,6 +174,7 @@ model Inventory {
|
||||
purchaseReceipts PurchaseReceipt[]
|
||||
stockAdjustments StockAdjustment[] @relation("Inventory_Stock_Adjustments")
|
||||
stockMovements StockMovement[] @relation("StockMovement_Inventory")
|
||||
counterStockMovements StockMovement[] @relation("StockMovement_CounterInventory")
|
||||
stockBalances StockBalance[] @relation("StockBalance_inventory")
|
||||
salesInvoices SalesInvoice[] @relation("Inventory_SalesInvoices")
|
||||
|
||||
@@ -317,6 +319,10 @@ model StockMovement {
|
||||
product Product @relation("StockMovement_Product", fields: [productId], references: [id])
|
||||
supplierId Int?
|
||||
supplier Supplier? @relation("StockMovement_Supplier", fields: [supplierId], references: [id])
|
||||
customerId Int?
|
||||
customer Customer? @relation("StockMovement_Customer", fields: [customerId], references: [id])
|
||||
counterInventoryId Int?
|
||||
counterInventory Inventory? @relation("StockMovement_CounterInventory", fields: [counterInventoryId], references: [id])
|
||||
|
||||
@@index([inventoryId], map: "Stock_Movements_inventoryId_fkey")
|
||||
@@index([productId], map: "Stock_Movements_productId_fkey")
|
||||
|
||||
Reference in New Issue
Block a user