mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
-open refund function for all admin (ignore whether the booking has invoice or not)
-when refund is before the whiteform, auto approve the transaction
This commit is contained in:
@@ -14,6 +14,7 @@ use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\CreatesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Bookings\Services\FetchesBookingQuotation;
|
||||
use App\Classes\Modules\Transactions\ControllersLogic\UpdateRefundTransactionStatusLogic;
|
||||
use App\Classes\Modules\Transactions\Services\UpdatesTransactionStatus;
|
||||
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionObject;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
@@ -48,6 +49,9 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
/** @var CreatesTransaction */
|
||||
private $createsTransaction;
|
||||
|
||||
/** @var UpdateRefundTransactionStatusLogic */
|
||||
private $updateRefundTransactionStatusLogic;
|
||||
|
||||
/**
|
||||
* CreateBookingPaymentLogic constructor.
|
||||
* @param FetchesBookingQuotation $fetchBookingQuotation
|
||||
@@ -55,14 +59,16 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
* @param UpdatesTransactionStatus $updatesTransactionStatus
|
||||
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
|
||||
* @param CreatesTransaction $createsTransaction
|
||||
* @param UpdateRefundTransactionStatusLogic $updateRefundTransactionStatusLogic
|
||||
*/
|
||||
public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction)
|
||||
public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, UpdateRefundTransactionStatusLogic $updateRefundTransactionStatusLogic)
|
||||
{
|
||||
$this->fetchBookingQuotation = $fetchBookingQuotation;
|
||||
$this->fetchesTransaction = $fetchesTransaction;
|
||||
$this->updatesTransactionStatus = $updatesTransactionStatus;
|
||||
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
|
||||
$this->createsTransaction = $createsTransaction;
|
||||
$this->updateRefundTransactionStatusLogic = $updateRefundTransactionStatusLogic;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,7 +85,7 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
|
||||
$invoice = $booking->transactions()->where('type', TransactionType::INVOICE)->whereIn('status', [ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->first();
|
||||
|
||||
if(auth()->user()->type === 3 || ($invoice && !(auth()->user()->type === 0 || auth()->user()->type === 1))) {
|
||||
if(auth()->user()->type === 3) {
|
||||
throw new MalformedRequestException('You do not have the permission to refund the order.');
|
||||
}
|
||||
|
||||
@@ -119,6 +125,11 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
|
||||
0, 0, null, ApprovalStatus::PENDING_VERIFICATION, [], $transaction->bill_no);
|
||||
|
||||
$transaction = $this->createsTransaction->execute($transaction, $object);
|
||||
} else {
|
||||
$request->route()->setParameter('id', $refund_transaction->id);
|
||||
$request->route()->setParameter('status', ApprovalStatus::APPROVED);
|
||||
$this->updateRefundTransactionStatusLogic->execute($request);
|
||||
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new TransactionResource($refund_transaction));
|
||||
|
||||
+2
-2
@@ -86,8 +86,8 @@ class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
if (!(Auth::user()->type === 0 || Auth::user()->type === 1)) {
|
||||
throw new MalformedRequestException('Only super admin can update refund status.');
|
||||
if(auth()->user()->type === 3) {
|
||||
throw new MalformedRequestException('You do not have the permission to refund the order.');
|
||||
}
|
||||
|
||||
$refundTransaction = $this->fetchesTransaction->execute(['id' => $request->route('id')]);
|
||||
|
||||
@@ -290,7 +290,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-t-10" v-show="!hasRefundInProgress && [2, 3].includes(item.status) && (totalRequestedRefund + totalRefunds) < data.original_amount">
|
||||
<div class="col" v-if="$store.getters.isSuperAdmin || ($store.getters.isAdmin && !data.booking.documents.invoice)">
|
||||
<div class="col" v-if="$store.getters.isAdmin">
|
||||
<button class="btn btn-xs all-caps b-rad-none bg-master-lighter btn-block no-border requestModal" data-type="transferSummary">Request Refund</button>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="transferSummary" size="large">
|
||||
<refund-confirmation-component :data="data" :section="section" :totalRefunds="totalRequestedRefund + totalRefunds"></refund-confirmation-component>
|
||||
|
||||
Reference in New Issue
Block a user