mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-23 22:44:03 +00:00
update purchase order amount and status upon refund approval
This commit is contained in:
+9
-2
@@ -15,7 +15,7 @@ use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Wallets\Processors\CreditWalletProcessor;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingPayableAmount;
|
||||
use App\Classes\Modules\Bookings\Services\CalculatesBookingRefundAmount;
|
||||
|
||||
use App\Classes\ValueObjects\Constants\TransactionType;
|
||||
|
||||
class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
{
|
||||
@@ -91,15 +91,22 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
|
||||
$reference = $refundTransaction->amount == $paymentTransaction->amount ? 'Fully Refund for Ref. ' . $booking->marking : 'Partially Refund for Ref. ' . $booking->marking;
|
||||
|
||||
$refundAmount = $this->calculatesBookingRefundAmount->calculateRefundAmount($paymentTransaction, $booking->fix_currency_id);
|
||||
|
||||
if ($refundTransaction->status == ApprovalStatus::APPROVED) {
|
||||
$this->creditWalletProcessor->execute($booking->company, $refundTransaction->type, $refundTransaction->amount, $reference);
|
||||
$po_transaction = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first();
|
||||
|
||||
if ($po_transaction) {
|
||||
$this->updatesTransactionStatus->execute($po_transaction, (float) number_format($po_transaction->amount, 2, '.', '') === (float) number_format((float)$booking->fix_amount - $refundAmount, 2, '.', '') ? ApprovalStatus::PENDING_VERIFICATION : ApprovalStatus::PENDING_SUBMISSION);
|
||||
}
|
||||
}
|
||||
|
||||
if ($supplierRefundTransaction) {
|
||||
$this->updatesTransactionStatus->execute($supplierRefundTransaction, $request->route('status'));
|
||||
}
|
||||
|
||||
$paidAmount = $paymentTransaction->original_amount - $this->calculatesBookingRefundAmount->calculateRefundAmount($paymentTransaction, $booking->fix_currency_id);
|
||||
$paidAmount = $paymentTransaction->original_amount - $refundAmount;
|
||||
if (!$paidAmount > 0) {
|
||||
$this->updatesTransactionStatus->execute($paymentTransaction, ApprovalStatus::REFUNDED);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user