close #1340 Fixed: Missing edit invoice and bill item taxes.

This commit is contained in:
Cüneyt Şentürk 2020-03-10 17:25:22 +03:00
parent f05425b091
commit 397b050eae
2 changed files with 50 additions and 0 deletions

View File

@ -27,6 +27,15 @@ class BillItem extends Model
*/ */
public $cloneable_relations = ['taxes']; public $cloneable_relations = ['taxes'];
public static function boot()
{
parent::boot();
static::retrieved(function($model) {
$model->setTaxIds();
});
}
public function bill() public function bill()
{ {
return $this->belongsTo('App\Models\Purchase\Bill'); return $this->belongsTo('App\Models\Purchase\Bill');
@ -74,4 +83,20 @@ class BillItem extends Model
{ {
$this->attributes['tax'] = (double) $value; $this->attributes['tax'] = (double) $value;
} }
/**
* Convert tax to Array.
*
* @return void
*/
public function setTaxIds()
{
$tax_ids = [];
foreach ($this->taxes as $tax) {
$tax_ids[] = (string) $tax->tax_id;
}
$this->setAttribute('tax_id', $tax_ids);
}
} }

View File

@ -26,6 +26,15 @@ class InvoiceItem extends Model
*/ */
public $cloneable_relations = ['taxes']; public $cloneable_relations = ['taxes'];
public static function boot()
{
parent::boot();
static::retrieved(function($model) {
$model->setTaxIds();
});
}
public function invoice() public function invoice()
{ {
return $this->belongsTo('App\Models\Sale\Invoice'); return $this->belongsTo('App\Models\Sale\Invoice');
@ -73,4 +82,20 @@ class InvoiceItem extends Model
{ {
$this->attributes['tax'] = (double) $value; $this->attributes['tax'] = (double) $value;
} }
/**
* Convert tax to Array.
*
* @return void
*/
public function setTaxIds()
{
$tax_ids = [];
foreach ($this->taxes as $tax) {
$tax_ids[] = (string) $tax->tax_id;
}
$this->setAttribute('tax_id', $tax_ids);
}
} }