1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 13:12:50 +01:00

Add rules to company transformer

This commit is contained in:
David Bomba 2022-11-21 21:49:33 +11:00
parent d046989e84
commit 4b4e023cb3
2 changed files with 15 additions and 0 deletions

View File

@ -189,6 +189,11 @@ class Company extends BaseModel
return $this->hasMany(BankTransaction::class); return $this->hasMany(BankTransaction::class);
} }
public function bank_transaction_rules()
{
return $this->hasMany(BankTransactionRule::class);
}
public function getCompanyIdAttribute() public function getCompanyIdAttribute()
{ {
return $this->encodePrimaryKey($this->id); return $this->encodePrimaryKey($this->id);

View File

@ -43,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\BankTransactionRuleTransformer;
use App\Transformers\BankTransactionTransformer; use App\Transformers\BankTransactionTransformer;
use App\Transformers\PurchaseOrderTransformer; use App\Transformers\PurchaseOrderTransformer;
use App\Transformers\RecurringExpenseTransformer; use App\Transformers\RecurringExpenseTransformer;
@ -104,6 +105,7 @@ class CompanyTransformer extends EntityTransformer
'purchase_orders', 'purchase_orders',
'bank_integrations', 'bank_integrations',
'bank_transactions', 'bank_transactions',
'bank_transaction_rules',
]; ];
/** /**
@ -231,6 +233,14 @@ class CompanyTransformer extends EntityTransformer
return $this->includeCollection($company->bank_transactions, $transformer, BankTransaction::class); return $this->includeCollection($company->bank_transactions, $transformer, BankTransaction::class);
} }
public function includeBankTransactionRules(Company $company)
{
$transformer = new BankTransactionRuleTransformer($this->serializer);
return $this->includeCollection($company->bank_transaction_rules, $transformer, BankTransactionRule::class);
}
public function includeBankIntegrations(Company $company) public function includeBankIntegrations(Company $company)
{ {
$transformer = new BankIntegrationTransformer($this->serializer); $transformer = new BankIntegrationTransformer($this->serializer);