feat: include parent transaction details in booking order retrieval
parent
d8fa72ba20
commit
f0e8fbddc9
|
@ -131,11 +131,17 @@ export class BookingOrderController {
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
async get(@Param('id') transactionId: string) {
|
async get(@Param('id') transactionId: string) {
|
||||||
const data = await this.serviceData.getOneByOptions({
|
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 },
|
where: { id: transactionId },
|
||||||
});
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
parent_id,
|
||||||
customer_name,
|
customer_name,
|
||||||
customer_phone,
|
customer_phone,
|
||||||
booking_date,
|
booking_date,
|
||||||
|
@ -143,6 +149,7 @@ export class BookingOrderController {
|
||||||
status,
|
status,
|
||||||
id,
|
id,
|
||||||
items,
|
items,
|
||||||
|
parent_transaction,
|
||||||
} = data;
|
} = data;
|
||||||
|
|
||||||
let timeGroup = null;
|
let timeGroup = null;
|
||||||
|
@ -195,6 +202,20 @@ export class BookingOrderController {
|
||||||
maskedCustomerPhone = '*'.repeat(customer_phone.length - 4) + last4;
|
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 {
|
return {
|
||||||
customer_name,
|
customer_name,
|
||||||
customer_phone: maskedCustomerPhone,
|
customer_phone: maskedCustomerPhone,
|
||||||
|
@ -202,8 +223,10 @@ export class BookingOrderController {
|
||||||
invoice_code,
|
invoice_code,
|
||||||
status,
|
status,
|
||||||
id,
|
id,
|
||||||
|
is_reschedule: !!parent_id,
|
||||||
items: usageItems,
|
items: usageItems,
|
||||||
time_group: timeGroup,
|
time_group: timeGroup,
|
||||||
|
parent: parentTransaction,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue