diff --git a/app/Services/Invoice/InvoiceService.php b/app/Services/Invoice/InvoiceService.php index 6dc73c1f7569..9e027a98f381 100644 --- a/app/Services/Invoice/InvoiceService.php +++ b/app/Services/Invoice/InvoiceService.php @@ -201,6 +201,14 @@ class InvoiceService return $this; } + public function updateStatus() + { + if($this->invoice->balance == 0) + $this->setStatus(Invoice::STATUS_PAID); + + return $this; + } + public function toggleFeesPaid() { $this->invoice->line_items = collect($this->invoice->line_items) diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php index 41bfb41e3ee6..e9d0fb1717b0 100644 --- a/app/Services/Payment/UpdateInvoicePayment.php +++ b/app/Services/Payment/UpdateInvoicePayment.php @@ -73,6 +73,7 @@ class UpdateInvoicePayment $invoice->service() //caution what if we amount paid was less than partial - we wipe it! ->clearPartial() ->updateBalance($paid_amount * -1) + ->updateStatus() ->save(); event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars()));