Enabled console invoice generation
This commit is contained in:
@@ -6,14 +6,22 @@ use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
use App\Traits\NextKey;
|
||||
use App\Traits\PushNew;
|
||||
use Leenooks\Carbon;
|
||||
|
||||
class InvoiceItem extends Model
|
||||
{
|
||||
protected $dates = ['date_start','date_stop'];
|
||||
public $dateFormat = 'U';
|
||||
use NextKey,PushNew;
|
||||
const RECORD_ID = 'invoice_item';
|
||||
public $incrementing = FALSE;
|
||||
|
||||
protected $table = 'ab_invoice_item';
|
||||
const CREATED_AT = 'date_orig';
|
||||
const UPDATED_AT = 'date_last';
|
||||
|
||||
protected $dates = ['date_start','date_stop'];
|
||||
public $dateFormat = 'U';
|
||||
|
||||
private $_tax = 0;
|
||||
|
||||
@@ -115,6 +123,7 @@ class InvoiceItem extends Model
|
||||
{
|
||||
return $this->quantity * $this->price_base;
|
||||
}
|
||||
|
||||
public function getTaxAttribute()
|
||||
{
|
||||
if (! $this->_tax)
|
||||
@@ -149,6 +158,7 @@ class InvoiceItem extends Model
|
||||
$iit = new InvoiceItemTax;
|
||||
$iit->tax_id = $to->id;
|
||||
$iit->amount = round($this->quantity*$this->price_base*$to->rate,3);
|
||||
$iit->site_id = 1;
|
||||
$this->taxes->push($iit);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user