mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
Improve client paid to date calc
This commit is contained in:
parent
d4f2fcdffb
commit
77d5016de7
@ -362,6 +362,8 @@ class InvoiceService
|
||||
if(!collect($this->invoice->line_items)->contains('type_id', 3))
|
||||
return $this;
|
||||
|
||||
$pre_count = count($this->invoice->line_items);
|
||||
|
||||
$this->invoice->line_items = collect($this->invoice->line_items)
|
||||
->reject(function ($item) {
|
||||
return $item->type_id == '3';
|
||||
@ -372,7 +374,7 @@ class InvoiceService
|
||||
/* 24-03-2022 */
|
||||
$new_balance = $this->invoice->balance;
|
||||
|
||||
if(floatval($balance) - floatval($new_balance) != 0)
|
||||
if($pre_count != count($this->invoice->line_items))
|
||||
{
|
||||
$adjustment = $balance - $new_balance;
|
||||
|
||||
|
@ -96,17 +96,17 @@ class MarkPaid extends AbstractService
|
||||
$payment->ledger()
|
||||
->updatePaymentBalance($payment->amount * -1);
|
||||
|
||||
// $client = $this->invoice->client->fresh();
|
||||
// $client->paid_to_date += $payment->amount;
|
||||
// $client->balance += $payment->amount * -1;
|
||||
// $client->save();
|
||||
$client = $this->invoice->client->fresh();
|
||||
$client->paid_to_date += $payment->amount;
|
||||
$client->balance += $payment->amount * -1;
|
||||
$client->save();
|
||||
|
||||
$this->invoice
|
||||
->client
|
||||
->service()
|
||||
->updateBalance($payment->amount * -1)
|
||||
->updatePaidToDate($payment->amount)
|
||||
->save();
|
||||
// $this->invoice
|
||||
// ->client
|
||||
// ->service()
|
||||
// ->updateBalance($payment->amount * -1)
|
||||
// ->updatePaidToDate($payment->amount)
|
||||
// ->save();
|
||||
|
||||
$this->invoice = $this->invoice
|
||||
->service()
|
||||
|
Loading…
Reference in New Issue
Block a user