diff --git a/app/Classes/Modules/Transactions/Processors/UpdateRefundTransactionStatusProcessor.php b/app/Classes/Modules/Transactions/Processors/UpdateRefundTransactionStatusProcessor.php index 82637da7..d62c962c 100644 --- a/app/Classes/Modules/Transactions/Processors/UpdateRefundTransactionStatusProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/UpdateRefundTransactionStatusProcessor.php @@ -14,8 +14,11 @@ use App\Classes\Modules\Bookings\Services\CalculatesBookingPayableAmount; use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount; use App\Classes\Modules\Transactions\Standards\Rules\CanUpdateRefundTransactionStatus; use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionV2Processor; +use App\Classes\ValueObjects\Constants\KVPKey; use App\Classes\ValueObjects\Constants\RemarkRefundReason; use App\Classes\ValueObjects\Constants\TransactionType; +use App\Models\Transaction; +use ErrorException; use Illuminate\Support\Facades\Log; class UpdateRefundTransactionStatusProcessor @@ -108,6 +111,14 @@ class UpdateRefundTransactionStatusProcessor $paidAmount = $paymentTransaction->original_amount - $refundAmount; + $claimed = Transaction::where('id', $refundTransaction->id) + ->where('process_status', null) + ->update(['process_status' => ApprovalStatus::PENDING_VERIFICATION]); + + if (!$claimed) { + throw new ErrorException("This refund transaction has already been processed"); + } + if ($refundTransaction->status == ApprovalStatus::APPROVED) { $this->creditWalletProcessor->execute($booking->company, $refundTransaction->type, $refundTransaction->amount, $reference, $refundTransaction); @@ -141,5 +152,9 @@ class UpdateRefundTransactionStatusProcessor 'bookingOriginalStatus' => $booking->status ]); } + + Transaction::where('id', $refundTransaction->id) + ->where('process_status', ApprovalStatus::PENDING_VERIFICATION) + ->update(['process_status' => ApprovalStatus::APPROVED]); } } diff --git a/database/migrations/2026_04_19_012052_add_process_status_to_transactions_table.php b/database/migrations/2026_04_19_012052_add_process_status_to_transactions_table.php new file mode 100644 index 00000000..e4ba8a35 --- /dev/null +++ b/database/migrations/2026_04_19_012052_add_process_status_to_transactions_table.php @@ -0,0 +1,36 @@ +unsignedTinyInteger('process_status') + ->nullable() + ->default(null) + ->after('status') + ->index(); + }); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('transactions', function (Blueprint $table) { + Schema::table('transactions', function (Blueprint $table) { + $table->dropColumn('process_status'); + }); + }); + } +}; diff --git a/database/migrations/2026_04_19_015052_add_process_status_to_transaction_logs_table.php b/database/migrations/2026_04_19_015052_add_process_status_to_transaction_logs_table.php new file mode 100644 index 00000000..cfc0df68 --- /dev/null +++ b/database/migrations/2026_04_19_015052_add_process_status_to_transaction_logs_table.php @@ -0,0 +1,36 @@ +unsignedTinyInteger('process_status') + ->nullable() + ->default(null) + ->after('status') + ->index(); + }); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('transaction_logs', function (Blueprint $table) { + Schema::table('transaction_logs', function (Blueprint $table) { + $table->dropColumn('process_status'); + }); + }); + } +}; diff --git a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue index df5fb8e3..0f690114 100644 --- a/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/PaymentHistoryComponent.vue @@ -475,7 +475,7 @@ - +