From 62cddde1b30fd8354e2b71ccb152fc9fcfa8c2b3 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Fri, 26 Sep 2025 14:28:45 +0800 Subject: [PATCH 1/2] E-Invoice - Partial Code revert for 'E-Invoice - Updated business logic for refund / return (credit note) without updating booking amount' --- .../UpdateBookingAmountWithPOLogic.php | 12 ++++++++++++ .../UpdateRefundTransactionStatusLogic.php | 8 +++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountWithPOLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountWithPOLogic.php index 73265a74..6d0b60bc 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountWithPOLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountWithPOLogic.php @@ -75,6 +75,9 @@ class UpdateBookingAmountWithPOLogic extends AbstractControllerLogic $booking = $this->fetchesBooking->execute(['id' => $request->route('id') ?? $id]); $outstandingAmount = $this->calculatesBookingOutstanding->execute($booking); $bookingAttribute = $booking->attributesKVP()->where('key', "BOOKING_AMOUNT_UPDATE")->first(); + + + /* cief todo: 90 - BEFORE REVERT $refundAmount = $this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id); $paidAmount = floatval($this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id)) - floatval($refundAmount); @@ -83,6 +86,15 @@ class UpdateBookingAmountWithPOLogic extends AbstractControllerLogic throw new MalformedRequestException('Purchase Order at this point can only be edited after editing the booking amount'); } } + */ + + // cief todo: 90 - REVERTED STARTS + $paidAmount = floatval($this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id)) - floatval($this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id)); + + if($paidAmount > 0 && $outstandingAmount > 0 && !$bookingAttribute){ + throw new MalformedRequestException('Purchase Order at this point can only be edited after editing the booking amount'); + } + // cief todo: 90 - REVERTED ENDS if($bookingAttribute){ $total = collect($request->input('products'))->sum(function($product){ diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php index 4a8fe3ae..63de0018 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php @@ -125,9 +125,11 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic $this->updatesTransactionStatus->execute($po_transaction, (float) number_format($po_transaction->amount, 2, '.', '') === (float) number_format((float)$booking->fix_amount - $refundTransaction->original_amount, 2, '.', '') ? ApprovalStatus::PENDING_VERIFICATION : ApprovalStatus::PENDING_SUBMISSION); } - // $request['fix_amount'] = $booking->fix_amount - $refundTransaction->original_amount; - // $request->route()->setParameter('id', $booking->id); - // $this->updateBookingAmountLogic->execute($request); + // cief todo: 90 - REVERTED STARTS (commented before revert) + $request['fix_amount'] = $booking->fix_amount - $refundTransaction->original_amount; + $request->route()->setParameter('id', $booking->id); + $this->updateBookingAmountLogic->execute($request); + // cief todo: 90 - REVERTED ENDS (commented before revert) } if ($supplierRefundTransaction) { From 4cbdfa6e4bb744d58c7c6a989a1f9f2ae479bbe8 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Mon, 29 Sep 2025 20:19:35 +0800 Subject: [PATCH 2/2] E-Invoice - Updated business logic for refund / return (credit note) without updating booking amount (PM feedback) --- .../UpdateBookingAmountWithPOLogic.php | 12 ++++++------ .../UpdateRefundTransactionStatusLogic.php | 6 +++--- .../forms/BookingPaymentQuotationV2Component.vue | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountWithPOLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountWithPOLogic.php index 6d0b60bc..4def81f7 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountWithPOLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/UpdateBookingAmountWithPOLogic.php @@ -77,7 +77,7 @@ class UpdateBookingAmountWithPOLogic extends AbstractControllerLogic $bookingAttribute = $booking->attributesKVP()->where('key', "BOOKING_AMOUNT_UPDATE")->first(); - /* cief todo: 90 - BEFORE REVERT + // cief todo: 90 - BEFORE REVERT $refundAmount = $this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id); $paidAmount = floatval($this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id)) - floatval($refundAmount); @@ -86,14 +86,14 @@ class UpdateBookingAmountWithPOLogic extends AbstractControllerLogic throw new MalformedRequestException('Purchase Order at this point can only be edited after editing the booking amount'); } } - */ + // // cief todo: 90 - REVERTED STARTS - $paidAmount = floatval($this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id)) - floatval($this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id)); + // $paidAmount = floatval($this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id)) - floatval($this->calculatesBookingRefundAmount->execute($booking, $booking->fix_currency_id)); - if($paidAmount > 0 && $outstandingAmount > 0 && !$bookingAttribute){ - throw new MalformedRequestException('Purchase Order at this point can only be edited after editing the booking amount'); - } + // if($paidAmount > 0 && $outstandingAmount > 0 && !$bookingAttribute){ + // throw new MalformedRequestException('Purchase Order at this point can only be edited after editing the booking amount'); + // } // cief todo: 90 - REVERTED ENDS if($bookingAttribute){ diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php index 63de0018..0a29023d 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php @@ -126,9 +126,9 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic } // cief todo: 90 - REVERTED STARTS (commented before revert) - $request['fix_amount'] = $booking->fix_amount - $refundTransaction->original_amount; - $request->route()->setParameter('id', $booking->id); - $this->updateBookingAmountLogic->execute($request); + // $request['fix_amount'] = $booking->fix_amount - $refundTransaction->original_amount; + // $request->route()->setParameter('id', $booking->id); + // $this->updateBookingAmountLogic->execute($request); // cief todo: 90 - REVERTED ENDS (commented before revert) } diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationV2Component.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationV2Component.vue index ad07a927..7dd9adc0 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationV2Component.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationV2Component.vue @@ -132,7 +132,7 @@
{{this.data.fixed_currency.short_code}} {{(Math.round((this.data.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}}
-
+