From f7ff5d34df1d4207d96145bdfdaaf03d096766fd Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 28 Feb 2022 10:15:36 +1100 Subject: [PATCH] add helper for Invoice payable amount --- app/Models/Invoice.php | 14 ++++++++++++++ .../views/portal/ninja2020/invoices/show.blade.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 3fcfb4ddf012..c85230a96bf0 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -498,6 +498,20 @@ class Invoice extends BaseModel return $this->calc()->getTotal(); } + public function getPayableAmount() + { + if($this->partial > 0) + return $this->partial; + + if($this->balance > 0) + return $this->balance; + + if($this->status_id = 1) + return $this->amount; + + return 0; + } + public function entityEmailEvent($invitation, $reminder_template, $template) { switch ($reminder_template) { diff --git a/resources/views/portal/ninja2020/invoices/show.blade.php b/resources/views/portal/ninja2020/invoices/show.blade.php index f374b14593ad..f56fbca5dfb2 100644 --- a/resources/views/portal/ninja2020/invoices/show.blade.php +++ b/resources/views/portal/ninja2020/invoices/show.blade.php @@ -59,7 +59,7 @@ @if($settings->client_portal_allow_under_payment || $settings->client_portal_allow_over_payment) @else - @livewire('pay-now-dropdown', ['total' => $invoice->partial > 0 ? $invoice->partial : $invoice->balance, 'company' => $company]) + @livewire('pay-now-dropdown', ['total' => $invoice->getPayableAmount(), 'company' => $company]) @endif