diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 555432e87d49..f38e588fab3d 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -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; diff --git a/app/Services/Invoice/MarkPaid.php b/app/Services/Invoice/MarkPaid.php index 5ea33b4b5cc9..4d14210d61a9 100644 --- a/app/Services/Invoice/MarkPaid.php +++ b/app/Services/Invoice/MarkPaid.php @@ -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()