This commit is contained in:
denisdulici
2018-12-22 14:59:58 +03:00
parent 44fe707b09
commit ca0b21b583
4 changed files with 48 additions and 10 deletions

View File

@ -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.
*