mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Various fixes and cleanup
This commit is contained in:
@@ -73,12 +73,12 @@ class NetWorth implements NetWorthInterface
|
||||
$cache->addProperty('net-worth-by-currency');
|
||||
$cache->addProperty(implode(',', $accounts->pluck('id')->toArray()));
|
||||
if ($cache->has()) {
|
||||
// return $cache->get();
|
||||
return $cache->get();
|
||||
}
|
||||
|
||||
$netWorth = [];
|
||||
$result = [];
|
||||
Log::debug(sprintf('Now in getNetWorthByCurrency(%s)', $date->format('Y-m-d')));
|
||||
// Log::debug(sprintf('Now in getNetWorthByCurrency(%s)', $date->format('Y-m-d')));
|
||||
|
||||
// get default currency
|
||||
$default = app('amount')->getDefaultCurrencyByUser($this->user);
|
||||
@@ -89,16 +89,16 @@ class NetWorth implements NetWorthInterface
|
||||
// get the preferred currency for this account
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
Log::debug(sprintf('Now at account #%d: "%s"', $account->id, $account->name));
|
||||
// Log::debug(sprintf('Now at account #%d: "%s"', $account->id, $account->name));
|
||||
$currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id');
|
||||
$currencyId = 0 === $currencyId ? $default->id : $currencyId;
|
||||
|
||||
Log::debug(sprintf('Currency ID is #%d', $currencyId));
|
||||
// Log::debug(sprintf('Currency ID is #%d', $currencyId));
|
||||
|
||||
// balance in array:
|
||||
$balance = $balances[$account->id] ?? '0';
|
||||
|
||||
Log::debug(sprintf('Balance for %s is %s', $date->format('Y-m-d'), $balance));
|
||||
//Log::debug(sprintf('Balance for %s is %s', $date->format('Y-m-d'), $balance));
|
||||
|
||||
// always subtract virtual balance.
|
||||
$virtualBalance = (string)$account->virtual_balance;
|
||||
@@ -106,14 +106,14 @@ class NetWorth implements NetWorthInterface
|
||||
$balance = bcsub($balance, $virtualBalance);
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Balance corrected to %s because of virtual balance (%s)', $balance, $virtualBalance));
|
||||
// Log::debug(sprintf('Balance corrected to %s because of virtual balance (%s)', $balance, $virtualBalance));
|
||||
|
||||
if (!array_key_exists($currencyId, $netWorth)) {
|
||||
$netWorth[$currencyId] = '0';
|
||||
}
|
||||
$netWorth[$currencyId] = bcadd($balance, $netWorth[$currencyId]);
|
||||
|
||||
Log::debug(sprintf('Total net worth for currency #%d is %s', $currencyId, $netWorth[$currencyId]));
|
||||
// Log::debug(sprintf('Total net worth for currency #%d is %s', $currencyId, $netWorth[$currencyId]));
|
||||
}
|
||||
ksort($netWorth);
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ trait ConvertsDataTypes
|
||||
if (null === $string) {
|
||||
return null;
|
||||
}
|
||||
if('' === $string) {
|
||||
if ('' === $string) {
|
||||
return '';
|
||||
}
|
||||
$search = [
|
||||
@@ -154,7 +154,7 @@ trait ConvertsDataTypes
|
||||
if (null === $string) {
|
||||
return null;
|
||||
}
|
||||
if('' === $string) {
|
||||
if ('' === $string) {
|
||||
return '';
|
||||
}
|
||||
return trim($string);
|
||||
|
||||
@@ -368,9 +368,10 @@ class User extends Authenticatable
|
||||
* @return int
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function getAdministrationId(): int {
|
||||
public function getAdministrationId(): int
|
||||
{
|
||||
$groupId = (int)$this->user_group_id;
|
||||
if(0 === $groupId) {
|
||||
if (0 === $groupId) {
|
||||
throw new FireflyException('User has no administration ID.');
|
||||
}
|
||||
return $groupId;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
* ValidatesAdministrationAccess.php
|
||||
* Copyright (c) 2023 james@firefly-iii.org
|
||||
|
||||
@@ -46,7 +46,7 @@ trait CurrencyValidation
|
||||
$transactions = $this->getTransactionsArray($validator);
|
||||
|
||||
foreach ($transactions as $index => $transaction) {
|
||||
if(!is_array($transaction)) {
|
||||
if (!is_array($transaction)) {
|
||||
continue;
|
||||
}
|
||||
// if foreign amount is present, then the currency must be as well.
|
||||
|
||||
Reference in New Issue
Block a user