mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 04:08:11 +00:00
feat: finish company profile in the backoffice
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
Get,
|
||||
HttpStatus,
|
||||
Param,
|
||||
ParseUUIDPipe,
|
||||
Post,
|
||||
Query,
|
||||
Res,
|
||||
@@ -33,6 +34,14 @@ import {
|
||||
export class PaymentController {
|
||||
constructor(private readonly paymentService: PaymentService) { }
|
||||
|
||||
@Get("by-company/:companyId/customer-view")
|
||||
@ApiOperation({ summary: "List payments for a company (customer-view shape, backoffice)" })
|
||||
findByCompanyCustomerView(
|
||||
@Param("companyId", ParseUUIDPipe) companyId: string,
|
||||
) {
|
||||
return this.paymentService.findByCompanyId(companyId);
|
||||
}
|
||||
|
||||
@Get("summary")
|
||||
@BookingView()
|
||||
@ApiOperation({ summary: "Payment count/amount summary for dashboard cards" })
|
||||
|
||||
@@ -61,4 +61,56 @@ export class PaymentRepository {
|
||||
return this.paymentRepo.createQueryBuilder(alias);
|
||||
}
|
||||
|
||||
async findByCompanyId(companyId: string): Promise<{
|
||||
id: string;
|
||||
merchantOrderId: string;
|
||||
bookingReference: string;
|
||||
amount: number;
|
||||
currency: string;
|
||||
method: string;
|
||||
status: string;
|
||||
paidAt: Date | null;
|
||||
createdAt: Date;
|
||||
}[]> {
|
||||
const rows: {
|
||||
id: string;
|
||||
merchant_order_id: string;
|
||||
booking_reference: string;
|
||||
amount: number;
|
||||
currency: string;
|
||||
method: string;
|
||||
status: string;
|
||||
paid_at: Date | null;
|
||||
created_at: Date;
|
||||
}[] = await this.dataSource.query(
|
||||
`SELECT p.id,
|
||||
p.merchant_order_id,
|
||||
b.reference AS booking_reference,
|
||||
p.amount,
|
||||
p.currency,
|
||||
p.method,
|
||||
p.status,
|
||||
p.paid_at,
|
||||
p.created_at
|
||||
FROM freight.payments p
|
||||
JOIN freight.bookings b ON b.id = p.ref_id
|
||||
WHERE b.company_id = $1
|
||||
AND p.deleted_at IS NULL
|
||||
AND b.deleted_at IS NULL
|
||||
ORDER BY p.created_at DESC`,
|
||||
[companyId],
|
||||
);
|
||||
return rows.map((r) => ({
|
||||
id: r.id,
|
||||
merchantOrderId: r.merchant_order_id,
|
||||
bookingReference: r.booking_reference,
|
||||
amount: Number(r.amount),
|
||||
currency: r.currency,
|
||||
method: r.method,
|
||||
status: r.status,
|
||||
paidAt: r.paid_at,
|
||||
createdAt: r.created_at,
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -428,4 +428,8 @@ export class PaymentService {
|
||||
default: return "action-required";
|
||||
}
|
||||
}
|
||||
|
||||
async findByCompanyId(companyId: string) {
|
||||
return this.paymentRepo.findByCompanyId(companyId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user