feat: group stats credit card by status

This commit is contained in:
Methapon2001 2025-02-19 16:20:37 +07:00
parent 8d27fdfae0
commit fe3096db69

View file

@ -100,7 +100,16 @@ export class CreditNoteController extends Controller {
},
},
} satisfies Prisma.CreditNoteWhereInput;
return await prisma.creditNote.count({ where });
const result = await prisma.creditNote.groupBy({
_count: true,
by: "creditNoteStatus",
where,
});
return result.reduce<Record<string, number>>((a, c) => {
a[c.creditNoteStatus] = c._count;
return a;
}, {});
}
@Get()