feat: export report csv endpoint
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 6s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 6s
This commit is contained in:
parent
90246bb3a8
commit
35fe9c69d1
3 changed files with 59 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ import { RequestWithUser } from "../interfaces/user";
|
|||
import { PaymentStatus } from "../generated/kysely/types";
|
||||
import { precisionRound } from "../utils/arithmetic";
|
||||
import dayjs from "dayjs";
|
||||
import { json2csv } from "json-2-csv";
|
||||
|
||||
const permissionCondCompany = createPermCondition((_) => true);
|
||||
|
||||
|
|
@ -23,6 +24,17 @@ const VAT_DEFAULT = config.vat;
|
|||
@Security("keycloak")
|
||||
@Tags("Report")
|
||||
export class StatsController extends Controller {
|
||||
@Get("quotation/download")
|
||||
async downloadQuotationReport(
|
||||
@Request() req: RequestWithUser,
|
||||
@Query() limit?: number,
|
||||
@Query() startDate?: Date,
|
||||
@Query() endDate?: Date,
|
||||
) {
|
||||
this.setHeader("Content-Type", "text/csv");
|
||||
return json2csv(await this.quotationReport(req, limit, startDate, endDate));
|
||||
}
|
||||
|
||||
@Get("quotation")
|
||||
async quotationReport(
|
||||
@Request() req: RequestWithUser,
|
||||
|
|
@ -54,6 +66,17 @@ export class StatsController extends Controller {
|
|||
}));
|
||||
}
|
||||
|
||||
@Get("invoice/download")
|
||||
async downloadInvoiceReport(
|
||||
@Request() req: RequestWithUser,
|
||||
@Query() limit?: number,
|
||||
@Query() startDate?: Date,
|
||||
@Query() endDate?: Date,
|
||||
) {
|
||||
this.setHeader("Content-Type", "text/csv");
|
||||
return json2csv(await this.invoiceReport(req, limit, startDate, endDate));
|
||||
}
|
||||
|
||||
@Get("invoice")
|
||||
async invoiceReport(
|
||||
@Request() req: RequestWithUser,
|
||||
|
|
@ -92,6 +115,17 @@ export class StatsController extends Controller {
|
|||
}));
|
||||
}
|
||||
|
||||
@Get("receipt/download")
|
||||
async downloadReceiptReport(
|
||||
@Request() req: RequestWithUser,
|
||||
@Query() limit?: number,
|
||||
@Query() startDate?: Date,
|
||||
@Query() endDate?: Date,
|
||||
) {
|
||||
this.setHeader("Content-Type", "text/csv");
|
||||
return json2csv(await this.receiptReport(req, limit, startDate, endDate));
|
||||
}
|
||||
|
||||
@Get("receipt")
|
||||
async receiptReport(
|
||||
@Request() req: RequestWithUser,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue