mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-28 17:04:06 +00:00
Merge branch 'dillon/34.8a-enhancement' into vapor/development
This commit is contained in:
@@ -4,16 +4,9 @@
|
||||
namespace App\Classes\Modules\Transactions\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Transactions\Services\FetchesTransaction;
|
||||
use App\Classes\Modules\Transactions\Services\GeneratesTransactionBillNumber;
|
||||
use App\Classes\Modules\Companies\Services\FetchesCompanyModule;
|
||||
use App\Classes\Modules\Transactions\Processors\CreatePaymentTransactionProcessor;
|
||||
use App\Classes\Modules\Groups\Services\CreatesGroup;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Classes\Modules\Wallets\Processors\CreateWalletTopUpTransactionProcessor;
|
||||
use App\Classes\Modules\Transactions\Processors\ReleaseGoodsToCustomerProcessor;
|
||||
use App\Classes\Modules\Transactions\Processors\CheckStorageInvoiceTransactionProcessor;
|
||||
use App\Http\Resources\TransactionVerifyResource;
|
||||
|
||||
|
||||
+48
-3
@@ -63,12 +63,23 @@
|
||||
</div>
|
||||
<div class="row" v-if="selectedInvoice.length">
|
||||
<div class="col">
|
||||
<div v-if="section === 'customerPendingPaymentInvoiceComponent'" class="btn btn-success btn-xl pointer m-t-10 w-100 requestModal" data-type="makePayment">Make Payment</div>
|
||||
<div v-if="section === 'customerPendingPaymentInvoiceComponent'" class="btn btn-success btn-xl pointer m-t-10 w-100 requestModal" @click="handleMakePaymentClick" data-type="makePayment">Make Payment</div>
|
||||
<div v-if="['customerPaidInvoiceComponent', 'customerPendingPaymentInvoiceComponent'].includes(section)" class="btn btn-info btn-xl pointer m-t-10 w-100" @click='generateSummaryInvoice'>Generate Summary Invoice</div>
|
||||
</div>
|
||||
</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="makePayment">
|
||||
<group-payment-form-component :section="section" :company_module_id="company_module_id" :selectedIds="selectedIds" :sumAmount="sumAmount"></group-payment-form-component>
|
||||
<div class="d-flex justify-content-center align-items-center" v-if="!showPaymentProceedModal && !showPaymentOutdatedModal">
|
||||
<i class="fa fa-spinner fa-spin"></i>
|
||||
</div>
|
||||
<group-payment-form-component :section="section" :company_module_id="company_module_id" :selectedIds="selectedIds" :selectedShippingInvoicesOnlyIds="selectedShippingInvoicesOnlyIds" :sumAmount="parseFloat(sumAmount)" v-on:isPaymentOutdated="paymentOutdated($event)" v-if="showPaymentProceedModal"></group-payment-form-component>
|
||||
<reload-confirmation-form-component
|
||||
contentText="Some information has been updated, click 'Yes' to reload page"
|
||||
buttonText="Yes"
|
||||
class="text-center"
|
||||
:section="section"
|
||||
v-if="showPaymentOutdatedModal"
|
||||
>
|
||||
</reload-confirmation-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
@@ -108,6 +119,9 @@
|
||||
selectedPaidInvoice: [],
|
||||
selectedUnpaidInvoice: [],
|
||||
selectAllInvoice: false,
|
||||
showPaymentProceedModal: false,
|
||||
showPaymentOutdatedModal: false,
|
||||
selectedShippingInvoicesOnlyIds: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -119,7 +133,8 @@
|
||||
var total = Object.keys(new_object).reduce(function(total, key) {
|
||||
return total + new_object[key].amount;
|
||||
}, 0).toFixed(2);
|
||||
return Math.round(total * 100) / 100;
|
||||
total = (Math.round(total * 100) / 100).toFixed(2);
|
||||
return total;
|
||||
},
|
||||
selectedIds () {
|
||||
return this.selectedInvoice.map(s=>s.id);
|
||||
@@ -183,6 +198,36 @@
|
||||
...(shippingInvoice ? [shippingInvoice] : [])
|
||||
];
|
||||
return mergedArray;
|
||||
},
|
||||
handleMakePaymentClick(event) {
|
||||
this.showPaymentProceedModal = false;
|
||||
this.showPaymentOutdatedModal = false;
|
||||
this.selectedShippingInvoicesOnlyIds = this.selectedInvoice.filter(invoice => invoice.type === 1).map(s=>s.id);
|
||||
this.submit(this.route('api.transaction.verify.transactions', JSON.stringify(this.selectedShippingInvoicesOnlyIds)), 'get', this.section, false, false);
|
||||
},
|
||||
successHandler(response){
|
||||
const totalAmount = response.payload.data.reduce((total, item) => {
|
||||
const topLevelAmount = item.amount || 0;
|
||||
const storagesAmount = item.storages.reduce((sum, storage) => {
|
||||
const storageInvoiceAmount = storage.storageInvoice?.amount || 0;
|
||||
return sum + storageInvoiceAmount;
|
||||
}, 0);
|
||||
|
||||
return total + topLevelAmount + storagesAmount;
|
||||
|
||||
}, 0).toFixed(2);
|
||||
|
||||
const epsilon = 0.0001;
|
||||
if(Math.abs(this.sumAmount - totalAmount) < epsilon){
|
||||
this.showPaymentProceedModal = true;
|
||||
}
|
||||
else{
|
||||
this.showPaymentOutdatedModal = true;
|
||||
}
|
||||
},
|
||||
paymentOutdated(){
|
||||
this.showPaymentProceedModal = false;
|
||||
this.showPaymentOutdatedModal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<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" v-show="!isLoading">
|
||||
<div class="col">
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<h4>{{ contentText }}</h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-sm btn-block b-rad-none" :class="[{'btn-danger': modalType !== 'confirm'}, {'btn-success': modalType === 'confirm'}]" @click="handleConfirm">{{ buttonText }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import componentHandler from '../../../general/mixins/componentHandler';
|
||||
import ModalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
export default {
|
||||
props: {
|
||||
contentText: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
modalType: {
|
||||
type: String,
|
||||
default: 'confirm'
|
||||
},
|
||||
buttonText: {
|
||||
type: String,
|
||||
default: 'Confirm'
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
handleConfirm() {
|
||||
window.location.reload();
|
||||
},
|
||||
},
|
||||
mixins: [componentHandler, ModalFormHandler]
|
||||
|
||||
}
|
||||
</script>
|
||||
+52
-5
@@ -279,9 +279,20 @@
|
||||
</div>
|
||||
<div class="row m-t-20" v-if="totalOutstanding - totalFloating > 0.009 && !groupPaymentPending">
|
||||
<div class="col">
|
||||
<div class="btn btn-sm all-caps b-rad-none btn-success btn-block requestModal" data-type="makePayment">Make Payment</div>
|
||||
<div class="btn btn-sm all-caps b-rad-none btn-success btn-block requestModal" @click="handleMakePaymentClick" data-type="makePayment">Make Payment</div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" styleType="fill-in" type="makePayment">
|
||||
<group-payment-form-component :section="section" :selectedIds="selectedIds" :sumAmount="totalOutstanding.toFixed(2)" :showManualPayment="true"></group-payment-form-component>
|
||||
<div class="d-flex justify-content-center align-items-center" v-if="!showPaymentProceedModal && !showPaymentOutdatedModal">
|
||||
<i class="fa fa-spinner fa-spin"></i>
|
||||
</div>
|
||||
<group-payment-form-component :section="section" :selectedIds="selectedIds" :sumAmount="parseFloat(totalOutstanding.toFixed(2))" :selectedShippingInvoicesOnlyIds="selectedShippingInvoicesOnlyIds" :showManualPayment="true" v-on:isPaymentOutdated="paymentOutdated($event)" v-if="showPaymentProceedModal"></group-payment-form-component>
|
||||
<reload-confirmation-form-component
|
||||
contentText="Some information has been updated, click 'Yes' to reload page"
|
||||
buttonText="Yes"
|
||||
class="text-center"
|
||||
:section="section"
|
||||
v-if="showPaymentOutdatedModal"
|
||||
>
|
||||
</reload-confirmation-form-component>
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
@@ -321,6 +332,9 @@
|
||||
transaction_details: [],
|
||||
},
|
||||
expanded: true,
|
||||
showPaymentProceedModal: false,
|
||||
showPaymentOutdatedModal: false,
|
||||
selectedShippingInvoicesOnlyIds: [],
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -365,9 +379,6 @@
|
||||
let questions = item.remarks;
|
||||
return questions.slice().reverse()[0];
|
||||
},
|
||||
successHandler(response){
|
||||
this.item = response.payload.data;
|
||||
},
|
||||
groupTransactionsExist(items, groups) {
|
||||
return groups.some(group =>
|
||||
group.payment_transaction &&
|
||||
@@ -376,6 +387,42 @@
|
||||
items.some(item => item.id === transaction.transaction_id)
|
||||
)
|
||||
);
|
||||
},
|
||||
handleMakePaymentClick(event) {
|
||||
this.showPaymentProceedModal = false;
|
||||
this.showPaymentOutdatedModal = false;
|
||||
this.selectedShippingInvoicesOnlyIds = this.items.filter(invoice => invoice.type === 1).map(s=>s.id);
|
||||
this.submit(this.route('api.transaction.verify.transactions', JSON.stringify(this.selectedShippingInvoicesOnlyIds)), 'get', 'verifyPaymentForOrderProfileV2Section', false, false);
|
||||
},
|
||||
successHandler(response, section){
|
||||
if(section === "verifyPaymentForOrderProfileV2Section")
|
||||
{
|
||||
const totalAmount = response.payload.data.reduce((total, item) => {
|
||||
const topLevelAmount = item.amount || 0;
|
||||
const storagesAmount = item.storages.reduce((sum, storage) => {
|
||||
const storageInvoiceAmount = storage.storageInvoice?.amount || 0;
|
||||
return sum + storageInvoiceAmount;
|
||||
}, 0);
|
||||
|
||||
return total + topLevelAmount + storagesAmount;
|
||||
|
||||
}, 0);
|
||||
|
||||
const epsilon = 0.0001;
|
||||
if(Math.abs(this.totalOutstanding - totalAmount) < epsilon){
|
||||
this.showPaymentProceedModal = true;
|
||||
}
|
||||
else{
|
||||
this.showPaymentOutdatedModal = true;
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.item = response.payload.data;
|
||||
}
|
||||
},
|
||||
paymentOutdated(){
|
||||
this.showPaymentProceedModal = false;
|
||||
this.showPaymentOutdatedModal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+60
-30
@@ -138,7 +138,7 @@
|
||||
<div class="btn btn-sm all-caps b-rad-none btn-default bg-master-lighter btn-block" @click="expandPayment = false" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col-8 p-l-0">
|
||||
<div class="btn btn-sm all-caps b-rad-none btn-default bg-success btn-block text-white" @click="submitForm()" :class="[{'hide': paymentMethod.name === ''}]">Proceed</div>
|
||||
<div class="btn btn-sm all-caps b-rad-none btn-default bg-success btn-block text-white" @click="handleProceedClick" :class="[{'hide': paymentMethod.name === ''}]">Proceed</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -174,11 +174,15 @@
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
selectedShippingInvoicesOnlyIds: {
|
||||
type: Array,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
parameters : {
|
||||
amount: this.sumAmount,
|
||||
amount: this.sumAmount.toFixed(2),
|
||||
// transaction_ids: this.data.id,
|
||||
payment_method: '',
|
||||
},
|
||||
@@ -214,39 +218,65 @@
|
||||
}
|
||||
this.error = '';
|
||||
},
|
||||
successHandler(response){
|
||||
// todo-new: when using the page reload, the section reload will auto refresh with new data and refresh again
|
||||
// however if dont use the page reload, then the section will refresh with old data
|
||||
// if (response.payload) {
|
||||
// if (response.payload.data.payment_method === 5) {
|
||||
// window.location.href = this.route('billplz.bill', response.payload.data.reference) + '?auto_submit=true';
|
||||
// } else {
|
||||
// location.reload();
|
||||
// }
|
||||
// }
|
||||
handleProceedClick(event) {
|
||||
this.showPaymentProceedModal = false;
|
||||
this.showPaymentOutdatedModal = false;
|
||||
this.submit(this.route('api.transaction.verify.transactions', JSON.stringify(this.selectedShippingInvoicesOnlyIds)), 'get', 'verifyPendingPaymentInvoice', false, false);
|
||||
},
|
||||
successHandler(response, section){
|
||||
if(section === 'verifyPendingPaymentInvoice'){
|
||||
const totalAmount = response.payload.data.reduce((total, item) => {
|
||||
const topLevelAmount = item.amount || 0;
|
||||
const storagesAmount = item.storages.reduce((sum, storage) => {
|
||||
const storageInvoiceAmount = storage.storageInvoice?.amount || 0;
|
||||
return sum + storageInvoiceAmount;
|
||||
}, 0);
|
||||
|
||||
let isClearToUpdateList = true;
|
||||
if(response.payload.data && response.payload.data.message){
|
||||
this.error = response.payload.data.message;
|
||||
isClearToUpdateList = false;
|
||||
return total + topLevelAmount + storagesAmount;
|
||||
|
||||
}, 0).toFixed(2);
|
||||
if(this.sumAmount == totalAmount){
|
||||
this.submitForm();
|
||||
}
|
||||
else{
|
||||
this.$emit('isPaymentOutdated', true);
|
||||
}
|
||||
}
|
||||
else if (response.payload.length == 0) {
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
else if (response.payload) {
|
||||
if (response.payload.data.payment_method === 5) {
|
||||
window.location.href = this.route('billplz.bill', response.payload.data.reference) + '?auto_submit=true';
|
||||
} else {
|
||||
location.reload();
|
||||
else{
|
||||
// todo-new: when using the page reload, the section reload will auto refresh with new data and refresh again
|
||||
// however if dont use the page reload, then the section will refresh with old data
|
||||
// if (response.payload) {
|
||||
// if (response.payload.data.payment_method === 5) {
|
||||
// window.location.href = this.route('billplz.bill', response.payload.data.reference) + '?auto_submit=true';
|
||||
// } else {
|
||||
// location.reload();
|
||||
// }
|
||||
// }
|
||||
|
||||
let isClearToUpdateList = true;
|
||||
if(response.payload.data && response.payload.data.message){
|
||||
this.error = response.payload.data.message;
|
||||
isClearToUpdateList = false;
|
||||
}
|
||||
else if (response.payload.length == 0) {
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
else if (response.payload) {
|
||||
if (response.payload.data.payment_method === 5) {
|
||||
window.location.href = this.route('billplz.bill', response.payload.data.reference) + '?auto_submit=true';
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
if(isClearToUpdateList){
|
||||
this.updateList();
|
||||
}
|
||||
}
|
||||
|
||||
if(isClearToUpdateList){
|
||||
this.updateList();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
mixins: [formHandler]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user