diff --git a/app/JsonApi/V3/Accounts/AccountRepository.php b/app/JsonApi/V3/Accounts/AccountRepository.php deleted file mode 100644 index 248dd6fbff..0000000000 --- a/app/JsonApi/V3/Accounts/AccountRepository.php +++ /dev/null @@ -1,71 +0,0 @@ -withUserGroup($this->userGroup) - ->withServer($this->server) - ->withSchema($this->schema); - } - -} diff --git a/app/JsonApi/V3/Accounts/AccountResource.php b/app/JsonApi/V3/Accounts/AccountResource.php deleted file mode 100644 index 36e97d061d..0000000000 --- a/app/JsonApi/V3/Accounts/AccountResource.php +++ /dev/null @@ -1,160 +0,0 @@ -resource->id; - } - - /** - * Get the resource's attributes. - * - * @param Request|null $request - * - * @return iterable - */ - public function attributes($request): iterable - { - return [ - 'created_at' => $this->resource->created_at, - 'updated_at' => $this->resource->updated_at, - 'name' => $this->resource->name, - 'iban' => '' === $this->resource->iban ? null : $this->resource->iban, - 'active' => $this->resource->active, -// 'virtual_balance' => $this->resource->virtual_balance, - 'last_activity' => $this->resource->last_activity, -// 'native_balance' => $this->resource->native_balance, - 'type' => $this->resource->type, - 'account_role' => $this->resource->account_role, - //'user' => $this->resource->user_array, -// 'balances' => [] -// - // currency -// 'currency_id' => $this->resource->currency_id, -// 'currency_code' => $this->resource->currency_code, -// 'currency_symbol' => $this->resource->currency_symbol, -// 'currency_decimal_places' => $this->resource->currency_decimal_places, - - // balance (in currency, on date) -// 'current_balance' => $this->resource->current_balance, - - - // 'current_balance' => app('steam')->bcround(app('steam')->balance($account, $date), $decimalPlaces), - // 'current_balance_date' => $date->toAtomString(), - // 'notes' => $this->repository->getNoteText($account), - // 'monthly_payment_date' => $monthlyPaymentDate, - // 'credit_card_type' => $creditCardType, - // 'account_number' => $this->repository->getMetaValue($account, 'account_number'), - // 'bic' => $this->repository->getMetaValue($account, 'BIC'), - // 'opening_balance' => $openingBalance, - // 'opening_balance_date' => $openingBalanceDate, - // 'liability_type' => $liabilityType, - // 'liability_direction' => $liabilityDirection, - // 'interest' => $interest, - // 'interest_period' => $interestPeriod, - // 'current_debt' => $this->repository->getMetaValue($account, 'current_debt'), - // 'include_net_worth' => $includeNetWorth, - // 'longitude' => $longitude, - // 'latitude' => $latitude, - // 'zoom_level' => $zoomLevel, - - // 'order' => $order, - - // 'currency_id' => (string) $currency->id, - // 'currency_code' => $currency->code, - // 'currency_symbol' => $currency->symbol, - // 'currency_decimal_places' => $currency->decimal_places, - // - // 'native_currency_id' => (string) $this->default->id, - // 'native_currency_code' => $this->default->code, - // 'native_currency_symbol' => $this->default->symbol, - // 'native_currency_decimal_places' => $this->default->decimal_places, - // - // // balance: - // 'current_balance' => $balance, - // 'native_current_balance' => $nativeBalance, - // 'current_balance_date' => $this->getDate()->endOfDay()->toAtomString(), - // - // // balance difference - // 'balance_difference' => $balanceDiff, - // 'native_balance_difference' => $nativeBalanceDiff, - // 'balance_difference_start' => $diffStart, - // 'balance_difference_end' => $diffEnd, - // - // // more meta - // 'last_activity' => array_key_exists($id, $this->lastActivity) ? $this->lastActivity[$id]->toAtomString() : null, - // - // // liability stuff - // 'liability_type' => $liabilityType, - // 'liability_direction' => $liabilityDirection, - // 'interest' => $interest, - // 'interest_period' => $interestPeriod, - // 'current_debt' => $currentDebt, - // - // // object group - // 'object_group_id' => null !== $objectGroupId ? (string) $objectGroupId : null, - // 'object_group_order' => $objectGroupOrder, - // 'object_group_title' => $objectGroupTitle, - // 'notes' => $this->repository->getNoteText($account), - // 'monthly_payment_date' => $monthlyPaymentDate, - // 'credit_card_type' => $creditCardType, - // 'bic' => $this->repository->getMetaValue($account, 'BIC'), - // 'virtual_balance' => number_format((float) $account->virtual_balance, $decimalPlaces, '.', ''), - // 'opening_balance' => $openingBalance, - // 'opening_balance_date' => $openingBalanceDate, - // 'include_net_worth' => $includeNetWorth, - // 'longitude' => $longitude, - // 'latitude' => $latitude, - // 'zoom_level' => $zoomLevel, - ]; - } - - /** - * Get the resource's relationships. - * - * @param Request|null $request - * - * @return iterable - */ - public function relationships($request): iterable - { - return [ - $this->relation('user')->withData($this->resource->user_array), - $this->relation('balances')->withData([]), - //$this->relation('tags')->withData($this->resource->getTags()), - ]; - } -} diff --git a/app/JsonApi/V3/Accounts/AccountSchema.php b/app/JsonApi/V3/Accounts/AccountSchema.php deleted file mode 100644 index 5710731f5c..0000000000 --- a/app/JsonApi/V3/Accounts/AccountSchema.php +++ /dev/null @@ -1,220 +0,0 @@ -sortable()->readOnly(), - DateTime::make('updated_at')->sortable()->readOnly(), - Attribute::make('name')->sortable(), - Attribute::make('iban'), - Attribute::make('active'), - - Attribute::make('last_activity')->sortable(), - Attribute::make('type'), - Attribute::make('account_role'), - - ToOne::make('user'), - ToMany::make('balances'), - - // currency -// Attribute::make('currency_id'), -// Attribute::make('currency_code'), -// Attribute::make('currency_symbol'), -// Attribute::make('currency_decimal_places'), -// -// // native currency -// Attribute::make('native_currency_id'), -// Attribute::make('native_currency_code'), -// Attribute::make('native_currency_symbol'), -// Attribute::make('native_currency_decimal_places'), -// -// // current balance (in currency, on date) -// Attribute::make('current_balance')->sortable(), -// Attribute::make('current_balance_date'), -// -// // native current balance (in native currency) -// Attribute::make('native_current_balance'), -// -// // virtual balance -// Attribute::make('virtual_balance'), -// -// // native virtual balance -// Attribute::make('native_virtual_balance'), - - // balance difference (if start + end filter present) - - // native balance difference (if start + end filter present) - - - - - //Attribute::make('current_balance')->sortable(), - - // 'type' => strtolower($accountType), - // 'account_role' => $accountRole, - // 'currency_id' => $currencyId, - // 'currency_code' => $currencyCode, - // 'currency_symbol' => $currencySymbol, - // 'currency_decimal_places' => $decimalPlaces, - // 'current_balance' => app('steam')->bcround(app('steam')->balance($account, $date), $decimalPlaces), - // 'current_balance_date' => $date->toAtomString(), - // 'notes' => $this->repository->getNoteText($account), - // 'monthly_payment_date' => $monthlyPaymentDate, - // 'credit_card_type' => $creditCardType, - // 'account_number' => $this->repository->getMetaValue($account, 'account_number'), - // 'bic' => $this->repository->getMetaValue($account, 'BIC'), - // 'opening_balance' => $openingBalance, - // 'opening_balance_date' => $openingBalanceDate, - // 'liability_type' => $liabilityType, - // 'liability_direction' => $liabilityDirection, - // 'interest' => $interest, - // 'interest_period' => $interestPeriod, - // 'current_debt' => $this->repository->getMetaValue($account, 'current_debt'), - // 'include_net_worth' => $includeNetWorth, - // 'longitude' => $longitude, - // 'latitude' => $latitude, - // 'zoom_level' => $zoomLevel, - // 'id' => (string) $account->id, - // 'created_at' => $account->created_at->toAtomString(), - // 'updated_at' => $account->updated_at->toAtomString(), - // 'active' => $account->active, - // 'order' => $order, - // 'name' => $account->name, - // 'iban' => '' === (string) $account->iban ? null : $account->iban, - // 'account_number' => $this->accountMeta[$id]['account_number'] ?? null, - // 'type' => strtolower($accountType), - // 'account_role' => $accountRole, - // 'currency_id' => (string) $currency->id, - // 'currency_code' => $currency->code, - // 'currency_symbol' => $currency->symbol, - // 'currency_decimal_places' => $currency->decimal_places, - // - // 'native_currency_id' => (string) $this->default->id, - // 'native_currency_code' => $this->default->code, - // 'native_currency_symbol' => $this->default->symbol, - // 'native_currency_decimal_places' => $this->default->decimal_places, - // - // // balance: - // 'current_balance' => $balance, - // 'native_current_balance' => $nativeBalance, - // 'current_balance_date' => $this->getDate()->endOfDay()->toAtomString(), - // - // // balance difference - // 'balance_difference' => $balanceDiff, - // 'native_balance_difference' => $nativeBalanceDiff, - // 'balance_difference_start' => $diffStart, - // 'balance_difference_end' => $diffEnd, - // - // // more meta - // 'last_activity' => array_key_exists($id, $this->lastActivity) ? $this->lastActivity[$id]->toAtomString() : null, - // - // // liability stuff - // 'liability_type' => $liabilityType, - // 'liability_direction' => $liabilityDirection, - // 'interest' => $interest, - // 'interest_period' => $interestPeriod, - // 'current_debt' => $currentDebt, - // - // // object group - // 'object_group_id' => null !== $objectGroupId ? (string) $objectGroupId : null, - // 'object_group_order' => $objectGroupOrder, - // 'object_group_title' => $objectGroupTitle, - // 'notes' => $this->repository->getNoteText($account), - // 'monthly_payment_date' => $monthlyPaymentDate, - // 'credit_card_type' => $creditCardType, - // 'bic' => $this->repository->getMetaValue($account, 'BIC'), - // 'virtual_balance' => number_format((float) $account->virtual_balance, $decimalPlaces, '.', ''), - // 'opening_balance' => $openingBalance, - // 'opening_balance_date' => $openingBalanceDate, - // 'include_net_worth' => $includeNetWorth, - // 'longitude' => $longitude, - // 'latitude' => $latitude, - // 'zoom_level' => $zoomLevel, - -// ToOne::make('user'), -// ToMany::make('tags'), - ]; - } - - /** - * @inheritDoc - */ - public function pagination(): EnumerablePagination - { - return EnumerablePagination::make(); - } - - - /** - * @inheritDoc - */ - public function filters(): iterable - { - return [ - Filter::make('name'), - Filter::make('type'), - ]; - } - public function repository(): AccountRepository - { - $userGroup = $this->validateUserGroup(request()); - return AccountRepository::make() - ->withUserGroup($userGroup) - ->withServer($this->server) - ->withSchema($this); - } - - - -} diff --git a/app/JsonApi/V3/Accounts/Capabilities/AccountQuery.php b/app/JsonApi/V3/Accounts/Capabilities/AccountQuery.php deleted file mode 100644 index 4ebf4f247d..0000000000 --- a/app/JsonApi/V3/Accounts/Capabilities/AccountQuery.php +++ /dev/null @@ -1,81 +0,0 @@ -queryParameters->filter(); - $sort = $this->queryParameters->sortFields(); - $pagination = $this->filtersPagination($this->queryParameters->page()); - $needsAll = $this->validateParams('account', $sort); - $query = $this->userGroup->accounts(); - - if (!$needsAll) { - $query = $this->addPagination($query, $pagination); - } - $query = $this->addSortParams($query, $sort); - $query = $this->addFilterParams('account', $query, $filters); - - $collection = $query->get(['accounts.*']); - - // enrich data - $enrichment = new AccountEnrichment(); - $collection = $enrichment->enrich($collection); - - - // add filters after the query - - // add sort after the query - $collection = $this->sortCollection($collection, $sort); - - - return $collection; - -// var_dump($filters->value('name')); -// exit; - } -}