mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 13:33:57 +00:00
fix fully refund bug
This commit is contained in:
@@ -100,6 +100,10 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
$billNumber = $this->generatesTransactionBillNumber->execute('RFD-');
|
||||
|
||||
$refund = $transaction->transactions()->refunds()->whereIn('status', [ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED])->sum('original_amount');
|
||||
$isFullyRefund = round($refund + $request->input('amount'), 2) == round((float) $transaction->original_amount, 2);
|
||||
if ($isFullyRefund) {
|
||||
$request->merge(['amount' => $transaction->original_amount]);
|
||||
}
|
||||
|
||||
$refundInPending = $transaction->transactions()->refunds()->where('status', ApprovalStatus::PENDING_VERIFICATION)->sum('original_amount');
|
||||
|
||||
@@ -120,10 +124,6 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
|
||||
$bookingAmountAfterRefunded = $booking->fix_amount - $refundInPending - $request->input('amount');
|
||||
|
||||
$refundAmount = round($refund + $request->input('amount'), 2);
|
||||
$originalAmount = round((float) $transaction->original_amount, 2);
|
||||
$isFullyRefund = $refundAmount == $originalAmount;
|
||||
|
||||
$voucherCode = null;
|
||||
$redemptionId = null;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Classes\Exceptions\MalformedRequestException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class UpdateBookingAmountLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -82,7 +83,9 @@ class UpdateBookingAmountLogic extends AbstractControllerLogic
|
||||
$minimum_amount = $booking->fix_amount - $this->calculatesBookingOutstanding->execute($booking);
|
||||
|
||||
if (((float)$input_amount + 0.01) < (float)$minimum_amount) {
|
||||
throw new MalformedRequestException('Booking Amount cannot be less than '. $minimum_amount .'.');
|
||||
$input_amount = 0;
|
||||
// throw new MalformedRequestException('Booking Amount cannot be less than '. $minimum_amount .'.');
|
||||
Log::warning('Booking ID: '. $booking->id .'. Booking Marking: '. $booking->marking .'. Booking Amount cannot be less than '. $minimum_amount .'.');
|
||||
}
|
||||
|
||||
$poTransaction = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first();
|
||||
|
||||
Reference in New Issue
Block a user