feat: include parent transaction details in booking order retrieval

pull/157/head
shancheas 2025-06-11 15:46:43 +07:00
parent d8fa72ba20
commit f0e8fbddc9
1 changed files with 24 additions and 1 deletions

View File

@ -131,11 +131,17 @@ export class BookingOrderController {
@Get(':id')
async get(@Param('id') transactionId: string) {
const data = await this.serviceData.getOneByOptions({
relations: ['items', 'items.item', 'items.item.time_group'],
relations: [
'items',
'parent_transaction',
'items.item',
'items.item.time_group',
],
where: { id: transactionId },
});
const {
parent_id,
customer_name,
customer_phone,
booking_date,
@ -143,6 +149,7 @@ export class BookingOrderController {
status,
id,
items,
parent_transaction,
} = data;
let timeGroup = null;
@ -195,6 +202,20 @@ export class BookingOrderController {
maskedCustomerPhone = '*'.repeat(customer_phone.length - 4) + last4;
}
let parentTransaction = undefined;
if (parent_transaction) {
const {
id: parentId,
invoice_code: parentInvoiceCode,
invoice_date: parentInvoiceDate,
} = parent_transaction;
parentTransaction = {
id: parentId,
invoice_code: parentInvoiceCode,
invoice_date: parentInvoiceDate,
};
}
return {
customer_name,
customer_phone: maskedCustomerPhone,
@ -202,8 +223,10 @@ export class BookingOrderController {
invoice_code,
status,
id,
is_reschedule: !!parent_id,
items: usageItems,
time_group: timeGroup,
parent: parentTransaction,
};
}