feat: add customer data to report
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 9s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 9s
This commit is contained in:
parent
26c671b032
commit
fbd423f84d
1 changed files with 68 additions and 9 deletions
|
|
@ -32,9 +32,19 @@ export class StatsController extends Controller {
|
||||||
@Query() endDate?: Date,
|
@Query() endDate?: Date,
|
||||||
) {
|
) {
|
||||||
this.setHeader("Content-Type", "text/csv");
|
this.setHeader("Content-Type", "text/csv");
|
||||||
return json2csv(await this.quotationReport(req, limit, startDate, endDate), {
|
return json2csv(
|
||||||
useDateIso8601Format: true,
|
await this.quotationReport(req, limit, startDate, endDate).then((v) =>
|
||||||
});
|
v.map((v) => ({
|
||||||
|
...v,
|
||||||
|
customerBranch: {
|
||||||
|
...v.customerBranch,
|
||||||
|
customerType: v.customerBranch.customer.customerType,
|
||||||
|
customer: undefined,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
{ useDateIso8601Format: true },
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("quotation")
|
@Get("quotation")
|
||||||
|
|
@ -48,6 +58,10 @@ export class StatsController extends Controller {
|
||||||
select: {
|
select: {
|
||||||
code: true,
|
code: true,
|
||||||
quotationStatus: true,
|
quotationStatus: true,
|
||||||
|
customerBranch: {
|
||||||
|
select: { customer: true },
|
||||||
|
},
|
||||||
|
finalPrice: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
updatedAt: true,
|
updatedAt: true,
|
||||||
},
|
},
|
||||||
|
|
@ -63,8 +77,11 @@ export class StatsController extends Controller {
|
||||||
document: "quotation",
|
document: "quotation",
|
||||||
code: v.code,
|
code: v.code,
|
||||||
status: v.quotationStatus,
|
status: v.quotationStatus,
|
||||||
|
amount: v.finalPrice,
|
||||||
createdAt: v.createdAt,
|
createdAt: v.createdAt,
|
||||||
updatedAt: v.updatedAt,
|
updatedAt: v.updatedAt,
|
||||||
|
|
||||||
|
customerBranch: v.customerBranch,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,9 +93,21 @@ export class StatsController extends Controller {
|
||||||
@Query() endDate?: Date,
|
@Query() endDate?: Date,
|
||||||
) {
|
) {
|
||||||
this.setHeader("Content-Type", "text/csv");
|
this.setHeader("Content-Type", "text/csv");
|
||||||
return json2csv(await this.invoiceReport(req, limit, startDate, endDate), {
|
return json2csv(
|
||||||
useDateIso8601Format: true,
|
await this.invoiceReport(req, limit, startDate, endDate).then((v) =>
|
||||||
});
|
v.map((v) => ({
|
||||||
|
...v,
|
||||||
|
customerBranch: {
|
||||||
|
...v.customerBranch,
|
||||||
|
customerType: v.customerBranch.customer.customerType,
|
||||||
|
customer: undefined,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
{
|
||||||
|
useDateIso8601Format: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("invoice")
|
@Get("invoice")
|
||||||
|
|
@ -91,6 +120,11 @@ export class StatsController extends Controller {
|
||||||
const record = await prisma.invoice.findMany({
|
const record = await prisma.invoice.findMany({
|
||||||
select: {
|
select: {
|
||||||
code: true,
|
code: true,
|
||||||
|
quotation: {
|
||||||
|
select: {
|
||||||
|
customerBranch: { select: { customer: true } },
|
||||||
|
},
|
||||||
|
},
|
||||||
payment: {
|
payment: {
|
||||||
select: {
|
select: {
|
||||||
paymentStatus: true,
|
paymentStatus: true,
|
||||||
|
|
@ -116,6 +150,8 @@ export class StatsController extends Controller {
|
||||||
status: v.payment?.paymentStatus,
|
status: v.payment?.paymentStatus,
|
||||||
amount: v.amount,
|
amount: v.amount,
|
||||||
createdAt: v.createdAt,
|
createdAt: v.createdAt,
|
||||||
|
|
||||||
|
customerBranch: v.quotation.customerBranch,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -127,9 +163,21 @@ export class StatsController extends Controller {
|
||||||
@Query() endDate?: Date,
|
@Query() endDate?: Date,
|
||||||
) {
|
) {
|
||||||
this.setHeader("Content-Type", "text/csv");
|
this.setHeader("Content-Type", "text/csv");
|
||||||
return json2csv(await this.receiptReport(req, limit, startDate, endDate), {
|
return json2csv(
|
||||||
useDateIso8601Format: true,
|
await this.receiptReport(req, limit, startDate, endDate).then((v) =>
|
||||||
});
|
v.map((v) => ({
|
||||||
|
...v,
|
||||||
|
customerBranch: {
|
||||||
|
...v.customerBranch,
|
||||||
|
customerType: v.customerBranch.customer.customerType,
|
||||||
|
customer: undefined,
|
||||||
|
},
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
{
|
||||||
|
useDateIso8601Format: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get("receipt")
|
@Get("receipt")
|
||||||
|
|
@ -142,6 +190,14 @@ export class StatsController extends Controller {
|
||||||
const record = await prisma.payment.findMany({
|
const record = await prisma.payment.findMany({
|
||||||
select: {
|
select: {
|
||||||
code: true,
|
code: true,
|
||||||
|
invoice: {
|
||||||
|
select: {
|
||||||
|
quotation: {
|
||||||
|
select: { customerBranch: { select: { customer: true } } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
amount: true,
|
||||||
paymentStatus: true,
|
paymentStatus: true,
|
||||||
createdAt: true,
|
createdAt: true,
|
||||||
},
|
},
|
||||||
|
|
@ -162,8 +218,11 @@ export class StatsController extends Controller {
|
||||||
return record.map((v) => ({
|
return record.map((v) => ({
|
||||||
document: "receipt",
|
document: "receipt",
|
||||||
code: v.code,
|
code: v.code,
|
||||||
|
amount: v.amount,
|
||||||
status: v.paymentStatus,
|
status: v.paymentStatus,
|
||||||
createdAt: v.createdAt,
|
createdAt: v.createdAt,
|
||||||
|
|
||||||
|
customerBranch: v.invoice.quotation.customerBranch,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue