diff --git a/app/Classes/Modules/Transactions/ControllersLogic/ApproveBillGroupPaymentVerificationLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/ApproveBillGroupPaymentVerificationLogic.php index f12060b4..00117f9e 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/ApproveBillGroupPaymentVerificationLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/ApproveBillGroupPaymentVerificationLogic.php @@ -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(); } diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateBillGroupPaymentProofDocumentLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateBillGroupPaymentProofDocumentLogic.php index 79e01eb0..2563c230 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateBillGroupPaymentProofDocumentLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateBillGroupPaymentProofDocumentLogic.php @@ -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(); } diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateBillGroupPaymentTransactionLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateBillGroupPaymentTransactionLogic.php index e2fc6dc1..75be47d4 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateBillGroupPaymentTransactionLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateBillGroupPaymentTransactionLogic.php @@ -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.'); } diff --git a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierBillGroupLogic.php b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierBillGroupLogic.php index 33284726..6213f55f 100644 --- a/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierBillGroupLogic.php +++ b/app/Classes/Modules/Transactions/ControllersLogic/CreateSupplierBillGroupLogic.php @@ -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; diff --git a/resources/assets/vue/components/bookings/elements/BillGroupPaymentSummaryComponent.vue b/resources/assets/vue/components/bookings/elements/BillGroupPaymentSummaryComponent.vue index 284f681d..f84541d1 100644 --- a/resources/assets/vue/components/bookings/elements/BillGroupPaymentSummaryComponent.vue +++ b/resources/assets/vue/components/bookings/elements/BillGroupPaymentSummaryComponent.vue @@ -80,7 +80,7 @@