Skip to content

Commit

Permalink
close #1340 Fixed: Missing edit invoice and bill item taxes.
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Mar 10, 2020
1 parent f05425b commit 397b050
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app/Models/Purchase/BillItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ class BillItem extends Model
*/
public $cloneable_relations = ['taxes'];

public static function boot()
{
parent::boot();

static::retrieved(function($model) {
$model->setTaxIds();
});
}

public function bill()
{
return $this->belongsTo('App\Models\Purchase\Bill');
Expand Down Expand Up @@ -74,4 +83,20 @@ public function setTaxAttribute($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);
}
}
25 changes: 25 additions & 0 deletions app/Models/Sale/InvoiceItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ class InvoiceItem extends Model
*/
public $cloneable_relations = ['taxes'];

public static function boot()
{
parent::boot();

static::retrieved(function($model) {
$model->setTaxIds();
});
}

public function invoice()
{
return $this->belongsTo('App\Models\Sale\Invoice');
Expand Down Expand Up @@ -73,4 +82,20 @@ public function setTaxAttribute($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);
}
}

0 comments on commit 397b050

Please sign in to comment.