diff --git a/app/Http/Controllers/Expenses/Bills.php b/app/Http/Controllers/Expenses/Bills.php
index 0915ab769..2360783fc 100644
--- a/app/Http/Controllers/Expenses/Bills.php
+++ b/app/Http/Controllers/Expenses/Bills.php
@@ -84,7 +84,9 @@ class Bills extends Controller
$payment_methods = Modules::getPaymentMethods();
- return view('expenses.bills.show', compact('bill', 'accounts', 'currencies', 'account_currency_code', 'vendors', 'categories', 'payment_methods'));
+ $taxes = Tax::enabled()->get()->pluck('title', 'name');
+
+ return view('expenses.bills.show', compact('bill', 'accounts', 'currencies', 'account_currency_code', 'vendors', 'categories', 'payment_methods', 'taxes'));
}
/**
@@ -100,7 +102,7 @@ class Bills extends Controller
$items = Item::enabled()->pluck('name', 'id');
- $taxes = Tax::enabled()->pluck('name', 'id');
+ $taxes = Tax::enabled()->get()->pluck('title', 'id');
return view('expenses.bills.create', compact('vendors', 'currencies', 'items', 'taxes'));
}
@@ -301,7 +303,7 @@ class Bills extends Controller
$items = Item::enabled()->pluck('name', 'id');
- $taxes = Tax::enabled()->pluck('name', 'id');
+ $taxes = Tax::enabled()->get()->pluck('title', 'id');
return view('expenses.bills.edit', compact('bill', 'vendors', 'currencies', 'items', 'taxes'));
}
@@ -476,7 +478,9 @@ class Bills extends Controller
$logo = $this->getLogo($bill);
- return view($bill->template_path, compact('bill', 'logo'));
+ $taxes = Tax::enabled()->get()->pluck('title', 'name');
+
+ return view($bill->template_path, compact('bill', 'logo', 'taxes'));
}
/**
@@ -492,7 +496,9 @@ class Bills extends Controller
$logo = $this->getLogo($bill);
- $html = view($bill->template_path, compact('bill', 'logo'))->render();
+ $taxes = Tax::enabled()->get()->pluck('title', 'name');
+
+ $html = view($bill->template_path, compact('bill', 'logo', 'taxes'))->render();
$pdf = \App::make('dompdf.wrapper');
$pdf->loadHTML($html);
diff --git a/app/Http/Controllers/Incomes/Invoices.php b/app/Http/Controllers/Incomes/Invoices.php
index 3611dee9f..8e0917d2c 100644
--- a/app/Http/Controllers/Incomes/Invoices.php
+++ b/app/Http/Controllers/Incomes/Invoices.php
@@ -87,7 +87,9 @@ class Invoices extends Controller
$payment_methods = Modules::getPaymentMethods();
- return view('incomes.invoices.show', compact('invoice', 'accounts', 'currencies', 'account_currency_code', 'customers', 'categories', 'payment_methods'));
+ $taxes = Tax::enabled()->get()->pluck('title', 'name');
+
+ return view('incomes.invoices.show', compact('invoice', 'accounts', 'currencies', 'account_currency_code', 'customers', 'categories', 'payment_methods', 'taxes'));
}
/**
@@ -103,7 +105,7 @@ class Invoices extends Controller
$items = Item::enabled()->pluck('name', 'id');
- $taxes = Tax::enabled()->pluck('name', 'id');
+ $taxes = Tax::enabled()->get()->pluck('title', 'id');
$number = $this->getNextInvoiceNumber();
@@ -322,7 +324,7 @@ class Invoices extends Controller
$items = Item::enabled()->pluck('name', 'id');
- $taxes = Tax::enabled()->pluck('name', 'id');
+ $taxes = Tax::enabled()->get()->pluck('title', 'id');
return view('incomes.invoices.edit', compact('invoice', 'customers', 'currencies', 'items', 'taxes'));
}
@@ -511,7 +513,11 @@ class Invoices extends Controller
$logo = $this->getLogo();
- $html = view($invoice->template_path, compact('invoice', 'logo'))->render();
+ $taxes = collect(Tax::enabled()->get())->each(function ($item) {
+ $item->title = $item->name . ' (' . $item->rate . '%)';
+ })->pluck('title', 'name');
+
+ $html = view($invoice->template_path, compact('invoice', 'logo', 'taxes'))->render();
$pdf = \App::make('dompdf.wrapper');
$pdf->loadHTML($html);
@@ -567,7 +573,9 @@ class Invoices extends Controller
$logo = $this->getLogo();
- return view($invoice->template_path, compact('invoice', 'logo'));
+ $taxes = Tax::enabled()->get()->pluck('title', 'name');
+
+ return view($invoice->template_path, compact('invoice', 'logo', 'taxes'));
}
/**
@@ -583,7 +591,9 @@ class Invoices extends Controller
$logo = $this->getLogo();
- $html = view($invoice->template_path, compact('invoice', 'logo'))->render();
+ $taxes = Tax::enabled()->get()->pluck('title', 'name');
+
+ $html = view($invoice->template_path, compact('invoice', 'logo', 'taxes'))->render();
$pdf = \App::make('dompdf.wrapper');
$pdf->loadHTML($html);
diff --git a/app/Http/Controllers/Items/Items.php b/app/Http/Controllers/Items/Items.php
index 2ab8d42bd..96b27f396 100644
--- a/app/Http/Controllers/Items/Items.php
+++ b/app/Http/Controllers/Items/Items.php
@@ -49,7 +49,7 @@ class Items extends Controller
{
$categories = Category::enabled()->type('item')->pluck('name', 'id');
- $taxes = Tax::enabled()->pluck('name', 'id');
+ $taxes = Tax::enabled()->get()->pluck('title', 'id');
return view('items.items.create', compact('categories', 'taxes'));
}
@@ -133,7 +133,7 @@ class Items extends Controller
{
$categories = Category::enabled()->type('item')->pluck('name', 'id');
- $taxes = Tax::enabled()->pluck('name', 'id');
+ $taxes = Tax::enabled()->get()->pluck('title', 'id');
return view('items.items.edit', compact('item', 'categories', 'taxes'));
}
diff --git a/app/Http/Controllers/Settings/Settings.php b/app/Http/Controllers/Settings/Settings.php
index 5b2f15658..919cebeb1 100644
--- a/app/Http/Controllers/Settings/Settings.php
+++ b/app/Http/Controllers/Settings/Settings.php
@@ -47,7 +47,7 @@ class Settings extends Controller
$currencies = Currency::enabled()->pluck('name', 'code');
- $taxes = Tax::enabled()->pluck('name', 'id');
+ $taxes = Tax::enabled()->get()->pluck('title', 'id');
$payment_methods = Modules::getPaymentMethods();
@@ -56,7 +56,7 @@ class Settings extends Controller
'd F Y' => '31 December 2017',
'd m Y' => '31 12 2017',
'm d Y' => '12 31 2017',
- 'Y m d' => '2017 12 31'
+ 'Y m d' => '2017 12 31',
];
$date_separators = [
@@ -71,7 +71,12 @@ class Settings extends Controller
'mail' => trans('settings.email.php'),
'smtp' => trans('settings.email.smtp.name'),
'sendmail' => trans('settings.email.sendmail'),
- 'log' => trans('settings.email.log')
+ 'log' => trans('settings.email.log'),
+ ];
+
+ $percent_positions = [
+ 'before' => trans('settings.localisation.percent.before'),
+ 'after' => trans('settings.localisation.percent.after'),
];
return view('settings.settings.edit', compact(
@@ -83,7 +88,8 @@ class Settings extends Controller
'payment_methods',
'date_formats',
'date_separators',
- 'email_protocols'
+ 'email_protocols',
+ 'percent_positions'
));
}
diff --git a/app/Models/Setting/Tax.php b/app/Models/Setting/Tax.php
index e3d71f6f8..30dd5b67b 100644
--- a/app/Models/Setting/Tax.php
+++ b/app/Models/Setting/Tax.php
@@ -9,6 +9,13 @@ class Tax extends Model
protected $table = 'taxes';
+ /**
+ * The accessors to append to the model's array form.
+ *
+ * @var array
+ */
+ protected $appends = ['title'];
+
/**
* Attributes that should be mass-assignable.
*
@@ -48,4 +55,24 @@ class Tax extends Model
{
$this->attributes['rate'] = (double) $value;
}
+
+ /**
+ * Get the name including rate.
+ *
+ * @return string
+ */
+ public function getTitleAttribute()
+ {
+ $title = $this->name . ' (';
+
+ if (setting('general.percent_position', 'after') == 'after') {
+ $title .= $this->rate . '%';
+ } else {
+ $title .= '%' . $this->rate;
+ }
+
+ $title .= ')';
+
+ return $title;
+ }
}
diff --git a/database/seeds/Settings.php b/database/seeds/Settings.php
index 2f9f9129e..5c27b9392 100644
--- a/database/seeds/Settings.php
+++ b/database/seeds/Settings.php
@@ -30,6 +30,7 @@ class Settings extends Seeder
'general.date_format' => 'd M Y',
'general.date_separator' => 'space',
'general.timezone' => 'Europe/London',
+ 'general.percent_position' => 'after',
'general.invoice_number_prefix' => 'INV-',
'general.invoice_number_digit' => '5',
'general.invoice_number_next' => '1',
diff --git a/resources/lang/en-GB/settings.php b/resources/lang/en-GB/settings.php
index 83c1308f3..20e7cc22b 100644
--- a/resources/lang/en-GB/settings.php
+++ b/resources/lang/en-GB/settings.php
@@ -21,6 +21,11 @@ return [
'space' => 'Space ( )',
],
'timezone' => 'Time Zone',
+ 'percent' => [
+ 'title' => 'Percent (%) Position',
+ 'before' => 'Before Number',
+ 'after' => 'After Number',
+ ],
],
'invoice' => [
'tab' => 'Invoice',
diff --git a/resources/views/expenses/bills/bill.blade.php b/resources/views/expenses/bills/bill.blade.php
index 8fa3bc9cb..d36efcb0a 100644
--- a/resources/views/expenses/bills/bill.blade.php
+++ b/resources/views/expenses/bills/bill.blade.php
@@ -114,10 +114,17 @@
@foreach($bill->totals as $total)
@if ($total->code != 'total')
-
- {{ trans($total['name']) }}: |
- @money($total->amount, $bill->currency_code, true) |
-
+ @if (($total->code == 'tax') && isset($taxes[$total->name]))
+
+ {{ $taxes[$total->name] }}: |
+ @money($total->amount, $bill->currency_code, true) |
+
+ @else
+
+ {{ trans($total->name) }}: |
+ @money($total->amount, $bill->currency_code, true) |
+
+ @endif
@else
@if ($bill->paid)
diff --git a/resources/views/expenses/bills/show.blade.php b/resources/views/expenses/bills/show.blade.php
index adffc2fc4..ecbc1d84e 100644
--- a/resources/views/expenses/bills/show.blade.php
+++ b/resources/views/expenses/bills/show.blade.php
@@ -117,12 +117,19 @@
- @foreach($bill->totals as $total)
+ @foreach ($bill->totals as $total)
@if ($total->code != 'total')
-
- {{ trans($total['name']) }}: |
- @money($total->amount, $bill->currency_code, true) |
-
+ @if (($total->code == 'tax') && isset($taxes[$total->name]))
+
+ {{ $taxes[$total->name] }}: |
+ @money($total->amount, $bill->currency_code, true) |
+
+ @else
+
+ {{ trans($total->name) }}: |
+ @money($total->amount, $bill->currency_code, true) |
+
+ @endif
@else
@if ($bill->paid)
@@ -131,7 +138,7 @@
@endif
- {{ trans($total['name']) }}: |
+ {{ trans($total->name) }}: |
@money($total->amount - $bill->paid, $bill->currency_code, true) |
@endif
diff --git a/resources/views/incomes/invoices/invoice.blade.php b/resources/views/incomes/invoices/invoice.blade.php
index e80137f2d..4cef5201b 100644
--- a/resources/views/incomes/invoices/invoice.blade.php
+++ b/resources/views/incomes/invoices/invoice.blade.php
@@ -112,12 +112,19 @@
- @foreach($invoice->totals as $total)
- @if($total->code != 'total')
-
- {{ trans($total['name']) }}: |
- @money($total->amount, $invoice->currency_code, true) |
-
+ @foreach ($invoice->totals as $total)
+ @if ($total->code != 'total')
+ @if (($total->code == 'tax') && isset($taxes[$total->name]))
+
+ {{ $taxes[$total->name] }}: |
+ @money($total->amount, $invoice->currency_code, true) |
+
+ @else
+
+ {{ trans($total->name) }}: |
+ @money($total->amount, $invoice->currency_code, true) |
+
+ @endif
@else
@if ($invoice->paid)
@@ -126,7 +133,7 @@
@endif
- {{ trans($total['name']) }}: |
+ {{ trans($total->name) }}: |
@money($total->amount - $invoice->paid, $invoice->currency_code, true) |
@endif
diff --git a/resources/views/incomes/invoices/show.blade.php b/resources/views/incomes/invoices/show.blade.php
index 9cef3d092..052a34fc4 100644
--- a/resources/views/incomes/invoices/show.blade.php
+++ b/resources/views/incomes/invoices/show.blade.php
@@ -119,12 +119,19 @@
- @foreach($invoice->totals as $total)
- @if($total->code != 'total')
-
- {{ trans($total['name']) }}: |
- @money($total->amount, $invoice->currency_code, true) |
-
+ @foreach ($invoice->totals as $total)
+ @if ($total->code != 'total')
+ @if (($total->code == 'tax') && isset($taxes[$total->name]))
+
+ {{ $taxes[$total->name] }}: |
+ @money($total->amount, $invoice->currency_code, true) |
+
+ @else
+
+ {{ trans($total->name) }}: |
+ @money($total->amount, $invoice->currency_code, true) |
+
+ @endif
@else
@if ($invoice->paid)
@@ -133,7 +140,7 @@
@endif
- {{ trans($total['name']) }}: |
+ {{ trans($total->name) }}: |
@money($total->amount - $invoice->paid, $invoice->currency_code, true) |
@endif
diff --git a/resources/views/settings/settings/edit.blade.php b/resources/views/settings/settings/edit.blade.php
index 3b078fcdc..9cda125e6 100644
--- a/resources/views/settings/settings/edit.blade.php
+++ b/resources/views/settings/settings/edit.blade.php
@@ -47,6 +47,8 @@
{{ Form::selectGroup('date_separator', trans('settings.localisation.date.separator'), 'minus', $date_separators, null, []) }}
{{ Form::selectGroup('timezone', trans('settings.localisation.timezone'), 'globe', $timezones, null, []) }}
+
+ {{ Form::selectGroup('percent_position', trans('settings.localisation.percent.title'), 'percent', $percent_positions, null, []) }}
@@ -164,6 +166,10 @@
placeholder: "{{ trans('general.form.select.field', ['field' => trans('settings.localisation.timezone')]) }}"
});
+ $("#percent_position").select2({
+ placeholder: "{{ trans('general.form.select.field', ['field' => trans('settings.localisation.percent.title')]) }}"
+ });
+
$("#default_account").select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans('settings.default.account')]) }}"
});