Files
psp_api/prisma/schema/stock.prisma
T
ahasani eb6e0e7a0d 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
2025-12-30 21:04:01 +03:30

62 lines
2.9 KiB
Plaintext

model StockMovement {
id Int @id @default(autoincrement())
type MovementType
quantity Decimal @db.Decimal(10, 0)
fee Decimal @db.Decimal(15, 2)
totalCost Decimal @db.Decimal(15, 2)
referenceType MovementReferenceType
referenceId String
createdAt DateTime @default(now()) @db.Timestamp(0)
productId Int
inventoryId Int
avgCost Decimal @db.Decimal(15, 2)
supplierId Int?
remainedInStock Decimal @default(0.00) @db.Decimal(10, 0)
counterInventoryId Int?
customerId Int?
counterInventory Inventory? @relation("StockMovement_CounterInventory", fields: [counterInventoryId], 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])
@@index([inventoryId], map: "Stock_Movements_inventoryId_fkey")
@@index([productId], map: "Stock_Movements_productId_fkey")
@@index([counterInventoryId], map: "Stock_Movements_counterInventoryId_fkey")
@@index([customerId], map: "Stock_Movements_customerId_fkey")
@@index([supplierId], map: "Stock_Movements_supplierId_fkey")
@@map("Stock_Movements")
}
model StockBalance {
quantity Decimal @default(0.000) @db.Decimal(14, 3)
totalCost Decimal @default(0.00) @db.Decimal(14, 2)
updatedAt DateTime @updatedAt @db.Timestamp(0)
avgCost Decimal @default(0.00) @db.Decimal(14, 2)
inventoryId Int
productId Int
createdAt DateTime @default(now()) @db.Timestamp(0)
id Int @id @default(autoincrement())
inventory Inventory @relation("StockBalance_inventory", fields: [inventoryId], references: [id])
product Product @relation("StockBalance_Product", fields: [productId], references: [id])
@@unique([productId, inventoryId])
@@index([productId])
@@index([inventoryId])
@@map("Stock_Balance")
}
model StockAdjustment {
id Int @id @default(autoincrement())
adjustedQuantity Decimal @db.Decimal(10, 0)
createdAt DateTime @default(now()) @db.Timestamp(0)
productId Int
inventoryId Int
inventory Inventory @relation("Inventory_Stock_Adjustments", fields: [inventoryId], references: [id])
product Product @relation("Product_Stock_Adjustments", fields: [productId], references: [id])
@@index([inventoryId], map: "Stock_Adjustments_inventoryId_fkey")
@@index([productId], map: "Stock_Adjustments_productId_fkey")
@@map("Stock_Adjustments")
}