fix: make it check for status

This commit is contained in:
Methapon2001 2024-12-20 13:15:30 +07:00
parent abf20e0fb1
commit c399cd26df

View file

@ -20,6 +20,7 @@ import {
createPermCheck,
createPermCondition,
} from "../services/permission";
import { PaymentStatus } from "../generated/kysely/types";
type InvoicePayload = {
quotationId: string;
@ -54,8 +55,18 @@ export class InvoiceController extends Controller {
};
const [pay, notPay] = await prisma.$transaction([
prisma.invoice.count({ where: { ...where, payment: { isNot: null } } }),
prisma.invoice.count({ where: { ...where, payment: null } }),
prisma.invoice.count({
where: {
...where,
payment: { paymentStatus: { not: PaymentStatus.PaymentSuccess } },
},
}),
prisma.invoice.count({
where: {
...where,
payment: { paymentStatus: PaymentStatus.PaymentSuccess },
},
}),
]);
return { pay, notPay };