human friendly invoice import/export
This commit is contained in:
@ -49,6 +49,16 @@ class Account extends Model
|
||||
return $this->hasMany('App\Models\Banking\Transaction');
|
||||
}
|
||||
|
||||
public function scopeName($query, $name)
|
||||
{
|
||||
return $query->where('name', '=', $name);
|
||||
}
|
||||
|
||||
public function scopeNumber($query, $number)
|
||||
{
|
||||
return $query->where('number', '=', $number);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert opening balance to double.
|
||||
*
|
||||
|
@ -79,6 +79,11 @@ class Contact extends Model
|
||||
return $query->whereIn('type', (array) $types);
|
||||
}
|
||||
|
||||
public function scopeEmail($query, $email)
|
||||
{
|
||||
return $query->where('email', '=', $email);
|
||||
}
|
||||
|
||||
public function onCloning($src, $child = null)
|
||||
{
|
||||
$this->user_id = null;
|
||||
|
@ -36,12 +36,12 @@ class Item extends Model
|
||||
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Setting\Category');
|
||||
return $this->belongsTo('App\Models\Setting\Category')->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')]);
|
||||
}
|
||||
|
||||
public function bill_items()
|
||||
@ -54,6 +54,11 @@ class Item extends Model
|
||||
return $this->hasMany('App\Models\Sale\InvoiceItem');
|
||||
}
|
||||
|
||||
public function scopeName($query, $name)
|
||||
{
|
||||
return $query->where('name', '=', $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert sale price to double.
|
||||
*
|
||||
|
@ -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';
|
||||
|
@ -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()
|
||||
|
@ -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')]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,6 +68,11 @@ class Category extends Model
|
||||
return $query->whereIn('type', (array) $types);
|
||||
}
|
||||
|
||||
public function scopeName($query, $name)
|
||||
{
|
||||
return $query->where('name', '=', $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope transfer category.
|
||||
*
|
||||
|
@ -44,6 +44,16 @@ class Tax extends Model
|
||||
return $this->hasMany('App\Models\Sale\InvoiceItemTax');
|
||||
}
|
||||
|
||||
public function scopeName($query, $name)
|
||||
{
|
||||
return $query->where('name', '=', $name);
|
||||
}
|
||||
|
||||
public function scopeRate($query, $rate)
|
||||
{
|
||||
return $query->where('rate', '=', $rate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert rate to double.
|
||||
*
|
||||
|
Reference in New Issue
Block a user