Initial refactoring work

This commit is contained in:
Deon George
2018-05-20 22:53:14 +10:00
parent d6cb505e1c
commit feda44db8a
121 changed files with 6601 additions and 602 deletions

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class InvoiceItem extends Model
{
protected $table = 'ab_invoice_item';
protected $with = ['taxes'];
private $_tax = 0;
public function invoice()
{
return $this->belongsTo(Invoice::class);
}
public function taxes()
{
return $this->hasMany(InvoiceItemTax::class);
}
public function getSubTotalAttribute()
{
return $this->quantity * $this->price_base;
}
public function getTaxAttribute()
{
if (! $this->_tax)
{
foreach ($this->taxes as $o)
{
$this->_tax += $o->amount;
}
}
return $this->_tax;
}
public function getTotalAttribute()
{
return $this->tax + $this->sub_total;
}
}