feat: group stats credit card by status
This commit is contained in:
parent
8d27fdfae0
commit
fe3096db69
1 changed files with 10 additions and 1 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue