mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 07:02:34 +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))
|
if(!collect($this->invoice->line_items)->contains('type_id', 3))
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
|
$pre_count = count($this->invoice->line_items);
|
||||||
|
|
||||||
$this->invoice->line_items = collect($this->invoice->line_items)
|
$this->invoice->line_items = collect($this->invoice->line_items)
|
||||||
->reject(function ($item) {
|
->reject(function ($item) {
|
||||||
return $item->type_id == '3';
|
return $item->type_id == '3';
|
||||||
@ -372,7 +374,7 @@ class InvoiceService
|
|||||||
/* 24-03-2022 */
|
/* 24-03-2022 */
|
||||||
$new_balance = $this->invoice->balance;
|
$new_balance = $this->invoice->balance;
|
||||||
|
|
||||||
if(floatval($balance) - floatval($new_balance) != 0)
|
if($pre_count != count($this->invoice->line_items))
|
||||||
{
|
{
|
||||||
$adjustment = $balance - $new_balance;
|
$adjustment = $balance - $new_balance;
|
||||||
|
|
||||||
|
@ -96,17 +96,17 @@ class MarkPaid extends AbstractService
|
|||||||
$payment->ledger()
|
$payment->ledger()
|
||||||
->updatePaymentBalance($payment->amount * -1);
|
->updatePaymentBalance($payment->amount * -1);
|
||||||
|
|
||||||
// $client = $this->invoice->client->fresh();
|
$client = $this->invoice->client->fresh();
|
||||||
// $client->paid_to_date += $payment->amount;
|
$client->paid_to_date += $payment->amount;
|
||||||
// $client->balance += $payment->amount * -1;
|
$client->balance += $payment->amount * -1;
|
||||||
// $client->save();
|
$client->save();
|
||||||
|
|
||||||
$this->invoice
|
// $this->invoice
|
||||||
->client
|
// ->client
|
||||||
->service()
|
// ->service()
|
||||||
->updateBalance($payment->amount * -1)
|
// ->updateBalance($payment->amount * -1)
|
||||||
->updatePaidToDate($payment->amount)
|
// ->updatePaidToDate($payment->amount)
|
||||||
->save();
|
// ->save();
|
||||||
|
|
||||||
$this->invoice = $this->invoice
|
$this->invoice = $this->invoice
|
||||||
->service()
|
->service()
|
||||||
|
Loading…
Reference in New Issue
Block a user