-fix purchase order section state issue when refund request is approved on booking page

-fix supplier bill group dashboard payment issue
This commit is contained in:
JiaSheng
2024-03-16 09:44:56 +08:00
parent 10151634a7
commit c498aec61d
6 changed files with 10 additions and 9 deletions
@@ -81,7 +81,7 @@ class ApproveBillGroupPaymentVerificationLogic extends AbstractControllerLogic
$billGroup->status = ApprovalStatus::PENDING_SUBMISSION;
$billGroup->save();
} else {
if ($billGroupPayment['outstanding_amount'] <= 0) {
if ($billGroupPayment['outstanding_amount'] <= 0 && $billGroupPayment['floating_amount'] <= 0) {
$billGroup->status = ApprovalStatus::APPROVED;
$billGroup->save();
}
@@ -83,7 +83,7 @@ class CreateBillGroupPaymentProofDocumentLogic extends AbstractControllerLogic
$billGroup = $transaction->owner;
$billGroupPayment = $this->calculatesBillGroupPaymentAmount->execute($billGroup);
if ($billGroupPayment['outstanding_amount'] <= 0) {
if ($billGroupPayment['outstanding_amount'] <= 0 && $billGroup->transactions()->where('status', ApprovalStatus::PENDING_SUBMISSION)->count() === 0) {
$billGroup->status = ApprovalStatus::PENDING_VERIFICATION;
$billGroup->save();
}
@@ -68,7 +68,7 @@ class CreateBillGroupPaymentTransactionLogic extends AbstractControllerLogic
$billGroupPayment = $this->calculatesBillGroupPaymentAmount->execute($billGroup);
$outstanding_amount = $billGroupPayment['outstanding_amount'];
if ($billGroupPayment['outstanding_amount'] == 0) {
if ($billGroupPayment['outstanding_amount'] <= 0) {
if ($billGroup->transactions()->whereIn('status', [ApprovalStatus::PENDING_SUBMISSION, ApprovalStatus::PENDING_VERIFICATION, ApprovalStatus::APPROVED, ApprovalStatus::COMPLETED])->count() !== 0) {
throw new MalformedRequestException('Invalid bill group, payment transaction already exist.');
}
@@ -159,11 +159,11 @@ class CreateSupplierBillGroupLogic extends AbstractControllerLogic
foreach ($supplierRefunds as $supplierRefund) {
$refund = Transaction::find($supplierRefund['id']);
$deductedRefunds = $refund->transactions()->where('type', TransactionType::BILL_REFUND)->where('status', ApprovalStatus::APPROVED)->get();
$refundDeductableAmount = $refund->amount - $deductedRefunds->sum('amount');
$refundDeductableOriginalAmount = $refund->original_amount - $deductedRefunds->sum('original_amount');
$refundDeductableAmount = round(($refund->amount - $deductedRefunds->sum('amount')), 2);
$refundDeductableOriginalAmount = round(($refund->original_amount - $deductedRefunds->sum('original_amount')), 2);
$amount -= round($refundDeductableAmount, 2);
$original_amount -= round($refundDeductableOriginalAmount, 2);
$amount -= $refundDeductableAmount;
$original_amount -= $refundDeductableOriginalAmount;
if ($amount > 0) {
$deductedRefundAmount = $refundDeductableAmount;
@@ -80,7 +80,7 @@
<div class="font-heading fs-12">MYR 0.00</div>
</div>
</div>
<div v-if="selectedBillGroup.status === 0 && (selectedBillGroup.outstanding_amount > 0 || (selectedBillGroup.bill_refund_amount === selectedBillGroup.amount && !selectedBillGroup.payment_history.some((item)=> [0, 1, 2, 3].includes(item.status))))">
<div v-if="selectedBillGroup.status === 0 && (selectedBillGroup.outstanding_amount > 0 || (selectedBillGroup.bill_refund_amount === (selectedBillGroup.amount + selectedBillGroup.service_charge) && !selectedBillGroup.payment_history.some((item)=> [0, 1, 2, 3].includes(item.status))))">
<div class="row p-r-15 m-t-20 m-b-10">
<div class="col p-r-0">
<validation-wrapper-component :validator="$v.parameters.payAmount">
@@ -101,7 +101,7 @@
<button id="payment-btn" class="btn btn-sm all-caps b-rad-none btn-success btn-block" @click="submitForm">Make Payment</button>
</div>
</div>
<div class="row m-t-20" v-if="(selectedBillGroup.bill_refund_amount === selectedBillGroup.amount)">
<div class="row m-t-20" v-if="(selectedBillGroup.bill_refund_amount === selectedBillGroup.amount + selectedBillGroup.service_charge)">
<div class="col">
<button id="payment-btn" class="btn btn-sm all-caps b-rad-none btn-success btn-block" @click="submitForm">Complete Order</button>
</div>
@@ -242,6 +242,7 @@
'data': function () {
if (this.data && this.data.purchase_order && this.data.purchase_order.details) {
this.products = this.data.purchase_order.details;
this.submitted = this.data.purchase_order ? this.data.purchase_order.status === 1 || this.data.purchase_order.status === 2: false;
} else {
this.products = [];
}