Merge branch 'dillon/151-fix-wallet-double-refund' into vapor/development

This commit is contained in:
Dillon Ngo
2026-04-19 03:08:25 +08:00
4 changed files with 88 additions and 1 deletions
@@ -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]);
}
}
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('transactions', function (Blueprint $table) {
Schema::table('transactions', function (Blueprint $table) {
$table->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');
});
});
}
};
@@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('transaction_logs', function (Blueprint $table) {
Schema::table('transaction_logs', function (Blueprint $table) {
$table->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');
});
});
}
};
@@ -475,7 +475,7 @@
<button class="btn btn-xs btn-outline-danger b-rad-none m-r-5 requestModal" data-type="deleteRefund">
<i class="fa fa-times fa-fw"></i>
</button>
<modal-component class="animate__animated animate__fast animate__fadeIn" type="deleteRefund">
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="deleteRefund">
<general-confirmation-form-component
contentText="Are you sure you want to delete this refund?"
modalType="delete"