mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-29 18:20:01 +00:00
Add enrichment
This commit is contained in:
@@ -31,6 +31,7 @@ use FireflyIII\Models\Account;
|
|||||||
use FireflyIII\Models\PiggyBank;
|
use FireflyIII\Models\PiggyBank;
|
||||||
use FireflyIII\Repositories\ObjectGroup\OrganisesObjectGroups;
|
use FireflyIII\Repositories\ObjectGroup\OrganisesObjectGroups;
|
||||||
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
|
||||||
|
use FireflyIII\Support\JsonApi\Enrichments\AccountEnrichment;
|
||||||
use FireflyIII\Transformers\AccountTransformer;
|
use FireflyIII\Transformers\AccountTransformer;
|
||||||
use FireflyIII\Transformers\PiggyBankTransformer;
|
use FireflyIII\Transformers\PiggyBankTransformer;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
@@ -87,13 +88,13 @@ class IndexController extends Controller
|
|||||||
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
$end = session('end', today(config('app.timezone'))->endOfMonth());
|
||||||
|
|
||||||
// transform piggies using the transformer:
|
// transform piggies using the transformer:
|
||||||
$parameters = new ParameterBag();
|
//$parameters = new ParameterBag();
|
||||||
$parameters->set('end', $end);
|
//$parameters->set('end', $end);
|
||||||
|
|
||||||
|
|
||||||
/** @var AccountTransformer $accountTransformer */
|
///** @var AccountTransformer $accountTransformer */
|
||||||
$accountTransformer = app(AccountTransformer::class);
|
//$accountTransformer = app(AccountTransformer::class);
|
||||||
$accountTransformer->setParameters($parameters);
|
//$accountTransformer->setParameters($parameters);
|
||||||
|
|
||||||
// data
|
// data
|
||||||
$piggyBanks = $this->groupPiggyBanks($collection);
|
$piggyBanks = $this->groupPiggyBanks($collection);
|
||||||
@@ -144,6 +145,9 @@ class IndexController extends Controller
|
|||||||
$accountTransformer = app(AccountTransformer::class);
|
$accountTransformer = app(AccountTransformer::class);
|
||||||
$accountTransformer->setParameters($parameters);
|
$accountTransformer->setParameters($parameters);
|
||||||
|
|
||||||
|
// enrich each account.
|
||||||
|
$enrichment = new AccountEnrichment();
|
||||||
|
|
||||||
$return = [];
|
$return = [];
|
||||||
|
|
||||||
/** @var PiggyBank $piggy */
|
/** @var PiggyBank $piggy */
|
||||||
@@ -152,6 +156,7 @@ class IndexController extends Controller
|
|||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
|
$account = $enrichment->enrichSingle($account);
|
||||||
$array = $accountTransformer->transform($account);
|
$array = $accountTransformer->transform($account);
|
||||||
$accountId = (int) $array['id'];
|
$accountId = (int) $array['id'];
|
||||||
if (!array_key_exists($accountId, $return)) {
|
if (!array_key_exists($accountId, $return)) {
|
||||||
|
@@ -65,7 +65,7 @@ class AccountTransformer extends AbstractTransformer
|
|||||||
if(null === $account->meta) {
|
if(null === $account->meta) {
|
||||||
$account->meta = [];
|
$account->meta = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// get account type:
|
// get account type:
|
||||||
$accountType = (string) config(sprintf('firefly.shortNamesByFullName.%s', $account->full_account_type));
|
$accountType = (string) config(sprintf('firefly.shortNamesByFullName.%s', $account->full_account_type));
|
||||||
$liabilityType = (string) config(sprintf('firefly.shortLiabilityNameByFullName.%s', $account->full_account_type));
|
$liabilityType = (string) config(sprintf('firefly.shortLiabilityNameByFullName.%s', $account->full_account_type));
|
||||||
|
Reference in New Issue
Block a user