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:
parent
05d7211c4c
commit
0e2edde2a5
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user