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