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:
@@ -170,7 +170,10 @@ export class PosService {
|
||||
|
||||
const newCode = String(Number(lastCode) + 1)
|
||||
|
||||
const totalAmount = data.items.reduce((acc, item) => acc + item.count * item.fee, 0)
|
||||
const totalAmount = data.items.reduce(
|
||||
(acc, item) => acc + item.count * item.unitPrice,
|
||||
0,
|
||||
)
|
||||
|
||||
const preparedOrder: SalesInvoiceCreateInput = {
|
||||
...res,
|
||||
@@ -182,8 +185,8 @@ export class PosService {
|
||||
create: items.map(item => ({
|
||||
product: { connect: { id: Number(item.productId) } },
|
||||
count: item.count,
|
||||
fee: item.fee,
|
||||
total: item.count * item.fee,
|
||||
unitPrice: item.unitPrice,
|
||||
total: item.count * item.unitPrice,
|
||||
})),
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user