Laravel Vapor - Fix a front end display inaccurate on user UI when editing recipient bank details

This commit is contained in:
Dillon Ngo
2024-10-28 15:46:11 +08:00
parent e86d3a075f
commit 4784c704c2
2 changed files with 5 additions and 1 deletions
@@ -22,13 +22,16 @@ class TransactionResource extends JsonResource
$booking = null; //cief todo: 66
$bank = null;
//Check if Transaction of type PAYMENT has an override for recipient bank - starts
$isEditedBankRecipient = false;
if(in_array((int)$this->type, [TransactionType::BILL, TransactionType::REFUND, TransactionType::SUPPLIER_REFUND])){
$booking = $this->owner->owner;
$bank = $this->owner->bank ?? $booking->bank;
$isEditedBankRecipient = $this->owner->bank ? true : false;
}
else{
$booking = $this->owner;
$bank = $this->bank ?? $booking->bank;
$isEditedBankRecipient = $this->bank ? true : false;
}
//Check if Transaction of type PAYMENT has an override for recipient bank - ends
$days = $this->created_at->endOfDay()->addWeekdays($booking->service_id === 3 ? 3 : 1);
@@ -66,6 +69,7 @@ class TransactionResource extends JsonResource
'remarks' => RemarkResource::collection($this->remarks),
'redemption' => new VoucherRedemptionResource($this->voucherRedemption),
'bank' => ((int) $this->type === TransactionType::PAYMENT) ? new BankResource($bank) : null, //When a transaction (of type payment) has an override recipient bank details on booking, this is NOT null
'bank_recipient_edited' => $isEditedBankRecipient
];
}
}