diff --git a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php index 771113c5..d2b921d1 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/UpdateRefundTransactionStatusLogic.php @@ -100,7 +100,7 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic $booking = $paymentTransaction->owner; - $reference = $refundTransaction->amount - $paymentTransaction->amount < 0.01 ? 'Fully Refund for Ref. ' . $booking->marking : 'Partially Refund for Ref. ' . $booking->marking; + $reference = $paymentTransaction->amount - $refundTransaction->amount < 0.01 ? 'Fully Refund for Ref. ' . $booking->marking : 'Partially Refund for Ref. ' . $booking->marking; $refundAmount = $this->calculatesBookingRefundAmount->calculateRefundAmount($paymentTransaction, $booking->fix_currency_id); diff --git a/app/Console/Commands/UpdateWrongFullyRefundPaymentReference.php b/app/Console/Commands/UpdateWrongFullyRefundPaymentReference.php new file mode 100644 index 00000000..20ba3360 --- /dev/null +++ b/app/Console/Commands/UpdateWrongFullyRefundPaymentReference.php @@ -0,0 +1,69 @@ +whereDate('created_at', '>=', Carbon::createFromDate(2024, 4, 2))->get(); + + foreach ($transactions as $transaction) { + $booking_marking = trim(explode('.', $transaction->payment_reference)[1]); + $booking = Booking::where('marking', $booking_marking)->first(); + + if ($booking) { + $payments = $booking->transactions()->payments()->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED, ApprovalStatus::REFUNDED])->get(); + + if ($payments->count() === 0) { + $this->info("Booking ID: {$booking->id}, payment not found"); + } else if ($payments->count() > 1) { + $this->info("Booking ID: {$booking->id}, more than 1 payment found"); + } else { + $payment = $payments->first(); + + if (!($payment->amount - $transaction->amount < 0.01)) { + $transaction->payment_reference = str_replace('Fully', 'Partially', $transaction->payment_reference); + $transaction->save(); + $this->info("Updated Payment Reference of Transaction ID: {$transaction->id}, corrected from Fully Refund to Partially Refund"); + } + } + } + } + } +}