v2 first commit

This commit is contained in:
denisdulici
2019-11-16 10:21:14 +03:00
parent 5b23e9c2c4
commit 6d50fa8442
3075 changed files with 3451681 additions and 65594 deletions

View File

@ -2,7 +2,7 @@
namespace App\Models\Setting;
use App\Models\Model;
use App\Abstracts\Model;
class Category extends Model
{
@ -39,24 +39,33 @@ class Category extends Model
public function payments()
{
return $this->hasMany('App\Models\Expense\Payment');
return $this->transactions()->where('type', 'expense');
}
public function revenues()
{
return $this->hasMany('App\Models\Income\Revenue');
return $this->transactions()->where('type', 'income');
}
public function transactions()
{
return $this->hasMany('App\Models\Banking\Transaction');
}
/**
* Scope to only include categories of a given type.
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param mixed $type
* @param mixed $types
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeType($query, $type)
public function scopeType($query, $types)
{
return $query->whereIn('type', (array) $type);
if (empty($types)) {
return $query;
}
return $query->whereIn('type', (array) $types);
}
/**

View File

@ -2,7 +2,7 @@
namespace App\Models\Setting;
use App\Models\Model;
use App\Abstracts\Model;
class Currency extends Model
{
@ -28,9 +28,19 @@ class Currency extends Model
return $this->hasMany('App\Models\Banking\Account', 'currency_code', 'code');
}
public function bills()
{
return $this->hasMany('App\Models\Expense\Bill', 'currency_code', 'code');
}
public function contacts()
{
return $this->hasMany('App\Models\Common\Contact', 'currency_code', 'code');
}
public function customers()
{
return $this->hasMany('App\Models\Income\Customer', 'currency_code', 'code');
return $this->contacts()->where('type', 'customer');
}
public function invoices()
@ -38,29 +48,24 @@ class Currency extends Model
return $this->hasMany('App\Models\Income\Invoice', 'currency_code', 'code');
}
public function invoice_payments()
public function payments()
{
return $this->hasMany('App\Models\Income\InvoicePayment', 'currency_code', 'code');
return $this->transactions()->where('type', 'expense');
}
public function revenues()
{
return $this->hasMany('App\Models\Income\Revenue', 'currency_code', 'code');
return $this->transactions()->where('type', 'income');
}
public function bills()
public function transactions()
{
return $this->hasMany('App\Models\Expense\Bill', 'currency_code', 'code');
return $this->hasMany('App\Models\Banking\Transaction', 'currency_code', 'code');
}
public function bill_payments()
public function vendors()
{
return $this->hasMany('App\Models\Expense\BillPayment', 'currency_code', 'code');
}
public function payments()
{
return $this->hasMany('App\Models\Expense\Payment', 'currency_code', 'code');
return $this->contacts()->where('type', 'vendor');
}
/**

View File

@ -3,9 +3,9 @@
namespace App\Models\Setting;
use App\Scopes\Company;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Model as Eloquent;
class Setting extends Model
class Setting extends Eloquent
{
protected $table = 'settings';

View File

@ -2,7 +2,7 @@
namespace App\Models\Setting;
use App\Models\Model;
use App\Abstracts\Model;
class Tax extends Model
{
@ -65,12 +65,11 @@ class Tax extends Model
{
$title = $this->name . ' (';
if (setting('general.percent_position', 'after') == 'after') {
$title .= $this->rate . '%';
if (setting('localisation.percent_position', 'after') == 'after') {
$title .= $this->getAttribute('type') == 'fixed' ? $this->rate : $this->rate . '%';
} else {
$title .= '%' . $this->rate;
$title .= $this->getAttribute('type') == 'fixed' ? $this->rate : '%' . $this->rate;
}
$title .= ')';
return $title;