From 4784c704c2492acfb6f464a8bcb3548ad27869f4 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 28 Oct 2024 15:46:11 +0800 Subject: [PATCH] Laravel Vapor - Fix a front end display inaccurate on user UI when editing recipient bank details --- app/Http/Resources/TransactionResource.php | 4 ++++ .../bookings/forms/BookingPaymentQuotationComponent.vue | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Resources/TransactionResource.php b/app/Http/Resources/TransactionResource.php index e14c32c0..a7297ac1 100644 --- a/app/Http/Resources/TransactionResource.php +++ b/app/Http/Resources/TransactionResource.php @@ -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 ]; } } diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index 5a03999c..9208852c 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -614,7 +614,7 @@ bookingId: this.data.id }, isEditRecipientBankDetailsCollapsed: false, - isAnyPaymentRecipientBankEdited: this.data.payment_history.some(payment => payment.bank !== null), + isAnyPaymentRecipientBankEdited: this.data.payment_history.some(payment => payment.bank_recipient_edited !== null && payment.bank_recipient_edited), } }, validations () {