fix fully refund oustanding

This commit is contained in:
Jia Sheng
2024-08-12 21:25:48 +08:00
parent 08e56acc24
commit 03472dc6be
@@ -108,6 +108,10 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
// $transactionRefundCalculationObject = new TransactionRefundCalculationObject($booking, $transaction, $request->input('amount'));
// $transactionRefundCalculationObject->init();
if ((float)$request->input('amount') === (float)$transaction->original_amount) {
$refundAmount = $transaction->original_amount / $transaction->currency_rate;
$service_charges_to_refund = $transaction->service_charge;
} else {
$refundAmount = bcdiv($request->input('amount'), $transaction->currency_rate, 7);
$bookingAmountBeforeCurrentRefund = $booking->fix_amount - $refundInPending;
@@ -131,6 +135,7 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
$quotationAfterRefund = $this->fetchBookingQuotation->execute($booking->company, $conversionObjectAfterRefund, $voucherCode);
$service_charges_to_refund = $isFullyRefund ? $quotationBeforeCurrentRefund->getServiceCharge() : $quotationBeforeCurrentRefund->getServiceCharge() - $quotationAfterRefund->getServiceCharge();
}
// refund service charges if booking is not E2E
$refundTotal = $refundAmount;