1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

fix logic with under over payments (#82)

This commit is contained in:
Benjamin Beganović 2024-08-16 23:54:18 +02:00 committed by GitHub
parent 05d7211c4c
commit 0e2edde2a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 7 deletions

View File

@ -127,7 +127,7 @@ class InvoicePay extends Component
#[On('payable-amount')] #[On('payable-amount')]
public function payableAmount($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; $this->under_over_payment = false;
} }

View File

@ -44,13 +44,13 @@ class UnderOverPayment extends Component
$this->errors = ''; $this->errors = '';
$settings = $this->getContext()['settings']; $settings = $this->getContext()['settings'];
$input_amount = 0;
foreach($payableInvoices as $key=>$invoice){ foreach($payableInvoices as $key => $invoice){
$input_amount += Number::parseFloat($invoice['formatted_amount']); $payableInvoices[$key]['amount'] = Number::parseFloat($invoice['formatted_amount']);
$payableInvoices[$key]['amount'] = $input_amount;
} }
$input_amount = collect($payableInvoices)->sum('amount');
if($settings->client_portal_allow_under_payment && $settings->client_portal_under_payment_minimum != 0) if($settings->client_portal_allow_under_payment && $settings->client_portal_under_payment_minimum != 0)
{ {
if($input_amount <= $settings->client_portal_under_payment_minimum){ 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)){ if(!$settings->client_portal_allow_over_payment && ($input_amount > $this->invoice_amount)){
$this->errors = ctrans('texts.over_payments_disabled'); $this->errors = ctrans('texts.over_payments_disabled');
$this->dispatch('errorMessageUpdate', errors: $this->errors); $this->dispatch('errorMessageUpdate', errors: $this->errors);
} }
if(!$this->errors){ if(!$this->errors){
$this->getContext()['payable_invoices'] = $payableInvoices; $this->setContext('payable_invoices', $payableInvoices);
$this->dispatch('payable-amount', payable_amount: $input_amount ); $this->dispatch('payable-amount', payable_amount: $input_amount );
} }
} }