fixed tax report
This commit is contained in:
parent
654bd509bd
commit
7beb5a7fad
@ -12,6 +12,13 @@ class BillTotal extends Model
|
||||
|
||||
protected $table = 'bill_totals';
|
||||
|
||||
/**
|
||||
* The accessors to append to the model's array form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = ['title'];
|
||||
|
||||
/**
|
||||
* Attributes that should be mass-assignable.
|
||||
*
|
||||
@ -40,39 +47,40 @@ class BillTotal extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNameAttribute($value)
|
||||
public function getTitleAttribute()
|
||||
{
|
||||
$name = $value;
|
||||
$title = $this->name;
|
||||
|
||||
$percent = 0;
|
||||
|
||||
// Discount
|
||||
if ($this->code == 'discount') {
|
||||
$name = trans($name);
|
||||
$percent = $this->bill->discount;
|
||||
}
|
||||
switch ($this->code) {
|
||||
case 'discount':
|
||||
$title = trans($title);
|
||||
$percent = $this->bill->discount;
|
||||
|
||||
// Tax
|
||||
if ($this->code == 'tax') {
|
||||
$rate = Tax::where('name', $name)->value('rate');
|
||||
break;
|
||||
case 'tax':
|
||||
$rate = Tax::where('name', $title)->value('rate');
|
||||
|
||||
if (!empty($rate)) {
|
||||
$percent = $rate;
|
||||
}
|
||||
if (!empty($rate)) {
|
||||
$percent = $rate;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($percent)) {
|
||||
$name .= ' (';
|
||||
$title .= ' (';
|
||||
|
||||
if (setting('general.percent_position', 'after') == 'after') {
|
||||
$name .= $percent . '%';
|
||||
$title .= $percent . '%';
|
||||
} else {
|
||||
$name .= '%' . $percent;
|
||||
$title .= '%' . $percent;
|
||||
}
|
||||
|
||||
$name .= ')';
|
||||
$title .= ')';
|
||||
}
|
||||
|
||||
return $name;
|
||||
return $title;
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,13 @@ class InvoiceTotal extends Model
|
||||
|
||||
protected $table = 'invoice_totals';
|
||||
|
||||
/**
|
||||
* The accessors to append to the model's array form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = ['title'];
|
||||
|
||||
/**
|
||||
* Attributes that should be mass-assignable.
|
||||
*
|
||||
@ -40,39 +47,40 @@ class InvoiceTotal extends Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getNameAttribute($value)
|
||||
public function getTitleAttribute()
|
||||
{
|
||||
$name = $value;
|
||||
$title = $this->name;
|
||||
|
||||
$percent = 0;
|
||||
|
||||
// Discount
|
||||
if ($this->code == 'discount') {
|
||||
$name = trans($name);
|
||||
$percent = $this->invoice->discount;
|
||||
}
|
||||
switch ($this->code) {
|
||||
case 'discount':
|
||||
$title = trans($title);
|
||||
$percent = $this->invoice->discount;
|
||||
|
||||
// Tax
|
||||
if ($this->code == 'tax') {
|
||||
$rate = Tax::where('name', $name)->value('rate');
|
||||
break;
|
||||
case 'tax':
|
||||
$rate = Tax::where('name', $title)->value('rate');
|
||||
|
||||
if (!empty($rate)) {
|
||||
$percent = $rate;
|
||||
}
|
||||
if (!empty($rate)) {
|
||||
$percent = $rate;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($percent)) {
|
||||
$name .= ' (';
|
||||
$title .= ' (';
|
||||
|
||||
if (setting('general.percent_position', 'after') == 'after') {
|
||||
$name .= $percent . '%';
|
||||
$title .= $percent . '%';
|
||||
} else {
|
||||
$name .= '%' . $percent;
|
||||
$title .= '%' . $percent;
|
||||
}
|
||||
|
||||
$name .= ')';
|
||||
$title .= ')';
|
||||
}
|
||||
|
||||
return $name;
|
||||
return $title;
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@
|
||||
@foreach($bill->totals as $total)
|
||||
@if ($total->code != 'total')
|
||||
<tr>
|
||||
<th>{{ trans($total->name) }}:</th>
|
||||
<th>{{ trans($total->title) }}:</th>
|
||||
<td class="text-right">@money($total->amount, $bill->currency_code, true)</td>
|
||||
</tr>
|
||||
@else
|
||||
@ -126,7 +126,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
|
||||
|
@ -132,7 +132,7 @@
|
||||
@foreach ($bill->totals as $total)
|
||||
@if ($total->code != 'total')
|
||||
<tr>
|
||||
<th>{{ trans($total->name) }}:</th>
|
||||
<th>{{ trans($total->title) }}:</th>
|
||||
<td class="text-right">@money($total->amount, $bill->currency_code, true)</td>
|
||||
</tr>
|
||||
@else
|
||||
|
@ -115,7 +115,7 @@
|
||||
@foreach ($invoice->totals as $total)
|
||||
@if ($total->code != 'total')
|
||||
<tr>
|
||||
<th>{{ trans($total->name) }}:</th>
|
||||
<th>{{ trans($total->title) }}:</th>
|
||||
<td class="text-right">@money($total->amount, $invoice->currency_code, true)</td>
|
||||
</tr>
|
||||
@else
|
||||
|
@ -134,7 +134,7 @@
|
||||
@foreach ($invoice->totals as $total)
|
||||
@if ($total->code != 'total')
|
||||
<tr>
|
||||
<th>{{ trans($total->name) }}:</th>
|
||||
<th>{{ trans($total->title) }}:</th>
|
||||
<td class="text-right">@money($total->amount, $invoice->currency_code, true)</td>
|
||||
</tr>
|
||||
@else
|
||||
|
Loading…
x
Reference in New Issue
Block a user