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 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');
}
/**