Merge branch 'master' of gitlab.com:CIEFWorldwideSdnBhd/exchange-2.0 into refund-booking

This commit is contained in:
edmondlang
2024-05-10 00:17:08 +08:00
15 changed files with 82 additions and 16 deletions
@@ -27,7 +27,7 @@ abstract class AbstractRule
public function passes(?DataTransferObject $object = null): bool {
try {
if(!$this->authorized()){
throw new AccessForbiddenException('You don\'t have permission to preform this action');
throw new AccessForbiddenException('You don\'t have permission to perform this action');
}
$this->validators($object);
@@ -36,7 +36,7 @@ abstract class AbstractRule
return true;
} catch(AccessForbiddenException $exception){
throw new AccessForbiddenException('You don\'t have permission to preform this action');
throw new AccessForbiddenException('You don\'t have permission to perform this action');
} catch(\Exception $exception){
throw new RequestValidationException($exception->getMessage());
}
@@ -0,0 +1,13 @@
<?php
namespace App\Classes\General\Interfaces;
use Illuminate\Database\Eloquent\Relations\MorphMany;
interface Remarkable
{
public function remarks(): morphMany;
}
@@ -14,12 +14,14 @@ 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\Remarks\DataTransferObjects\RemarkObject;
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;
use App\Classes\Modules\Transactions\DataTransferObjects\TransactionRefundCalculationObject;
use App\Classes\ValueObjects\Constants\PaymentMethodType;
use App\Classes\Modules\Remarks\Processors\CreateRemarkProcessor;
class CreateBookingRefundLogic extends AbstractControllerLogic
{
@@ -52,6 +54,9 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
/** @var UpdateRefundTransactionStatusLogic */
private $updateRefundTransactionStatusLogic;
/** @var CreateRemarkProcessor */
private $createRemarkProcessor;
/**
* CreateBookingPaymentLogic constructor.
* @param FetchesBookingQuotation $fetchBookingQuotation
@@ -60,8 +65,9 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
* @param GeneratesTransactionBillNumber $generatesTransactionBillNumber
* @param CreatesTransaction $createsTransaction
* @param UpdateRefundTransactionStatusLogic $updateRefundTransactionStatusLogic
* @param CreateRemarkProcessor $createRemarkProcessor
*/
public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, UpdateRefundTransactionStatusLogic $updateRefundTransactionStatusLogic)
public function __construct(FetchesBookingQuotation $fetchBookingQuotation, FetchesTransaction $fetchesTransaction, UpdatesTransactionStatus $updatesTransactionStatus, GeneratesTransactionBillNumber $generatesTransactionBillNumber, CreatesTransaction $createsTransaction, UpdateRefundTransactionStatusLogic $updateRefundTransactionStatusLogic, CreateRemarkProcessor $createRemarkProcessor)
{
$this->fetchBookingQuotation = $fetchBookingQuotation;
$this->fetchesTransaction = $fetchesTransaction;
@@ -69,6 +75,7 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
$this->generatesTransactionBillNumber = $generatesTransactionBillNumber;
$this->createsTransaction = $createsTransaction;
$this->updateRefundTransactionStatusLogic = $updateRefundTransactionStatusLogic;
$this->createRemarkProcessor = $createRemarkProcessor;
}
/**
@@ -132,6 +139,11 @@ class CreateBookingRefundLogic extends AbstractControllerLogic
}
if($request->input('refundRemark')){
$remarkObject = new RemarkObject($request->input('refundRemark'), Auth()->user()->id);
$this->createRemarkProcessor->execute($this->fetchesTransaction->execute(['id' => $refund_transaction->id]), $remarkObject);
}
return $this->resourceResponse(new TransactionResource($refund_transaction));
}
@@ -26,7 +26,7 @@ class CanCreateRemark extends AbstractRule
/**
* @return bool
*/
protected function authorized($object): bool
protected function authorized(): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanDeleteRemark extends AbstractRule
/**
* @return bool
*/
protected function authorized($object): bool
protected function authorized(): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanFetchRemark extends AbstractRule
/**
* @return bool
*/
protected function authorized($object): bool
protected function authorized(): bool
{
// TODO Set Authorization rules
return true;
@@ -13,7 +13,7 @@ class CanListRemarks extends AbstractRule
/**
* @return bool
*/
protected function authorized($object): bool
protected function authorized(): bool
{
// TODO Set Authorization rules
return true;
@@ -26,7 +26,7 @@ class CanUpdateRemark extends AbstractRule
/**
* @return bool
*/
protected function authorized($object): bool
protected function authorized(): bool
{
// TODO Set Authorization rules
return true;
@@ -53,6 +53,7 @@ class TransactionResource extends JsonResource
'value' => $days->gt(Carbon::now()) ? '+' : '-',
'duration' => $days->diff(Carbon::now())->format('%d'),
],
'remarks' => RemarkResource::collection($this->remarks),
'redemption' => new VoucherRedemptionResource($this->voucherRedemption)
];
}
+2 -1
View File
@@ -3,6 +3,7 @@
namespace App\Models;
use App\Classes\General\Interfaces\Documentable;
use App\Classes\General\Interfaces\Remarkable;
use App\Classes\General\Interfaces\Transactionable;
use App\Classes\General\Interfaces\Voucherifiable;
use App\Classes\General\Traits\LogData;
@@ -21,7 +22,7 @@ use Staudenmeir\EloquentHasManyDeep\HasTableAlias;
use App\Models\StatementTransactionOwner;
class Transaction extends AbstractModel implements Documentable, Transactionable, Voucherifiable
class Transaction extends AbstractModel implements Documentable, Transactionable, Voucherifiable, Remarkable
{
use HasTableAlias;
use SoftDeletes;
@@ -332,6 +332,14 @@
<div class="font-heading fs-10 bold" :class="[{'text-warning': refund.status === 1}, {'text-success': refund.status === 2}, {'text-danger': refund.status === 4}]">{{ refund.status === 1 ? 'Pending Verification' : refund.status === 2 ? 'Approved' : 'Rejected'}}</div>
</div>
</div>
<div class="col-auto" v-if="$store.getters.isAdmin">
<span class="btn requestModal no-border" size="large" data-type="chatmodal">
<i class="fa fa-comment-o"></i>
</span>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="chatmodal">
<remark-component :section="section" :data="refund" module_type="Transaction"></remark-component>
</modal-component>
</div>
<div class="col text-right">
<div class="font-heading fs-10 muted all-caps">Amount</div>
<div class="font-heading fs-10">
@@ -35,6 +35,14 @@
</div>
</div>
</div>
<div class="row m-t-5 m-b-5">
<div class="col">
<validation-wrapper-component :validator="$v.refundRemark">
<label>Refund Remarks</label>
<input class="form-control" name="amount" v-model="refundRemark" >
</validation-wrapper-component>
</div>
</div>
<div class="row m-t-10 m-b-10">
<div class="col">
<div class="font-heading all-caps fs-10 m-b-5">Paid Amount: {{ paidAmount }}</div>
@@ -71,6 +79,7 @@ export default {
data() {
return {
refundAmount: (Math.round((this.data.original_amount - this.data.refunded_amount + Number.EPSILON) * 100) / 100).toFixed(2),
refundRemark: '',
refundMethod: { name: 'Fully Refund', status: false },
refundMethods: [
{ name: 'Fully Refund', label: 'Full Refund' },
@@ -82,7 +91,8 @@ export default {
return {
refundAmount: {
maxValue: maxValue(this.refundMaxValue)
}
},
refundRemark: {}
}
},
computed: {
@@ -96,6 +106,7 @@ export default {
methods: {
submitForm() {
this.parameters.amount = this.refundAmount;
this.parameters.refundRemark = this.refundRemark;
this.submit(this.route('api.booking.refund.create', this.data.booking.id, this.data.id), 'post', this.section, true, true)
},
updateRefundType(refund) {
@@ -3,17 +3,34 @@
<div class="col">
<loading-component style="height: 300px; top: 0;" key="1" color="success" v-show="isLoading" ></loading-component>
<!-- <div class="row justify-content-center padding-30" v-show="!isLoading"> -->
<div class="row justify-content-center" v-show="!isLoading">
<div class="row justify-content-center flex-column bg-white rounded padding-30" v-show="!isLoading">
<h4 class="m-b-20">Remarks</h4>
<div class="col">
<div class="row" v-for="remark in data.remarks">
<div class="col">
<remark-list-component :section="section" :data="remark"></remark-list-component>
</div>
</div>
<div class="row align-items-center justify-content-center p-t-50 p-b-50" v-if="!data.remarks.length">
<div class="col-10">
<div class="row align-items-center justify-content-center hint-text">
<div class="col-4 hint-text">
<img src="/images/not-found-illustration.png" class="w-100 hint-text" />
</div>
</div>
<div class="row text-center">
<div class="col">
<div class="row m-t-20">
<div class="col">
<p class="all-caps no-margin fs-11" style="letter-spacing: 2px;">Nothing To Show Here Yet!</p>
</div>
</div>
</div>
</div>
</div>
</div>
<remark-comment-form-component :section="section" :module_type="module_type" :id="data.id"></remark-comment-form-component>
</div>
</div>
</div>
</div>
@@ -41,12 +41,12 @@
<div class="row">
<div class="col">
<p v-if="!isEdit">{{item.content}}</p>
<container-comment-form-component :section="section" :data="item" :id="item.owner_id" v-on:submit="isEdit=false" v-if="isEdit"></container-comment-form-component>
<remark-comment-form-component :section="section" :data="item" :id="item.owner_id" v-on:submit="isEdit=false" v-if="isEdit" module_type="Transaction"></remark-comment-form-component>
</div>
</div>
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="deleteComment">
<delete-container-comment-form-component :section="section" :data="item"></delete-container-comment-form-component>
<delete-remark-form-component :section="section" :data="item"></delete-remark-form-component>
</modal-component>
</div>
</div>
@@ -1,5 +1,5 @@
<template>
<div class="row m-t-5">
<div class="row m-t-5" @keyup.enter="submitForm">
<div class="col">
<validation-wrapper-component :validator="$v.parameters.content">
<input type="text" class="form-control fs-12" placeholder="Write your comments..." v-model.trim="parameters.content">
@@ -48,6 +48,9 @@
submitForm() {
this.submit(this.data ? this.route('api.remark.update', this.data.id) : this.route('api.remark.create', this.id), this.data ? 'put' : 'post', this.section, true, true);
this.$emit('submit')
},
successHandler(response){
this.content = '';
}
},
mixins: [modalFormHandler]