From dbab1d93c339df47ac2e18b3b4b208e446f7f578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Duli=C3=A7i?= Date: Fri, 22 Jan 2021 14:24:53 +0300 Subject: [PATCH] added amount due to email templates --- app/Models/Document/Document.php | 12 ++++++++++++ app/Notifications/Purchase/Bill.php | 4 +++- app/Notifications/Sale/Invoice.php | 2 ++ .../views/components/documents/show/header.blade.php | 4 ++-- resources/views/settings/email/edit.blade.php | 9 +++++++-- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/app/Models/Document/Document.php b/app/Models/Document/Document.php index b56390061..02b5c9af2 100644 --- a/app/Models/Document/Document.php +++ b/app/Models/Document/Document.php @@ -298,6 +298,18 @@ class Document extends Model return round($paid, $precision); } + /** + * Get the not paid amount. + * + * @return string + */ + public function getAmountDueAttribute() + { + $precision = config('money.' . $this->currency_code . '.precision'); + + return round($this->amount - $this->paid, $precision); + } + /** * Get the status label. * diff --git a/app/Notifications/Purchase/Bill.php b/app/Notifications/Purchase/Bill.php index 6bdc35ef0..fe99f7423 100644 --- a/app/Notifications/Purchase/Bill.php +++ b/app/Notifications/Purchase/Bill.php @@ -66,6 +66,7 @@ class Bill extends Notification return [ '{bill_number}', '{bill_total}', + '{bill_amount_due}', '{bill_due_date}', '{bill_admin_link}', '{vendor_name}', @@ -80,8 +81,9 @@ class Bill extends Notification public function getTagsReplacement() { return [ - $this->bill->bill_number, + $this->bill->document_number, money($this->bill->amount, $this->bill->currency_code, true), + money($this->bill->amount_due, $this->bill->currency_code, true), company_date($this->bill->due_at), route('bills.show', $this->bill->id), $this->bill->contact_name, diff --git a/app/Notifications/Sale/Invoice.php b/app/Notifications/Sale/Invoice.php index ea9e60206..0dfb3e1d2 100644 --- a/app/Notifications/Sale/Invoice.php +++ b/app/Notifications/Sale/Invoice.php @@ -74,6 +74,7 @@ class Invoice extends Notification return [ '{invoice_number}', '{invoice_total}', + '{invoice_amount_due}', '{invoice_due_date}', '{invoice_guest_link}', '{invoice_admin_link}', @@ -92,6 +93,7 @@ class Invoice extends Notification return [ $this->invoice->document_number, money($this->invoice->amount, $this->invoice->currency_code, true), + money($this->invoice->amount_due, $this->invoice->currency_code, true), company_date($this->invoice->due_at), URL::signedRoute('signed.invoices.show', [$this->invoice->id, 'company_id' => $this->invoice->company_id]), route('invoices.show', $this->invoice->id), diff --git a/resources/views/components/documents/show/header.blade.php b/resources/views/components/documents/show/header.blade.php index 0b6dacbb9..214eda433 100644 --- a/resources/views/components/documents/show/header.blade.php +++ b/resources/views/components/documents/show/header.blade.php @@ -4,7 +4,7 @@
{{ trans_choice('general.statuses', 1) }}
- + @@ -41,7 +41,7 @@ - @money($document->amount - $document->paid, $document->currency_code, true) + @money($document->amount_due, $document->currency_code, true)

diff --git a/resources/views/settings/email/edit.blade.php b/resources/views/settings/email/edit.blade.php index 02f843f51..7e7cbbf82 100644 --- a/resources/views/settings/email/edit.blade.php +++ b/resources/views/settings/email/edit.blade.php @@ -20,8 +20,13 @@
@foreach($templates as $template) - @php $aria_expanded_status = in_array($card, [1, 2]) ? 'true' : 'false'; @endphp - @php $collapse_status = in_array($card, [1, 2]) ? 'show' : ''; @endphp + @php + if (!class_exists($template->class)) { + continue; + } + $aria_expanded_status = in_array($card, [1, 2]) ? 'true' : 'false'; + $collapse_status = in_array($card, [1, 2]) ? 'show' : ''; + @endphp