diff --git a/app/Livewire/Flow2/InvoicePay.php b/app/Livewire/Flow2/InvoicePay.php index 6a71c98d6e..951c010ce0 100644 --- a/app/Livewire/Flow2/InvoicePay.php +++ b/app/Livewire/Flow2/InvoicePay.php @@ -127,7 +127,7 @@ class InvoicePay extends Component #[On('payable-amount')] public function payableAmount($payable_amount) { - $this->setContext('payable_invoices.0.amount', Number::parseFloat($payable_amount)); // $this->context['payable_invoices'][0]['amount'] = Number::parseFloat($payable_amount); //TODO DB: check parseFloat() + // $this->setContext('payable_invoices.0.amount', Number::parseFloat($payable_amount)); // $this->context['payable_invoices'][0]['amount'] = Number::parseFloat($payable_amount); //TODO DB: check parseFloat() $this->under_over_payment = false; } diff --git a/app/Livewire/Flow2/UnderOverPayment.php b/app/Livewire/Flow2/UnderOverPayment.php index 7d80d1949b..31ec54cb69 100644 --- a/app/Livewire/Flow2/UnderOverPayment.php +++ b/app/Livewire/Flow2/UnderOverPayment.php @@ -44,13 +44,13 @@ class UnderOverPayment extends Component $this->errors = ''; $settings = $this->getContext()['settings']; - $input_amount = 0; - foreach($payableInvoices as $key=>$invoice){ - $input_amount += Number::parseFloat($invoice['formatted_amount']); - $payableInvoices[$key]['amount'] = $input_amount; + foreach($payableInvoices as $key => $invoice){ + $payableInvoices[$key]['amount'] = Number::parseFloat($invoice['formatted_amount']); } + $input_amount = collect($payableInvoices)->sum('amount'); + if($settings->client_portal_allow_under_payment && $settings->client_portal_under_payment_minimum != 0) { if($input_amount <= $settings->client_portal_under_payment_minimum){ @@ -63,11 +63,10 @@ class UnderOverPayment extends Component if(!$settings->client_portal_allow_over_payment && ($input_amount > $this->invoice_amount)){ $this->errors = ctrans('texts.over_payments_disabled'); $this->dispatch('errorMessageUpdate', errors: $this->errors); - } if(!$this->errors){ - $this->getContext()['payable_invoices'] = $payableInvoices; + $this->setContext('payable_invoices', $payableInvoices); $this->dispatch('payable-amount', payable_amount: $input_amount ); } }