From 019cc09dbb3592552c25c6d47fb337d0ab230a70 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 30 Aug 2019 16:16:39 +1000 Subject: [PATCH] Working on replacing variables for templates --- app/Models/Invoice.php | 89 ++++++++++++ app/Models/Presenters/InvoicePresenter.php | 12 +- app/Utils/Traits/MakesInvoiceLabels.php | 153 +++++++++++++++++++++ 3 files changed, 249 insertions(+), 5 deletions(-) create mode 100644 app/Utils/Traits/MakesInvoiceLabels.php diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index c1ab91a143fe..7d8ca24a2bea 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -13,6 +13,7 @@ namespace App\Models; use App\Models\Currency; use App\Models\Filterable; +use App\Utils\Number; use App\Utils\Traits\MakesDates; use App\Utils\Traits\NumberFormatter; use Illuminate\Database\Eloquent\Model; @@ -247,4 +248,92 @@ class Invoice extends BaseModel return $this->settings->design ?: 'pdf.design1'; } + public function makeInvoiceValues() + { + $data = []; + + $data['invoice'] = ; + $data['invoice_date'] = $this->invoice_date; +// $data['due_date'] = ; + $data['invoice_number'] = $this->invoice_number; + $data['po_number'] = $this->po_number; + // $data['discount'] = ; + // $data['taxes'] = ; + // $data['tax'] = ; + // $data['item'] = ; + // $data['description'] = ; + // $data['unit_cost'] = ; + // $data['quantity'] = ; + // $data['line_total'] = ; + // $data['subtotal'] = ; + // $data['paid_to_date'] = ; + $data['balance_due'] = Number::formatMoney($this->balance, $this->client->currency, $this->client->country, $this->client->settings); + $data['partial_due'] = Number::formatMoney($this->partial, $this->client->currency, $this->client->country, $this->client->settings); + // $data['terms'] = $this->terms; + // $data['your_invoice'] = ; + // $data['quote'] = ; + // $data['your_quote'] = ; + // $data['quote_date'] = ; + // $data['quote_number'] = ; + $data['total'] = Number::formatMoney($this->amount, $this->client->currency, $this->client->country, $this->client->settings); + // $data['invoice_issued_to'] = ; + // $data['quote_issued_to'] = ; + // $data['rate'] = ; + // $data['hours'] = ; + // $data['balance'] = ; + // $data['from'] = ; + // $data['to'] = ; + // $data['invoice_to'] = ; + // $data['quote_to'] = ; + // $data['details'] = ; + $data['invoice_no'] = $this->invoice_number; + // $data['quote_no'] = ; + // $data['valid_until'] = ; + $data['client_name'] = $this->present()->clientName(); + $data['address1'] = $this->client->address1; + $data['address2'] = $this->client->address2; + $data['id_number'] = $this->client->id_number; + $data['vat_number'] = $this->client->vat_number; + $data['city_state_postal'] = ; + $data['postal_city_state'] = ; + $data['country'] = ; + $data['email'] = ; + $data['contact_nae'] = ; + $data['company_name'] = ; + $data['website'] = ; + $data['phone'] = ; + $data['blank'] = ; + $data['surcharge'] = ; + $data['tax_invoice'] = + $data['tax_quote'] = + $data['statement'] = ; + $data['statement_date'] = ; + $data['your_statement'] = ; + $data['statement_issued_to'] = ; + $data['statement_to'] = ; + $data['credit_note'] = ; + $data['credit_date'] = ; + $data['credit_number'] = ; + $data['credit_issued_to'] = ; + $data['credit_to'] = ; + $data['your_credit'] = ; + $data['work_phone'] = ; + $data['invoice_total'] = ; + $data['outstanding'] = ; + $data['invoice_due_date'] = ; + $data['quote_due_date'] = ; + $data['service'] = ; + $data['product_key'] = ; + $data['unit_cost'] = ; + $data['custom_value1'] = ; + $data['custom_value2'] = ; + $data['delivery_note'] = ; + $data['date'] = ; + $data['method'] = ; + $data['payment_date'] = ; + $data['reference'] = ; + $data['amount'] = ; + $data['amount_paid'] =; + } + } \ No newline at end of file diff --git a/app/Models/Presenters/InvoicePresenter.php b/app/Models/Presenters/InvoicePresenter.php index 50f58e31460c..72ca95b8aa77 100644 --- a/app/Models/Presenters/InvoicePresenter.php +++ b/app/Models/Presenters/InvoicePresenter.php @@ -36,28 +36,30 @@ class InvoicePresenter extends EntityPresenter return $this->client->present()->address(); } - public function shipping_address() + public function shippingAddress() { return $this->client->present()->shipping_address(); } - public function company_logo() + public function companyLogo() { return $this->company->logo; } - public function client_logo() + public function clientLogo() { return $this->client->logo; } - public function company_name() + public function companyName() { return $this->company->present()->name() } - public function company_address() + public function companyAddress() { return $this->company->present()->address(); } + + } diff --git a/app/Utils/Traits/MakesInvoiceLabels.php b/app/Utils/Traits/MakesInvoiceLabels.php new file mode 100644 index 000000000000..2f7014484eef --- /dev/null +++ b/app/Utils/Traits/MakesInvoiceLabels.php @@ -0,0 +1,153 @@ +