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
@@ -21,8 +21,8 @@ export class PurchaseReceiptsService {
create: dto.items.map((item, idx) => {
const mapped = {
count: new Prisma.Decimal(item.count ?? 0),
fee: new Prisma.Decimal(item.fee ?? 0),
total: new Prisma.Decimal(item.total ?? 0),
unitPrice: new Prisma.Decimal(item.unitPrice ?? 0),
totalAmount: new Prisma.Decimal(item.totalAmount ?? 0),
description: item.description ?? null,
product: { connect: { id: item.productId } },
}
@@ -34,6 +34,10 @@ export class PurchaseReceiptsService {
const item = await this.prisma.purchaseReceipt.create({
data,
include: { items: true },
omit: {
supplierId: true,
inventoryId: true,
},
})
return ResponseMapper.create(item)
}