mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Various messy code.
This commit is contained in:
@@ -27,6 +27,7 @@ use FireflyIII\Models\Account;
|
||||
use FireflyIII\Support\JsonApi\Concerns\UsergroupAware;
|
||||
use LaravelJsonApi\Contracts\Store\QueriesAll;
|
||||
use LaravelJsonApi\NonEloquent\AbstractRepository;
|
||||
use LaravelJsonApi\NonEloquent\Concerns\HasCrudCapability;
|
||||
|
||||
|
||||
class AccountRepository extends AbstractRepository implements QueriesAll
|
||||
@@ -39,6 +40,17 @@ class AccountRepository extends AbstractRepository implements QueriesAll
|
||||
*/
|
||||
public function __construct() {}
|
||||
|
||||
/**
|
||||
* Get the tags relationship
|
||||
*
|
||||
* @param Account $account
|
||||
* @return iterable
|
||||
*/
|
||||
public function getBalances(Account $account): iterable
|
||||
{
|
||||
die('here we are');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
|
||||
@@ -54,18 +54,24 @@ class AccountResource extends JsonApiResource
|
||||
'name' => $this->resource->name,
|
||||
'iban' => '' === $this->resource->iban ? null : $this->resource->iban,
|
||||
'active' => $this->resource->active,
|
||||
'virtual_balance' => $this->resource->virtual_balance,
|
||||
// 'virtual_balance' => $this->resource->virtual_balance,
|
||||
'last_activity' => $this->resource->last_activity,
|
||||
'balance' => $this->resource->balance,
|
||||
'native_balance' => $this->resource->native_balance,
|
||||
'type' => $this->resource->name,
|
||||
// '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,
|
||||
|
||||
|
||||
// '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),
|
||||
@@ -84,16 +90,9 @@ class AccountResource extends JsonApiResource
|
||||
// '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,
|
||||
@@ -153,7 +152,8 @@ class AccountResource extends JsonApiResource
|
||||
public function relationships($request): iterable
|
||||
{
|
||||
return [
|
||||
$this->relation('user')->withData($this->resource->user),
|
||||
$this->relation('user')->withData($this->resource->user_array),
|
||||
$this->relation('balances')->withData([]),
|
||||
//$this->relation('tags')->withData($this->resource->getTags()),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -59,14 +59,43 @@ class AccountSchema extends Schema
|
||||
Attribute::make('name')->sortable(),
|
||||
Attribute::make('iban'),
|
||||
Attribute::make('active'),
|
||||
Attribute::make('virtual_balance'),
|
||||
|
||||
Attribute::make('last_activity')->sortable(),
|
||||
Attribute::make('balance')->sortable(),
|
||||
Attribute::make('native_balance')->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)
|
||||
|
||||
// fancy fields:
|
||||
|
||||
|
||||
|
||||
@@ -153,7 +182,7 @@ class AccountSchema extends Schema
|
||||
// 'latitude' => $latitude,
|
||||
// 'zoom_level' => $zoomLevel,
|
||||
|
||||
ToOne::make('user'),
|
||||
// ToOne::make('user'),
|
||||
// ToMany::make('tags'),
|
||||
];
|
||||
}
|
||||
@@ -174,6 +203,7 @@ class AccountSchema extends Schema
|
||||
{
|
||||
return [
|
||||
Filter::make('name'),
|
||||
Filter::make('type'),
|
||||
];
|
||||
}
|
||||
public function repository(): AccountRepository
|
||||
|
||||
@@ -77,8 +77,5 @@ class AccountQuery extends QueryAll implements HasPagination
|
||||
|
||||
// var_dump($filters->value('name'));
|
||||
// exit;
|
||||
|
||||
|
||||
return Account::get();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user