feat(statistics): implement top alert stocks, top last sales, top supplier debts, and top selling products endpoints with SQL queries

This commit is contained in:
2026-01-04 13:45:26 +03:30
parent eb6e0e7a0d
commit a2db2daa70
72 changed files with 11934 additions and 2559 deletions
+17 -1
View File
@@ -2,7 +2,7 @@ model StockMovement {
id Int @id @default(autoincrement())
type MovementType
quantity Decimal @db.Decimal(10, 0)
fee Decimal @db.Decimal(15, 2)
unitPrice Decimal @db.Decimal(15, 2)
totalCost Decimal @db.Decimal(15, 2)
referenceType MovementReferenceType
referenceId String
@@ -59,3 +59,19 @@ model StockAdjustment {
@@index([productId], map: "Stock_Adjustments_productId_fkey")
@@map("Stock_Adjustments")
}
model StockReservation {
id Int @id @default(autoincrement())
quantity Decimal @db.Decimal(10, 0)
expiresAt DateTime @db.Timestamp(0)
createdAt DateTime @default(now()) @db.Timestamp(0)
productId Int
inventoryId Int
orderId Int
inventory Inventory @relation(fields: [inventoryId], references: [id])
product Product @relation(fields: [productId], references: [id])
@@index([inventoryId])
@@index([productId])
@@map("Stock_Reservations")
}