feat: add invoice stats endpoint
This commit is contained in:
parent
5309581e14
commit
abf20e0fb1
1 changed files with 21 additions and 0 deletions
|
|
@ -40,6 +40,27 @@ const permissionCheck = createPermCheck(globalAllow);
|
||||||
@Route("/api/v1/invoice")
|
@Route("/api/v1/invoice")
|
||||||
@Tags("Invoice")
|
@Tags("Invoice")
|
||||||
export class InvoiceController extends Controller {
|
export class InvoiceController extends Controller {
|
||||||
|
@Get("stats")
|
||||||
|
@OperationId("getInvoiceStats")
|
||||||
|
@Security("keycloak")
|
||||||
|
async getInvoiceStats(@Request() req: RequestWithUser, @Query() quotationId?: string) {
|
||||||
|
const where = {
|
||||||
|
quotationId,
|
||||||
|
quotation: {
|
||||||
|
registeredBranch: {
|
||||||
|
OR: permissionCondCompany(req.user),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const [pay, notPay] = await prisma.$transaction([
|
||||||
|
prisma.invoice.count({ where: { ...where, payment: { isNot: null } } }),
|
||||||
|
prisma.invoice.count({ where: { ...where, payment: null } }),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return { pay, notPay };
|
||||||
|
}
|
||||||
|
|
||||||
@Get()
|
@Get()
|
||||||
@OperationId("getInvoiceList")
|
@OperationId("getInvoiceList")
|
||||||
@Security("keycloak")
|
@Security("keycloak")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue