human friendly invoice import/export

This commit is contained in:
denisdulici
2020-01-20 22:58:49 +03:00
parent 8562223ff3
commit 6923a3d6e4
27 changed files with 497 additions and 76 deletions

View File

@@ -125,6 +125,11 @@ class Invoice extends Model
return $query->where('status', '<>', 'paid');
}
public function scopeNumber($query, $number)
{
return $query->where('invoice_number', '=', $number);
}
public function onCloning($src, $child = null)
{
$this->status = 'draft';

View File

@@ -34,7 +34,7 @@ class InvoiceItem extends Model
public function item()
{
return $this->belongsTo('App\Models\Common\Item');
return $this->belongsTo('App\Models\Common\Item')->withDefault(['name' => trans('general.na')]);
}
public function taxes()

View File

@@ -4,11 +4,11 @@ namespace App\Models\Sale;
use App\Abstracts\Model;
use App\Traits\Currencies;
use Znck\Eloquent\Traits\BelongsToThrough;
class InvoiceItemTax extends Model
{
use Currencies;
use Currencies, BelongsToThrough;
protected $table = 'invoice_item_taxes';
@@ -24,9 +24,14 @@ class InvoiceItemTax extends Model
return $this->belongsTo('App\Models\Sale\Invoice');
}
public function item()
{
return $this->belongsToThrough('App\Models\Common\Item', 'App\Models\Sale\InvoiceItem', 'invoice_item_id')->withDefault(['name' => trans('general.na')]);
}
public function tax()
{
return $this->belongsTo('App\Models\Setting\Tax');
return $this->belongsTo('App\Models\Setting\Tax')->withDefault(['name' => trans('general.na')]);
}
/**