This commit is contained in:
denisdulici 2018-04-16 19:01:29 +03:00
parent 7897300cb8
commit d2b0a816e3
12 changed files with 130 additions and 41 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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'));
}

View File

@ -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'
));
}

View File

@ -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;
}
}

View File

@ -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',

View File

@ -21,6 +21,11 @@ return [
'space' => 'Space ( )',
],
'timezone' => 'Time Zone',
'percent' => [
'title' => 'Percent (%) Position',
'before' => 'Before Number',
'after' => 'After Number',
],
],
'invoice' => [
'tab' => 'Invoice',

View File

@ -114,10 +114,17 @@
<tbody>
@foreach($bill->totals as $total)
@if ($total->code != 'total')
<tr>
<th>{{ trans($total['name']) }}:</th>
<td class="text-right">@money($total->amount, $bill->currency_code, true)</td>
</tr>
@if (($total->code == 'tax') && isset($taxes[$total->name]))
<tr>
<th>{{ $taxes[$total->name] }}:</th>
<td class="text-right">@money($total->amount, $bill->currency_code, true)</td>
</tr>
@else
<tr>
<th>{{ trans($total->name) }}:</th>
<td class="text-right">@money($total->amount, $bill->currency_code, true)</td>
</tr>
@endif
@else
@if ($bill->paid)
<tr class="text-success">

View File

@ -117,12 +117,19 @@
<div class="table-responsive">
<table class="table">
<tbody>
@foreach($bill->totals as $total)
@foreach ($bill->totals as $total)
@if ($total->code != 'total')
<tr>
<th>{{ trans($total['name']) }}:</th>
<td class="text-right">@money($total->amount, $bill->currency_code, true)</td>
</tr>
@if (($total->code == 'tax') && isset($taxes[$total->name]))
<tr>
<th>{{ $taxes[$total->name] }}:</th>
<td class="text-right">@money($total->amount, $bill->currency_code, true)</td>
</tr>
@else
<tr>
<th>{{ trans($total->name) }}:</th>
<td class="text-right">@money($total->amount, $bill->currency_code, true)</td>
</tr>
@endif
@else
@if ($bill->paid)
<tr class="text-success">
@ -131,7 +138,7 @@
</tr>
@endif
<tr>
<th>{{ trans($total['name']) }}:</th>
<th>{{ trans($total->name) }}:</th>
<td class="text-right">@money($total->amount - $bill->paid, $bill->currency_code, true)</td>
</tr>
@endif

View File

@ -112,12 +112,19 @@
<div class="table-responsive">
<table class="table">
<tbody>
@foreach($invoice->totals as $total)
@if($total->code != 'total')
<tr>
<th>{{ trans($total['name']) }}:</th>
<td class="text-right">@money($total->amount, $invoice->currency_code, true)</td>
</tr>
@foreach ($invoice->totals as $total)
@if ($total->code != 'total')
@if (($total->code == 'tax') && isset($taxes[$total->name]))
<tr>
<th>{{ $taxes[$total->name] }}:</th>
<td class="text-right">@money($total->amount, $invoice->currency_code, true)</td>
</tr>
@else
<tr>
<th>{{ trans($total->name) }}:</th>
<td class="text-right">@money($total->amount, $invoice->currency_code, true)</td>
</tr>
@endif
@else
@if ($invoice->paid)
<tr class="text-success">
@ -126,7 +133,7 @@
</tr>
@endif
<tr>
<th>{{ trans($total['name']) }}:</th>
<th>{{ trans($total->name) }}:</th>
<td class="text-right">@money($total->amount - $invoice->paid, $invoice->currency_code, true)</td>
</tr>
@endif

View File

@ -119,12 +119,19 @@
<div class="table-responsive">
<table class="table">
<tbody>
@foreach($invoice->totals as $total)
@if($total->code != 'total')
<tr>
<th>{{ trans($total['name']) }}:</th>
<td class="text-right">@money($total->amount, $invoice->currency_code, true)</td>
</tr>
@foreach ($invoice->totals as $total)
@if ($total->code != 'total')
@if (($total->code == 'tax') && isset($taxes[$total->name]))
<tr>
<th>{{ $taxes[$total->name] }}:</th>
<td class="text-right">@money($total->amount, $invoice->currency_code, true)</td>
</tr>
@else
<tr>
<th>{{ trans($total->name) }}:</th>
<td class="text-right">@money($total->amount, $invoice->currency_code, true)</td>
</tr>
@endif
@else
@if ($invoice->paid)
<tr class="text-success">
@ -133,7 +140,7 @@
</tr>
@endif
<tr>
<th>{{ trans($total['name']) }}:</th>
<th>{{ trans($total->name) }}:</th>
<td class="text-right">@money($total->amount - $invoice->paid, $invoice->currency_code, true)</td>
</tr>
@endif

View File

@ -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, []) }}
</div>
<div class="tab-pane tab-margin" id="invoice">
@ -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')]) }}"
});