fixed #695
This commit is contained in:
		@@ -156,7 +156,7 @@ class ProfitLoss extends Controller
 | 
			
		||||
    private function setAmount(&$totals, &$compares, $items, $type, $date_field)
 | 
			
		||||
    {
 | 
			
		||||
        foreach ($items as $item) {
 | 
			
		||||
            if ($item['table'] == 'bill_payments' || $item['table'] == 'invoice_payments') {
 | 
			
		||||
            if (($item['table'] == 'bill_payments') || ($item['table'] == 'invoice_payments')) {
 | 
			
		||||
                $type_item = $item->$type;
 | 
			
		||||
 | 
			
		||||
                $item->category_id = $type_item->category_id;
 | 
			
		||||
@@ -170,7 +170,7 @@ class ProfitLoss extends Controller
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            $amount = $item->getConvertedAmount();
 | 
			
		||||
            $amount = $item->getConvertedAmount(false, false);
 | 
			
		||||
 | 
			
		||||
            // Forecasting
 | 
			
		||||
            if ((($type == 'invoice') || ($type == 'bill')) && ($date_field == 'due_at')) {
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@ class Bill extends Model
 | 
			
		||||
     *
 | 
			
		||||
     * @var array
 | 
			
		||||
     */
 | 
			
		||||
    protected $appends = ['attachment', 'discount', 'paid'];
 | 
			
		||||
    protected $appends = ['attachment', 'amount_without_tax', 'discount', 'paid'];
 | 
			
		||||
 | 
			
		||||
    protected $dates = ['deleted_at', 'billed_at', 'due_at'];
 | 
			
		||||
 | 
			
		||||
@@ -201,6 +201,22 @@ class Bill extends Model
 | 
			
		||||
        return $percent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the amount without tax.
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     */
 | 
			
		||||
    public function getAmountWithoutTaxAttribute()
 | 
			
		||||
    {
 | 
			
		||||
        $amount = $this->amount;
 | 
			
		||||
 | 
			
		||||
        $this->totals()->where('code', 'tax')->each(function ($tax) use(&$amount) {
 | 
			
		||||
            $amount -= $tax->amount;
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        return $amount;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the paid amount.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ class Invoice extends Model
 | 
			
		||||
     *
 | 
			
		||||
     * @var array
 | 
			
		||||
     */
 | 
			
		||||
    protected $appends = ['attachment', 'discount', 'paid'];
 | 
			
		||||
    protected $appends = ['attachment', 'amount_without_tax', 'discount', 'paid'];
 | 
			
		||||
 | 
			
		||||
    protected $dates = ['deleted_at', 'invoiced_at', 'due_at'];
 | 
			
		||||
 | 
			
		||||
@@ -205,6 +205,22 @@ class Invoice extends Model
 | 
			
		||||
        return $percent;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the amount without tax.
 | 
			
		||||
     *
 | 
			
		||||
     * @return string
 | 
			
		||||
     */
 | 
			
		||||
    public function getAmountWithoutTaxAttribute()
 | 
			
		||||
    {
 | 
			
		||||
        $amount = $this->amount;
 | 
			
		||||
 | 
			
		||||
        $this->totals()->where('code', 'tax')->each(function ($tax) use(&$amount) {
 | 
			
		||||
            $amount -= $tax->amount;
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        return $amount;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Get the paid amount.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -60,18 +60,24 @@ trait Currencies
 | 
			
		||||
        return $money;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getConvertedAmount($format = false)
 | 
			
		||||
    public function getConvertedAmount($format = false, $with_tax = true)
 | 
			
		||||
    {
 | 
			
		||||
        return $this->convert($this->amount, $this->currency_code, $this->currency_rate, $format);
 | 
			
		||||
        $amount = $with_tax ? $this->amount : isset($this->amount_without_tax) ? $this->amount_without_tax : $this->amount;
 | 
			
		||||
 | 
			
		||||
        return $this->convert($amount, $this->currency_code, $this->currency_rate, $format);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getReverseConvertedAmount($format = false)
 | 
			
		||||
    public function getReverseConvertedAmount($format = false, $with_tax = true)
 | 
			
		||||
    {
 | 
			
		||||
        return $this->reverseConvert($this->amount, $this->currency_code, $this->currency_rate, $format);
 | 
			
		||||
        $amount = $with_tax ? $this->amount : isset($this->amount_without_tax) ? $this->amount_without_tax : $this->amount;
 | 
			
		||||
 | 
			
		||||
        return $this->reverseConvert($amount, $this->currency_code, $this->currency_rate, $format);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getDynamicConvertedAmount($format = false)
 | 
			
		||||
    public function getDynamicConvertedAmount($format = false, $with_tax = true)
 | 
			
		||||
    {
 | 
			
		||||
        return $this->dynamicConvert($this->default_currency_code, $this->amount, $this->currency_code, $this->currency_rate, $format);
 | 
			
		||||
        $amount = $with_tax ? $this->amount : isset($this->amount_without_tax) ? $this->amount_without_tax : $this->amount;
 | 
			
		||||
 | 
			
		||||
        return $this->dynamicConvert($this->default_currency_code, $amount, $this->currency_code, $this->currency_rate, $format);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user