mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
working on invoice labels and template values
This commit is contained in:
parent
019cc09dbb
commit
d99443806a
@ -151,10 +151,10 @@ class InvoiceCalc
|
||||
{
|
||||
|
||||
// custom fields charged taxes
|
||||
if (isset($this->invoice->custom_value1) && $this->settings->custom_taxes1) {
|
||||
if (isset($this->invoice->custom_value1) && isset($this->settings->custom_taxes1)) {
|
||||
$this->total += $this->invoice->custom_value1;
|
||||
}
|
||||
if (isset($this->invoice->custom_value2) && $this->settings->custom_taxes2) {
|
||||
if (isset($this->invoice->custom_value2) && isset($this->settings->custom_taxes2)) {
|
||||
$this->total += $this->invoice->custom_value2;
|
||||
}
|
||||
|
||||
|
@ -91,7 +91,9 @@ class CreateInvoicePdf
|
||||
|
||||
$data['invoice'] = $invoice;
|
||||
|
||||
return view($design, $data)->render();
|
||||
$template_variables = array_merge($invoice->makeLabels(), $invoice->makeValues());
|
||||
|
||||
return view($design, array_merge($data, $template_variables))->render();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ use App\Models\Currency;
|
||||
use App\Models\Filterable;
|
||||
use App\Utils\Number;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Utils\Traits\MakesInvoiceLabels;
|
||||
use App\Utils\Traits\MakesInvoiceValues;
|
||||
use App\Utils\Traits\NumberFormatter;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
@ -29,7 +31,8 @@ class Invoice extends BaseModel
|
||||
use NumberFormatter;
|
||||
use MakesDates;
|
||||
use PresentableTrait;
|
||||
|
||||
use MakesInvoiceValues;
|
||||
use MakesInvoiceLabels;
|
||||
protected $presenter = 'App\Models\Presenters\InvoicePresenter';
|
||||
|
||||
protected $hidden = [
|
||||
@ -248,92 +251,4 @@ 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'] =;
|
||||
}
|
||||
|
||||
}
|
@ -51,6 +51,10 @@ class Payment extends BaseModel
|
||||
'transaction_reference'
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'settings' => 'object'
|
||||
];
|
||||
|
||||
public function client()
|
||||
{
|
||||
return $this->belongsTo(Client::class);
|
||||
|
@ -26,6 +26,11 @@ class ClientPresenter extends EntityPresenter
|
||||
return $this->entity->name ?: $this->entity->primary_contact->first()->first_name . ' '. $this->entity->primary_contact->first()->last_name;
|
||||
}
|
||||
|
||||
public function primary_contact_name()
|
||||
{
|
||||
return $this->entity->primary_contact->first()->first_name . ' '. $this->entity->primary_contact->first()->last_name;;
|
||||
}
|
||||
|
||||
public function address()
|
||||
{
|
||||
$str = '';
|
||||
|
@ -53,7 +53,7 @@ class InvoicePresenter extends EntityPresenter
|
||||
|
||||
public function companyName()
|
||||
{
|
||||
return $this->company->present()->name()
|
||||
return $this->company->present()->name();
|
||||
}
|
||||
|
||||
public function companyAddress()
|
||||
|
@ -151,3 +151,4 @@ trait MakesInvoiceLabels
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
116
app/Utils/Traits/MakesInvoiceValues.php
Normal file
116
app/Utils/Traits/MakesInvoiceValues.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Utils\Traits;
|
||||
|
||||
use App\Utils\Number;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class MakesInvoiceValues
|
||||
* @package App\Utils\Traits
|
||||
*/
|
||||
trait MakesInvoiceValues
|
||||
{
|
||||
|
||||
public function makeValues()
|
||||
{
|
||||
$data = [];
|
||||
|
||||
//$data['invoice'] = ;
|
||||
$data['invoice_date'] = $this->invoice_date;
|
||||
$data['due_date'] = $this->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'] = $this->present()->cityStateZip($this->client->city, $this->client->state, $this->client->postal_code, FALSE);
|
||||
$data['postal_city_state'] = $this->present()->cityStateZip($this->client->city, $this->client->state, $this->client->postal_code, TRUE);
|
||||
$data['country'] = $this->client->country->name;
|
||||
$data['email'] = isset($this->client->primary_contact()->first()->email) ?: 'no primary contact set';
|
||||
$data['contact_name'] = $this->client->present()->primary_contact_name();
|
||||
$data['company_name'] = $this->company->name;
|
||||
$data['website'] = $this->client->website;
|
||||
$data['phone'] = $this->client->primary_contact->first()->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'] =;
|
||||
*/
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
@ -98,12 +98,15 @@ class RandomDataSeeder extends Seeder
|
||||
factory(\App\Models\Product::class,50)->create(['user_id' => $user->id, 'company_id' => $company->id]);
|
||||
|
||||
/** Invoice Factory */
|
||||
factory(\App\Models\Invoice::class,500)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
|
||||
factory(\App\Models\Invoice::class,500)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id, 'settings' => ClientSettings::buildClientSettings($company->settings, $client->settings)]);
|
||||
|
||||
/** Recurring Invoice Factory */
|
||||
factory(\App\Models\RecurringInvoice::class,20)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
|
||||
|
||||
factory(\App\Models\Payment::class,20)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id, 'settings' => ClientSettings::buildClientSettings($company->settings, $client->settings)]);
|
||||
// factory(\App\Models\Payment::class,20)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id, 'settings' => ClientSettings::buildClientSettings($company->settings, $client->settings)]);
|
||||
|
||||
factory(\App\Models\Payment::class,20)->create(['user_id' => $user->id, 'company_id' => $company->id, 'client_id' => $client->id]);
|
||||
|
||||
|
||||
$clients = Client::all();
|
||||
|
||||
|
@ -139,6 +139,23 @@
|
||||
John Doe<br>
|
||||
john@example.com
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{{$client_name}}<br>
|
||||
{{$address1}}<br>
|
||||
{{$address2}}<br>
|
||||
{{$id_number}}<br>
|
||||
{{$vat_number}}<br>
|
||||
{{$city_state_postal}}<br>
|
||||
{{$postal_city_state}}<br>
|
||||
{{$country}}<br>
|
||||
{{$email}}<br>
|
||||
{{$contact_name}}<br>
|
||||
{{$company_name}}<br>
|
||||
{{$website}}<br>
|
||||
{{$phone}}<br>
|
||||
{{$terms}}<br>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
@ -413,70 +430,6 @@
|
||||
Website design
|
||||
</td>
|
||||
|
||||
<td>
|
||||
$300.00
|
||||
</td>
|
||||
</tr> <tr class="item">
|
||||
<td>
|
||||
Website design
|
||||
</td>
|
||||
|
||||
<td>
|
||||
$300.00
|
||||
</td>
|
||||
</tr> <tr class="item">
|
||||
<td>
|
||||
Website design
|
||||
</td>
|
||||
|
||||
<td>
|
||||
$300.00
|
||||
</td>
|
||||
</tr> <tr class="item">
|
||||
<td>
|
||||
Website design
|
||||
</td>
|
||||
|
||||
<td>
|
||||
$300.00
|
||||
</td>
|
||||
</tr> <tr class="item">
|
||||
<td>
|
||||
Website design
|
||||
</td>
|
||||
|
||||
<td>
|
||||
$300.00
|
||||
</td>
|
||||
</tr> <tr class="item">
|
||||
<td>
|
||||
Website design
|
||||
</td>
|
||||
|
||||
<td>
|
||||
$300.00
|
||||
</td>
|
||||
</tr> <tr class="item">
|
||||
<td>
|
||||
Website design
|
||||
</td>
|
||||
|
||||
<td>
|
||||
$300.00
|
||||
</td>
|
||||
</tr> <tr class="item">
|
||||
<td>
|
||||
Website design
|
||||
</td>
|
||||
|
||||
<td>
|
||||
$300.00
|
||||
</td>
|
||||
</tr> <tr class="item">
|
||||
<td>
|
||||
Website design
|
||||
</td>
|
||||
|
||||
<td>
|
||||
$300.00
|
||||
</td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user