fix: error field ambigous
This commit is contained in:
parent
2c790de606
commit
6598cd3bdf
3 changed files with 53 additions and 45 deletions
|
|
@ -618,9 +618,22 @@ export class StatsController extends Controller {
|
|||
startDate = dayjs(startDate).startOf("month").add(1, "month").toDate();
|
||||
}
|
||||
|
||||
const invoices = await tx.invoice.findMany({
|
||||
select: { id: true },
|
||||
where: {
|
||||
quotation: {
|
||||
quotationStatus: { notIn: [QuotationStatus.Canceled] },
|
||||
registeredBranch: { OR: permissionCondCompany(req.user) },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (invoices.length === 0) return [];
|
||||
|
||||
return await Promise.all(
|
||||
months.map(async (v) => {
|
||||
const date = dayjs(v);
|
||||
|
||||
return {
|
||||
month: date.format("MM"),
|
||||
year: date.format("YYYY"),
|
||||
|
|
@ -629,12 +642,7 @@ export class StatsController extends Controller {
|
|||
_sum: { amount: true },
|
||||
where: {
|
||||
createdAt: { gte: v, lte: date.endOf("month").toDate() },
|
||||
invoice: {
|
||||
quotation: {
|
||||
quotationStatus: { notIn: [QuotationStatus.Canceled] },
|
||||
registeredBranch: { OR: permissionCondCompany(req.user) },
|
||||
},
|
||||
},
|
||||
invoiceId: { in: invoices.map((v) => v.id) },
|
||||
},
|
||||
by: "paymentStatus",
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue