mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 10:33:30 +00:00
Fix columns, improve views.
This commit is contained in:
@@ -94,6 +94,8 @@ class ShowController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new AccountEnrichment();
|
$enrichment = new AccountEnrichment();
|
||||||
$enrichment->setDate($this->parameters->get('date'));
|
$enrichment->setDate($this->parameters->get('date'));
|
||||||
|
$enrichment->setStart($this->parameters->get('start'));
|
||||||
|
$enrichment->setEnd($this->parameters->get('end'));
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$accounts = $enrichment->enrich($accounts);
|
$accounts = $enrichment->enrich($accounts);
|
||||||
|
|
||||||
@@ -117,7 +119,7 @@ class ShowController extends Controller
|
|||||||
*
|
*
|
||||||
* Show single instance.
|
* Show single instance.
|
||||||
*/
|
*/
|
||||||
public function show(Account $account): JsonResponse
|
public function show(ShowRequest $request, Account $account): JsonResponse
|
||||||
{
|
{
|
||||||
// get list of accounts. Count it and split it.
|
// get list of accounts. Count it and split it.
|
||||||
$this->repository->resetAccountOrder();
|
$this->repository->resetAccountOrder();
|
||||||
@@ -129,6 +131,8 @@ class ShowController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new AccountEnrichment();
|
$enrichment = new AccountEnrichment();
|
||||||
$enrichment->setDate($this->parameters->get('date'));
|
$enrichment->setDate($this->parameters->get('date'));
|
||||||
|
$enrichment->setStart($this->parameters->get('start'));
|
||||||
|
$enrichment->setEnd($this->parameters->get('end'));
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$account = $enrichment->enrichSingle($account);
|
$account = $enrichment->enrichSingle($account);
|
||||||
|
|
||||||
|
@@ -43,14 +43,14 @@ class ShowRequest extends FormRequest
|
|||||||
if (0 === $limit) {
|
if (0 === $limit) {
|
||||||
// get default for user:
|
// get default for user:
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
|
|
||||||
/** @var Preference $pageSize */
|
/** @var Preference $pageSize */
|
||||||
$limit = (int)Preferences::getForUser($user, 'listPageSize', 50)->data;
|
$limit = (int)Preferences::getForUser($user, 'listPageSize', 50)->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
$page = $this->convertInteger('page');
|
$page = $this->convertInteger('page');
|
||||||
$page = min(max(1, $page), 2 ** 16);
|
$page = min(max(1, $page), 2 ** 16);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'type' => $this->convertString('type', 'all'),
|
'type' => $this->convertString('type', 'all'),
|
||||||
@@ -63,12 +63,11 @@ class ShowRequest extends FormRequest
|
|||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
$keys = implode(',', array_keys($this->types));
|
$keys = implode(',', array_keys($this->types));
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'date' => 'date',
|
'date' => 'date',
|
||||||
'start' => 'date|present_with:end|before_or_equal:end|before:2038-01-17|after:1970-01-02',
|
'start' => 'date|present_with:end|before_or_equal:end|before:2038-01-17|after:1970-01-02',
|
||||||
'end' => 'date|present_with:start|after_or_equal:start|before:2038-01-17|after:1970-01-02',
|
'end' => 'date|present_with:start|after_or_equal:start|before:2038-01-17|after:1970-01-02',
|
||||||
'sort' => 'in:active,iban,name,order,-active,-iban,-name,-order', // TODO improve me.
|
'sort' => 'nullable|in:active,iban,name,order,-active,-iban,-name,-order', // TODO improve me.
|
||||||
'type' => sprintf('in:%s', $keys),
|
'type' => sprintf('in:%s', $keys),
|
||||||
'limit' => 'numeric|min:1|max:131337',
|
'limit' => 'numeric|min:1|max:131337',
|
||||||
'page' => 'numeric|min:1|max:131337',
|
'page' => 'numeric|min:1|max:131337',
|
||||||
@@ -83,6 +82,8 @@ class ShowRequest extends FormRequest
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$data = $validator->getData();
|
$data = $validator->getData();
|
||||||
|
|
||||||
|
|
||||||
if (array_key_exists('date', $data) && array_key_exists('start', $data) && array_key_exists('end', $data)) {
|
if (array_key_exists('date', $data) && array_key_exists('start', $data) && array_key_exists('end', $data)) {
|
||||||
// assume valid dates, before we got here.
|
// assume valid dates, before we got here.
|
||||||
$start = Carbon::parse($data['start'], config('app.timezone'))->startOfDay();
|
$start = Carbon::parse($data['start'], config('app.timezone'))->startOfDay();
|
||||||
|
@@ -67,8 +67,12 @@ class AccountEnrichment implements EnrichmentInterface
|
|||||||
private UserGroup $userGroup;
|
private UserGroup $userGroup;
|
||||||
private array $lastActivities = [];
|
private array $lastActivities = [];
|
||||||
private ?Carbon $date = null;
|
private ?Carbon $date = null;
|
||||||
|
private ?Carbon $start = null;
|
||||||
|
private ?Carbon $end = null;
|
||||||
private bool $convertToPrimary;
|
private bool $convertToPrimary;
|
||||||
private array $balances = [];
|
private array $balances = [];
|
||||||
|
private array $startBalances = [];
|
||||||
|
private array $endBalances = [];
|
||||||
private array $objectGroups = [];
|
private array $objectGroups = [];
|
||||||
private array $mappedObjects = [];
|
private array $mappedObjects = [];
|
||||||
|
|
||||||
@@ -138,10 +142,9 @@ class AccountEnrichment implements EnrichmentInterface
|
|||||||
|
|
||||||
private function collectMetaData(): void
|
private function collectMetaData(): void
|
||||||
{
|
{
|
||||||
$set = AccountMeta::whereIn('name', ['is_multi_currency', 'include_net_worth', 'currency_id', 'account_role', 'account_number', 'BIC', 'liability_direction', 'interest', 'interest_period', 'current_debt'])
|
$set = AccountMeta::whereIn('name', ['is_multi_currency', 'include_net_worth', 'currency_id', 'account_role', 'account_number', 'BIC', 'liability_direction', 'interest', 'interest_period', 'current_debt'])
|
||||||
->whereIn('account_id', $this->ids)
|
->whereIn('account_id', $this->ids)
|
||||||
->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data'])->toArray()
|
->get(['account_meta.id', 'account_meta.account_id', 'account_meta.name', 'account_meta.data'])->toArray();
|
||||||
;
|
|
||||||
|
|
||||||
/** @var array $entry */
|
/** @var array $entry */
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
@@ -167,10 +170,9 @@ class AccountEnrichment implements EnrichmentInterface
|
|||||||
private function collectNotes(): void
|
private function collectNotes(): void
|
||||||
{
|
{
|
||||||
$notes = Note::query()->whereIn('noteable_id', $this->ids)
|
$notes = Note::query()->whereIn('noteable_id', $this->ids)
|
||||||
->whereNotNull('notes.text')
|
->whereNotNull('notes.text')
|
||||||
->where('notes.text', '!=', '')
|
->where('notes.text', '!=', '')
|
||||||
->where('noteable_type', Account::class)->get(['notes.noteable_id', 'notes.text'])->toArray()
|
->where('noteable_type', Account::class)->get(['notes.noteable_id', 'notes.text'])->toArray();
|
||||||
;
|
|
||||||
foreach ($notes as $note) {
|
foreach ($notes as $note) {
|
||||||
$this->notes[(int)$note['noteable_id']] = (string)$note['text'];
|
$this->notes[(int)$note['noteable_id']] = (string)$note['text'];
|
||||||
}
|
}
|
||||||
@@ -180,15 +182,14 @@ class AccountEnrichment implements EnrichmentInterface
|
|||||||
private function collectLocations(): void
|
private function collectLocations(): void
|
||||||
{
|
{
|
||||||
$locations = Location::query()->whereIn('locatable_id', $this->ids)
|
$locations = Location::query()->whereIn('locatable_id', $this->ids)
|
||||||
->where('locatable_type', Account::class)->get(['locations.locatable_id', 'locations.latitude', 'locations.longitude', 'locations.zoom_level'])->toArray()
|
->where('locatable_type', Account::class)->get(['locations.locatable_id', 'locations.latitude', 'locations.longitude', 'locations.zoom_level'])->toArray();
|
||||||
;
|
|
||||||
foreach ($locations as $location) {
|
foreach ($locations as $location) {
|
||||||
$this->locations[(int)$location['locatable_id']]
|
$this->locations[(int)$location['locatable_id']]
|
||||||
= [
|
= [
|
||||||
'latitude' => (float)$location['latitude'],
|
'latitude' => (float)$location['latitude'],
|
||||||
'longitude' => (float)$location['longitude'],
|
'longitude' => (float)$location['longitude'],
|
||||||
'zoom_level' => (int)$location['zoom_level'],
|
'zoom_level' => (int)$location['zoom_level'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
Log::debug(sprintf('Enrich with %d locations(s)', count($this->locations)));
|
Log::debug(sprintf('Enrich with %d locations(s)', count($this->locations)));
|
||||||
}
|
}
|
||||||
@@ -203,20 +204,19 @@ class AccountEnrichment implements EnrichmentInterface
|
|||||||
->setUserGroup($this->userGroup)
|
->setUserGroup($this->userGroup)
|
||||||
->setAccounts($this->collection)
|
->setAccounts($this->collection)
|
||||||
->withAccountInformation()
|
->withAccountInformation()
|
||||||
->setTypes([TransactionTypeEnum::OPENING_BALANCE->value])
|
->setTypes([TransactionTypeEnum::OPENING_BALANCE->value]);
|
||||||
;
|
$journals = $collector->getExtractedJournals();
|
||||||
$journals = $collector->getExtractedJournals();
|
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$this->openingBalances[(int)$journal['source_account_id']]
|
$this->openingBalances[(int)$journal['source_account_id']]
|
||||||
= [
|
= [
|
||||||
'amount' => Steam::negative($journal['amount']),
|
'amount' => Steam::negative($journal['amount']),
|
||||||
'date' => $journal['date'],
|
'date' => $journal['date'],
|
||||||
];
|
];
|
||||||
$this->openingBalances[(int)$journal['destination_account_id']]
|
$this->openingBalances[(int)$journal['destination_account_id']]
|
||||||
= [
|
= [
|
||||||
'amount' => Steam::positive($journal['amount']),
|
'amount' => Steam::positive($journal['amount']),
|
||||||
'date' => $journal['date'],
|
'date' => $journal['date'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,9 +234,9 @@ class AccountEnrichment implements EnrichmentInterface
|
|||||||
private function appendCollectedData(): void
|
private function appendCollectedData(): void
|
||||||
{
|
{
|
||||||
$this->collection = $this->collection->map(function (Account $item) {
|
$this->collection = $this->collection->map(function (Account $item) {
|
||||||
$id = (int)$item->id;
|
$id = (int)$item->id;
|
||||||
$item->full_account_type = $this->accountTypes[(int)$item->account_type_id] ?? null;
|
$item->full_account_type = $this->accountTypes[(int)$item->account_type_id] ?? null;
|
||||||
$meta = [
|
$meta = [
|
||||||
'currency' => null,
|
'currency' => null,
|
||||||
'location' => [
|
'location' => [
|
||||||
'latitude' => null,
|
'latitude' => null,
|
||||||
@@ -256,7 +256,7 @@ class AccountEnrichment implements EnrichmentInterface
|
|||||||
// add object group if available
|
// add object group if available
|
||||||
if (array_key_exists($id, $this->mappedObjects)) {
|
if (array_key_exists($id, $this->mappedObjects)) {
|
||||||
$key = $this->mappedObjects[$id];
|
$key = $this->mappedObjects[$id];
|
||||||
$meta['object_group_id'] = (string) $this->objectGroups[$key]['id'];
|
$meta['object_group_id'] = (string)$this->objectGroups[$key]['id'];
|
||||||
$meta['object_group_title'] = $this->objectGroups[$key]['title'];
|
$meta['object_group_title'] = $this->objectGroups[$key]['title'];
|
||||||
$meta['object_group_order'] = $this->objectGroups[$key]['order'];
|
$meta['object_group_order'] = $this->objectGroups[$key]['order'];
|
||||||
}
|
}
|
||||||
@@ -283,43 +283,47 @@ class AccountEnrichment implements EnrichmentInterface
|
|||||||
|
|
||||||
// add balances
|
// add balances
|
||||||
// get currencies:
|
// get currencies:
|
||||||
$currency = $this->primaryCurrency; // assume primary currency
|
$currency = $this->primaryCurrency; // assume primary currency
|
||||||
if (null !== $meta['currency']) {
|
if (null !== $meta['currency']) {
|
||||||
$currency = $meta['currency'];
|
$currency = $meta['currency'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the current balance:
|
// get the current balance:
|
||||||
$date = $this->getDate();
|
$date = $this->getDate();
|
||||||
// $finalBalance = Steam::finalAccountBalance($item, $date, $this->primaryCurrency, $this->convertToPrimary);
|
// $finalBalance = Steam::finalAccountBalance($item, $date, $this->primaryCurrency, $this->convertToPrimary);
|
||||||
$finalBalance = $this->balances[$id];
|
$finalBalance = $this->balances[$id];
|
||||||
|
$balanceDifference = $this->getBalanceDifference($id, $currency);
|
||||||
Log::debug(sprintf('Call finalAccountBalance(%s) with date/time "%s"', var_export($this->convertToPrimary, true), $date->toIso8601String()), $finalBalance);
|
Log::debug(sprintf('Call finalAccountBalance(%s) with date/time "%s"', var_export($this->convertToPrimary, true), $date->toIso8601String()), $finalBalance);
|
||||||
|
|
||||||
// collect current balances:
|
// collect current balances:
|
||||||
$currentBalance = Steam::bcround($finalBalance[$currency->code] ?? '0', $currency->decimal_places);
|
$currentBalance = Steam::bcround($finalBalance[$currency->code] ?? '0', $currency->decimal_places);
|
||||||
$openingBalance = Steam::bcround($meta['opening_balance_amount'] ?? '0', $currency->decimal_places);
|
$openingBalance = Steam::bcround($meta['opening_balance_amount'] ?? '0', $currency->decimal_places);
|
||||||
$virtualBalance = Steam::bcround($account->virtual_balance ?? '0', $currency->decimal_places);
|
$virtualBalance = Steam::bcround($account->virtual_balance ?? '0', $currency->decimal_places);
|
||||||
$debtAmount = $meta['current_debt'] ?? null;
|
$debtAmount = $meta['current_debt'] ?? null;
|
||||||
|
|
||||||
// set some pc_ default values to NULL:
|
// set some pc_ default values to NULL:
|
||||||
$pcCurrentBalance = null;
|
$pcCurrentBalance = null;
|
||||||
$pcOpeningBalance = null;
|
$pcOpeningBalance = null;
|
||||||
$pcVirtualBalance = null;
|
$pcVirtualBalance = null;
|
||||||
$pcDebtAmount = null;
|
$pcDebtAmount = null;
|
||||||
|
$pcBalanceDifference = null;
|
||||||
|
|
||||||
// convert to primary currency if needed:
|
// convert to primary currency if needed:
|
||||||
if ($this->convertToPrimary && $currency->id !== $this->primaryCurrency->id) {
|
if ($this->convertToPrimary && $currency->id !== $this->primaryCurrency->id) {
|
||||||
Log::debug(sprintf('Convert to primary, from %s to %s', $currency->code, $this->primaryCurrency->code));
|
Log::debug(sprintf('Convert to primary, from %s to %s', $currency->code, $this->primaryCurrency->code));
|
||||||
$converter = new ExchangeRateConverter();
|
$converter = new ExchangeRateConverter();
|
||||||
$pcCurrentBalance = $converter->convert($currency, $this->primaryCurrency, $date, $currentBalance);
|
$pcCurrentBalance = $converter->convert($currency, $this->primaryCurrency, $date, $currentBalance);
|
||||||
$pcOpeningBalance = $converter->convert($currency, $this->primaryCurrency, $date, $openingBalance);
|
$pcOpeningBalance = $converter->convert($currency, $this->primaryCurrency, $date, $openingBalance);
|
||||||
$pcVirtualBalance = $converter->convert($currency, $this->primaryCurrency, $date, $virtualBalance);
|
$pcVirtualBalance = $converter->convert($currency, $this->primaryCurrency, $date, $virtualBalance);
|
||||||
$pcDebtAmount = null === $debtAmount ? null : $converter->convert($currency, $this->primaryCurrency, $date, $debtAmount);
|
$pcBalanceDifference = null === $balanceDifference ? null : $converter->convert($currency, $this->primaryCurrency, $date, $balanceDifference);
|
||||||
|
$pcDebtAmount = null === $debtAmount ? null : $converter->convert($currency, $this->primaryCurrency, $date, $debtAmount);
|
||||||
}
|
}
|
||||||
if ($this->convertToPrimary && $currency->id === $this->primaryCurrency->id) {
|
if ($this->convertToPrimary && $currency->id === $this->primaryCurrency->id) {
|
||||||
$pcCurrentBalance = $currentBalance;
|
$pcCurrentBalance = $currentBalance;
|
||||||
$pcOpeningBalance = $openingBalance;
|
$pcOpeningBalance = $openingBalance;
|
||||||
$pcVirtualBalance = $virtualBalance;
|
$pcVirtualBalance = $virtualBalance;
|
||||||
$pcDebtAmount = $debtAmount;
|
$pcBalanceDifference = $balanceDifference;
|
||||||
|
$pcDebtAmount = $debtAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set opening balance(s) to NULL if the date is null
|
// set opening balance(s) to NULL if the date is null
|
||||||
@@ -337,9 +341,11 @@ class AccountEnrichment implements EnrichmentInterface
|
|||||||
'pc_virtual_balance' => $pcVirtualBalance,
|
'pc_virtual_balance' => $pcVirtualBalance,
|
||||||
'debt_amount' => $debtAmount,
|
'debt_amount' => $debtAmount,
|
||||||
'pc_debt_amount' => $pcDebtAmount,
|
'pc_debt_amount' => $pcDebtAmount,
|
||||||
|
'balance_difference' => $balanceDifference,
|
||||||
|
'pc_balance_difference' => $pcBalanceDifference,
|
||||||
];
|
];
|
||||||
// end add balances
|
// end add balances
|
||||||
$item->meta = $meta;
|
$item->meta = $meta;
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
});
|
});
|
||||||
@@ -353,17 +359,20 @@ class AccountEnrichment implements EnrichmentInterface
|
|||||||
private function collectBalances(): void
|
private function collectBalances(): void
|
||||||
{
|
{
|
||||||
$this->balances = Steam::accountsBalancesOptimized($this->collection, $this->getDate(), $this->primaryCurrency, $this->convertToPrimary);
|
$this->balances = Steam::accountsBalancesOptimized($this->collection, $this->getDate(), $this->primaryCurrency, $this->convertToPrimary);
|
||||||
|
if (null !== $this->start && null !== $this->end) {
|
||||||
|
$this->startBalances = Steam::accountsBalancesOptimized($this->collection, $this->start, $this->primaryCurrency, $this->convertToPrimary);
|
||||||
|
$this->endBalances = Steam::accountsBalancesOptimized($this->collection, $this->end, $this->primaryCurrency, $this->convertToPrimary);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function collectObjectGroups(): void
|
private function collectObjectGroups(): void
|
||||||
{
|
{
|
||||||
$set = DB::table('object_groupables')
|
$set = DB::table('object_groupables')
|
||||||
->whereIn('object_groupable_id', $this->ids)
|
->whereIn('object_groupable_id', $this->ids)
|
||||||
->where('object_groupable_type', Account::class)
|
->where('object_groupable_type', Account::class)
|
||||||
->get(['object_groupable_id', 'object_group_id'])
|
->get(['object_groupable_id', 'object_group_id']);
|
||||||
;
|
|
||||||
|
|
||||||
$ids = array_unique($set->pluck('object_group_id')->toArray());
|
$ids = array_unique($set->pluck('object_group_id')->toArray());
|
||||||
|
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$this->mappedObjects[(int)$entry->object_groupable_id] = (int)$entry->object_group_id;
|
$this->mappedObjects[(int)$entry->object_groupable_id] = (int)$entry->object_group_id;
|
||||||
@@ -394,4 +403,32 @@ class AccountEnrichment implements EnrichmentInterface
|
|||||||
|
|
||||||
return $this->date;
|
return $this->date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setStart(?Carbon $start): void
|
||||||
|
{
|
||||||
|
$this->start = $start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setEnd(?Carbon $end): void
|
||||||
|
{
|
||||||
|
$this->end = $end;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getBalanceDifference(int $id, TransactionCurrency $currency): ?string
|
||||||
|
{
|
||||||
|
if (null === $this->start || null === $this->end) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$startBalance = $this->startBalances[$id] ?? [];
|
||||||
|
$endBalance = $this->endBalances[$id] ?? [];
|
||||||
|
if (count($startBalance) === 0 || count($endBalance) === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$start = $startBalance[$currency->code] ?? '0';
|
||||||
|
$end = $endBalance[$currency->code] ?? '0';
|
||||||
|
|
||||||
|
return bcsub($end, $start);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -66,20 +66,20 @@ class AccountTransformer extends AbstractTransformer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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));
|
||||||
$liabilityType = '' === $liabilityType ? null : strtolower($liabilityType);
|
$liabilityType = '' === $liabilityType ? null : strtolower($liabilityType);
|
||||||
$liabilityDirection = $account->meta['liability_direction'] ?? null;
|
$liabilityDirection = $account->meta['liability_direction'] ?? null;
|
||||||
$accountRole = $this->getAccountRole($account, $accountType);
|
$accountRole = $this->getAccountRole($account, $accountType);
|
||||||
$hasCurrencySettings = null !== $account->meta['currency'];
|
$hasCurrencySettings = null !== $account->meta['currency'];
|
||||||
$includeNetWorth = 1 === (int) ($account->meta['include_net_worth'] ?? 0);
|
$includeNetWorth = 1 === (int)($account->meta['include_net_worth'] ?? 0);
|
||||||
$longitude = $account->meta['location']['longitude'] ?? null;
|
$longitude = $account->meta['location']['longitude'] ?? null;
|
||||||
$latitude = $account->meta['location']['latitude'] ?? null;
|
$latitude = $account->meta['location']['latitude'] ?? null;
|
||||||
$zoomLevel = $account->meta['location']['zoom_level'] ?? null;
|
$zoomLevel = $account->meta['location']['zoom_level'] ?? null;
|
||||||
$order = $account->order;
|
$order = $account->order;
|
||||||
|
|
||||||
// get primary currency as fallback:
|
// get primary currency as fallback:
|
||||||
$currency = $this->primary; // assume primary currency
|
$currency = $this->primary; // assume primary currency
|
||||||
if ($hasCurrencySettings) {
|
if ($hasCurrencySettings) {
|
||||||
$currency = $account->meta['currency'];
|
$currency = $account->meta['currency'];
|
||||||
}
|
}
|
||||||
@@ -91,34 +91,34 @@ class AccountTransformer extends AbstractTransformer
|
|||||||
|
|
||||||
// get some listed information from the account meta-data:
|
// get some listed information from the account meta-data:
|
||||||
[$creditCardType, $monthlyPaymentDate] = $this->getCCInfo($account, $accountRole, $accountType);
|
[$creditCardType, $monthlyPaymentDate] = $this->getCCInfo($account, $accountRole, $accountType);
|
||||||
$openingBalanceDate = $this->getOpeningBalance($account, $accountType);
|
$openingBalanceDate = $this->getOpeningBalance($account, $accountType);
|
||||||
[$interest, $interestPeriod] = $this->getInterest($account, $accountType);
|
[$interest, $interestPeriod] = $this->getInterest($account, $accountType);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => (string) $account->id,
|
'id' => (string)$account->id,
|
||||||
'created_at' => $account->created_at->toAtomString(),
|
'created_at' => $account->created_at->toAtomString(),
|
||||||
'updated_at' => $account->updated_at->toAtomString(),
|
'updated_at' => $account->updated_at->toAtomString(),
|
||||||
'active' => $account->active,
|
'active' => $account->active,
|
||||||
'order' => $order,
|
'order' => $order,
|
||||||
'name' => $account->name,
|
'name' => $account->name,
|
||||||
'type' => strtolower($accountType),
|
'type' => strtolower($accountType),
|
||||||
'account_role' => $accountRole,
|
'account_role' => $accountRole,
|
||||||
|
|
||||||
'object_group_id' => $account->meta['object_group_id'],
|
'object_group_id' => $account->meta['object_group_id'],
|
||||||
'object_group_order' => $account->meta['object_group_order'],
|
'object_group_order' => $account->meta['object_group_order'],
|
||||||
'object_group_title' => $account->meta['object_group_title'],
|
'object_group_title' => $account->meta['object_group_title'],
|
||||||
|
|
||||||
// currency information, structured for 6.3.0.
|
// currency information, structured for 6.3.0.
|
||||||
'object_has_currency_setting' => $hasCurrencySettings,
|
'object_has_currency_setting' => $hasCurrencySettings,
|
||||||
|
|
||||||
// currency is object specific or primary, already determined above.
|
// currency is object specific or primary, already determined above.
|
||||||
'currency_id' => (string) $currency['id'],
|
'currency_id' => (string)$currency['id'],
|
||||||
'currency_name' => $currency['name'],
|
'currency_name' => $currency['name'],
|
||||||
'currency_code' => $currency['code'],
|
'currency_code' => $currency['code'],
|
||||||
'currency_symbol' => $currency['symbol'],
|
'currency_symbol' => $currency['symbol'],
|
||||||
'currency_decimal_places' => $currency['decimal_places'],
|
'currency_decimal_places' => $currency['decimal_places'],
|
||||||
|
|
||||||
'primary_currency_id' => (string) $this->primary->id,
|
'primary_currency_id' => (string)$this->primary->id,
|
||||||
'primary_currency_name' => $this->primary->name,
|
'primary_currency_name' => $this->primary->name,
|
||||||
'primary_currency_code' => $this->primary->code,
|
'primary_currency_code' => $this->primary->code,
|
||||||
'primary_currency_symbol' => $this->primary->symbol,
|
'primary_currency_symbol' => $this->primary->symbol,
|
||||||
@@ -128,33 +128,36 @@ class AccountTransformer extends AbstractTransformer
|
|||||||
'current_balance' => $account->meta['balances']['current_balance'],
|
'current_balance' => $account->meta['balances']['current_balance'],
|
||||||
'pc_current_balance' => $account->meta['balances']['pc_current_balance'],
|
'pc_current_balance' => $account->meta['balances']['pc_current_balance'],
|
||||||
|
|
||||||
'opening_balance' => $account->meta['balances']['opening_balance'],
|
'opening_balance' => $account->meta['balances']['opening_balance'],
|
||||||
'pc_opening_balance' => $account->meta['balances']['pc_opening_balance'],
|
'pc_opening_balance' => $account->meta['balances']['pc_opening_balance'],
|
||||||
|
|
||||||
'virtual_balance' => $account->meta['balances']['virtual_balance'],
|
'virtual_balance' => $account->meta['balances']['virtual_balance'],
|
||||||
'pc_virtual_balance' => $account->meta['balances']['pc_virtual_balance'],
|
'pc_virtual_balance' => $account->meta['balances']['pc_virtual_balance'],
|
||||||
|
|
||||||
'debt_amount' => $account->meta['balances']['debt_amount'],
|
'debt_amount' => $account->meta['balances']['debt_amount'],
|
||||||
'pc_debt_amount' => $account->meta['balances']['pc_debt_amount'],
|
'pc_debt_amount' => $account->meta['balances']['pc_debt_amount'],
|
||||||
|
|
||||||
'current_balance_date' => $account->meta['current_balance_date']->toAtomString(),
|
'balance_difference' => $account->meta['balances']['balance_difference'],
|
||||||
'notes' => $account->meta['notes'] ?? null,
|
'pc_balance_difference' => $account->meta['balances']['pc_balance_difference'],
|
||||||
'monthly_payment_date' => $monthlyPaymentDate,
|
|
||||||
'credit_card_type' => $creditCardType,
|
'current_balance_date' => $account->meta['current_balance_date']->toAtomString(),
|
||||||
'account_number' => $account->meta['account_number'],
|
'notes' => $account->meta['notes'] ?? null,
|
||||||
'iban' => '' === $account->iban ? null : $account->iban,
|
'monthly_payment_date' => $monthlyPaymentDate,
|
||||||
'bic' => $account->meta['BIC'] ?? null,
|
'credit_card_type' => $creditCardType,
|
||||||
'opening_balance_date' => $openingBalanceDate,
|
'account_number' => $account->meta['account_number'],
|
||||||
'liability_type' => $liabilityType,
|
'iban' => '' === $account->iban ? null : $account->iban,
|
||||||
'liability_direction' => $liabilityDirection,
|
'bic' => $account->meta['BIC'] ?? null,
|
||||||
'interest' => $interest,
|
'opening_balance_date' => $openingBalanceDate,
|
||||||
'interest_period' => $interestPeriod,
|
'liability_type' => $liabilityType,
|
||||||
'include_net_worth' => $includeNetWorth,
|
'liability_direction' => $liabilityDirection,
|
||||||
'longitude' => $longitude,
|
'interest' => $interest,
|
||||||
'latitude' => $latitude,
|
'interest_period' => $interestPeriod,
|
||||||
'zoom_level' => $zoomLevel,
|
'include_net_worth' => $includeNetWorth,
|
||||||
'last_activity' => $account->meta['last_activity']?->toAtomString(),
|
'longitude' => $longitude,
|
||||||
'links' => [
|
'latitude' => $latitude,
|
||||||
|
'zoom_level' => $zoomLevel,
|
||||||
|
'last_activity' => $account->meta['last_activity']?->toAtomString(),
|
||||||
|
'links' => [
|
||||||
[
|
[
|
||||||
'rel' => 'self',
|
'rel' => 'self',
|
||||||
'uri' => sprintf('/accounts/%d', $account->id),
|
'uri' => sprintf('/accounts/%d', $account->id),
|
||||||
@@ -166,7 +169,7 @@ class AccountTransformer extends AbstractTransformer
|
|||||||
private function getAccountRole(Account $account, string $accountType): ?string
|
private function getAccountRole(Account $account, string $accountType): ?string
|
||||||
{
|
{
|
||||||
$accountRole = $account->meta['account_role'] ?? null;
|
$accountRole = $account->meta['account_role'] ?? null;
|
||||||
if ('asset' !== $accountType || '' === (string) $accountRole) {
|
if ('asset' !== $accountType || '' === (string)$accountRole) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,13 +199,13 @@ class AccountTransformer extends AbstractTransformer
|
|||||||
if (null !== $monthlyPaymentDate) {
|
if (null !== $monthlyPaymentDate) {
|
||||||
// try classic date:
|
// try classic date:
|
||||||
if (10 === strlen($monthlyPaymentDate)) {
|
if (10 === strlen($monthlyPaymentDate)) {
|
||||||
$object = Carbon::createFromFormat('!Y-m-d', $monthlyPaymentDate, config('app.timezone'));
|
$object = Carbon::createFromFormat('!Y-m-d', $monthlyPaymentDate, config('app.timezone'));
|
||||||
if (!$object instanceof Carbon) {
|
if (!$object instanceof Carbon) {
|
||||||
$object = today(config('app.timezone'));
|
$object = today(config('app.timezone'));
|
||||||
}
|
}
|
||||||
$monthlyPaymentDate = $object->toAtomString();
|
$monthlyPaymentDate = $object->toAtomString();
|
||||||
}
|
}
|
||||||
if (10 !== strlen((string) $monthlyPaymentDate)) {
|
if (10 !== strlen((string)$monthlyPaymentDate)) {
|
||||||
$monthlyPaymentDate = Carbon::parse($monthlyPaymentDate, config('app.timezone'))->toAtomString();
|
$monthlyPaymentDate = Carbon::parse($monthlyPaymentDate, config('app.timezone'))->toAtomString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -217,7 +220,7 @@ class AccountTransformer extends AbstractTransformer
|
|||||||
$openingBalanceDate = $account->meta['opening_balance_date'] ?? null;
|
$openingBalanceDate = $account->meta['opening_balance_date'] ?? null;
|
||||||
}
|
}
|
||||||
if (null !== $openingBalanceDate) {
|
if (null !== $openingBalanceDate) {
|
||||||
$object = Carbon::createFromFormat('Y-m-d H:i:s', $openingBalanceDate, config('app.timezone'));
|
$object = Carbon::createFromFormat('Y-m-d H:i:s', $openingBalanceDate, config('app.timezone'));
|
||||||
if (!$object instanceof Carbon) {
|
if (!$object instanceof Carbon) {
|
||||||
$object = today(config('app.timezone'));
|
$object = today(config('app.timezone'));
|
||||||
}
|
}
|
||||||
|
@@ -378,8 +378,8 @@ let index = function () {
|
|||||||
date: format(today,'yyyy-MM-dd'),
|
date: format(today,'yyyy-MM-dd'),
|
||||||
type: type,
|
type: type,
|
||||||
page: this.page,
|
page: this.page,
|
||||||
// startPeriod: start,
|
start: start,
|
||||||
// endPeriod: end
|
end: end
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!this.tableColumns.balance_difference.enabled) {
|
if (!this.tableColumns.balance_difference.enabled) {
|
||||||
@@ -403,17 +403,26 @@ let index = function () {
|
|||||||
role: current.attributes.account_role,
|
role: current.attributes.account_role,
|
||||||
iban: null === current.attributes.iban ? '' : current.attributes.iban.match(/.{1,4}/g).join(' '),
|
iban: null === current.attributes.iban ? '' : current.attributes.iban.match(/.{1,4}/g).join(' '),
|
||||||
account_number: null === current.attributes.account_number ? '' : current.attributes.account_number,
|
account_number: null === current.attributes.account_number ? '' : current.attributes.account_number,
|
||||||
current_balance: current.attributes.current_balance,
|
|
||||||
currency_code: current.attributes.currency_code,
|
|
||||||
last_activity: null === current.attributes.last_activity ? '' : format(new Date(current.attributes.last_activity), i18next.t('config.month_and_day_fns')),
|
last_activity: null === current.attributes.last_activity ? '' : format(new Date(current.attributes.last_activity), i18next.t('config.month_and_day_fns')),
|
||||||
liability_type: current.attributes.liability_type,
|
liability_type: current.attributes.liability_type,
|
||||||
liability_direction: current.attributes.liability_direction,
|
liability_direction: current.attributes.liability_direction,
|
||||||
interest: current.attributes.interest,
|
interest: current.attributes.interest,
|
||||||
interest_period: current.attributes.interest_period,
|
interest_period: current.attributes.interest_period,
|
||||||
// balance: current.attributes.balance,
|
|
||||||
// pc_balance: current.attributes.pc_balance,
|
// currency info
|
||||||
// balances: current.attributes.balances,
|
currency_code: current.attributes.currency_code,
|
||||||
|
primary_currency_code: current.attributes.primary_currency_code,
|
||||||
|
|
||||||
|
|
||||||
|
// balances.
|
||||||
|
current_balance: current.attributes.current_balance,
|
||||||
|
pc_current_balance: current.attributes.pc_current_balance,
|
||||||
|
balance_difference: current.attributes.balance_difference,
|
||||||
|
pc_balance_difference: current.attributes.pc_balance_difference,
|
||||||
|
debt_amount: current.attributes.debt_amount,
|
||||||
|
pc_debt_amount: current.attributes.debt_amount,
|
||||||
};
|
};
|
||||||
|
console.log(account);
|
||||||
// get group info:
|
// get group info:
|
||||||
let groupId = current.attributes.object_group_id;
|
let groupId = current.attributes.object_group_id;
|
||||||
if(!this.pageOptions.groupedAccounts) {
|
if(!this.pageOptions.groupedAccounts) {
|
||||||
|
@@ -263,39 +263,74 @@
|
|||||||
</td>
|
</td>
|
||||||
<td x-show="tableColumns.current_balance.visible && tableColumns.current_balance.enabled">
|
<td x-show="tableColumns.current_balance.visible && tableColumns.current_balance.enabled">
|
||||||
<span x-show="parseFloat(account.current_balance) < 0.0" class="text-danger"
|
<span x-show="parseFloat(account.current_balance) < 0.0" class="text-danger"
|
||||||
x-text="formatMoney(account.current_balance, account.currency_code)"></span>
|
x-text="formatMoney(account.current_balance, account.primary_currency_code)"></span>
|
||||||
<span x-show="parseFloat(account.current_balance) === 0.0" class="text-muted"
|
<span x-show="parseFloat(account.current_balance) === 0.0" class="text-muted"
|
||||||
x-text="formatMoney(account.current_balance, account.currency_code)"></span>
|
x-text="formatMoney(account.current_balance, account.primary_currency_code)"></span>
|
||||||
<span x-show="parseFloat(account.current_balance) > 0.0" class="text-success"
|
<span x-show="parseFloat(account.current_balance) > 0.0" class="text-success"
|
||||||
x-text="formatMoney(account.current_balance, account.currency_code)"></span>
|
x-text="formatMoney(account.current_balance, account.primary_currency_code)"></span>
|
||||||
<template x-if="null !== account.pc_current_balance">
|
<template x-if="null !== account.pc_current_balance">
|
||||||
<span>PC current balance TODO.</span>
|
<span>(
|
||||||
|
<span x-show="parseFloat(account.pc_current_balance) < 0.0" class="text-danger"
|
||||||
|
x-text="formatMoney(account.pc_current_balance, account.primary_currency_code)"></span>
|
||||||
|
<span x-show="parseFloat(account.pc_current_balance) === 0.0" class="text-muted"
|
||||||
|
x-text="formatMoney(account.pc_current_balance, account.primary_currency_code)"></span>
|
||||||
|
<span x-show="parseFloat(account.pc_current_balance) > 0.0" class="text-success"
|
||||||
|
x-text="formatMoney(account.pc_current_balance, account.primary_currency_code)"></span>
|
||||||
|
)
|
||||||
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</td>
|
</td>
|
||||||
<td x-show="tableColumns.amount_due.visible && tableColumns.amount_due.enabled">
|
<td x-show="tableColumns.amount_due.visible && tableColumns.amount_due.enabled">
|
||||||
<!--
|
<template x-if="null !== account.debt_amount">
|
||||||
<template x-if="null !== account.current_debt">
|
<span>
|
||||||
<span class="text-info"
|
<span x-show="null != account.debt_amount && account.debt_amount < 0" class="text-danger"
|
||||||
x-text="formatMoney(account.current_debt, account.currency_code)"></span>
|
x-text="formatMoney(account.debt_amount, account.currency_code)"></span>
|
||||||
|
<span x-show="null != account.debt_amount && account.debt_amount == 0" class="text-muted"
|
||||||
|
x-text="formatMoney(account.debt_amount, account.currency_code)"></span>
|
||||||
|
<span x-show="null != account.debt_amount && account.debt_amount > 0" class="text-success"
|
||||||
|
x-text="formatMoney(account.debt_amount, account.currency_code)"></span>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<template x-if="null !== account.pc_debt_amount">
|
||||||
|
<span>(
|
||||||
|
<span x-show="parseFloat(account.pc_debt_amount) < 0.0" class="text-danger"
|
||||||
|
x-text="formatMoney(account.pc_debt_amount, account.primary_currency_code)"></span>
|
||||||
|
<span x-show="parseFloat(account.pc_debt_amount) === 0.0" class="text-muted"
|
||||||
|
x-text="formatMoney(account.pc_debt_amount, account.primary_currency_code)"></span>
|
||||||
|
<span x-show="parseFloat(account.pc_debt_amount) > 0.0" class="text-success"
|
||||||
|
x-text="formatMoney(account.pc_debt_amount, account.primary_currency_code)"></span>
|
||||||
|
)
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
-->
|
|
||||||
FIXME
|
|
||||||
</td>
|
</td>
|
||||||
<td x-show="tableColumns.last_activity.visible && tableColumns.last_activity.enabled">
|
<td x-show="tableColumns.last_activity.visible && tableColumns.last_activity.enabled">
|
||||||
<span x-text="account.last_activity"></span>
|
<span x-text="account.last_activity"></span>
|
||||||
</td>
|
</td>
|
||||||
<td x-show="tableColumns.balance_difference.visible && tableColumns.balance_difference.enabled">
|
<td x-show="tableColumns.balance_difference.visible && tableColumns.balance_difference.enabled">
|
||||||
<template x-if="null !== account.balance">
|
<template x-if="null !== account.balance_difference">
|
||||||
<template x-for="balance in account.balance">
|
|
||||||
<span>
|
<span>
|
||||||
<span x-show="null != balance.balance_difference && balance.balance_difference < 0" class="text-danger"
|
<span x-show="null != account.balance_difference && account.balance_difference < 0" class="text-danger"
|
||||||
x-text="formatMoney(balance.balance_difference, balance.currency_code)"></span>
|
x-text="formatMoney(account.balance_difference, account.currency_code)"></span>
|
||||||
<span x-show="null != balance.balance_difference && balance.balance_difference == 0" class="text-muted"
|
<span x-show="null != account.balance_difference && account.balance_difference == 0" class="text-muted"
|
||||||
x-text="formatMoney(balance.balance_difference, balance.currency_code)"></span>
|
x-text="formatMoney(account.balance_difference, account.currency_code)"></span>
|
||||||
<span x-show="null != balance.balance_difference && balance.balance_difference > 0" class="text-success"
|
<span x-show="null != account.balance_difference && account.balance_difference > 0" class="text-success"
|
||||||
x-text="formatMoney(balance.balance_difference, balance.currency_code)"></span>
|
x-text="formatMoney(account.balance_difference, account.currency_code)"></span>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
|
||||||
|
<template x-if="null !== account.pc_balance_difference">
|
||||||
|
<span>(
|
||||||
|
<span x-show="parseFloat(account.pc_balance_difference) < 0.0" class="text-danger"
|
||||||
|
x-text="formatMoney(account.pc_balance_difference, account.primary_currency_code)"></span>
|
||||||
|
<span x-show="parseFloat(account.pc_balance_difference) === 0.0" class="text-muted"
|
||||||
|
x-text="formatMoney(account.pc_balance_difference, account.primary_currency_code)"></span>
|
||||||
|
<span x-show="parseFloat(account.pc_balance_difference) > 0.0" class="text-success"
|
||||||
|
x-text="formatMoney(account.pc_balance_difference, account.primary_currency_code)"></span>
|
||||||
|
)
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
</td>
|
</td>
|
||||||
<td x-show="tableColumns.menu.visible && tableColumns.menu.enabled">
|
<td x-show="tableColumns.menu.visible && tableColumns.menu.enabled">
|
||||||
|
Reference in New Issue
Block a user