From e8437a9bbdd6dc68848052fb9d4f52d97b13de48 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 30 May 2017 16:02:15 +0300 Subject: [PATCH] Add and email variables --- app/Ninja/Presenters/InvoicePresenter.php | 8 ++++++++ app/Services/TemplateService.php | 2 ++ resources/views/partials/email_templates.blade.php | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/app/Ninja/Presenters/InvoicePresenter.php b/app/Ninja/Presenters/InvoicePresenter.php index 473423aad5..1d7e969a3e 100644 --- a/app/Ninja/Presenters/InvoicePresenter.php +++ b/app/Ninja/Presenters/InvoicePresenter.php @@ -29,6 +29,14 @@ class InvoicePresenter extends EntityPresenter return $account->formatMoney($invoice->amount, $invoice->client); } + public function balance() + { + $invoice = $this->entity; + $account = $invoice->account; + + return $account->formatMoney($invoice->balance, $invoice->client); + } + public function requestedAmount() { $invoice = $this->entity; diff --git a/app/Services/TemplateService.php b/app/Services/TemplateService.php index 5df95d2d24..6d778b79aa 100644 --- a/app/Services/TemplateService.php +++ b/app/Services/TemplateService.php @@ -55,6 +55,8 @@ class TemplateService '$contact' => $contact->getDisplayName(), '$firstName' => $contact->first_name, '$amount' => $account->formatMoney($data['amount'], $client), + '$total' => $invoice->present()->amount, + '$balance' => $invoice->present()->balance, '$invoice' => $invoice->invoice_number, '$quote' => $invoice->invoice_number, '$link' => $invitation->getLink(), diff --git a/resources/views/partials/email_templates.blade.php b/resources/views/partials/email_templates.blade.php index 5aa12fa725..7b1ed836b8 100644 --- a/resources/views/partials/email_templates.blade.php +++ b/resources/views/partials/email_templates.blade.php @@ -21,6 +21,8 @@ 'invoiceDate': invoice ? invoice.invoice_date : "{{ $account->formatDate($account->getDateTime()) }}", 'client': invoice ? getClientDisplayName(invoice.client) : "{{ trans('texts.client_name') }}", 'amount': invoice ? formatMoneyInvoice(parseFloat(invoice.partial) || parseFloat(invoice.balance_amount), invoice) : formatMoneyAccount(100, account), + 'balance': invoice ? formatMoneyInvoice(parseFloat(invoice.balance), invoice) : formatMoneyAccount(100, account), + 'total': invoice ? formatMoneyInvoice(parseFloat(invoice.amount), invoice) : formatMoneyAccount(100, account), 'contact': invoice ? getContactDisplayName(invoice.client.contacts[0]) : 'Contact Name', 'firstName': invoice ? invoice.client.contacts[0].first_name : 'First Name', 'invoice': invoice ? invoice.invoice_number : '0001', @@ -111,6 +113,8 @@ 'invoice', 'quote', 'amount', + 'total', + 'balance', 'invoiceDate', 'dueDate', 'documents',