mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-17 09:51:40 +00:00
Try to convert balance to native, still internal debates.
This commit is contained in:
@@ -131,6 +131,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
|
|
||||||
// currency info:
|
// currency info:
|
||||||
'source.amount as amount',
|
'source.amount as amount',
|
||||||
|
'source.native_amount as native_amount',
|
||||||
'source.transaction_currency_id as currency_id',
|
'source.transaction_currency_id as currency_id',
|
||||||
'currency.code as currency_code',
|
'currency.code as currency_code',
|
||||||
'currency.name as currency_name',
|
'currency.name as currency_name',
|
||||||
@@ -139,6 +140,7 @@ class GroupCollector implements GroupCollectorInterface
|
|||||||
|
|
||||||
// foreign currency info
|
// foreign currency info
|
||||||
'source.foreign_amount as foreign_amount',
|
'source.foreign_amount as foreign_amount',
|
||||||
|
'source.native_foreign_amount as native_foreign_amount',
|
||||||
'source.foreign_currency_id as foreign_currency_id',
|
'source.foreign_currency_id as foreign_currency_id',
|
||||||
'foreign_currency.code as foreign_currency_code',
|
'foreign_currency.code as foreign_currency_code',
|
||||||
'foreign_currency.name as foreign_currency_name',
|
'foreign_currency.name as foreign_currency_name',
|
||||||
|
@@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Http\Controllers\Chart;
|
namespace FireflyIII\Http\Controllers\Chart;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use FireflyIII\Enums\AccountTypeEnum;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||||
@@ -300,7 +301,7 @@ class AccountController extends Controller
|
|||||||
{
|
{
|
||||||
$start = clone session('start', today(config('app.timezone'))->startOfMonth());
|
$start = clone session('start', today(config('app.timezone'))->startOfMonth());
|
||||||
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
|
$end = clone session('end', today(config('app.timezone'))->endOfMonth());
|
||||||
$defaultSet = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray();
|
$defaultSet = $repository->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value])->pluck('id')->toArray();
|
||||||
Log::debug('Default set is ', $defaultSet);
|
Log::debug('Default set is ', $defaultSet);
|
||||||
$frontpage = app('preferences')->get('frontpageAccounts', $defaultSet);
|
$frontpage = app('preferences')->get('frontpageAccounts', $defaultSet);
|
||||||
$frontpageArray = !is_array($frontpage->data) ? [] : $frontpage->data;
|
$frontpageArray = !is_array($frontpage->data) ? [] : $frontpage->data;
|
||||||
|
@@ -23,12 +23,14 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Http\Controllers;
|
namespace FireflyIII\Http\Controllers;
|
||||||
|
|
||||||
|
use FireflyIII\Support\Facades\Steam;
|
||||||
use FireflyIII\Support\Http\Controllers\RequestInformation;
|
use FireflyIII\Support\Http\Controllers\RequestInformation;
|
||||||
use FireflyIII\Support\Http\Controllers\UserNavigation;
|
use FireflyIII\Support\Http\Controllers\UserNavigation;
|
||||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||||
use Illuminate\Routing\Controller as BaseController;
|
use Illuminate\Routing\Controller as BaseController;
|
||||||
|
use Illuminate\Support\Facades\View;
|
||||||
use Route;
|
use Route;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,13 +63,13 @@ abstract class Controller extends BaseController
|
|||||||
// is site a demo site?
|
// is site a demo site?
|
||||||
$isDemoSiteConfig = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site', false));
|
$isDemoSiteConfig = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site', false));
|
||||||
$isDemoSite = (bool) $isDemoSiteConfig->data;
|
$isDemoSite = (bool) $isDemoSiteConfig->data;
|
||||||
app('view')->share('IS_DEMO_SITE', $isDemoSite);
|
View::share('IS_DEMO_SITE', $isDemoSite);
|
||||||
app('view')->share('DEMO_USERNAME', config('firefly.demo_username'));
|
View::share('DEMO_USERNAME', config('firefly.demo_username'));
|
||||||
app('view')->share('DEMO_PASSWORD', config('firefly.demo_password'));
|
View::share('DEMO_PASSWORD', config('firefly.demo_password'));
|
||||||
app('view')->share('FF_VERSION', config('firefly.version'));
|
View::share('FF_VERSION', config('firefly.version'));
|
||||||
|
|
||||||
// is webhooks enabled?
|
// is webhooks enabled?
|
||||||
app('view')->share('featuringWebhooks', true === config('firefly.feature_flags.webhooks') && true === config('firefly.allow_webhooks'));
|
View::share('featuringWebhooks', true === config('firefly.feature_flags.webhooks') && true === config('firefly.allow_webhooks'));
|
||||||
|
|
||||||
// share custom auth guard info.
|
// share custom auth guard info.
|
||||||
$authGuard = config('firefly.authentication_guard');
|
$authGuard = config('firefly.authentication_guard');
|
||||||
@@ -75,17 +77,17 @@ abstract class Controller extends BaseController
|
|||||||
|
|
||||||
// overrule v2 layout back to v1.
|
// overrule v2 layout back to v1.
|
||||||
if ('true' === request()->get('force_default_layout') && 'v2' === config('view.layout')) {
|
if ('true' === request()->get('force_default_layout') && 'v2' === config('view.layout')) {
|
||||||
app('view')->getFinder()->setPaths([realpath(base_path('resources/views'))]); // @phpstan-ignore-line
|
View::getFinder()->setPaths([realpath(base_path('resources/views'))]); // @phpstan-ignore-line
|
||||||
}
|
}
|
||||||
|
|
||||||
app('view')->share('authGuard', $authGuard);
|
View::share('authGuard', $authGuard);
|
||||||
app('view')->share('logoutUrl', $logoutUrl);
|
View::share('logoutUrl', $logoutUrl);
|
||||||
|
|
||||||
// upload size
|
// upload size
|
||||||
$maxFileSize = app('steam')->phpBytes((string) ini_get('upload_max_filesize'));
|
$maxFileSize = Steam::phpBytes((string) ini_get('upload_max_filesize'));
|
||||||
$maxPostSize = app('steam')->phpBytes((string) ini_get('post_max_size'));
|
$maxPostSize = Steam::phpBytes((string) ini_get('post_max_size'));
|
||||||
$uploadSize = min($maxFileSize, $maxPostSize);
|
$uploadSize = min($maxFileSize, $maxPostSize);
|
||||||
app('view')->share('uploadSize', $uploadSize);
|
View::share('uploadSize', $uploadSize);
|
||||||
|
|
||||||
// share is alpha, is beta
|
// share is alpha, is beta
|
||||||
$isAlpha = false;
|
$isAlpha = false;
|
||||||
@@ -98,12 +100,12 @@ abstract class Controller extends BaseController
|
|||||||
$isBeta = true;
|
$isBeta = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
app('view')->share('FF_IS_ALPHA', $isAlpha);
|
View::share('FF_IS_ALPHA', $isAlpha);
|
||||||
app('view')->share('FF_IS_BETA', $isBeta);
|
View::share('FF_IS_BETA', $isBeta);
|
||||||
|
|
||||||
$this->middleware(
|
$this->middleware(
|
||||||
function ($request, $next): mixed {
|
function ($request, $next): mixed {
|
||||||
$locale = app('steam')->getLocale();
|
$locale = Steam::getLocale();
|
||||||
// translations for specific strings:
|
// translations for specific strings:
|
||||||
$this->monthFormat = (string) trans('config.month_js', [], $locale);
|
$this->monthFormat = (string) trans('config.month_js', [], $locale);
|
||||||
$this->monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
|
$this->monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
|
||||||
@@ -111,18 +113,20 @@ abstract class Controller extends BaseController
|
|||||||
$darkMode = 'browser';
|
$darkMode = 'browser';
|
||||||
// get shown-intro-preference:
|
// get shown-intro-preference:
|
||||||
if (auth()->check()) {
|
if (auth()->check()) {
|
||||||
$language = app('steam')->getLanguage();
|
$language = Steam::getLanguage();
|
||||||
$locale = app('steam')->getLocale();
|
$locale = Steam::getLocale();
|
||||||
$darkMode = app('preferences')->get('darkMode', 'browser')->data;
|
$darkMode = app('preferences')->get('darkMode', 'browser')->data;
|
||||||
|
$convertToNative =app('preferences')->get('convert_to_native', false)->data;
|
||||||
$page = $this->getPageName();
|
$page = $this->getPageName();
|
||||||
$shownDemo = $this->hasSeenDemo();
|
$shownDemo = $this->hasSeenDemo();
|
||||||
app('view')->share('language', $language);
|
View::share('language', $language);
|
||||||
app('view')->share('locale', $locale);
|
View::share('locale', $locale);
|
||||||
app('view')->share('shownDemo', $shownDemo);
|
View::share('convertToNative', $convertToNative);
|
||||||
app('view')->share('current_route_name', $page);
|
View::share('shownDemo', $shownDemo);
|
||||||
app('view')->share('original_route_name', Route::currentRouteName());
|
View::share('current_route_name', $page);
|
||||||
|
View::share('original_route_name', Route::currentRouteName());
|
||||||
}
|
}
|
||||||
app('view')->share('darkMode', $darkMode);
|
View::share('darkMode', $darkMode);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
|
@@ -50,8 +50,9 @@ trait ChartGeneration
|
|||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty('chart.account.account-balance-chart');
|
$cache->addProperty('chart.account.account-balance-chart');
|
||||||
$cache->addProperty($accounts);
|
$cache->addProperty($accounts);
|
||||||
|
$convertToNative =app('preferences')->get('convert_to_native', false)->data;
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get();
|
// return $cache->get();
|
||||||
}
|
}
|
||||||
app('log')->debug('Regenerate chart.account.account-balance-chart from scratch.');
|
app('log')->debug('Regenerate chart.account.account-balance-chart from scratch.');
|
||||||
$locale = app('steam')->getLocale();
|
$locale = app('steam')->getLocale();
|
||||||
@@ -72,6 +73,11 @@ trait ChartGeneration
|
|||||||
if (null === $currency) {
|
if (null === $currency) {
|
||||||
$currency = $default;
|
$currency = $default;
|
||||||
}
|
}
|
||||||
|
// if the user prefers the native currency, overrule the currency of the account.
|
||||||
|
if($currency->id !== $default->id && $convertToNative) {
|
||||||
|
$currency = $default;
|
||||||
|
}
|
||||||
|
|
||||||
$currentSet = [
|
$currentSet = [
|
||||||
'label' => $account->name,
|
'label' => $account->name,
|
||||||
'currency_symbol' => $currency->symbol,
|
'currency_symbol' => $currency->symbol,
|
||||||
@@ -79,7 +85,7 @@ trait ChartGeneration
|
|||||||
];
|
];
|
||||||
|
|
||||||
$currentStart = clone $start;
|
$currentStart = clone $start;
|
||||||
$range = app('steam')->balanceInRange($account, $start, clone $end);
|
$range = $convertToNative ? app('steam')->balanceInRangeNative($account, $start, clone $end) : app('steam')->balanceInRange($account, $start, clone $end);
|
||||||
$previous = array_values($range)[0];
|
$previous = array_values($range)[0];
|
||||||
while ($currentStart <= $end) {
|
while ($currentStart <= $end) {
|
||||||
$format = $currentStart->format('Y-m-d');
|
$format = $currentStart->format('Y-m-d');
|
||||||
|
@@ -41,7 +41,7 @@ class Steam
|
|||||||
{
|
{
|
||||||
public function balanceByTransactions(Account $account, Carbon $date, ?TransactionCurrency $currency): array
|
public function balanceByTransactions(Account $account, Carbon $date, ?TransactionCurrency $currency): array
|
||||||
{
|
{
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
$cache->addProperty('balance-by-transactions');
|
$cache->addProperty('balance-by-transactions');
|
||||||
$cache->addProperty($date);
|
$cache->addProperty($date);
|
||||||
@@ -50,13 +50,12 @@ class Steam
|
|||||||
return $cache->get();
|
return $cache->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $account->transactions()
|
$query = $account->transactions()
|
||||||
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->orderBy('transaction_journals.date', 'desc')
|
->orderBy('transaction_journals.date', 'desc')
|
||||||
->orderBy('transaction_journals.order', 'asc')
|
->orderBy('transaction_journals.order', 'asc')
|
||||||
->orderBy('transaction_journals.description', 'desc')
|
->orderBy('transaction_journals.description', 'desc')
|
||||||
->orderBy('transactions.amount', 'desc')
|
->orderBy('transactions.amount', 'desc');
|
||||||
;
|
|
||||||
if (null !== $currency) {
|
if (null !== $currency) {
|
||||||
$query->where('transactions.transaction_currency_id', $currency->id);
|
$query->where('transactions.transaction_currency_id', $currency->id);
|
||||||
$query->limit(1);
|
$query->limit(1);
|
||||||
@@ -71,7 +70,7 @@ class Steam
|
|||||||
$return = [];
|
$return = [];
|
||||||
$result = $query->get(['transactions.transaction_currency_id', 'transactions.balance_after']);
|
$result = $query->get(['transactions.transaction_currency_id', 'transactions.balance_after']);
|
||||||
foreach ($result as $entry) {
|
foreach ($result as $entry) {
|
||||||
$key = (int) $entry->transaction_currency_id;
|
$key = (int) $entry->transaction_currency_id;
|
||||||
if (array_key_exists($key, $return)) {
|
if (array_key_exists($key, $return)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -81,13 +80,16 @@ class Steam
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
public function balanceConvertedIgnoreVirtual(Account $account, Carbon $date, TransactionCurrency $currency): string
|
public function balanceConvertedIgnoreVirtual(Account $account, Carbon $date, TransactionCurrency $currency): string
|
||||||
{
|
{
|
||||||
$balance = $this->balanceConverted($account, $date, $currency);
|
$balance = $this->balanceConverted($account, $date, $currency);
|
||||||
$virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;
|
$virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;
|
||||||
|
|
||||||
// currency of account
|
// currency of account
|
||||||
$repository = app(AccountRepositoryInterface::class);
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
$repository->setUser($account->user);
|
$repository->setUser($account->user);
|
||||||
$accountCurrency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
|
$accountCurrency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
|
||||||
if ($accountCurrency->id !== $currency->id && 0 !== bccomp($virtual, '0')) {
|
if ($accountCurrency->id !== $currency->id && 0 !== bccomp($virtual, '0')) {
|
||||||
@@ -100,7 +102,13 @@ class Steam
|
|||||||
return bcsub($balance, $virtual);
|
return bcsub($balance, $virtual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @throws FireflyException
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
* @deprecated
|
||||||
* selection of transactions
|
* selection of transactions
|
||||||
* 1: all normal transactions. No foreign currency info. In $currency. Need conversion.
|
* 1: all normal transactions. No foreign currency info. In $currency. Need conversion.
|
||||||
* 2: all normal transactions. No foreign currency info. In $native. Need NO conversion.
|
* 2: all normal transactions. No foreign currency info. In $native. Need NO conversion.
|
||||||
@@ -115,23 +123,18 @@ class Steam
|
|||||||
* Gets balance at the end of current month by default. Returns the balance converted
|
* Gets balance at the end of current month by default. Returns the balance converted
|
||||||
* to the indicated currency ($native).
|
* to the indicated currency ($native).
|
||||||
*
|
*
|
||||||
* @throws FireflyException
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
|
||||||
*/
|
*/
|
||||||
public function balanceConverted(Account $account, Carbon $date, TransactionCurrency $native): string
|
public function balanceConverted(Account $account, Carbon $date, TransactionCurrency $native): string
|
||||||
{
|
{
|
||||||
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
|
||||||
Log::debug(sprintf('Now in balanceConverted (%s) for account #%d, converting to %s', $date->format('Y-m-d'), $account->id, $native->code));
|
Log::debug(sprintf('Now in balanceConverted (%s) for account #%d, converting to %s', $date->format('Y-m-d'), $account->id, $native->code));
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
$cache->addProperty('balance');
|
$cache->addProperty('balance-converted');
|
||||||
$cache->addProperty($date);
|
$cache->addProperty($date);
|
||||||
$cache->addProperty($native->id);
|
$cache->addProperty($native->id);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
Log::debug('Cached!');
|
Log::debug('Cached!');
|
||||||
|
// return $cache->get();
|
||||||
return $cache->get();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var AccountRepositoryInterface $repository */
|
/** @var AccountRepositoryInterface $repository */
|
||||||
@@ -144,72 +147,66 @@ class Steam
|
|||||||
return $this->balance($account, $date);
|
return $this->balance($account, $date);
|
||||||
}
|
}
|
||||||
|
|
||||||
$new = [];
|
$new = [];
|
||||||
$existing = [];
|
$existing = [];
|
||||||
$new[] = $account->transactions() // 1
|
$new[] = $account->transactions() // 1
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.transaction_currency_id', $currency->id)
|
->where('transactions.transaction_currency_id', $currency->id)
|
||||||
->whereNull('transactions.foreign_currency_id')
|
->whereNull('transactions.foreign_currency_id')
|
||||||
->get(['transaction_journals.date', 'transactions.amount'])->toArray()
|
->get(['transaction_journals.date', 'transactions.amount'])->toArray();
|
||||||
;
|
|
||||||
Log::debug(sprintf('%d transaction(s) in set #1', count($new[0])));
|
Log::debug(sprintf('%d transaction(s) in set #1', count($new[0])));
|
||||||
$existing[] = $account->transactions() // 2
|
$existing[] = $account->transactions() // 2
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.transaction_currency_id', $native->id)
|
->where('transactions.transaction_currency_id', $native->id)
|
||||||
->whereNull('transactions.foreign_currency_id')
|
->whereNull('transactions.foreign_currency_id')
|
||||||
->get(['transactions.amount'])->toArray()
|
->get(['transactions.amount'])->toArray();
|
||||||
;
|
|
||||||
Log::debug(sprintf('%d transaction(s) in set #2', count($existing[0])));
|
Log::debug(sprintf('%d transaction(s) in set #2', count($existing[0])));
|
||||||
$new[] = $account->transactions() // 3
|
$new[] = $account->transactions() // 3
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.transaction_currency_id', '!=', $currency->id)
|
->where('transactions.transaction_currency_id', '!=', $currency->id)
|
||||||
->where('transactions.transaction_currency_id', '!=', $native->id)
|
->where('transactions.transaction_currency_id', '!=', $native->id)
|
||||||
->whereNull('transactions.foreign_currency_id')
|
->whereNull('transactions.foreign_currency_id')
|
||||||
->get(['transaction_journals.date', 'transactions.amount'])->toArray()
|
->get(['transaction_journals.date', 'transactions.amount'])->toArray();
|
||||||
;
|
|
||||||
Log::debug(sprintf('%d transactions in set #3', count($new[1])));
|
Log::debug(sprintf('%d transactions in set #3', count($new[1])));
|
||||||
$existing[] = $account->transactions() // 4
|
$existing[] = $account->transactions() // 4
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.foreign_currency_id', $native->id)
|
->where('transactions.foreign_currency_id', $native->id)
|
||||||
->whereNotNull('transactions.foreign_amount')
|
->whereNotNull('transactions.foreign_amount')
|
||||||
->get(['transactions.foreign_amount'])->toArray()
|
->get(['transactions.foreign_amount'])->toArray();
|
||||||
;
|
|
||||||
Log::debug(sprintf('%d transactions in set #4', count($existing[1])));
|
Log::debug(sprintf('%d transactions in set #4', count($existing[1])));
|
||||||
$new[] = $account->transactions()// 5
|
$new[] = $account->transactions()// 5
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.transaction_currency_id', $currency->id)
|
->where('transactions.transaction_currency_id', $currency->id)
|
||||||
->where('transactions.foreign_currency_id', '!=', $native->id)
|
->where('transactions.foreign_currency_id', '!=', $native->id)
|
||||||
->whereNotNull('transactions.foreign_amount')
|
->whereNotNull('transactions.foreign_amount')
|
||||||
->get(['transaction_journals.date', 'transactions.amount'])->toArray()
|
->get(['transaction_journals.date', 'transactions.amount'])->toArray();
|
||||||
;
|
|
||||||
Log::debug(sprintf('%d transactions in set #5', count($new[2])));
|
Log::debug(sprintf('%d transactions in set #5', count($new[2])));
|
||||||
$new[] = $account->transactions()// 6
|
$new[] = $account->transactions()// 6
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.transaction_currency_id', '!=', $currency->id)
|
->where('transactions.transaction_currency_id', '!=', $currency->id)
|
||||||
->where('transactions.foreign_currency_id', '!=', $native->id)
|
->where('transactions.foreign_currency_id', '!=', $native->id)
|
||||||
->whereNotNull('transactions.foreign_amount')
|
->whereNotNull('transactions.foreign_amount')
|
||||||
->get(['transaction_journals.date', 'transactions.amount'])->toArray()
|
->get(['transaction_journals.date', 'transactions.amount'])->toArray();
|
||||||
;
|
|
||||||
Log::debug(sprintf('%d transactions in set #6', count($new[3])));
|
Log::debug(sprintf('%d transactions in set #6', count($new[3])));
|
||||||
|
|
||||||
// process both sets of transactions. Of course, no need to convert set "existing".
|
// process both sets of transactions. Of course, no need to convert set "existing".
|
||||||
$balance = $this->sumTransactions($existing[0], 'amount');
|
$balance = $this->sumTransactions($existing[0], 'amount');
|
||||||
$balance = bcadd($balance, $this->sumTransactions($existing[1], 'foreign_amount'));
|
$balance = bcadd($balance, $this->sumTransactions($existing[1], 'foreign_amount'));
|
||||||
Log::debug(sprintf('Balance from set #2 and #4 is %f', $balance));
|
Log::debug(sprintf('Balance from set #2 and #4 is %f', $balance));
|
||||||
|
|
||||||
// need to convert the others. All sets use the "amount" value as their base (that's easy)
|
// need to convert the others. All sets use the "amount" value as their base (that's easy)
|
||||||
// but we need to convert each transaction separately because the date difference may
|
// but we need to convert each transaction separately because the date difference may
|
||||||
// incur huge currency changes.
|
// incur huge currency changes.
|
||||||
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
|
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
|
||||||
$start = clone $date;
|
$start = clone $date;
|
||||||
$end = clone $date;
|
$end = clone $date;
|
||||||
$converter = new ExchangeRateConverter();
|
$converter = new ExchangeRateConverter();
|
||||||
foreach ($new as $set) {
|
foreach ($new as $set) {
|
||||||
foreach ($set as $transaction) {
|
foreach ($set as $transaction) {
|
||||||
$currentDate = false;
|
$currentDate = false;
|
||||||
@@ -232,7 +229,7 @@ class Steam
|
|||||||
|
|
||||||
foreach ($new as $set) {
|
foreach ($new as $set) {
|
||||||
foreach ($set as $transaction) {
|
foreach ($set as $transaction) {
|
||||||
$currentDate = false;
|
$currentDate = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$currentDate = Carbon::parse($transaction['date'], config('app.timezone'));
|
$currentDate = Carbon::parse($transaction['date'], config('app.timezone'));
|
||||||
@@ -249,9 +246,9 @@ class Steam
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add virtual balance (also needs conversion)
|
// add virtual balance (also needs conversion)
|
||||||
$virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;
|
$virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;
|
||||||
$virtual = $converter->convert($currency, $native, $account->created_at, $virtual);
|
$virtual = $converter->convert($currency, $native, $account->created_at, $virtual);
|
||||||
$balance = bcadd($balance, $virtual);
|
$balance = bcadd($balance, $virtual);
|
||||||
$converter->summarize();
|
$converter->summarize();
|
||||||
|
|
||||||
$cache->store($balance);
|
$cache->store($balance);
|
||||||
@@ -260,6 +257,78 @@ class Steam
|
|||||||
return $balance;
|
return $balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Balance of an (asset) account in the user's native currency.
|
||||||
|
* Is calculated by summing up three numbers.
|
||||||
|
*
|
||||||
|
* - Transactions in foreign amount that happen to be in the native currency.
|
||||||
|
* - The rest of the transactions in the native currency.
|
||||||
|
* - Where both are zero or NULL, the normal amount converted (and stored!)
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
|
public function balanceNative(Account $account, Carbon $date): string
|
||||||
|
{
|
||||||
|
$native = app('amount')->getDefaultCurrency();
|
||||||
|
Log::debug(sprintf('Now in balanceNative (%s) for account #%d, converting to %s', $date->format('Y-m-d'), $account->id, $native->code));
|
||||||
|
$cache = new CacheProperties();
|
||||||
|
$cache->addProperty($account->id);
|
||||||
|
$cache->addProperty('balance-native');
|
||||||
|
$cache->addProperty($date);
|
||||||
|
$cache->addProperty($native->id);
|
||||||
|
if ($cache->has()) {
|
||||||
|
$value = $cache->get();
|
||||||
|
Log::debug(sprintf('Return cached value %s', $value));
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var AccountRepositoryInterface $repository */
|
||||||
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
|
$currency = $repository->getAccountCurrency($account);
|
||||||
|
$currency = null === $currency ? $native : $currency;
|
||||||
|
if ($native->id === $currency->id) {
|
||||||
|
Log::debug('No conversion necessary!');
|
||||||
|
|
||||||
|
return $this->balance($account, $date);
|
||||||
|
}
|
||||||
|
$balance = '0';
|
||||||
|
// transactions in foreign amount that happen to be in the native currency:
|
||||||
|
$set = $account->transactions()
|
||||||
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
|
->where('transactions.foreign_currency_id', $native->id)
|
||||||
|
->get(['transactions.foreign_amount'])->toArray();
|
||||||
|
$balance = bcadd($this->sumTransactions($set, 'foreign_amount'), $balance);
|
||||||
|
Log::debug(sprintf('The balance is now %s', $balance));
|
||||||
|
|
||||||
|
// transactions in the native amount.
|
||||||
|
$set = $account->transactions()
|
||||||
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
|
->whereNull('transactions.foreign_currency_id')
|
||||||
|
->whereNotNull('transactions.native_amount')
|
||||||
|
->get(['transactions.native_amount'])->toArray();
|
||||||
|
$balance = bcadd($this->sumTransactions($set, 'native_amount'), $balance);
|
||||||
|
Log::debug(sprintf('The balance is now %s', $balance));
|
||||||
|
|
||||||
|
// transactions in the normal amount with no native amount set.
|
||||||
|
$set = $account->transactions()
|
||||||
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
|
->whereNull('transactions.foreign_currency_id')
|
||||||
|
->whereNull('transactions.native_amount')
|
||||||
|
->get(['transactions.amount'])->toArray();
|
||||||
|
$balance = bcadd($this->sumTransactions($set, 'amount'), $balance);
|
||||||
|
Log::debug(sprintf('The balance is now %s', $balance));
|
||||||
|
|
||||||
|
// add virtual balance (also needs conversion)
|
||||||
|
$virtualNative = null === $account->native_virtual_balance ? '0' : $account->native_virtual_balance;
|
||||||
|
$final = bcadd($virtualNative, $balance);
|
||||||
|
Log::debug(sprintf('Final balance is %s', $final));
|
||||||
|
$cache->store($final);
|
||||||
|
return $final;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets balance at the end of current month by default
|
* Gets balance at the end of current month by default
|
||||||
*
|
*
|
||||||
@@ -269,7 +338,7 @@ class Steam
|
|||||||
{
|
{
|
||||||
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
||||||
// abuse chart properties:
|
// abuse chart properties:
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
$cache->addProperty('balance');
|
$cache->addProperty('balance');
|
||||||
$cache->addProperty($date);
|
$cache->addProperty($date);
|
||||||
@@ -279,26 +348,24 @@ class Steam
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var AccountRepositoryInterface $repository */
|
/** @var AccountRepositoryInterface $repository */
|
||||||
$repository = app(AccountRepositoryInterface::class);
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
if (null === $currency) {
|
if (null === $currency) {
|
||||||
$currency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
|
$currency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
|
||||||
}
|
}
|
||||||
// first part: get all balances in own currency:
|
// first part: get all balances in own currency:
|
||||||
$transactions = $account->transactions()
|
$transactions = $account->transactions()
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.transaction_currency_id', $currency->id)
|
->where('transactions.transaction_currency_id', $currency->id)
|
||||||
->get(['transactions.amount'])->toArray()
|
->get(['transactions.amount'])->toArray();
|
||||||
;
|
$nativeBalance = $this->sumTransactions($transactions, 'amount');
|
||||||
$nativeBalance = $this->sumTransactions($transactions, 'amount');
|
|
||||||
// get all balances in foreign currency:
|
// get all balances in foreign currency:
|
||||||
$transactions = $account->transactions()
|
$transactions = $account->transactions()
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.foreign_currency_id', $currency->id)
|
->where('transactions.foreign_currency_id', $currency->id)
|
||||||
->where('transactions.transaction_currency_id', '!=', $currency->id)
|
->where('transactions.transaction_currency_id', '!=', $currency->id)
|
||||||
->get(['transactions.foreign_amount'])->toArray()
|
->get(['transactions.foreign_amount'])->toArray();
|
||||||
;
|
|
||||||
$foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');
|
$foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');
|
||||||
$balance = bcadd($nativeBalance, $foreignBalance);
|
$balance = bcadd($nativeBalance, $foreignBalance);
|
||||||
$virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;
|
$virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;
|
||||||
@@ -317,26 +384,24 @@ class Steam
|
|||||||
throw new FireflyException('Deprecated method balanceIgnoreVirtual.');
|
throw new FireflyException('Deprecated method balanceIgnoreVirtual.');
|
||||||
|
|
||||||
/** @var AccountRepositoryInterface $repository */
|
/** @var AccountRepositoryInterface $repository */
|
||||||
$repository = app(AccountRepositoryInterface::class);
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
$repository->setUser($account->user);
|
$repository->setUser($account->user);
|
||||||
|
|
||||||
$currencyId = (int) $repository->getMetaValue($account, 'currency_id');
|
$currencyId = (int) $repository->getMetaValue($account, 'currency_id');
|
||||||
$transactions = $account->transactions()
|
$transactions = $account->transactions()
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.transaction_currency_id', $currencyId)
|
->where('transactions.transaction_currency_id', $currencyId)
|
||||||
->get(['transactions.amount'])->toArray()
|
->get(['transactions.amount'])->toArray();
|
||||||
;
|
$nativeBalance = $this->sumTransactions($transactions, 'amount');
|
||||||
$nativeBalance = $this->sumTransactions($transactions, 'amount');
|
|
||||||
|
|
||||||
// get all balances in foreign currency:
|
// get all balances in foreign currency:
|
||||||
$transactions = $account->transactions()
|
$transactions = $account->transactions()
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.foreign_currency_id', $currencyId)
|
->where('transactions.foreign_currency_id', $currencyId)
|
||||||
->where('transactions.transaction_currency_id', '!=', $currencyId)
|
->where('transactions.transaction_currency_id', '!=', $currencyId)
|
||||||
->get(['transactions.foreign_amount'])->toArray()
|
->get(['transactions.foreign_amount'])->toArray();
|
||||||
;
|
|
||||||
|
|
||||||
$foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');
|
$foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');
|
||||||
|
|
||||||
@@ -357,6 +422,7 @@ class Steam
|
|||||||
return $sum;
|
return $sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the balance for the given account during the whole range, using this format:.
|
* Gets the balance for the given account during the whole range, using this format:.
|
||||||
*
|
*
|
||||||
@@ -367,7 +433,7 @@ class Steam
|
|||||||
public function balanceInRange(Account $account, Carbon $start, Carbon $end, ?TransactionCurrency $currency = null): array
|
public function balanceInRange(Account $account, Carbon $start, Carbon $end, ?TransactionCurrency $currency = null): array
|
||||||
{
|
{
|
||||||
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
$cache->addProperty('balance-in-range');
|
$cache->addProperty('balance-in-range');
|
||||||
$cache->addProperty(null !== $currency ? $currency->id : 0);
|
$cache->addProperty(null !== $currency ? $currency->id : 0);
|
||||||
@@ -379,42 +445,41 @@ class Steam
|
|||||||
|
|
||||||
$start->subDay();
|
$start->subDay();
|
||||||
$end->addDay();
|
$end->addDay();
|
||||||
$balances = [];
|
$balances = [];
|
||||||
$formatted = $start->format('Y-m-d');
|
$formatted = $start->format('Y-m-d');
|
||||||
$startBalance = $this->balance($account, $start, $currency);
|
$startBalance = $this->balance($account, $start, $currency);
|
||||||
|
|
||||||
$balances[$formatted] = $startBalance;
|
$balances[$formatted] = $startBalance;
|
||||||
if (null === $currency) {
|
if (null === $currency) {
|
||||||
$repository = app(AccountRepositoryInterface::class);
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
$repository->setUser($account->user);
|
$repository->setUser($account->user);
|
||||||
$currency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
|
$currency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
|
||||||
}
|
}
|
||||||
$currencyId = $currency->id;
|
$currencyId = $currency->id;
|
||||||
|
|
||||||
$start->addDay();
|
$start->addDay();
|
||||||
|
|
||||||
// query!
|
// query!
|
||||||
$set = $account->transactions()
|
$set = $account->transactions()
|
||||||
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))
|
->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))
|
||||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $end->format('Y-m-d 23:59:59'))
|
||||||
->groupBy('transaction_journals.date')
|
->groupBy('transaction_journals.date')
|
||||||
->groupBy('transactions.transaction_currency_id')
|
->groupBy('transactions.transaction_currency_id')
|
||||||
->groupBy('transactions.foreign_currency_id')
|
->groupBy('transactions.foreign_currency_id')
|
||||||
->orderBy('transaction_journals.date', 'ASC')
|
->orderBy('transaction_journals.date', 'ASC')
|
||||||
->whereNull('transaction_journals.deleted_at')
|
->whereNull('transaction_journals.deleted_at')
|
||||||
->get(
|
->get(
|
||||||
[ // @phpstan-ignore-line
|
[ // @phpstan-ignore-line
|
||||||
'transaction_journals.date',
|
'transaction_journals.date',
|
||||||
'transactions.transaction_currency_id',
|
'transactions.transaction_currency_id',
|
||||||
\DB::raw('SUM(transactions.amount) AS modified'),
|
\DB::raw('SUM(transactions.amount) AS modified'),
|
||||||
'transactions.foreign_currency_id',
|
'transactions.foreign_currency_id',
|
||||||
\DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'),
|
\DB::raw('SUM(transactions.foreign_amount) AS modified_foreign'),
|
||||||
]
|
]
|
||||||
)
|
);
|
||||||
;
|
|
||||||
|
|
||||||
$currentBalance = $startBalance;
|
$currentBalance = $startBalance;
|
||||||
|
|
||||||
/** @var Transaction $entry */
|
/** @var Transaction $entry */
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
@@ -450,14 +515,14 @@ class Steam
|
|||||||
public function balanceInRangeConverted(Account $account, Carbon $start, Carbon $end, TransactionCurrency $native): array
|
public function balanceInRangeConverted(Account $account, Carbon $start, Carbon $end, TransactionCurrency $native): array
|
||||||
{
|
{
|
||||||
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
$cache->addProperty('balance-in-range-converted');
|
$cache->addProperty('balance-in-range-converted');
|
||||||
$cache->addProperty($native->id);
|
$cache->addProperty($native->id);
|
||||||
$cache->addProperty($start);
|
$cache->addProperty($start);
|
||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return $cache->get();
|
//return $cache->get();
|
||||||
}
|
}
|
||||||
Log::debug(sprintf('balanceInRangeConverted for account #%d to %s', $account->id, $native->code));
|
Log::debug(sprintf('balanceInRangeConverted for account #%d to %s', $account->id, $native->code));
|
||||||
$start->subDay();
|
$start->subDay();
|
||||||
@@ -470,35 +535,34 @@ class Steam
|
|||||||
|
|
||||||
Log::debug(sprintf('Start balance on %s is %s', $formatted, $startBalance));
|
Log::debug(sprintf('Start balance on %s is %s', $formatted, $startBalance));
|
||||||
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
|
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
|
||||||
$converter = new ExchangeRateConverter();
|
$converter = new ExchangeRateConverter();
|
||||||
|
|
||||||
// not sure why this is happening:
|
// not sure why this is happening:
|
||||||
$start->addDay();
|
$start->addDay();
|
||||||
|
|
||||||
// grab all transactions between start and end:
|
// grab all transactions between start and end:
|
||||||
$set = $account->transactions()
|
$set = $account->transactions()
|
||||||
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))
|
->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))
|
||||||
->where('transaction_journals.date', '<=', $end->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $end->format('Y-m-d 23:59:59'))
|
||||||
->orderBy('transaction_journals.date', 'ASC')
|
->orderBy('transaction_journals.date', 'ASC')
|
||||||
->whereNull('transaction_journals.deleted_at')
|
->whereNull('transaction_journals.deleted_at')
|
||||||
->get(
|
->get(
|
||||||
[
|
[
|
||||||
'transaction_journals.date',
|
'transaction_journals.date',
|
||||||
'transactions.transaction_currency_id',
|
'transactions.transaction_currency_id',
|
||||||
'transactions.amount',
|
'transactions.amount',
|
||||||
'transactions.foreign_currency_id',
|
'transactions.foreign_currency_id',
|
||||||
'transactions.foreign_amount',
|
'transactions.foreign_amount',
|
||||||
]
|
]
|
||||||
)->toArray()
|
)->toArray();
|
||||||
;
|
|
||||||
|
|
||||||
// loop the set and convert if necessary:
|
// loop the set and convert if necessary:
|
||||||
$currentBalance = $startBalance;
|
$currentBalance = $startBalance;
|
||||||
|
|
||||||
/** @var Transaction $transaction */
|
/** @var Transaction $transaction */
|
||||||
foreach ($set as $transaction) {
|
foreach ($set as $transaction) {
|
||||||
$day = false;
|
$day = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$day = Carbon::parse($transaction['date'], config('app.timezone'));
|
$day = Carbon::parse($transaction['date'], config('app.timezone'));
|
||||||
@@ -508,7 +572,7 @@ class Steam
|
|||||||
if (false === $day) {
|
if (false === $day) {
|
||||||
$day = today(config('app.timezone'));
|
$day = today(config('app.timezone'));
|
||||||
}
|
}
|
||||||
$format = $day->format('Y-m-d');
|
$format = $day->format('Y-m-d');
|
||||||
// if the transaction is in the expected currency, change nothing.
|
// if the transaction is in the expected currency, change nothing.
|
||||||
if ((int) $transaction['transaction_currency_id'] === $native->id) {
|
if ((int) $transaction['transaction_currency_id'] === $native->id) {
|
||||||
// change the current balance, set it to today, continue the loop.
|
// change the current balance, set it to today, continue the loop.
|
||||||
@@ -531,21 +595,21 @@ class Steam
|
|||||||
$currency = $currencies[$currencyId] ?? TransactionCurrency::find($currencyId);
|
$currency = $currencies[$currencyId] ?? TransactionCurrency::find($currencyId);
|
||||||
$currencies[$currencyId] = $currency;
|
$currencies[$currencyId] = $currency;
|
||||||
|
|
||||||
$rate = $converter->getCurrencyRate($currency, $native, $day);
|
$rate = $converter->getCurrencyRate($currency, $native, $day);
|
||||||
$convertedAmount = bcmul($transaction['amount'], $rate);
|
$convertedAmount = bcmul($transaction['amount'], $rate);
|
||||||
$currentBalance = bcadd($currentBalance, $convertedAmount);
|
$currentBalance = bcadd($currentBalance, $convertedAmount);
|
||||||
$balances[$format] = $currentBalance;
|
$balances[$format] = $currentBalance;
|
||||||
|
|
||||||
Log::debug(sprintf(
|
Log::debug(sprintf(
|
||||||
'%s: transaction in %s(!). Conversion rate is %s. %s %s = %s %s',
|
'%s: transaction in %s(!). Conversion rate is %s. %s %s = %s %s',
|
||||||
$format,
|
$format,
|
||||||
$currency->code,
|
$currency->code,
|
||||||
$rate,
|
$rate,
|
||||||
$currency->code,
|
$currency->code,
|
||||||
$transaction['amount'],
|
$transaction['amount'],
|
||||||
$native->code,
|
$native->code,
|
||||||
$convertedAmount
|
$convertedAmount
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$cache->store($balances);
|
$cache->store($balances);
|
||||||
@@ -554,6 +618,111 @@ class Steam
|
|||||||
return $balances;
|
return $balances;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws FireflyException
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
|
public function balanceInRangeNative(Account $account, Carbon $start, Carbon $end): array
|
||||||
|
{
|
||||||
|
$native = app('amount')->getDefaultCurrency();
|
||||||
|
Log::debug(sprintf('balanceInRangeNative for account #%d, to %s', $account->id, $native->code));
|
||||||
|
$repository = app(AccountRepositoryInterface::class);
|
||||||
|
$repository->setUser($account->user);
|
||||||
|
$currency = $repository->getAccountCurrency($account) ?? $native;
|
||||||
|
if ($native->id === $currency->id) {
|
||||||
|
Log::debug('No need to get native balance, account prefers this currency.');
|
||||||
|
return $this->balanceInRange($account, $start, $end, $native);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$cache = new CacheProperties();
|
||||||
|
$cache->addProperty($account->id);
|
||||||
|
$cache->addProperty('balance-in-range-native');
|
||||||
|
$cache->addProperty($native->id);
|
||||||
|
$cache->addProperty($start);
|
||||||
|
$cache->addProperty($end);
|
||||||
|
if ($cache->has()) {
|
||||||
|
$value = $cache->get();
|
||||||
|
Log::debug('Return cached values');
|
||||||
|
//return $value;
|
||||||
|
}
|
||||||
|
$start->subDay();
|
||||||
|
$end->addDay();
|
||||||
|
$balances = [];
|
||||||
|
$formatted = $start->format('Y-m-d');
|
||||||
|
$startBalance = $this->balanceNative($account, $start); // already converted to native amount
|
||||||
|
|
||||||
|
$balances[$formatted] = $startBalance;
|
||||||
|
|
||||||
|
Log::debug(sprintf('Start balance on %s is %s', $formatted, $startBalance));
|
||||||
|
|
||||||
|
// not sure why this is happening:
|
||||||
|
$start->addDay();
|
||||||
|
|
||||||
|
// grab all transactions between start and end:
|
||||||
|
$set = $account->transactions()
|
||||||
|
->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id')
|
||||||
|
->where('transaction_journals.date', '>=', $start->format('Y-m-d 00:00:00'))
|
||||||
|
->where('transaction_journals.date', '<=', $end->format('Y-m-d 23:59:59'))
|
||||||
|
->orderBy('transaction_journals.date', 'ASC')
|
||||||
|
->whereNull('transaction_journals.deleted_at')
|
||||||
|
->get(
|
||||||
|
[
|
||||||
|
'transaction_journals.date',
|
||||||
|
'transactions.transaction_currency_id',
|
||||||
|
'transactions.amount',
|
||||||
|
'transactions.native_amount',
|
||||||
|
'transactions.foreign_currency_id',
|
||||||
|
'transactions.foreign_amount',
|
||||||
|
]
|
||||||
|
)->toArray();
|
||||||
|
|
||||||
|
// loop the set
|
||||||
|
$currentBalance = $startBalance;
|
||||||
|
|
||||||
|
/** @var Transaction $transaction */
|
||||||
|
foreach ($set as $transaction) {
|
||||||
|
$day = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$day = Carbon::parse($transaction['date'], config('app.timezone'));
|
||||||
|
} catch (InvalidFormatException $e) {
|
||||||
|
Log::error(sprintf('Could not parse date "%s" in %s: %s', $transaction['date'], __METHOD__, $e->getMessage()));
|
||||||
|
}
|
||||||
|
if (false === $day) {
|
||||||
|
$day = today(config('app.timezone'));
|
||||||
|
}
|
||||||
|
$format = $day->format('Y-m-d');
|
||||||
|
|
||||||
|
// first, check the native amount. If not NULL, add it, and continue.
|
||||||
|
if (null !== $transaction['native_amount']) {
|
||||||
|
$currentBalance = bcadd($currentBalance, $transaction['native_amount']);
|
||||||
|
$balances[$format] = $currentBalance;
|
||||||
|
Log::debug(sprintf('%s: transaction in %s (native), new balance is %s.', $format, $native->code, $currentBalance));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the foreign amount is in the native currency, add it and continue.
|
||||||
|
if ((int) $transaction['foreign_currency_id'] === $native->id) {
|
||||||
|
$currentBalance = bcadd($currentBalance, $transaction['foreign_amount']);
|
||||||
|
$balances[$format] = $currentBalance;
|
||||||
|
Log::debug(sprintf('%s: transaction in %s (foreign), new balance is %s.', $format, $native->code, $currentBalance));
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// anything else is added as is. Warning in logs.
|
||||||
|
Log::warning(sprintf('Account "%s" (#%d) has transactions that are not converted in the native currency. Please run "php artisan firefly-iii:recalculate-native-amounts"', $account->name, $account->id));
|
||||||
|
$currentBalance = bcadd($currentBalance, $transaction['amount']);
|
||||||
|
$balances[$format] = $currentBalance;
|
||||||
|
Log::debug(sprintf('%s: transaction BAD currency, new balance is %s.', $format, $currentBalance));
|
||||||
|
}
|
||||||
|
|
||||||
|
$cache->store($balances);
|
||||||
|
|
||||||
|
return $balances;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method always ignores the virtual balance.
|
* This method always ignores the virtual balance.
|
||||||
*
|
*
|
||||||
@@ -562,9 +731,9 @@ class Steam
|
|||||||
public function balancesByAccounts(Collection $accounts, Carbon $date): array
|
public function balancesByAccounts(Collection $accounts, Carbon $date): array
|
||||||
{
|
{
|
||||||
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
||||||
$ids = $accounts->pluck('id')->toArray();
|
$ids = $accounts->pluck('id')->toArray();
|
||||||
// cache this property.
|
// cache this property.
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($ids);
|
$cache->addProperty($ids);
|
||||||
$cache->addProperty('balances');
|
$cache->addProperty('balances');
|
||||||
$cache->addProperty($date);
|
$cache->addProperty($date);
|
||||||
@@ -593,9 +762,9 @@ class Steam
|
|||||||
public function balancesByAccountsConverted(Collection $accounts, Carbon $date): array
|
public function balancesByAccountsConverted(Collection $accounts, Carbon $date): array
|
||||||
{
|
{
|
||||||
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
||||||
$ids = $accounts->pluck('id')->toArray();
|
$ids = $accounts->pluck('id')->toArray();
|
||||||
// cache this property.
|
// cache this property.
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($ids);
|
$cache->addProperty($ids);
|
||||||
$cache->addProperty('balances-converted');
|
$cache->addProperty('balances-converted');
|
||||||
$cache->addProperty($date);
|
$cache->addProperty($date);
|
||||||
@@ -611,9 +780,9 @@ class Steam
|
|||||||
$default = app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
|
$default = app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
|
||||||
$result[$account->id]
|
$result[$account->id]
|
||||||
= [
|
= [
|
||||||
'balance' => $this->balance($account, $date),
|
'balance' => $this->balance($account, $date),
|
||||||
'native_balance' => $this->balanceConverted($account, $date, $default),
|
'native_balance' => $this->balanceConverted($account, $date, $default),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$cache->store($result);
|
$cache->store($result);
|
||||||
@@ -627,9 +796,9 @@ class Steam
|
|||||||
public function balancesPerCurrencyByAccounts(Collection $accounts, Carbon $date): array
|
public function balancesPerCurrencyByAccounts(Collection $accounts, Carbon $date): array
|
||||||
{
|
{
|
||||||
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
||||||
$ids = $accounts->pluck('id')->toArray();
|
$ids = $accounts->pluck('id')->toArray();
|
||||||
// cache this property.
|
// cache this property.
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($ids);
|
$cache->addProperty($ids);
|
||||||
$cache->addProperty('balances-per-currency');
|
$cache->addProperty('balances-per-currency');
|
||||||
$cache->addProperty($date);
|
$cache->addProperty($date);
|
||||||
@@ -654,7 +823,7 @@ class Steam
|
|||||||
{
|
{
|
||||||
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
// Log::warning(sprintf('Deprecated method %s, do not use.', __METHOD__));
|
||||||
// abuse chart properties:
|
// abuse chart properties:
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
$cache->addProperty('balance-per-currency');
|
$cache->addProperty('balance-per-currency');
|
||||||
$cache->addProperty($date);
|
$cache->addProperty($date);
|
||||||
@@ -662,10 +831,9 @@ class Steam
|
|||||||
return $cache->get();
|
return $cache->get();
|
||||||
}
|
}
|
||||||
$query = $account->transactions()
|
$query = $account->transactions()
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->groupBy('transactions.transaction_currency_id')
|
->groupBy('transactions.transaction_currency_id');
|
||||||
;
|
|
||||||
$balances = $query->get(['transactions.transaction_currency_id', \DB::raw('SUM(transactions.amount) as sum_for_currency')]); // @phpstan-ignore-line
|
$balances = $query->get(['transactions.transaction_currency_id', \DB::raw('SUM(transactions.amount) as sum_for_currency')]); // @phpstan-ignore-line
|
||||||
$return = [];
|
$return = [];
|
||||||
|
|
||||||
@@ -697,10 +865,10 @@ class Steam
|
|||||||
// Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision));
|
// Log::debug(sprintf('Trying bcround("%s",%d)', $number, $precision));
|
||||||
if (str_contains($number, '.')) {
|
if (str_contains($number, '.')) {
|
||||||
if ('-' !== $number[0]) {
|
if ('-' !== $number[0]) {
|
||||||
return bcadd($number, '0.'.str_repeat('0', $precision).'5', $precision);
|
return bcadd($number, '0.' . str_repeat('0', $precision) . '5', $precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bcsub($number, '0.'.str_repeat('0', $precision).'5', $precision);
|
return bcsub($number, '0.' . str_repeat('0', $precision) . '5', $precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $number;
|
return $number;
|
||||||
@@ -790,15 +958,15 @@ class Steam
|
|||||||
{
|
{
|
||||||
$list = [];
|
$list = [];
|
||||||
|
|
||||||
$set = auth()->user()->transactions()
|
$set = auth()->user()->transactions()
|
||||||
->whereIn('transactions.account_id', $accounts)
|
->whereIn('transactions.account_id', $accounts)
|
||||||
->groupBy(['transactions.account_id', 'transaction_journals.user_id'])
|
->groupBy(['transactions.account_id', 'transaction_journals.user_id'])
|
||||||
->get(['transactions.account_id', \DB::raw('MAX(transaction_journals.date) AS max_date')]) // @phpstan-ignore-line
|
->get(['transactions.account_id', \DB::raw('MAX(transaction_journals.date) AS max_date')]) // @phpstan-ignore-line
|
||||||
;
|
;
|
||||||
|
|
||||||
/** @var Transaction $entry */
|
/** @var Transaction $entry */
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
$date = new Carbon($entry->max_date, config('app.timezone'));
|
$date = new Carbon($entry->max_date, config('app.timezone'));
|
||||||
$date->setTimezone(config('app.timezone'));
|
$date->setTimezone(config('app.timezone'));
|
||||||
$list[$entry->account_id] = $date;
|
$list[$entry->account_id] = $date;
|
||||||
}
|
}
|
||||||
@@ -873,9 +1041,9 @@ class Steam
|
|||||||
public function getSafeUrl(string $unknownUrl, string $safeUrl): string
|
public function getSafeUrl(string $unknownUrl, string $safeUrl): string
|
||||||
{
|
{
|
||||||
// Log::debug(sprintf('getSafeUrl(%s, %s)', $unknownUrl, $safeUrl));
|
// Log::debug(sprintf('getSafeUrl(%s, %s)', $unknownUrl, $safeUrl));
|
||||||
$returnUrl = $safeUrl;
|
$returnUrl = $safeUrl;
|
||||||
$unknownHost = parse_url($unknownUrl, PHP_URL_HOST);
|
$unknownHost = parse_url($unknownUrl, PHP_URL_HOST);
|
||||||
$safeHost = parse_url($safeUrl, PHP_URL_HOST);
|
$safeHost = parse_url($safeUrl, PHP_URL_HOST);
|
||||||
|
|
||||||
if (null !== $unknownHost && $unknownHost === $safeHost) {
|
if (null !== $unknownHost && $unknownHost === $safeHost) {
|
||||||
$returnUrl = $unknownUrl;
|
$returnUrl = $unknownUrl;
|
||||||
@@ -912,7 +1080,7 @@ class Steam
|
|||||||
*/
|
*/
|
||||||
public function floatalize(string $value): string
|
public function floatalize(string $value): string
|
||||||
{
|
{
|
||||||
$value = strtoupper($value);
|
$value = strtoupper($value);
|
||||||
if (!str_contains($value, 'E')) {
|
if (!str_contains($value, 'E')) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
@@ -14,14 +14,17 @@
|
|||||||
"/public/v1/js/app.js.LICENSE.txt": "/public/v1/js/app.js.LICENSE.txt",
|
"/public/v1/js/app.js.LICENSE.txt": "/public/v1/js/app.js.LICENSE.txt",
|
||||||
"/public/v1/js/app_vue.js": "/public/v1/js/app_vue.js",
|
"/public/v1/js/app_vue.js": "/public/v1/js/app_vue.js",
|
||||||
"/public/v1/js/app_vue.js.LICENSE.txt": "/public/v1/js/app_vue.js.LICENSE.txt",
|
"/public/v1/js/app_vue.js.LICENSE.txt": "/public/v1/js/app_vue.js.LICENSE.txt",
|
||||||
|
"/public/v1/js/create.js": "/public/v1/js/create.js",
|
||||||
|
"/public/v1/js/create.js.LICENSE.txt": "/public/v1/js/create.js.LICENSE.txt",
|
||||||
"/public/v1/js/create_transaction.js": "/public/v1/js/create_transaction.js",
|
"/public/v1/js/create_transaction.js": "/public/v1/js/create_transaction.js",
|
||||||
"/public/v1/js/create_transaction.js.LICENSE.txt": "/public/v1/js/create_transaction.js.LICENSE.txt",
|
"/public/v1/js/create_transaction.js.LICENSE.txt": "/public/v1/js/create_transaction.js.LICENSE.txt",
|
||||||
|
"/public/v1/js/edit.js": "/public/v1/js/edit.js",
|
||||||
|
"/public/v1/js/edit.js.LICENSE.txt": "/public/v1/js/edit.js.LICENSE.txt",
|
||||||
"/public/v1/js/edit_transaction.js": "/public/v1/js/edit_transaction.js",
|
"/public/v1/js/edit_transaction.js": "/public/v1/js/edit_transaction.js",
|
||||||
"/public/v1/js/edit_transaction.js.LICENSE.txt": "/public/v1/js/edit_transaction.js.LICENSE.txt",
|
"/public/v1/js/edit_transaction.js.LICENSE.txt": "/public/v1/js/edit_transaction.js.LICENSE.txt",
|
||||||
"/public/v1/js/exchange-rates/index.js": "/public/v1/js/exchange-rates/index.js",
|
"/public/v1/js/exchange-rates/index.js": "/public/v1/js/exchange-rates/index.js",
|
||||||
"/public/v1/js/exchange-rates/index.js.LICENSE.txt": "/public/v1/js/exchange-rates/index.js.LICENSE.txt",
|
"/public/v1/js/exchange-rates/index.js.LICENSE.txt": "/public/v1/js/exchange-rates/index.js.LICENSE.txt",
|
||||||
"/public/v1/js/exchange-rates/rates.js": "/public/v1/js/exchange-rates/rates.js",
|
"/public/v1/js/exchange-rates/rates.js": "/public/v1/js/exchange-rates/rates.js",
|
||||||
"/public/v1/js/exchange-rates/rates.js.LICENSE.txt": "/public/v1/js/exchange-rates/rates.js.LICENSE.txt",
|
|
||||||
"/public/v1/js/ff/accounts/create.js": "/public/v1/js/ff/accounts/create.js",
|
"/public/v1/js/ff/accounts/create.js": "/public/v1/js/ff/accounts/create.js",
|
||||||
"/public/v1/js/ff/accounts/edit-reconciliation.js": "/public/v1/js/ff/accounts/edit-reconciliation.js",
|
"/public/v1/js/ff/accounts/edit-reconciliation.js": "/public/v1/js/ff/accounts/edit-reconciliation.js",
|
||||||
"/public/v1/js/ff/accounts/edit.js": "/public/v1/js/ff/accounts/edit.js",
|
"/public/v1/js/ff/accounts/edit.js": "/public/v1/js/ff/accounts/edit.js",
|
||||||
@@ -90,6 +93,8 @@
|
|||||||
"/public/v1/js/ff/transactions/mass/edit-bulk.js": "/public/v1/js/ff/transactions/mass/edit-bulk.js",
|
"/public/v1/js/ff/transactions/mass/edit-bulk.js": "/public/v1/js/ff/transactions/mass/edit-bulk.js",
|
||||||
"/public/v1/js/ff/transactions/mass/edit.js": "/public/v1/js/ff/transactions/mass/edit.js",
|
"/public/v1/js/ff/transactions/mass/edit.js": "/public/v1/js/ff/transactions/mass/edit.js",
|
||||||
"/public/v1/js/ff/transactions/show.js": "/public/v1/js/ff/transactions/show.js",
|
"/public/v1/js/ff/transactions/show.js": "/public/v1/js/ff/transactions/show.js",
|
||||||
|
"/public/v1/js/index.js": "/public/v1/js/index.js",
|
||||||
|
"/public/v1/js/index.js.LICENSE.txt": "/public/v1/js/index.js.LICENSE.txt",
|
||||||
"/public/v1/js/lib/Chart.bundle.min.js": "/public/v1/js/lib/Chart.bundle.min.js",
|
"/public/v1/js/lib/Chart.bundle.min.js": "/public/v1/js/lib/Chart.bundle.min.js",
|
||||||
"/public/v1/js/lib/accounting.min.js": "/public/v1/js/lib/accounting.min.js",
|
"/public/v1/js/lib/accounting.min.js": "/public/v1/js/lib/accounting.min.js",
|
||||||
"/public/v1/js/lib/bootstrap-multiselect.js": "/public/v1/js/lib/bootstrap-multiselect.js",
|
"/public/v1/js/lib/bootstrap-multiselect.js": "/public/v1/js/lib/bootstrap-multiselect.js",
|
||||||
@@ -148,6 +153,8 @@
|
|||||||
"/public/v1/js/lib/vue.js": "/public/v1/js/lib/vue.js",
|
"/public/v1/js/lib/vue.js": "/public/v1/js/lib/vue.js",
|
||||||
"/public/v1/js/profile.js": "/public/v1/js/profile.js",
|
"/public/v1/js/profile.js": "/public/v1/js/profile.js",
|
||||||
"/public/v1/js/profile.js.LICENSE.txt": "/public/v1/js/profile.js.LICENSE.txt",
|
"/public/v1/js/profile.js.LICENSE.txt": "/public/v1/js/profile.js.LICENSE.txt",
|
||||||
|
"/public/v1/js/show.js": "/public/v1/js/show.js",
|
||||||
|
"/public/v1/js/show.js.LICENSE.txt": "/public/v1/js/show.js.LICENSE.txt",
|
||||||
"/public/v1/js/webhooks/create.js": "/public/v1/js/webhooks/create.js",
|
"/public/v1/js/webhooks/create.js": "/public/v1/js/webhooks/create.js",
|
||||||
"/public/v1/js/webhooks/create.js.LICENSE.txt": "/public/v1/js/webhooks/create.js.LICENSE.txt",
|
"/public/v1/js/webhooks/create.js.LICENSE.txt": "/public/v1/js/webhooks/create.js.LICENSE.txt",
|
||||||
"/public/v1/js/webhooks/edit.js": "/public/v1/js/webhooks/edit.js",
|
"/public/v1/js/webhooks/edit.js": "/public/v1/js/webhooks/edit.js",
|
||||||
|
@@ -27,9 +27,7 @@
|
|||||||
<h3 class="box-title">{{ $t('firefly.header_exchange_rates') }}</h3>
|
<h3 class="box-title">{{ $t('firefly.header_exchange_rates') }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<p>
|
<p v-html="$t('firefly.exchange_rates_intro')"></p>
|
||||||
{{ $t('firefly.exchange_rates_intro') }}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -12,6 +12,10 @@
|
|||||||
{% if null != transaction.foreign_amount %}
|
{% if null != transaction.foreign_amount %}
|
||||||
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if convertToNative and null != transaction.native_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% elseif transaction.transaction_type_type == 'Transfer' %}
|
{% elseif transaction.transaction_type_type == 'Transfer' %}
|
||||||
<span class="text-info money-transfer">
|
<span class="text-info money-transfer">
|
||||||
{# transfer away: #}
|
{# transfer away: #}
|
||||||
@@ -20,13 +24,18 @@
|
|||||||
{% if null != transaction.foreign_amount %}
|
{% if null != transaction.foreign_amount %}
|
||||||
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }})
|
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if convertToNative and null != transaction.native_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places, false) }}
|
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places, false) }}
|
||||||
{% if null != transaction.foreign_amount %}
|
{% if null != transaction.foreign_amount %}
|
||||||
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }})
|
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if convertToNative and null != transaction.native_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# transfer to #}
|
{# transfer to #}
|
||||||
</span>
|
</span>
|
||||||
{% elseif transaction.transaction_type_type == 'Opening balance' %}
|
{% elseif transaction.transaction_type_type == 'Opening balance' %}
|
||||||
@@ -35,11 +44,17 @@
|
|||||||
{% if null != transaction.foreign_amount %}
|
{% if null != transaction.foreign_amount %}
|
||||||
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if convertToNative and null != transaction.native_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
{% if null != transaction.foreign_amount %}
|
{% if null != transaction.foreign_amount %}
|
||||||
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if convertToNative and null != transaction.native_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.native_amount, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% elseif transaction.transaction_type_type == 'Reconciliation' %}
|
{% elseif transaction.transaction_type_type == 'Reconciliation' %}
|
||||||
{% if transaction.source_account_type == 'Reconciliation account' %}
|
{% if transaction.source_account_type == 'Reconciliation account' %}
|
||||||
@@ -47,17 +62,26 @@
|
|||||||
{% if null != transaction.foreign_amount %}
|
{% if null != transaction.foreign_amount %}
|
||||||
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if convertToNative and null != transaction.native_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
{% if null != transaction.foreign_amount %}
|
{% if null != transaction.foreign_amount %}
|
||||||
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if convertToNative and null != transaction.native_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.native_amount, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||||
{% if null != transaction.foreign_amount %}
|
{% if null != transaction.foreign_amount %}
|
||||||
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if convertToNative and null != transaction.native_amount %}
|
||||||
|
({{ formatAmountBySymbol(transaction.native_amount, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
|
Reference in New Issue
Block a user