mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add bank transactios as default includes
This commit is contained in:
parent
43a29c2bb0
commit
599424d75f
@ -106,6 +106,7 @@ class BaseController extends Controller
|
|||||||
'company.webhooks',
|
'company.webhooks',
|
||||||
'company.system_logs',
|
'company.system_logs',
|
||||||
'company.bank_integrations',
|
'company.bank_integrations',
|
||||||
|
'company.bank_transactions',
|
||||||
];
|
];
|
||||||
|
|
||||||
private $mini_load = [
|
private $mini_load = [
|
||||||
@ -447,6 +448,13 @@ class BaseController extends Controller
|
|||||||
$query->where('bank_integrations.user_id', $user->id);
|
$query->where('bank_integrations.user_id', $user->id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'company.bank_transactions'=> function ($query) use ($updated_at, $user) {
|
||||||
|
$query->whereNotNull('updated_at');
|
||||||
|
|
||||||
|
if (! $user->isAdmin()) {
|
||||||
|
$query->where('bank_transactions.user_id', $user->id);
|
||||||
|
}
|
||||||
|
},
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -763,6 +771,13 @@ class BaseController extends Controller
|
|||||||
$query->where('bank_integrations.user_id', $user->id);
|
$query->where('bank_integrations.user_id', $user->id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
'company.bank_transactions'=> function ($query) use ($created_at, $user) {
|
||||||
|
$query->where('created_at', '>=', $created_at);
|
||||||
|
|
||||||
|
if (! $user->isAdmin()) {
|
||||||
|
$query->where('bank_transactions.user_id', $user->id);
|
||||||
|
}
|
||||||
|
},
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -181,6 +181,11 @@ class Company extends BaseModel
|
|||||||
return $this->hasMany(BankIntegration::class);
|
return $this->hasMany(BankIntegration::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function bank_transactions()
|
||||||
|
{
|
||||||
|
return $this->hasMany(BankTransaction::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function getCompanyIdAttribute()
|
public function getCompanyIdAttribute()
|
||||||
{
|
{
|
||||||
return $this->encodePrimaryKey($this->id);
|
return $this->encodePrimaryKey($this->id);
|
||||||
|
@ -14,6 +14,7 @@ namespace App\Transformers;
|
|||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\Activity;
|
use App\Models\Activity;
|
||||||
use App\Models\BankIntegration;
|
use App\Models\BankIntegration;
|
||||||
|
use App\Models\BankTransaction;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\CompanyGateway;
|
use App\Models\CompanyGateway;
|
||||||
@ -42,6 +43,7 @@ use App\Models\TaxRate;
|
|||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Webhook;
|
use App\Models\Webhook;
|
||||||
use App\Transformers\BankIntegrationTransformer;
|
use App\Transformers\BankIntegrationTransformer;
|
||||||
|
use App\Transformers\BankTransactionTransformer;
|
||||||
use App\Transformers\PurchaseOrderTransformer;
|
use App\Transformers\PurchaseOrderTransformer;
|
||||||
use App\Transformers\RecurringExpenseTransformer;
|
use App\Transformers\RecurringExpenseTransformer;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -101,6 +103,7 @@ class CompanyTransformer extends EntityTransformer
|
|||||||
'recurring_expenses',
|
'recurring_expenses',
|
||||||
'purchase_orders',
|
'purchase_orders',
|
||||||
'bank_integrations',
|
'bank_integrations',
|
||||||
|
'bank_transactions',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -227,6 +230,13 @@ class CompanyTransformer extends EntityTransformer
|
|||||||
return $this->includeCollection($company->bank_integrations, $transformer, BankIntegration::class);
|
return $this->includeCollection($company->bank_integrations, $transformer, BankIntegration::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function includeBankTransactions(Company $company)
|
||||||
|
{
|
||||||
|
$transformer = new BankTransactionTransformer($this->serializer);
|
||||||
|
|
||||||
|
return $this->includeCollection($company->bank_transactions(), $transformer, BankTransaction::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function includeTokensHashed(Company $company)
|
public function includeTokensHashed(Company $company)
|
||||||
{
|
{
|
||||||
$transformer = new CompanyTokenHashedTransformer($this->serializer);
|
$transformer = new CompanyTokenHashedTransformer($this->serializer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user