mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Replace native with primary where possible
This commit is contained in:
@@ -75,7 +75,7 @@ class NetWorth implements NetWorthInterface
|
||||
return $cache->get();
|
||||
}
|
||||
Log::debug(sprintf('Now in byAccounts("%s", "%s")', $ids, $date->format('Y-m-d H:i:s')));
|
||||
$default = Amount::getPrimaryCurrency();
|
||||
$primary = Amount::getPrimaryCurrency();
|
||||
$netWorth = [];
|
||||
Log::debug(sprintf('NetWorth: finalAccountsBalance("%s")', $date->format('Y-m-d H:i:s')));
|
||||
$balances = Steam::finalAccountsBalance($accounts, $date);
|
||||
@@ -83,9 +83,9 @@ class NetWorth implements NetWorthInterface
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
// Log::debug(sprintf('Now at account #%d ("%s")', $account->id, $account->name));
|
||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $default;
|
||||
$usePrimary = $convertToPrimary && $default->id !== $currency->id;
|
||||
$currency = $usePrimary ? $default : $currency;
|
||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $primary;
|
||||
$usePrimary = $convertToPrimary && $primary->id !== $currency->id;
|
||||
$currency = $usePrimary ? $primary : $currency;
|
||||
$currencyCode = $currency->code;
|
||||
$balance = '0';
|
||||
$primaryBalance = '0';
|
||||
|
@@ -103,7 +103,7 @@ class Amount
|
||||
{
|
||||
$convertToPrimary = $this->convertToPrimary();
|
||||
$currency = $this->getPrimaryCurrency();
|
||||
$field = $convertToPrimary && $currency->id !== $journal['currency_id'] ? 'native_amount' : 'amount';
|
||||
$field = $convertToPrimary && $currency->id !== $journal['currency_id'] ? 'pc_amount' : 'amount';
|
||||
$amount = $journal[$field] ?? '0';
|
||||
// Log::debug(sprintf('Field is %s, amount is %s', $field, $amount));
|
||||
// fallback, the transaction has a foreign amount in $currency.
|
||||
@@ -118,10 +118,10 @@ class Amount
|
||||
public function convertToPrimary(?User $user = null): bool
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
return true === Preferences::get('convert_to_native', false)->data && true === config('cer.enabled');
|
||||
return true === Preferences::get('convert_to_primary', false)->data && true === config('cer.enabled');
|
||||
}
|
||||
|
||||
return true === Preferences::getForUser($user, 'convert_to_native', false)->data && true === config('cer.enabled');
|
||||
return true === Preferences::getForUser($user, 'convert_to_primary', false)->data && true === config('cer.enabled');
|
||||
}
|
||||
|
||||
public function getPrimaryCurrency(): TransactionCurrency
|
||||
@@ -171,7 +171,7 @@ class Amount
|
||||
{
|
||||
$convertToPrimary = $this->convertToPrimary();
|
||||
$currency = $this->getPrimaryCurrency();
|
||||
$field = $convertToPrimary && $currency->id !== $journal->transaction_currency_id ? 'native_amount' : 'amount';
|
||||
$field = $convertToPrimary && $currency->id !== $journal->transaction_currency_id ? 'pc_amount' : 'amount';
|
||||
|
||||
/** @var null|Transaction $sourceTransaction */
|
||||
$sourceTransaction = $journal->transactions()->where('amount', '<', 0)->first();
|
||||
|
@@ -39,7 +39,7 @@ use Illuminate\Support\Facades\Log;
|
||||
*/
|
||||
class FrontpageChartGenerator
|
||||
{
|
||||
public bool $convertToNative = false;
|
||||
public bool $convertToPrimary = false;
|
||||
public TransactionCurrency $default;
|
||||
protected OperationsRepositoryInterface $opsRepository;
|
||||
private readonly BudgetLimitRepositoryInterface $blRepository;
|
||||
@@ -149,12 +149,12 @@ class FrontpageChartGenerator
|
||||
*/
|
||||
private function processLimit(array $data, Budget $budget, BudgetLimit $limit): array
|
||||
{
|
||||
$useNative = $this->convertToNative && $this->default->id !== $limit->transaction_currency_id;
|
||||
$usePrimary = $this->convertToPrimary && $this->default->id !== $limit->transaction_currency_id;
|
||||
$currency = $limit->transactionCurrency;
|
||||
if ($useNative) {
|
||||
Log::debug(sprintf('Processing limit #%d with (native) %s %s', $limit->id, $this->default->code, $limit->native_amount));
|
||||
if ($usePrimary) {
|
||||
Log::debug(sprintf('Processing limit #%d with (primary currency) %s %s', $limit->id, $this->default->code, $limit->native_amount));
|
||||
}
|
||||
if (!$useNative) {
|
||||
if (!$usePrimary) {
|
||||
Log::debug(sprintf('Processing limit #%d with %s %s', $limit->id, $limit->transactionCurrency->code, $limit->amount));
|
||||
}
|
||||
|
||||
@@ -164,12 +164,12 @@ class FrontpageChartGenerator
|
||||
/** @var array $entry */
|
||||
foreach ($spent as $entry) {
|
||||
// only spent the entry where the entry's currency matches the budget limit's currency
|
||||
// or when useNative is true.
|
||||
if ($entry['currency_id'] === $limit->transaction_currency_id || $useNative) {
|
||||
// or when usePrimary is true.
|
||||
if ($entry['currency_id'] === $limit->transaction_currency_id || $usePrimary) {
|
||||
Log::debug(sprintf('Process spent row (%s)', $entry['currency_code']));
|
||||
$data = $this->processRow($data, $budget, $limit, $entry);
|
||||
}
|
||||
if (!($entry['currency_id'] === $limit->transaction_currency_id || $useNative)) {
|
||||
if (!($entry['currency_id'] === $limit->transaction_currency_id || $usePrimary)) {
|
||||
Log::debug(sprintf('Skipping spent row (%s).', $entry['currency_code']));
|
||||
}
|
||||
}
|
||||
@@ -196,10 +196,10 @@ class FrontpageChartGenerator
|
||||
$limit->end_date->isoFormat($this->monthAndDayFormat)
|
||||
);
|
||||
}
|
||||
$useNative = $this->convertToNative && $this->default->id !== $limit->transaction_currency_id;
|
||||
$usePrimary = $this->convertToPrimary && $this->default->id !== $limit->transaction_currency_id;
|
||||
$amount = $limit->amount;
|
||||
Log::debug(sprintf('Amount is "%s".', $amount));
|
||||
if ($useNative && $limit->transaction_currency_id !== $this->default->id) {
|
||||
if ($usePrimary && $limit->transaction_currency_id !== $this->default->id) {
|
||||
$amount = $limit->native_amount;
|
||||
Log::debug(sprintf('Amount is now "%s".', $amount));
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ class FrontpageChartGenerator
|
||||
{
|
||||
use AugumentData;
|
||||
|
||||
public bool $convertToNative = false;
|
||||
public bool $convertToPrimary = false;
|
||||
public TransactionCurrency $defaultCurrency;
|
||||
private AccountRepositoryInterface $accountRepos;
|
||||
private array $currencies;
|
||||
|
@@ -36,7 +36,7 @@ use Illuminate\Support\Collection;
|
||||
*/
|
||||
class WholePeriodChartGenerator
|
||||
{
|
||||
public bool $convertToNative;
|
||||
public bool $convertToPrimary;
|
||||
|
||||
public function generate(Category $category, Carbon $start, Carbon $end): array
|
||||
{
|
||||
|
@@ -43,8 +43,8 @@ class ChartData
|
||||
if (array_key_exists('currency_id', $data)) {
|
||||
$data['currency_id'] = (string) $data['currency_id'];
|
||||
}
|
||||
if (array_key_exists('native_currency_id', $data)) {
|
||||
$data['native_currency_id'] = (string) $data['native_currency_id'];
|
||||
if (array_key_exists('primary_currency_id', $data)) {
|
||||
$data['primary_currency_id'] = (string) $data['primary_currency_id'];
|
||||
}
|
||||
$required = ['start', 'date', 'end', 'entries'];
|
||||
foreach ($required as $field) {
|
||||
|
@@ -734,11 +734,11 @@ class ExportDataGenerator
|
||||
{
|
||||
Log::debug('Will now export transactions.');
|
||||
// TODO better place for keys?
|
||||
$header = ['user_id', 'group_id', 'journal_id', 'created_at', 'updated_at', 'group_title', 'type', 'currency_code', 'amount', 'foreign_currency_code', 'foreign_amount', 'native_currency_code', 'native_amount', 'native_foreign_amount', 'description', 'date', 'source_name', 'source_iban', 'source_type', 'destination_name', 'destination_iban', 'destination_type', 'reconciled', 'category', 'budget', 'bill', 'tags', 'notes'];
|
||||
$header = ['user_id', 'group_id', 'journal_id', 'created_at', 'updated_at', 'group_title', 'type', 'currency_code', 'amount', 'foreign_currency_code', 'foreign_amount', 'primary_currency_code', 'pc_amount', 'pc_foreign_amount', 'description', 'date', 'source_name', 'source_iban', 'source_type', 'destination_name', 'destination_iban', 'destination_type', 'reconciled', 'category', 'budget', 'bill', 'tags', 'notes'];
|
||||
|
||||
$metaFields = config('firefly.journal_meta_fields');
|
||||
$header = array_merge($header, $metaFields);
|
||||
$default = Amount::getPrimaryCurrency();
|
||||
$primary = Amount::getPrimaryCurrency();
|
||||
|
||||
$collector = app(GroupCollectorInterface::class);
|
||||
$collector->setUser($this->user);
|
||||
@@ -760,28 +760,28 @@ class ExportDataGenerator
|
||||
$metaData = $repository->getMetaFields($journal['transaction_journal_id'], $metaFields);
|
||||
$amount = Steam::bcround(Steam::negative($journal['amount']), $journal['currency_decimal_places']);
|
||||
$foreignAmount = null === $journal['foreign_amount'] ? null : Steam::bcround(Steam::negative($journal['foreign_amount']), $journal['foreign_currency_decimal_places']);
|
||||
$nativeAmount = null === $journal['native_amount'] ? null : Steam::bcround(Steam::negative($journal['native_amount']), $default->decimal_places);
|
||||
$nativeForeignAmount = null === $journal['native_foreign_amount'] ? null : Steam::bcround(Steam::negative($journal['native_foreign_amount']), $default->decimal_places);
|
||||
$pcAmount = null === $journal['pc_amount'] ? null : Steam::bcround(Steam::negative($journal['pc_amount']), $primary->decimal_places);
|
||||
$pcForeignAmount = null === $journal['pc_foreign_amount'] ? null : Steam::bcround(Steam::negative($journal['pc_foreign_amount']), $primary->decimal_places);
|
||||
|
||||
if (TransactionTypeEnum::WITHDRAWAL->value !== $journal['transaction_type_type']) {
|
||||
$amount = Steam::bcround(Steam::positive($journal['amount']), $journal['currency_decimal_places']);
|
||||
$foreignAmount = null === $journal['foreign_amount'] ? null : Steam::bcround(Steam::positive($journal['foreign_amount']), $journal['foreign_currency_decimal_places']);
|
||||
$nativeAmount = null === $journal['native_amount'] ? null : Steam::bcround(Steam::positive($journal['native_amount']), $default->decimal_places);
|
||||
$nativeForeignAmount = null === $journal['native_foreign_amount'] ? null : Steam::bcround(Steam::positive($journal['native_foreign_amount']), $default->decimal_places);
|
||||
$pcAmount = null === $journal['pc_amount'] ? null : Steam::bcround(Steam::positive($journal['pc_amount']), $primary->decimal_places);
|
||||
$pcForeignAmount = null === $journal['pc_foreign_amount'] ? null : Steam::bcround(Steam::positive($journal['pc_foreign_amount']), $primary->decimal_places);
|
||||
}
|
||||
|
||||
// opening balance depends on source account type.
|
||||
if (TransactionTypeEnum::OPENING_BALANCE->value === $journal['transaction_type_type'] && AccountTypeEnum::ASSET->value === $journal['source_account_type']) {
|
||||
$amount = Steam::bcround(Steam::negative($journal['amount']), $journal['currency_decimal_places']);
|
||||
$foreignAmount = null === $journal['foreign_amount'] ? null : Steam::bcround(Steam::negative($journal['foreign_amount']), $journal['foreign_currency_decimal_places']);
|
||||
$nativeAmount = null === $journal['native_amount'] ? null : Steam::bcround(Steam::negative($journal['native_amount']), $default->decimal_places);
|
||||
$nativeForeignAmount = null === $journal['native_foreign_amount'] ? null : Steam::bcround(Steam::negative($journal['native_foreign_amount']), $default->decimal_places);
|
||||
$pcAmount = null === $journal['pc_amount'] ? null : Steam::bcround(Steam::negative($journal['pc_amount']), $primary->decimal_places);
|
||||
$pcForeignAmount = null === $journal['pc_foreign_amount'] ? null : Steam::bcround(Steam::negative($journal['pc_foreign_amount']), $primary->decimal_places);
|
||||
}
|
||||
|
||||
$records[] = [
|
||||
$journal['user_id'], $journal['transaction_group_id'], $journal['transaction_journal_id'], $journal['created_at']->toAtomString(), $journal['updated_at']->toAtomString(), $journal['transaction_group_title'], $journal['transaction_type_type'],
|
||||
// amounts and currencies
|
||||
$journal['currency_code'], $amount, $journal['foreign_currency_code'], $foreignAmount, $default->code, $nativeAmount, $nativeForeignAmount,
|
||||
$journal['currency_code'], $amount, $journal['foreign_currency_code'], $foreignAmount, $primary->code, $pcAmount, $pcForeignAmount,
|
||||
|
||||
// more fields
|
||||
$journal['description'], $journal['date']->toAtomString(), $journal['source_account_name'], $journal['source_account_iban'], $journal['source_account_type'], $journal['destination_account_name'], $journal['destination_account_iban'], $journal['destination_account_type'], $journal['reconciled'], $journal['category_name'], $journal['budget_name'], $journal['bill_name'],
|
||||
|
@@ -41,7 +41,7 @@ class AccountBalanceGrouped
|
||||
private readonly ExchangeRateConverter $converter;
|
||||
private array $currencies = [];
|
||||
private array $data = [];
|
||||
private TransactionCurrency $default;
|
||||
private TransactionCurrency $primary;
|
||||
private Carbon $end;
|
||||
private array $journals = [];
|
||||
private string $preferredRange;
|
||||
@@ -70,16 +70,16 @@ class AccountBalanceGrouped
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'native_currency_id' => (string) $currency['native_currency_id'],
|
||||
'native_currency_symbol' => $currency['native_currency_symbol'],
|
||||
'native_currency_code' => $currency['native_currency_code'],
|
||||
'native_currency_decimal_places' => $currency['native_currency_decimal_places'],
|
||||
'primary_currency_id' => (string) $currency['primary_currency_id'],
|
||||
'primary_currency_symbol' => $currency['primary_currency_symbol'],
|
||||
'primary_currency_code' => $currency['primary_currency_code'],
|
||||
'primary_currency_decimal_places' => $currency['primary_currency_decimal_places'],
|
||||
'date' => $this->start->toAtomString(),
|
||||
'start' => $this->start->toAtomString(),
|
||||
'end' => $this->end->toAtomString(),
|
||||
'period' => $this->preferredRange,
|
||||
'entries' => [],
|
||||
'native_entries' => [],
|
||||
'primary_entries' => [],
|
||||
];
|
||||
$expense = [
|
||||
'label' => 'spent',
|
||||
@@ -87,16 +87,16 @@ class AccountBalanceGrouped
|
||||
'currency_symbol' => $currency['currency_symbol'],
|
||||
'currency_code' => $currency['currency_code'],
|
||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||
'native_currency_id' => (string) $currency['native_currency_id'],
|
||||
'native_currency_symbol' => $currency['native_currency_symbol'],
|
||||
'native_currency_code' => $currency['native_currency_code'],
|
||||
'native_currency_decimal_places' => $currency['native_currency_decimal_places'],
|
||||
'primary_currency_id' => (string) $currency['primary_currency_id'],
|
||||
'primary_currency_symbol' => $currency['primary_currency_symbol'],
|
||||
'primary_currency_code' => $currency['primary_currency_code'],
|
||||
'primary_currency_decimal_places' => $currency['primary_currency_decimal_places'],
|
||||
'date' => $this->start->toAtomString(),
|
||||
'start' => $this->start->toAtomString(),
|
||||
'end' => $this->end->toAtomString(),
|
||||
'period' => $this->preferredRange,
|
||||
'entries' => [],
|
||||
'native_entries' => [],
|
||||
'pc_entries' => [],
|
||||
];
|
||||
// loop all possible periods between $start and $end, and add them to the correct dataset.
|
||||
$currentStart = clone $this->start;
|
||||
@@ -108,8 +108,8 @@ class AccountBalanceGrouped
|
||||
$expense['entries'][$label] = app('steam')->bcround($currency[$key]['spent'] ?? '0', $currency['currency_decimal_places']);
|
||||
|
||||
// converted entries
|
||||
$income['native_entries'][$label] = app('steam')->bcround($currency[$key]['native_earned'] ?? '0', $currency['native_currency_decimal_places']);
|
||||
$expense['native_entries'][$label] = app('steam')->bcround($currency[$key]['native_spent'] ?? '0', $currency['native_currency_decimal_places']);
|
||||
$income['pc_entries'][$label] = app('steam')->bcround($currency[$key]['pc_earned'] ?? '0', $currency['primary_currency_decimal_places']);
|
||||
$expense['pc_entries'][$label] = app('steam')->bcround($currency[$key]['pc_spent'] ?? '0', $currency['primary_currency_decimal_places']);
|
||||
|
||||
// next loop
|
||||
$currentStart = app('navigation')->addPeriod($currentStart, $this->preferredRange, 0);
|
||||
@@ -159,8 +159,8 @@ class AccountBalanceGrouped
|
||||
$rate = $this->getRate($currency, $journal['date']);
|
||||
$amountConverted = bcmul((string) $amount, $rate);
|
||||
|
||||
// perhaps transaction already has the foreign amount in the native currency.
|
||||
if ((int) $journal['foreign_currency_id'] === $this->default->id) {
|
||||
// perhaps transaction already has the foreign amount in the primary currency.
|
||||
if ((int) $journal['foreign_currency_id'] === $this->primary->id) {
|
||||
$amountConverted = $journal['foreign_amount'] ?? '0';
|
||||
$amountConverted = 'earned' === $key ? app('steam')->positive($amountConverted) : app('steam')->negative($amountConverted);
|
||||
}
|
||||
@@ -169,7 +169,7 @@ class AccountBalanceGrouped
|
||||
$this->data[$currencyId][$period][$key] = bcadd((string) $this->data[$currencyId][$period][$key], (string) $amount);
|
||||
|
||||
// add converted entry
|
||||
$convertedKey = sprintf('native_%s', $key);
|
||||
$convertedKey = sprintf('pc_%s', $key);
|
||||
$this->data[$currencyId][$period][$convertedKey] = bcadd((string) $this->data[$currencyId][$period][$convertedKey], (string) $amountConverted);
|
||||
}
|
||||
|
||||
@@ -192,11 +192,11 @@ class AccountBalanceGrouped
|
||||
'currency_code' => $journal['currency_code'],
|
||||
'currency_name' => $journal['currency_name'],
|
||||
'currency_decimal_places' => $journal['currency_decimal_places'],
|
||||
// native currency info (could be the same)
|
||||
'native_currency_id' => (string) $this->default->id,
|
||||
'native_currency_code' => $this->default->code,
|
||||
'native_currency_symbol' => $this->default->symbol,
|
||||
'native_currency_decimal_places' => $this->default->decimal_places,
|
||||
// primary currency info (could be the same)
|
||||
'primary_currency_id' => (string) $this->primary->id,
|
||||
'primary_currency_code' => $this->primary->code,
|
||||
'primary_currency_symbol' => $this->primary->symbol,
|
||||
'primary_currency_decimal_places' => $this->primary->decimal_places,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -208,8 +208,8 @@ class AccountBalanceGrouped
|
||||
'period' => $period,
|
||||
'spent' => '0',
|
||||
'earned' => '0',
|
||||
'native_spent' => '0',
|
||||
'native_earned' => '0',
|
||||
'pc_spent' => '0',
|
||||
'pc_earned' => '0',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ class AccountBalanceGrouped
|
||||
private function getRate(TransactionCurrency $currency, Carbon $date): string
|
||||
{
|
||||
try {
|
||||
$rate = $this->converter->getCurrencyRate($currency, $this->default, $date);
|
||||
$rate = $this->converter->getCurrencyRate($currency, $this->primary, $date);
|
||||
} catch (FireflyException $e) {
|
||||
app('log')->error($e->getMessage());
|
||||
$rate = '1';
|
||||
@@ -252,22 +252,22 @@ class AccountBalanceGrouped
|
||||
$this->accountIds = $accounts->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
public function setDefault(TransactionCurrency $default): void
|
||||
public function setPrimary(TransactionCurrency $primary): void
|
||||
{
|
||||
$this->default = $default;
|
||||
$defaultCurrencyId = $default->id;
|
||||
$this->currencies = [$default->id => $default]; // currency cache
|
||||
$this->data[$defaultCurrencyId] = [
|
||||
'currency_id' => (string) $defaultCurrencyId,
|
||||
'currency_symbol' => $default->symbol,
|
||||
'currency_code' => $default->code,
|
||||
'currency_name' => $default->name,
|
||||
'currency_decimal_places' => $default->decimal_places,
|
||||
'native_currency_id' => (string) $defaultCurrencyId,
|
||||
'native_currency_symbol' => $default->symbol,
|
||||
'native_currency_code' => $default->code,
|
||||
'native_currency_name' => $default->name,
|
||||
'native_currency_decimal_places' => $default->decimal_places,
|
||||
$this->primary = $primary;
|
||||
$primaryCurrencyId = $primary->id;
|
||||
$this->currencies = [$primary->id => $primary]; // currency cache
|
||||
$this->data[$primaryCurrencyId] = [
|
||||
'currency_id' => (string) $primaryCurrencyId,
|
||||
'currency_symbol' => $primary->symbol,
|
||||
'currency_code' => $primary->code,
|
||||
'currency_name' => $primary->name,
|
||||
'currency_decimal_places' => $primary->decimal_places,
|
||||
'primary_currency_id' => (string) $primaryCurrencyId,
|
||||
'primary_currency_symbol' => $primary->symbol,
|
||||
'primary_currency_code' => $primary->code,
|
||||
'primary_currency_name' => $primary->name,
|
||||
'primary_currency_decimal_places' => $primary->decimal_places,
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -50,8 +50,8 @@ trait CleansChartData
|
||||
if (array_key_exists('currency_id', $array)) {
|
||||
$array['currency_id'] = (string) $array['currency_id'];
|
||||
}
|
||||
if (array_key_exists('native_currency_id', $array)) {
|
||||
$array['native_currency_id'] = (string) $array['native_currency_id'];
|
||||
if (array_key_exists('primary_currency_id', $array)) {
|
||||
$array['primary_currency_id'] = (string) $array['primary_currency_id'];
|
||||
}
|
||||
if (!array_key_exists('start', $array)) {
|
||||
throw new FireflyException(sprintf('Data-set "%s" is missing the "start"-variable.', $index));
|
||||
|
@@ -57,8 +57,8 @@ class SummaryBalanceGrouped
|
||||
};
|
||||
|
||||
$return[] = [
|
||||
'key' => sprintf('%s-in-native', $title),
|
||||
'value' => $this->amounts[$key]['native'] ?? '0',
|
||||
'key' => sprintf('%s-in-pc', $title),
|
||||
'value' => $this->amounts[$key]['primary'] ?? '0',
|
||||
'currency_id' => (string) $this->default->id,
|
||||
'currency_code' => $this->default->code,
|
||||
'currency_symbol' => $this->default->symbol,
|
||||
@@ -68,8 +68,8 @@ class SummaryBalanceGrouped
|
||||
// loop 3: format amounts:
|
||||
$currencyIds = array_keys($this->amounts[self::SUM] ?? []);
|
||||
foreach ($currencyIds as $currencyId) {
|
||||
if ('native' === $currencyId) {
|
||||
// skip native entries.
|
||||
if ('primary' === $currencyId) {
|
||||
// skip primary entries.
|
||||
continue;
|
||||
}
|
||||
$currencyId = (int) $currencyId;
|
||||
@@ -112,23 +112,23 @@ class SummaryBalanceGrouped
|
||||
$amount = bcmul((string) $journal['amount'], $multiplier);
|
||||
$currency = $this->currencies[$currencyId] ?? TransactionCurrency::find($currencyId);
|
||||
$this->currencies[$currencyId] = $currency;
|
||||
$nativeAmount = $converter->convert($currency, $this->default, $journal['date'], $amount);
|
||||
$pcAmount = $converter->convert($currency, $this->default, $journal['date'], $amount);
|
||||
if ((int) $journal['foreign_currency_id'] === $this->default->id) {
|
||||
// use foreign amount instead
|
||||
$nativeAmount = $journal['foreign_amount'];
|
||||
$pcAmount = $journal['foreign_amount'];
|
||||
}
|
||||
// prep the arrays
|
||||
$this->amounts[$key] ??= [];
|
||||
$this->amounts[$key][$currencyId] ??= '0';
|
||||
$this->amounts[$key]['native'] ??= '0';
|
||||
$this->amounts[$key]['primary'] ??= '0';
|
||||
$this->amounts[self::SUM][$currencyId] ??= '0';
|
||||
$this->amounts[self::SUM]['native'] ??= '0';
|
||||
$this->amounts[self::SUM]['primary'] ??= '0';
|
||||
|
||||
// add values:
|
||||
$this->amounts[$key][$currencyId] = bcadd((string) $this->amounts[$key][$currencyId], $amount);
|
||||
$this->amounts[self::SUM][$currencyId] = bcadd((string) $this->amounts[self::SUM][$currencyId], $amount);
|
||||
$this->amounts[$key]['native'] = bcadd((string) $this->amounts[$key]['native'], (string) $nativeAmount);
|
||||
$this->amounts[self::SUM]['native'] = bcadd((string) $this->amounts[self::SUM]['native'], (string) $nativeAmount);
|
||||
$this->amounts[$key]['primary'] = bcadd((string) $this->amounts[$key]['primary'], (string) $pcAmount);
|
||||
$this->amounts[self::SUM]['primary'] = bcadd((string) $this->amounts[self::SUM]['primary'], (string) $pcAmount);
|
||||
}
|
||||
$converter->summarize();
|
||||
}
|
||||
|
@@ -182,7 +182,7 @@ trait AugumentData
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($budget->id);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
$cache->addProperty('get-limits');
|
||||
|
||||
if ($cache->has()) {
|
||||
@@ -193,14 +193,14 @@ trait AugumentData
|
||||
|
||||
$budgetCollection = new Collection([$budget]);
|
||||
|
||||
// merge sets based on a key, in case of convert to native
|
||||
// merge sets based on a key, in case of convert to primary currency
|
||||
$limits = new Collection();
|
||||
|
||||
/** @var BudgetLimit $entry */
|
||||
foreach ($set as $entry) {
|
||||
Log::debug(sprintf('Now at budget limit #%d', $entry->id));
|
||||
$currency = $entry->transactionCurrency;
|
||||
if ($this->convertToNative) {
|
||||
if ($this->convertToPrimary) {
|
||||
// the sumExpenses method already handles this.
|
||||
$currency = $this->defaultCurrency;
|
||||
}
|
||||
@@ -213,10 +213,10 @@ trait AugumentData
|
||||
$currentEnd = clone $currentStart;
|
||||
$currentEnd->addMonth();
|
||||
}
|
||||
// native amount.
|
||||
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $entry->transactionCurrency, $this->convertToNative);
|
||||
// primary currency amount.
|
||||
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $entry->transactionCurrency, $this->convertToPrimary);
|
||||
$spent = $expenses[$currency->id]['sum'] ?? '0';
|
||||
$entry->native_spent = $spent;
|
||||
$entry->pc_spent = $spent;
|
||||
|
||||
// normal amount:
|
||||
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $entry->transactionCurrency, false);
|
||||
|
@@ -38,7 +38,7 @@ trait BasicDataSupport
|
||||
*/
|
||||
protected function isInArray(array $array, int $entryId)
|
||||
{
|
||||
$key = $this->convertToNative ? 'native_balance' : 'balance';
|
||||
$key = $this->convertToPrimary ? 'pc_balance' : 'balance';
|
||||
|
||||
return $array[$entryId][$key] ?? '0';
|
||||
}
|
||||
|
@@ -48,13 +48,13 @@ trait ChartGeneration
|
||||
protected function accountBalanceChart(Collection $accounts, Carbon $start, Carbon $end): array // chart helper method.
|
||||
{
|
||||
// chart properties for cache:
|
||||
$convertToNative = Amount::convertToPrimary();
|
||||
$convertToPrimary = Amount::convertToPrimary();
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty('chart.account.account-balance-chart');
|
||||
$cache->addProperty($accounts);
|
||||
$cache->addProperty($convertToNative);
|
||||
$cache->addProperty($convertToPrimary);
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
}
|
||||
@@ -76,9 +76,9 @@ trait ChartGeneration
|
||||
foreach ($accounts as $account) {
|
||||
Log::debug(sprintf('Now at account #%d ("%s)', $account->id, $account->name));
|
||||
$currency = $accountRepos->getAccountCurrency($account) ?? $default;
|
||||
$useNative = $convertToNative && $default->id !== $currency->id;
|
||||
$field = $convertToNative ? 'native_balance' : 'balance';
|
||||
$currency = $useNative ? $default : $currency;
|
||||
$usePrimary = $convertToPrimary && $default->id !== $currency->id;
|
||||
$field = $convertToPrimary ? 'pc_balance' : 'balance';
|
||||
$currency = $usePrimary ? $default : $currency;
|
||||
Log::debug(sprintf('Will use field %s', $field));
|
||||
$currentSet = [
|
||||
'label' => $account->name,
|
||||
@@ -87,7 +87,7 @@ trait ChartGeneration
|
||||
];
|
||||
|
||||
$currentStart = clone $start;
|
||||
$range = Steam::finalAccountBalanceInRange($account, clone $start, clone $end, $this->convertToNative);
|
||||
$range = Steam::finalAccountBalanceInRange($account, clone $start, clone $end, $this->convertToPrimary);
|
||||
$previous = array_values($range)[0];
|
||||
Log::debug(sprintf('Start balance for account #%d ("%s) is', $account->id, $account->name), $previous);
|
||||
while ($currentStart <= $end) {
|
||||
|
@@ -194,15 +194,15 @@ trait PeriodOverview
|
||||
$foreignCurrencyId = $journal['foreign_currency_id'];
|
||||
$amount = $journal['amount'] ?? '0';
|
||||
|
||||
if ($this->convertToNative && $currencyId !== $this->defaultCurrency->id && $foreignCurrencyId !== $this->defaultCurrency->id) {
|
||||
$amount = $journal['native_amount'] ?? '0';
|
||||
$currencyId = $this->defaultCurrency->id;
|
||||
$currencyCode = $this->defaultCurrency->code;
|
||||
$currencyName = $this->defaultCurrency->name;
|
||||
$currencySymbol = $this->defaultCurrency->symbol;
|
||||
$currencyDecimalPlaces = $this->defaultCurrency->decimal_places;
|
||||
if ($this->convertToPrimary && $currencyId !== $this->primaryCurrency->id && $foreignCurrencyId !== $this->primaryCurrency->id) {
|
||||
$amount = $journal['pc_amount'] ?? '0';
|
||||
$currencyId = $this->primaryCurrency->id;
|
||||
$currencyCode = $this->primaryCurrency->code;
|
||||
$currencyName = $this->primaryCurrency->name;
|
||||
$currencySymbol = $this->primaryCurrency->symbol;
|
||||
$currencyDecimalPlaces = $this->primaryCurrency->decimal_places;
|
||||
}
|
||||
if ($this->convertToNative && $currencyId !== $this->defaultCurrency->id && $foreignCurrencyId === $this->defaultCurrency->id) {
|
||||
if ($this->convertToPrimary && $currencyId !== $this->primaryCurrency->id && $foreignCurrencyId === $this->primaryCurrency->id) {
|
||||
$currencyId = (int) $foreignCurrencyId;
|
||||
$currencyCode = $journal['foreign_currency_code'];
|
||||
$currencyName = $journal['foreign_currency_name'];
|
||||
@@ -334,7 +334,7 @@ trait PeriodOverview
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
$cache->addProperty('no-budget-period-entries');
|
||||
|
||||
if ($cache->has()) {
|
||||
|
@@ -55,7 +55,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
private array $currencies;
|
||||
private array $locations;
|
||||
private array $meta;
|
||||
private TransactionCurrency $native;
|
||||
private TransactionCurrency $primaryCurrency;
|
||||
private array $notes;
|
||||
private array $openingBalances;
|
||||
private User $user;
|
||||
@@ -150,7 +150,7 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
foreach ($currencies as $currency) {
|
||||
$this->currencies[(int) $currency->id] = $currency;
|
||||
}
|
||||
$this->currencies[0] = $this->native;
|
||||
$this->currencies[0] = $this->primaryCurrency;
|
||||
foreach ($this->currencies as $id => $currency) {
|
||||
if (true === $currency) {
|
||||
throw new FireflyException(sprintf('Currency #%d not found.', $id));
|
||||
@@ -278,9 +278,9 @@ class AccountEnrichment implements EnrichmentInterface
|
||||
});
|
||||
}
|
||||
|
||||
public function setNative(TransactionCurrency $native): void
|
||||
public function setPrimaryCurrency(TransactionCurrency $primary): void
|
||||
{
|
||||
$this->native = $native;
|
||||
$this->primaryCurrency = $primary;
|
||||
}
|
||||
|
||||
private function collectLastActivities(): void
|
||||
|
@@ -26,7 +26,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
private User $user;
|
||||
private UserGroup $userGroup;
|
||||
private Collection $collection;
|
||||
private bool $convertToNative = false;
|
||||
private bool $convertToPrimary = false;
|
||||
private ?Carbon $start = null;
|
||||
private ?Carbon $end = null;
|
||||
private array $subscriptionIds = [];
|
||||
@@ -35,7 +35,7 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
private array $paidDates = [];
|
||||
private array $notes = [];
|
||||
private array $payDates = [];
|
||||
private TransactionCurrency $nativeCurrency;
|
||||
private TransactionCurrency $primaryCurrency;
|
||||
private BillDateCalculator $calculator;
|
||||
|
||||
public function enrich(Collection $collection): Collection
|
||||
@@ -88,15 +88,15 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
$meta['notes'] = $notes[$item->id];
|
||||
}
|
||||
|
||||
// Convert amounts to native currency if needed
|
||||
if ($this->convertToNative && $item->currency_id !== $this->nativeCurrency->id) {
|
||||
Log::debug('Convert to native currency');
|
||||
// Convert amounts to primary currency if needed
|
||||
if ($this->convertToPrimary && $item->currency_id !== $this->primaryCurrency->id) {
|
||||
Log::debug('Convert to primary currency');
|
||||
$converter = new ExchangeRateConverter();
|
||||
$amounts = [
|
||||
'amount_min' => Steam::bcround($converter->convert($item->transactionCurrency, $this->nativeCurrency, today(), $item->amount_min), $this->nativeCurrency->decimal_places),
|
||||
'amount_max' => Steam::bcround($converter->convert($item->transactionCurrency, $this->nativeCurrency, today(), $item->amount_max), $this->nativeCurrency->decimal_places),
|
||||
'amount_min' => Steam::bcround($converter->convert($item->transactionCurrency, $this->primaryCurrency, today(), $item->amount_min), $this->primaryCurrency->decimal_places),
|
||||
'amount_max' => Steam::bcround($converter->convert($item->transactionCurrency, $this->primaryCurrency, today(), $item->amount_max), $this->primaryCurrency->decimal_places),
|
||||
];
|
||||
$amounts['average'] = Steam::bcround(bcdiv(bcadd($amounts['amount_min'], $amounts['amount_max']), '2'), $this->nativeCurrency->decimal_places);
|
||||
$amounts['average'] = Steam::bcround(bcdiv(bcadd($amounts['amount_min'], $amounts['amount_max']), '2'), $this->primaryCurrency->decimal_places);
|
||||
}
|
||||
$item->amounts = $amounts;
|
||||
$item->meta = $meta;
|
||||
@@ -140,14 +140,14 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
$this->userGroup = $userGroup;
|
||||
}
|
||||
|
||||
public function setConvertToNative(bool $convertToNative): void
|
||||
public function setConvertToPrimary(bool $convertToPrimary): void
|
||||
{
|
||||
$this->convertToNative = $convertToNative;
|
||||
$this->convertToPrimary = $convertToPrimary;
|
||||
}
|
||||
|
||||
public function setNative(TransactionCurrency $nativeCurrency): void
|
||||
public function setPrimaryCurrency(TransactionCurrency $primaryCurrency): void
|
||||
{
|
||||
$this->nativeCurrency = $nativeCurrency;
|
||||
$this->primaryCurrency = $primaryCurrency;
|
||||
}
|
||||
|
||||
private function collectSubscriptionIds(): void
|
||||
@@ -267,11 +267,11 @@ class SubscriptionEnrichment implements EnrichmentInterface
|
||||
$array['foreign_currency_decimal_places'] = $entry->foreign_currency_decimal_places;
|
||||
$array['foreign_amount'] = Steam::bcround($entry->foreign_amount, $entry->foreign_currency_decimal_places);
|
||||
}
|
||||
if($this->convertToNative) {
|
||||
$array['amount'] = $converter->convert($entry->transactionCurrency, $this->nativeCurrency, $entry->date, $entry->amount);
|
||||
$array['currency_id'] = $this->nativeCurrency->id;
|
||||
$array['currency_code'] = $this->nativeCurrency->code;
|
||||
$array['currency_decimal_places'] = $this->nativeCurrency->decimal_places;
|
||||
if($this->convertToPrimary) {
|
||||
$array['amount'] = $converter->convert($entry->transactionCurrency, $this->primaryCurrency, $entry->date, $entry->amount);
|
||||
$array['currency_id'] = $this->primaryCurrency->id;
|
||||
$array['currency_code'] = $this->primaryCurrency->code;
|
||||
$array['currency_decimal_places'] = $this->primaryCurrency->decimal_places;
|
||||
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class TransactionSummarizer
|
||||
{
|
||||
private bool $convertToNative = false;
|
||||
private bool $convertToPrimary = false;
|
||||
private TransactionCurrency $default;
|
||||
private User $user;
|
||||
|
||||
@@ -46,7 +46,7 @@ class TransactionSummarizer
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->default = Amount::getPrimaryCurrencyByUserGroup($user->userGroup);
|
||||
$this->convertToNative = Amount::convertToPrimary($user);
|
||||
$this->convertToPrimary = Amount::convertToPrimary($user);
|
||||
}
|
||||
|
||||
public function groupByCurrencyId(array $journals, string $method = 'negative', bool $includeForeign = true): array
|
||||
@@ -70,14 +70,14 @@ class TransactionSummarizer
|
||||
$foreignCurrencyCode = null;
|
||||
$foreignCurrencyDecimalPlaces = null;
|
||||
|
||||
if ($this->convertToNative) {
|
||||
// Log::debug('convertToNative is true.');
|
||||
// if convert to native, use the native amount yes or no?
|
||||
$useNative = $this->default->id !== (int) $journal['currency_id'];
|
||||
if ($this->convertToPrimary) {
|
||||
// Log::debug('convertToPrimary is true.');
|
||||
// if convert to primary currency, use the primary currency amount yes or no?
|
||||
$usePrimary = $this->default->id !== (int) $journal['currency_id'];
|
||||
$useForeign = $this->default->id === (int) $journal['foreign_currency_id'];
|
||||
if ($useNative) {
|
||||
// Log::debug(sprintf('Journal #%d switches to native amount (original is %s)', $journal['transaction_journal_id'], $journal['currency_code']));
|
||||
$field = 'native_amount';
|
||||
if ($usePrimary) {
|
||||
// Log::debug(sprintf('Journal #%d switches to primary currency amount (original is %s)', $journal['transaction_journal_id'], $journal['currency_code']));
|
||||
$field = 'pc_amount';
|
||||
$currencyId = $this->default->id;
|
||||
$currencyName = $this->default->name;
|
||||
$currencySymbol = $this->default->symbol;
|
||||
@@ -94,8 +94,8 @@ class TransactionSummarizer
|
||||
$currencyDecimalPlaces = $journal['foreign_currency_decimal_places'];
|
||||
}
|
||||
}
|
||||
if (!$this->convertToNative) {
|
||||
// Log::debug('convertToNative is false.');
|
||||
if (!$this->convertToPrimary) {
|
||||
// Log::debug('convertToPrimary is false.');
|
||||
// use foreign amount?
|
||||
$foreignCurrencyId = (int) $journal['foreign_currency_id'];
|
||||
if (0 !== $foreignCurrencyId) {
|
||||
@@ -159,8 +159,8 @@ class TransactionSummarizer
|
||||
$array = [];
|
||||
$idKey = sprintf('%s_account_id', $direction);
|
||||
$nameKey = sprintf('%s_account_name', $direction);
|
||||
$convertToNative = Amount::convertToPrimary($this->user);
|
||||
$default = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
$convertToPrimary = Amount::convertToPrimary($this->user);
|
||||
$primary = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
|
||||
|
||||
Log::debug(sprintf('groupByDirection(array, %s, %s).', $direction, $method));
|
||||
@@ -171,18 +171,18 @@ class TransactionSummarizer
|
||||
$currencySymbol = $journal['currency_symbol'];
|
||||
$currencyCode = $journal['currency_code'];
|
||||
$currencyDecimalPlaces = $journal['currency_decimal_places'];
|
||||
$field = $convertToNative && $currencyId !== $default->id ? 'native_amount' : 'amount';
|
||||
$field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';
|
||||
|
||||
// perhaps use default currency instead?
|
||||
if ($convertToNative && $journal['currency_id'] !== $default->id) {
|
||||
$currencyId = $default->id;
|
||||
$currencyName = $default->name;
|
||||
$currencySymbol = $default->symbol;
|
||||
$currencyCode = $default->code;
|
||||
$currencyDecimalPlaces = $default->decimal_places;
|
||||
if ($convertToPrimary && $journal['currency_id'] !== $primary->id) {
|
||||
$currencyId = $primary->id;
|
||||
$currencyName = $primary->name;
|
||||
$currencySymbol = $primary->symbol;
|
||||
$currencyCode = $primary->code;
|
||||
$currencyDecimalPlaces = $primary->decimal_places;
|
||||
}
|
||||
// use foreign amount when the foreign currency IS the default currency.
|
||||
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
|
||||
if ($convertToPrimary && $journal['currency_id'] !== $primary->id && $primary->id === $journal['foreign_currency_id']) {
|
||||
$field = 'foreign_amount';
|
||||
}
|
||||
$key = sprintf('%s-%s', $journal[$idKey], $currencyId);
|
||||
@@ -202,9 +202,9 @@ class TransactionSummarizer
|
||||
$array[$key]['sum'] = bcadd($array[$key]['sum'], (string) app('steam')->{$method}((string) ($journal[$field] ?? '0'))); // @phpstan-ignore-line
|
||||
Log::debug(sprintf('Field for transaction #%d is "%s" (%s). Sum: %s', $journal['transaction_group_id'], $currencyCode, $field, $array[$key]['sum']));
|
||||
|
||||
// also do foreign amount, but only when convertToNative is false (otherwise we have it already)
|
||||
// or when convertToNative is true and the foreign currency is ALSO not the default currency.
|
||||
if ((!$convertToNative || $journal['foreign_currency_id'] !== $default->id) && 0 !== (int) $journal['foreign_currency_id']) {
|
||||
// also do foreign amount, but only when convertToPrimary is false (otherwise we have it already)
|
||||
// or when convertToPrimary is true and the foreign currency is ALSO not the default currency.
|
||||
if ((!$convertToPrimary || $journal['foreign_currency_id'] !== $primary->id) && 0 !== (int) $journal['foreign_currency_id']) {
|
||||
Log::debug(sprintf('Use foreign amount from transaction #%d: %s %s. Sum: %s', $journal['transaction_group_id'], $currencyCode, $journal['foreign_amount'], $array[$key]['sum']));
|
||||
$key = sprintf('%s-%s', $journal[$idKey], $journal['foreign_currency_id']);
|
||||
$array[$key] ??= [
|
||||
@@ -224,9 +224,9 @@ class TransactionSummarizer
|
||||
return $array;
|
||||
}
|
||||
|
||||
public function setConvertToNative(bool $convertToNative): void
|
||||
public function setConvertToPrimary(bool $convertToPrimary): void
|
||||
{
|
||||
Log::debug(sprintf('Overrule convertToNative to become %s', var_export($convertToNative, true)));
|
||||
$this->convertToNative = $convertToNative;
|
||||
Log::debug(sprintf('Overrule convertToPrimary to become %s', var_export($convertToPrimary, true)));
|
||||
$this->convertToPrimary = $convertToPrimary;
|
||||
}
|
||||
}
|
||||
|
@@ -73,19 +73,19 @@ class Steam
|
||||
return $number;
|
||||
}
|
||||
|
||||
public function filterAccountBalances(array $total, Account $account, bool $convertToNative, ?TransactionCurrency $currency = null): array
|
||||
public function filterAccountBalances(array $total, Account $account, bool $convertToPrimary, ?TransactionCurrency $currency = null): array
|
||||
{
|
||||
Log::debug(sprintf('filterAccountBalances(#%d)', $account->id));
|
||||
$return = [];
|
||||
foreach ($total as $key => $value) {
|
||||
$return[$key] = $this->filterAccountBalance($value, $account, $convertToNative, $currency);
|
||||
$return[$key] = $this->filterAccountBalance($value, $account, $convertToPrimary, $currency);
|
||||
}
|
||||
Log::debug(sprintf('end of filterAccountBalances(#%d)', $account->id));
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function filterAccountBalance(array $set, Account $account, bool $convertToNative, ?TransactionCurrency $currency = null): array
|
||||
public function filterAccountBalance(array $set, Account $account, bool $convertToPrimary, ?TransactionCurrency $currency = null): array
|
||||
{
|
||||
Log::debug(sprintf('filterAccountBalance(#%d)', $account->id), $set);
|
||||
if (0 === count($set)) {
|
||||
@@ -93,14 +93,14 @@ class Steam
|
||||
|
||||
return [];
|
||||
}
|
||||
$defaultCurrency = Amount::getPrimaryCurrency();
|
||||
if ($convertToNative) {
|
||||
if ($defaultCurrency->id === $currency?->id) {
|
||||
Log::debug(sprintf('Unset [%s] for account #%d (no longer unset "native_balance")', $defaultCurrency->code, $account->id));
|
||||
unset($set[$defaultCurrency->code]);
|
||||
$primaryCurrency = Amount::getPrimaryCurrency();
|
||||
if ($convertToPrimary) {
|
||||
if ($primaryCurrency->id === $currency?->id) {
|
||||
Log::debug(sprintf('Unset [%s] for account #%d (no longer unset "pc_balance")', $primaryCurrency->code, $account->id));
|
||||
unset($set[$primaryCurrency->code]);
|
||||
}
|
||||
// todo rethink this logic.
|
||||
if ($currency instanceof TransactionCurrency && $defaultCurrency->id !== $currency->id) {
|
||||
if ($currency instanceof TransactionCurrency && $primaryCurrency->id !== $currency->id) {
|
||||
Log::debug(sprintf('Unset balance for account #%d', $account->id));
|
||||
unset($set['balance']);
|
||||
}
|
||||
@@ -111,22 +111,22 @@ class Steam
|
||||
}
|
||||
}
|
||||
|
||||
if (!$convertToNative) {
|
||||
if (!$convertToPrimary) {
|
||||
if (!$currency instanceof TransactionCurrency) {
|
||||
Log::debug(sprintf('Unset native_balance and make defaultCurrency balance the balance for account #%d', $account->id));
|
||||
$set['balance'] = $set[$defaultCurrency->code] ?? '0';
|
||||
unset($set[$defaultCurrency->code]);
|
||||
Log::debug(sprintf('Unset pc_balance and make defaultCurrency balance the balance for account #%d', $account->id));
|
||||
$set['balance'] = $set[$primaryCurrency->code] ?? '0';
|
||||
unset($set[$primaryCurrency->code]);
|
||||
}
|
||||
|
||||
if ($currency instanceof TransactionCurrency) {
|
||||
Log::debug(sprintf('Unset [%s] + [%s] balance for account #%d', $defaultCurrency->code, $currency->code, $account->id));
|
||||
unset($set[$defaultCurrency->code], $set[$currency->code]);
|
||||
Log::debug(sprintf('Unset [%s] + [%s] balance for account #%d', $primaryCurrency->code, $currency->code, $account->id));
|
||||
unset($set[$primaryCurrency->code], $set[$currency->code]);
|
||||
}
|
||||
}
|
||||
|
||||
// put specific value first in array.
|
||||
if (array_key_exists('native_balance', $set)) {
|
||||
$set = ['native_balance' => $set['native_balance']] + $set;
|
||||
if (array_key_exists('pc_balance', $set)) {
|
||||
$set = ['pc_balance' => $set['pc_balance']] + $set;
|
||||
}
|
||||
if (array_key_exists('balance', $set)) {
|
||||
$set = ['balance' => $set['balance']] + $set;
|
||||
@@ -195,7 +195,7 @@ class Steam
|
||||
return str_replace($search, '', $string);
|
||||
}
|
||||
|
||||
public function finalAccountBalanceInRange(Account $account, Carbon $start, Carbon $end, bool $convertToNative): array
|
||||
public function finalAccountBalanceInRange(Account $account, Carbon $start, Carbon $end, bool $convertToPrimary): array
|
||||
{
|
||||
// expand period.
|
||||
$start->startOfDay();
|
||||
@@ -207,7 +207,7 @@ class Steam
|
||||
$cache->addProperty($account->id);
|
||||
$cache->addProperty('final-balance-in-range');
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($convertToNative);
|
||||
$cache->addProperty($convertToPrimary);
|
||||
$cache->addProperty($end);
|
||||
if ($cache->has()) {
|
||||
return $cache->get();
|
||||
@@ -224,10 +224,10 @@ class Steam
|
||||
$request->subDay()->endOfDay();
|
||||
Log::debug(sprintf('finalAccountBalanceInRange: Call finalAccountBalance with date/time "%s"', $request->toIso8601String()));
|
||||
$startBalance = $this->finalAccountBalance($account, $request);
|
||||
$nativeCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
$primaryCurrency = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
$accountCurrency = $this->getAccountCurrency($account);
|
||||
$hasCurrency = $accountCurrency instanceof TransactionCurrency;
|
||||
$currency = $accountCurrency ?? $nativeCurrency;
|
||||
$currency = $accountCurrency ?? $primaryCurrency;
|
||||
Log::debug(sprintf('Currency is %s', $currency->code));
|
||||
|
||||
|
||||
@@ -237,12 +237,12 @@ class Steam
|
||||
$startBalance[$accountCurrency->code] ??= '0';
|
||||
}
|
||||
if (!$hasCurrency) {
|
||||
Log::debug(sprintf('Also set start balance in %s', $nativeCurrency->code));
|
||||
$startBalance[$nativeCurrency->code] ??= '0';
|
||||
Log::debug(sprintf('Also set start balance in %s', $primaryCurrency->code));
|
||||
$startBalance[$primaryCurrency->code] ??= '0';
|
||||
}
|
||||
$currencies = [
|
||||
$currency->id => $currency,
|
||||
$nativeCurrency->id => $nativeCurrency,
|
||||
$primaryCurrency->id => $primaryCurrency,
|
||||
];
|
||||
|
||||
$balances[$formatted] = $startBalance;
|
||||
@@ -294,15 +294,15 @@ class Steam
|
||||
$currentBalance[$entryCurrency->code] ??= '0';
|
||||
$currentBalance[$entryCurrency->code] = bcadd($sumOfDay, (string) $currentBalance[$entryCurrency->code]);
|
||||
|
||||
// if not requested to convert to native, add the amount to "balance", do nothing else.
|
||||
if (!$convertToNative) {
|
||||
// if not requested to convert to primary currency, add the amount to "balance", do nothing else.
|
||||
if (!$convertToPrimary) {
|
||||
$currentBalance['balance'] = bcadd((string) $currentBalance['balance'], $sumOfDay);
|
||||
}
|
||||
// if convert to native add the converted amount to "native_balance".
|
||||
// if there is a request to convert, convert to "native_balance" and use "balance" for whichever amount is in the native currency.
|
||||
if ($convertToNative) {
|
||||
$nativeSumOfDay = $converter->convert($entryCurrency, $nativeCurrency, $carbon, $sumOfDay);
|
||||
$currentBalance['native_balance'] = bcadd((string) ($currentBalance['native_balance'] ?? '0'), $nativeSumOfDay);
|
||||
// if convert to primary currency add the converted amount to "pc_balance".
|
||||
// if there is a request to convert, convert to "pc_balance" and use "balance" for whichever amount is in the primary currency.
|
||||
if ($convertToPrimary) {
|
||||
$pcSumOfDay = $converter->convert($entryCurrency, $primaryCurrency, $carbon, $sumOfDay);
|
||||
$currentBalance['pc_balance'] = bcadd((string) ($currentBalance['pc_balance'] ?? '0'), $pcSumOfDay);
|
||||
// if it's the same currency as the entry, also add to balance (see other code).
|
||||
if ($currency->id === $entryCurrency->id) {
|
||||
$currentBalance['balance'] = bcadd((string) $currentBalance['balance'], $sumOfDay);
|
||||
@@ -323,15 +323,15 @@ class Steam
|
||||
*
|
||||
* Returns the balance of an account at exact moment given. Array with at least one value.
|
||||
* Always returns:
|
||||
* "balance": balance in the account's currency OR user's native currency if the account has no currency
|
||||
* "balance": balance in the account's currency OR user's primary currency if the account has no currency
|
||||
* "EUR": balance in EUR (or whatever currencies the account has balance in)
|
||||
*
|
||||
* If the user has $convertToNative:
|
||||
* "balance": balance in the account's currency OR user's native currency if the account has no currency
|
||||
* --> "native_balance": balance in the user's native balance, with all amounts converted to native.
|
||||
* If the user has $convertToPrimary:
|
||||
* "balance": balance in the account's currency OR user's primary currency if the account has no currency
|
||||
* --> "pc_balance": balance in the user's primary currency, with all amounts converted to the primary currency.
|
||||
* "EUR": balance in EUR (or whatever currencies the account has balance in)
|
||||
*/
|
||||
public function finalAccountBalance(Account $account, Carbon $date, ?TransactionCurrency $native = null, ?bool $convertToNative = null): array
|
||||
public function finalAccountBalance(Account $account, Carbon $date, ?TransactionCurrency $primary = null, ?bool $convertToPrimary = null): array
|
||||
{
|
||||
|
||||
$cache = new CacheProperties();
|
||||
@@ -343,11 +343,11 @@ class Steam
|
||||
return $cache->get();
|
||||
}
|
||||
// Log::debug(sprintf('finalAccountBalance(#%d, %s)', $account->id, $date->format('Y-m-d H:i:s')));
|
||||
if (null === $convertToNative) {
|
||||
$convertToNative = Amount::convertToPrimary($account->user);
|
||||
if (null === $convertToPrimary) {
|
||||
$convertToPrimary = Amount::convertToPrimary($account->user);
|
||||
}
|
||||
if (!$native instanceof TransactionCurrency) {
|
||||
$native = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
if (!$primary instanceof TransactionCurrency) {
|
||||
$primary = Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
}
|
||||
// account balance thing.
|
||||
$currencyPresent = isset($account->meta) && array_key_exists('currency', $account->meta) && null !== $account->meta['currency'];
|
||||
@@ -359,9 +359,9 @@ class Steam
|
||||
$accountCurrency = $this->getAccountCurrency($account);
|
||||
}
|
||||
$hasCurrency = null !== $accountCurrency;
|
||||
$currency = $hasCurrency ? $accountCurrency : $native;
|
||||
$currency = $hasCurrency ? $accountCurrency : $primary;
|
||||
$return = [
|
||||
'native_balance' => '0',
|
||||
'pc_balance' => '0',
|
||||
'balance' => '0', // this key is overwritten right away, but I must remember it is always created.
|
||||
];
|
||||
// balance(s) in all currencies.
|
||||
@@ -373,32 +373,32 @@ class Steam
|
||||
;
|
||||
$others = $this->groupAndSumTransactions($array, 'code', 'amount');
|
||||
// Log::debug('All balances are (joined)', $others);
|
||||
// if there is no request to convert, take this as "balance" and "native_balance".
|
||||
// if there is no request to convert, take this as "balance" and "pc_balance".
|
||||
$return['balance'] = $others[$currency->code] ?? '0';
|
||||
if (!$convertToNative) {
|
||||
unset($return['native_balance']);
|
||||
// Log::debug(sprintf('Set balance to %s, unset native_balance', $return['balance']));
|
||||
if (!$convertToPrimary) {
|
||||
unset($return['pc_balance']);
|
||||
// Log::debug(sprintf('Set balance to %s, unset pc_balance', $return['balance']));
|
||||
}
|
||||
// if there is a request to convert, convert to "native_balance" and use "balance" for whichever amount is in the native currency.
|
||||
if ($convertToNative) {
|
||||
$return['native_balance'] = $this->convertAllBalances($others, $native, $date); // todo sum all and convert.
|
||||
// Log::debug(sprintf('Set native_balance to %s', $return['native_balance']));
|
||||
// if there is a request to convert, convert to "pc_balance" and use "balance" for whichever amount is in the primary currency.
|
||||
if ($convertToPrimary) {
|
||||
$return['primary_balance'] = $this->convertAllBalances($others, $primary, $date); // todo sum all and convert.
|
||||
// Log::debug(sprintf('Set pc_balance to %s', $return['pc_balance']));
|
||||
}
|
||||
|
||||
// either way, the balance is always combined with the virtual balance:
|
||||
$virtualBalance = (string) ('' === (string) $account->virtual_balance ? '0' : $account->virtual_balance);
|
||||
|
||||
if ($convertToNative) {
|
||||
// the native balance is combined with a converted virtual_balance:
|
||||
if ($convertToPrimary) {
|
||||
// the primary currency balance is combined with a converted virtual_balance:
|
||||
$converter = new ExchangeRateConverter();
|
||||
$nativeVirtualBalance = $converter->convert($currency, $native, $date, $virtualBalance);
|
||||
$return['native_balance'] = bcadd($nativeVirtualBalance, $return['native_balance']);
|
||||
// Log::debug(sprintf('Native virtual balance makes the native total %s', $return['native_balance']));
|
||||
$pcVirtualBalance = $converter->convert($currency, $primary, $date, $virtualBalance);
|
||||
$return['pc_balance'] = bcadd($pcVirtualBalance, $return['pc_balance']);
|
||||
// Log::debug(sprintf('Primary virtual balance makes the primary total %s', $return['pc_balance']));
|
||||
}
|
||||
if (!$convertToNative) {
|
||||
// if not, also increase the balance + native balance for consistency.
|
||||
if (!$convertToPrimary) {
|
||||
// if not, also increase the balance + primary balance for consistency.
|
||||
$return['balance'] = bcadd($return['balance'], $virtualBalance);
|
||||
// Log::debug(sprintf('Virtual balance makes the (native) total %s', $return['balance']));
|
||||
// Log::debug(sprintf('Virtual balance makes the (primary currency) total %s', $return['balance']));
|
||||
}
|
||||
$final = array_merge($return, $others);
|
||||
// Log::debug('Final balance is', $final);
|
||||
@@ -436,7 +436,7 @@ class Steam
|
||||
return $return;
|
||||
}
|
||||
|
||||
private function convertAllBalances(array $others, TransactionCurrency $native, Carbon $date): string
|
||||
private function convertAllBalances(array $others, TransactionCurrency $primary, Carbon $date): string
|
||||
{
|
||||
$total = '0';
|
||||
$converter = new ExchangeRateConverter();
|
||||
@@ -445,8 +445,8 @@ class Steam
|
||||
if (null === $currency) {
|
||||
continue;
|
||||
}
|
||||
$current = $converter->convert($currency, $native, $date, $amount);
|
||||
Log::debug(sprintf('Convert %s %s to %s %s', $currency->code, $amount, $native->code, $current));
|
||||
$current = $converter->convert($currency, $primary, $date, $amount);
|
||||
Log::debug(sprintf('Convert %s %s to %s %s', $currency->code, $amount, $primary->code, $current));
|
||||
$total = bcadd($current, $total);
|
||||
}
|
||||
|
||||
|
@@ -156,7 +156,7 @@ class AmountFormat extends AbstractExtension
|
||||
/** @var null|TransactionCurrency $currency */
|
||||
$currency = TransactionCurrency::whereCode($code)->first();
|
||||
if (null === $currency) {
|
||||
Log::error(sprintf('Could not find currency with code "%s". Fallback to native currency.', $code));
|
||||
Log::error(sprintf('Could not find currency with code "%s". Fallback to primary currency.', $code));
|
||||
$currency = Amount::getPrimaryCurrency();
|
||||
Log::error(sprintf('Fallback currency is "%s".', $currency->code));
|
||||
}
|
||||
|
@@ -75,30 +75,30 @@ class General extends AbstractExtension
|
||||
Log::debug(sprintf('twig balance: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$info = Steam::finalAccountBalance($account, $date);
|
||||
$currency = Steam::getAccountCurrency($account);
|
||||
$default = Amount::getPrimaryCurrency();
|
||||
$convertToNative = Amount::convertToPrimary();
|
||||
$useNative = $convertToNative && $default->id !== $currency->id;
|
||||
$currency ??= $default;
|
||||
$primary = Amount::getPrimaryCurrency();
|
||||
$convertToPrimary = Amount::convertToPrimary();
|
||||
$usePrimary = $convertToPrimary && $primary->id !== $currency->id;
|
||||
$currency ??= $primary;
|
||||
$strings = [];
|
||||
foreach ($info as $key => $balance) {
|
||||
if ('balance' === $key) {
|
||||
// balance in account currency.
|
||||
if (!$useNative) {
|
||||
if (!$usePrimary) {
|
||||
$strings[] = app('amount')->formatAnything($currency, $balance, false);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
if ('native_balance' === $key) {
|
||||
// balance in native currency.
|
||||
if ($useNative) {
|
||||
$strings[] = app('amount')->formatAnything($default, $balance, false);
|
||||
if ('pc_balance' === $key) {
|
||||
// balance in primary currency.
|
||||
if ($usePrimary) {
|
||||
$strings[] = app('amount')->formatAnything($primary, $balance, false);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
// for multi currency accounts.
|
||||
if ($useNative && $key !== $default->code) {
|
||||
if ($usePrimary && $key !== $primary->code) {
|
||||
$strings[] = app('amount')->formatAnything(TransactionCurrency::where('code', $key)->first(), $balance, false);
|
||||
}
|
||||
}
|
||||
|
@@ -118,7 +118,7 @@ class BudgetLimitTransformer extends AbstractTransformer
|
||||
'amount' => $amount,
|
||||
'pc_amount' => $this->convertToPrimary ? app('steam')->bcround($budgetLimit->native_amount, $primary->decimal_places) : null,
|
||||
'period' => $budgetLimit->period,
|
||||
'spent' => $expenses[$currencyId]['sum'] ?? '0', // will be in native if convertToNative.
|
||||
'spent' => $expenses[$currencyId]['sum'] ?? '0', // will be in primary currency if convertToPrimary.
|
||||
'notes' => '' === $notes ? null : $notes,
|
||||
'links' => [
|
||||
[
|
||||
|
@@ -186,7 +186,7 @@ return [
|
||||
'currencyPreference' => 'EUR',
|
||||
'language' => 'en_US',
|
||||
'locale' => 'equal',
|
||||
'convertToNative' => false,
|
||||
'convertToPrimary' => false,
|
||||
],
|
||||
'default_currency' => 'EUR',
|
||||
'default_language' => envNonEmpty('DEFAULT_LANGUAGE', 'en_US'),
|
||||
|
@@ -315,7 +315,7 @@ return [
|
||||
'list' => [
|
||||
'title',
|
||||
'active',
|
||||
'native_currency',
|
||||
'primary_currency',
|
||||
'trigger',
|
||||
'response',
|
||||
'delivery',
|
||||
|
@@ -121,9 +121,9 @@ export default {
|
||||
this.administration = {
|
||||
id: current.id,
|
||||
title: current.attributes.title,
|
||||
currency_id: parseInt(current.attributes.native_currency_id),
|
||||
currency_code: current.attributes.native_currency_code,
|
||||
currency_name: current.attributes.native_currency_name,
|
||||
currency_id: parseInt(current.attributes.primary_currency_id),
|
||||
currency_code: current.attributes.primary_currency_code,
|
||||
currency_name: current.attributes.primary_currency_name,
|
||||
};
|
||||
this.pageTitle = this.administration.title;
|
||||
});
|
||||
@@ -143,7 +143,7 @@ export default {
|
||||
// collect data
|
||||
let data = {
|
||||
title: this.administration.title,
|
||||
native_currency_id: parseInt(this.administration.currency_id),
|
||||
primary_currency_id: parseInt(this.administration.currency_id),
|
||||
};
|
||||
|
||||
// post!
|
||||
@@ -154,7 +154,7 @@ export default {
|
||||
|
||||
this.error_message = error.response.data.message;
|
||||
this.errors.title = error.response.data.errors.title;
|
||||
this.errors.native_currency_id = error.response.data.errors.native_currency_id;
|
||||
this.errors.primary_currency_id = error.response.data.errors.primary_currency_id;
|
||||
|
||||
// enable button again
|
||||
$('#submitButton').prop("disabled", false);
|
||||
|
@@ -48,7 +48,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ $t('list.title') }}</th>
|
||||
<th>{{ $t('list.native_currency') }}</th>
|
||||
<th>{{ $t('list.primary_currency') }}</th>
|
||||
<th class="hidden-sm hidden-xs"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -106,8 +106,8 @@ export default {
|
||||
let administration = {
|
||||
id: current.id,
|
||||
title: current.attributes.title,
|
||||
currency_code: current.attributes.native_currency_code,
|
||||
currency_name: current.attributes.native_currency_name,
|
||||
currency_code: current.attributes.primary_currency_code,
|
||||
currency_name: current.attributes.primary_currency_name,
|
||||
};
|
||||
this.administrations.push(administration);
|
||||
}
|
||||
|
@@ -407,7 +407,7 @@ let index = function () {
|
||||
interest: current.attributes.interest,
|
||||
interest_period: current.attributes.interest_period,
|
||||
balance: current.attributes.balance,
|
||||
native_balance: current.attributes.native_balance,
|
||||
pc_balance: current.attributes.pc_balance,
|
||||
balances: current.attributes.balances,
|
||||
};
|
||||
// get group info:
|
||||
|
@@ -39,7 +39,7 @@ export default () => ({
|
||||
loading: false,
|
||||
loadingAccounts: false,
|
||||
accountList: [],
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
chartOptions: null,
|
||||
localCacheKey(type) {
|
||||
return 'ds_accounts_' + type;
|
||||
@@ -48,7 +48,7 @@ export default () => ({
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
console.log('I heard that! (dashboard/accounts)');
|
||||
this.convertToNative = event.detail;
|
||||
this.convertToPrimary = event.detail;
|
||||
this.accountList = [];
|
||||
chartData = null;
|
||||
this.loadChart();
|
||||
@@ -60,7 +60,7 @@ export default () => ({
|
||||
getFreshData() {
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
const chartCacheKey = getCacheKey(this.localCacheKey('chart'), {convertToNative: this.convertToNative, start: start, end: end})
|
||||
const chartCacheKey = getCacheKey(this.localCacheKey('chart'), {convertToPrimary: this.convertToPrimary, start: start, end: end})
|
||||
|
||||
const cacheValid = window.store.get('cacheValid');
|
||||
let cachedData = window.store.get(chartCacheKey);
|
||||
@@ -100,18 +100,18 @@ export default () => ({
|
||||
dataset.label = current.label;
|
||||
|
||||
// use the "native" currency code and use the "native_entries" as array
|
||||
if (this.convertToNative) {
|
||||
if (this.convertToPrimary) {
|
||||
currencies.push(current.native_currency_code);
|
||||
dataset.currency_code = current.native_currency_code;
|
||||
if(!current.hasOwnProperty('native_entries')) {
|
||||
console.error('No native entries ('+this.convertToNative+') found for account: ', current);
|
||||
console.error('No native entries ('+this.convertToPrimary+') found for account: ', current);
|
||||
}
|
||||
if(current.hasOwnProperty('native_entries')) {
|
||||
collection = Object.values(current.native_entries);
|
||||
}
|
||||
yAxis = 'y' + current.native_currency_code;
|
||||
}
|
||||
if (!this.convertToNative) {
|
||||
if (!this.convertToPrimary) {
|
||||
yAxis = 'y' + current.currency_code;
|
||||
dataset.currency_code = current.currency_code;
|
||||
currencies.push(current.currency_code);
|
||||
@@ -295,9 +295,9 @@ export default () => ({
|
||||
getConfiguration('cer.enabled', false) // 3
|
||||
]).then((values) => {
|
||||
//console.log('accounts after promises');
|
||||
this.convertToNative = values[1] && values[3];
|
||||
this.convertToPrimary = values[1] && values[3];
|
||||
afterPromises = true;
|
||||
//console.log('convertToNative in accounts.js: ', values);
|
||||
//console.log('convertToPrimary in accounts.js: ', values);
|
||||
|
||||
// main dashboard chart:
|
||||
this.loadChart();
|
||||
@@ -318,7 +318,7 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
// console.log('accounts observe convertToNative');
|
||||
// console.log('accounts observe convertToPrimary');
|
||||
this.loadChart();
|
||||
this.loadAccounts();
|
||||
});
|
||||
|
@@ -31,13 +31,13 @@ export default () => ({
|
||||
billBox: {paid: [], unpaid: []},
|
||||
leftBox: {left: [], perDay: []},
|
||||
netBox: {net: []},
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
loading: false,
|
||||
boxData: null,
|
||||
boxOptions: null,
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
this.convertToNative = event.detail;
|
||||
this.convertToPrimary = event.detail;
|
||||
this.accountList = [];
|
||||
console.log('I heard that! (dashboard/boxes)');
|
||||
this.boxData = null;
|
||||
@@ -49,7 +49,7 @@ export default () => ({
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
// TODO cache key is hard coded, problem?
|
||||
const boxesCacheKey = getCacheKey('ds_boxes_data', {convertToNative: this.convertToNative, start: start, end: end});
|
||||
const boxesCacheKey = getCacheKey('ds_boxes_data', {convertToPrimary: this.convertToPrimary, start: start, end: end});
|
||||
cleanupCache();
|
||||
|
||||
//const cacheValid = window.store.get('cacheValid');
|
||||
@@ -166,7 +166,7 @@ export default () => ({
|
||||
Promise.all([getVariable('viewRange'), getVariable('convert_to_native', false)]).then((values) => {
|
||||
// console.log('boxes after promises');
|
||||
afterPromises = true;
|
||||
this.convertToNative = values[1];
|
||||
this.convertToPrimary = values[1];
|
||||
this.loadBoxes();
|
||||
});
|
||||
window.store.observe('end', () => {
|
||||
@@ -181,8 +181,8 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
// console.log('boxes observe convertToNative');
|
||||
this.convertToNative = newValue;
|
||||
// console.log('boxes observe convertToPrimary');
|
||||
this.convertToPrimary = newValue;
|
||||
this.loadBoxes();
|
||||
});
|
||||
},
|
||||
|
@@ -34,7 +34,7 @@ let afterPromises = false;
|
||||
|
||||
export default () => ({
|
||||
loading: false,
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
loadChart() {
|
||||
if (true === this.loading) {
|
||||
return;
|
||||
@@ -52,7 +52,7 @@ export default () => ({
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
console.log('I heard that! (dashboard/budgets)');
|
||||
this.convertToNative = event.detail;
|
||||
this.convertToPrimary = event.detail;
|
||||
chartData = null;
|
||||
this.loadChart();
|
||||
}
|
||||
@@ -69,7 +69,7 @@ export default () => ({
|
||||
getFreshData() {
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
const cacheKey = getCacheKey('ds_bdg_chart', {convertToNative: this.convertToNative, start: start, end: end});
|
||||
const cacheKey = getCacheKey('ds_bdg_chart', {convertToPrimary: this.convertToPrimary, start: start, end: end});
|
||||
//const cacheValid = window.store.get('cacheValid');
|
||||
const cacheValid = false;
|
||||
let cachedData = window.store.get(cacheKey);
|
||||
@@ -168,7 +168,7 @@ export default () => ({
|
||||
|
||||
init() {
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
this.convertToPrimary = values[0];
|
||||
afterPromises = true;
|
||||
if (false === this.loading) {
|
||||
this.loadChart();
|
||||
@@ -188,8 +188,8 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
// console.log('boxes observe convertToNative');
|
||||
this.convertToNative = newValue;
|
||||
// console.log('boxes observe convertToPrimary');
|
||||
this.convertToPrimary = newValue;
|
||||
if (false === this.loading) {
|
||||
this.loadChart();
|
||||
}
|
||||
|
@@ -32,12 +32,12 @@ let afterPromises = false;
|
||||
|
||||
export default () => ({
|
||||
loading: false,
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
console.log('I heard that! (dashboard/categories)');
|
||||
this.convertToNative = event.detail;
|
||||
this.convertToPrimary = event.detail;
|
||||
chartData = null;
|
||||
this.loadChart();
|
||||
}
|
||||
@@ -146,7 +146,7 @@ export default () => ({
|
||||
getFreshData() {
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
const cacheKey = getCacheKey('ds_ct_chart', {convertToNative: this.convertToNative, start: start, end: end});
|
||||
const cacheKey = getCacheKey('ds_ct_chart', {convertToPrimary: this.convertToPrimary, start: start, end: end});
|
||||
|
||||
const cacheValid = window.store.get('cacheValid');
|
||||
let cachedData = window.store.get(cacheKey);
|
||||
@@ -183,7 +183,7 @@ export default () => ({
|
||||
init() {
|
||||
// console.log('categories init');
|
||||
Promise.all([getVariable('convert_to_native', false),]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
this.convertToPrimary = values[0];
|
||||
afterPromises = true;
|
||||
this.loadChart();
|
||||
});
|
||||
@@ -198,7 +198,7 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
this.convertToNative = newValue;
|
||||
this.convertToPrimary = newValue;
|
||||
this.loadChart();
|
||||
});
|
||||
},
|
||||
|
@@ -69,7 +69,7 @@ Chart.register({
|
||||
|
||||
let index = function () {
|
||||
return {
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
saveNativeSettings(event) {
|
||||
let target = event.currentTarget || event.target;
|
||||
setVariable('convert_to_native',target.checked).then(() => {
|
||||
@@ -79,7 +79,7 @@ let index = function () {
|
||||
},
|
||||
init() {
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
this.convertToPrimary = values[0];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -29,14 +29,14 @@ const PIGGY_CACHE_KEY = 'ds_pg_data';
|
||||
|
||||
export default () => ({
|
||||
loading: false,
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
sankeyGrouping: 'account',
|
||||
piggies: [],
|
||||
getFreshData() {
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
// needs user data.
|
||||
const cacheKey = getCacheKey(PIGGY_CACHE_KEY, {convertToNative: this.convertToNative, start: start, end: end});
|
||||
const cacheKey = getCacheKey(PIGGY_CACHE_KEY, {convertToPrimary: this.convertToPrimary, start: start, end: end});
|
||||
|
||||
const cacheValid = window.store.get('cacheValid');
|
||||
let cachedData = window.store.get(cacheKey);
|
||||
@@ -96,14 +96,14 @@ export default () => ({
|
||||
id: current.id,
|
||||
name: current.attributes.name,
|
||||
percentage: parseInt(current.attributes.percentage),
|
||||
amount: this.convertToNative ? current.attributes.native_current_amount : current.attributes.current_amount,
|
||||
amount: this.convertToPrimary ? current.attributes.native_current_amount : current.attributes.current_amount,
|
||||
// left to save
|
||||
left_to_save: this.convertToNative ? current.attributes.native_left_to_save : current.attributes.left_to_save,
|
||||
left_to_save: this.convertToPrimary ? current.attributes.native_left_to_save : current.attributes.left_to_save,
|
||||
// target amount
|
||||
target_amount: this.convertToNative ? current.attributes.native_target_amount : current.attributes.target_amount,
|
||||
target_amount: this.convertToPrimary ? current.attributes.native_target_amount : current.attributes.target_amount,
|
||||
// save per month
|
||||
save_per_month: this.convertToNative ? current.attributes.native_save_per_month : current.attributes.save_per_month,
|
||||
currency_code: this.convertToNative ? current.attributes.native_currency_code : current.attributes.currency_code,
|
||||
save_per_month: this.convertToPrimary ? current.attributes.native_save_per_month : current.attributes.save_per_month,
|
||||
currency_code: this.convertToPrimary ? current.attributes.native_currency_code : current.attributes.currency_code,
|
||||
|
||||
};
|
||||
dataSet[groupName].piggies.push(piggy);
|
||||
@@ -132,7 +132,7 @@ export default () => ({
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
|
||||
afterPromises = true;
|
||||
this.convertToNative = values[0];
|
||||
this.convertToPrimary = values[0];
|
||||
this.loadPiggyBanks();
|
||||
|
||||
});
|
||||
@@ -148,8 +148,8 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
// console.log('piggies observe convertToNative');
|
||||
this.convertToNative = newValue;
|
||||
// console.log('piggies observe convertToPrimary');
|
||||
this.convertToPrimary = newValue;
|
||||
this.loadPiggyBanks();
|
||||
});
|
||||
},
|
||||
|
@@ -33,7 +33,7 @@ let currencies = [];
|
||||
let afterPromises = false;
|
||||
let chart = null;
|
||||
let transactions = [];
|
||||
let convertToNative = false;
|
||||
let convertToPrimary = false;
|
||||
let translations = {
|
||||
category: null,
|
||||
unknown_category: null,
|
||||
@@ -79,7 +79,7 @@ const getColor = function (key) {
|
||||
|
||||
// little helper
|
||||
function getObjectName(type, name, direction, code) {
|
||||
if(convertToNative) {
|
||||
if(convertToPrimary) {
|
||||
return getObjectNameWithoutCurrency(type, name, direction);
|
||||
}
|
||||
return getObjectNameWithCurrency(type, name, direction, code);
|
||||
@@ -123,7 +123,7 @@ function getObjectNameWithCurrency(type, name, direction, code) {
|
||||
|
||||
|
||||
function getLabel(type, name, code) {
|
||||
if(convertToNative) {
|
||||
if(convertToPrimary) {
|
||||
return getLabelWithoutCurrency(type, name);
|
||||
}
|
||||
return getLabelWithCurrency(type, name, code);
|
||||
@@ -157,13 +157,13 @@ function getLabelWithCurrency(type, name, code) {
|
||||
|
||||
export default () => ({
|
||||
loading: false,
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
processedData: null,
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
console.log('I heard that! (dashboard/sankey)');
|
||||
this.convertToNative = event.detail;
|
||||
convertToNative = event.detail;
|
||||
this.convertToPrimary = event.detail;
|
||||
convertToPrimary = event.detail;
|
||||
this.processedData = null;
|
||||
this.loadChart();
|
||||
}
|
||||
@@ -226,7 +226,7 @@ export default () => ({
|
||||
let currencyCode = transaction.currency_code;
|
||||
let amount = parseFloat(transaction.amount);
|
||||
let flowKey;
|
||||
if (this.convertToNative) {
|
||||
if (this.convertToPrimary) {
|
||||
currencyCode = transaction.native_currency_code;
|
||||
amount = parseFloat(transaction.native_amount);
|
||||
}
|
||||
@@ -254,7 +254,7 @@ export default () => ({
|
||||
|
||||
if (!this.processedData.amounts.hasOwnProperty(flowKey)) {
|
||||
this.processedData.amounts[flowKey] = {
|
||||
from: translations.all_money + (this.convertToNative ? ' (' + currencyCode + ')' : ''),
|
||||
from: translations.all_money + (this.convertToPrimary ? ' (' + currencyCode + ')' : ''),
|
||||
to: budget,
|
||||
amount: 0
|
||||
};
|
||||
@@ -319,7 +319,7 @@ export default () => ({
|
||||
if (!this.processedData.amounts.hasOwnProperty(flowKey)) {
|
||||
this.processedData.amounts[flowKey] = {
|
||||
from: category,
|
||||
to: translations.all_money + (this.convertToNative ? ' (' + currencyCode + ')' : ''),
|
||||
to: translations.all_money + (this.convertToPrimary ? ' (' + currencyCode + ')' : ''),
|
||||
amount: 0
|
||||
};
|
||||
}
|
||||
@@ -363,7 +363,7 @@ export default () => ({
|
||||
downloadTransactions(params) {
|
||||
const start = new Date(window.store.get('start'));
|
||||
const end = new Date(window.store.get('end'));
|
||||
const cacheKey = getCacheKey(SANKEY_CACHE_KEY, {convertToNative: this.convertToNative, start: start, end: end});
|
||||
const cacheKey = getCacheKey(SANKEY_CACHE_KEY, {convertToPrimary: this.convertToPrimary, start: start, end: end});
|
||||
|
||||
//console.log('Downloading page ' + params.page + '...');
|
||||
const getter = new Get();
|
||||
@@ -400,8 +400,8 @@ export default () => ({
|
||||
// console.log('sankey init');
|
||||
transactions = [];
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
convertToNative = values[0];
|
||||
this.convertToPrimary = values[0];
|
||||
convertToPrimary = values[0];
|
||||
|
||||
// some translations:
|
||||
translations.all_money = i18next.t('firefly.all_money');
|
||||
@@ -434,8 +434,8 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
// console.log('sankey observe convertToNative');
|
||||
this.convertToNative = newValue;
|
||||
// console.log('sankey observe convertToPrimary');
|
||||
this.convertToPrimary = newValue;
|
||||
this.loadChart();
|
||||
});
|
||||
},
|
||||
|
@@ -30,7 +30,7 @@ import i18next from "i18next";
|
||||
let afterPromises = false;
|
||||
let apiData = [];
|
||||
let subscriptionData = {};
|
||||
let convertToNative = false;
|
||||
let convertToPrimary = false;
|
||||
|
||||
function addObjectGroupInfo(data) {
|
||||
let objectGroupId = parseInt(data.object_group_id);
|
||||
@@ -71,7 +71,7 @@ function parseBillInfo(data) {
|
||||
pay_dates: parsePayDates(data.attributes.pay_dates),
|
||||
paid: data.attributes.paid_dates.length > 0,
|
||||
};
|
||||
if(convertToNative) {
|
||||
if(convertToPrimary) {
|
||||
result.currency_code = data.attributes.native_currency_code;
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ function downloadSubscriptions(params) {
|
||||
|
||||
export default () => ({
|
||||
loading: false,
|
||||
convertToNative: false,
|
||||
convertToPrimary: false,
|
||||
subscriptions: [],
|
||||
formatMoney(amount, currencyCode) {
|
||||
return formatMoney(amount, currencyCode);
|
||||
@@ -219,8 +219,8 @@ export default () => ({
|
||||
eventListeners: {
|
||||
['@convert-to-native.window'](event){
|
||||
console.log('I heard that! (dashboard/subscriptions)');
|
||||
this.convertToNative = event.detail;
|
||||
convertToNative = event.detail;
|
||||
this.convertToPrimary = event.detail;
|
||||
convertToPrimary = event.detail;
|
||||
this.startSubscriptions();
|
||||
}
|
||||
},
|
||||
@@ -243,7 +243,7 @@ export default () => ({
|
||||
let params = {
|
||||
start: format(start, 'y-MM-dd'),
|
||||
end: format(end, 'y-MM-dd'),
|
||||
// convertToNative: this.convertToNative,
|
||||
// convertToPrimary: this.convertToPrimary,
|
||||
page: 1
|
||||
};
|
||||
downloadSubscriptions(params).then(() => {
|
||||
@@ -314,8 +314,8 @@ export default () => ({
|
||||
|
||||
init() {
|
||||
Promise.all([getVariable('convert_to_native', false)]).then((values) => {
|
||||
this.convertToNative = values[0];
|
||||
convertToNative = values[0];
|
||||
this.convertToPrimary = values[0];
|
||||
convertToPrimary = values[0];
|
||||
afterPromises = true;
|
||||
|
||||
if (false === this.loading) {
|
||||
@@ -336,7 +336,7 @@ export default () => ({
|
||||
if (!afterPromises) {
|
||||
return;
|
||||
}
|
||||
this.convertToNative = newValue;
|
||||
this.convertToPrimary = newValue;
|
||||
if (false === this.loading) {
|
||||
this.startSubscriptions();
|
||||
}
|
||||
|
@@ -194,7 +194,7 @@ return [
|
||||
'journals_in_period_for_category' => 'All transactions for category :name between :start and :end',
|
||||
'journals_in_period_for_tag' => 'All transactions for tag :tag between :start and :end',
|
||||
'not_available_demo_user' => 'The feature you try to access is not available to demo users.',
|
||||
'exchange_rate_instructions' => 'Asset account "@name" only accepts transactions in @native_currency. If you wish to use @foreign_currency instead, make sure that the amount in @native_currency is known as well:',
|
||||
'exchange_rate_instructions' => 'Asset account "@name" only accepts transactions in @primary_currency. If you wish to use @foreign_currency instead, make sure that the amount in @primary_currency is known as well:',
|
||||
'transfer_exchange_rate_instructions' => 'Source asset account "@source_name" only accepts transactions in @source_currency. Destination asset account "@dest_name" only accepts transactions in @dest_currency. You must provide the transferred amount correctly in both currencies.',
|
||||
'transaction_data' => 'Transaction data',
|
||||
'invalid_server_configuration' => 'Invalid server configuration',
|
||||
@@ -1388,9 +1388,9 @@ return [
|
||||
'pref_languages_help' => 'Firefly III supports several languages. Which one do you prefer?',
|
||||
'pref_locale_help' => 'Firefly III allows you to set other local settings, like how currencies, numbers and dates are formatted. Entries in this list may not be supported by your system. Firefly III doesn\'t have the correct date settings for every locale; contact me for improvements.',
|
||||
'pref_locale_no_demo' => 'This feature won\'t work for the demo user.',
|
||||
'pref_convert_to_native' => 'Display amounts in your native currency',
|
||||
'pref_convert_to_native_help' => 'This option will make Firefly III try to display and show your native currency in as many places as possible, converting amounts where necessary. This sacrifices accuracy for ease of use, because conversion is not always exact. Please verify that Firefly III has the necessary conversion rates on the "exchange rates"-page.',
|
||||
'pref_convert_native_help' => 'Display native amounts',
|
||||
'pref_convert_to_primary' => 'Display amounts in your primary currency',
|
||||
'pref_convert_to_primary_help' => 'This option will make Firefly III try to display and show your primary currency in as many places as possible, converting amounts where necessary. This sacrifices accuracy for ease of use, because conversion is not always exact. Please verify that Firefly III has the necessary conversion rates on the "exchange rates"-page.',
|
||||
'pref_convert_primary_help' => 'Display primary amounts',
|
||||
'pref_custom_fiscal_year' => 'Fiscal year settings',
|
||||
'pref_custom_fiscal_year_label' => 'Enabled',
|
||||
'pref_custom_fiscal_year_help' => 'In countries that use a financial year other than January 1 to December 31, you can switch this on and specify start / end days of the fiscal year',
|
||||
@@ -1496,9 +1496,9 @@ return [
|
||||
'edit_administration_breadcrumb' => 'Edit financial administration ":title"',
|
||||
'administrations_page_edit_sub_title' => 'Edit financial administration ":title"',
|
||||
'administrations_page_edit_sub_title_js' => 'Edit financial administration "{title}"',
|
||||
'temp_administrations_introduction' => 'Firefly III will soon get the ability to manage multiple financial administrations. Right now, you only have the one. You can set the title of this administration and its native currency. This replaces the previous setting where you would set your "default currency". This setting is now tied to the financial administration and can be different per administration.',
|
||||
'temp_administrations_introduction_edit' => 'Currently, you can only set the "native currency" of the default financial administration. This replaces the "default currency" setting. This setting is now tied to the financial administration and can be different per administration.',
|
||||
'administration_currency_form_help' => 'It may take a long time for the page to load if you change the native currency because transaction may need to be converted to your (new) native currency.',
|
||||
'temp_administrations_introduction' => 'Firefly III will soon get the ability to manage multiple financial administrations. Right now, you only have the one. You can set the title of this administration and its primary currency. This replaces the previous setting where you would set your "default currency". This setting is now tied to the financial administration and can be different per administration.',
|
||||
'temp_administrations_introduction_edit' => 'Currently, you can only set the "primary currency" of the default financial administration. This replaces the "default currency" setting. This setting is now tied to the financial administration and can be different per administration.',
|
||||
'administration_currency_form_help' => 'It may take a long time for the page to load if you change the primary currency because transaction may need to be converted to your (new) primary currency.',
|
||||
'flash_administration_updated' => 'Administration ":title" has been updated',
|
||||
'flash_administration_created' => 'Administration ":title" has been created',
|
||||
'flash_administration_deleted' => 'Administration ":title" has been deleted',
|
||||
@@ -1648,7 +1648,7 @@ return [
|
||||
'profile_personal_access_tokens' => 'Personal Access Tokens',
|
||||
'profile_personal_access_token' => 'Personal Access Token',
|
||||
'profile_oauth_confidential' => 'Confidential',
|
||||
'profile_oauth_confidential_help' => 'Require the client to authenticate with a secret. Confidential clients can hold credentials in a secure way without exposing them to unauthorized parties. Public applications, such as native desktop or JavaScript SPA applications, are unable to hold secrets securely.',
|
||||
'profile_oauth_confidential_help' => 'Require the client to authenticate with a secret. Confidential clients can hold credentials in a secure way without exposing them to unauthorized parties. Public applications, such as primary desktop or JavaScript SPA applications, are unable to hold secrets securely.',
|
||||
'profile_personal_access_token_explanation' => 'Here is your new personal access token. This is the only time it will be shown so don\'t lose it! You may now use this token to make API requests.',
|
||||
'profile_no_personal_access_token' => 'You have not created any personal access tokens.',
|
||||
'profile_create_new_token' => 'Create new token',
|
||||
@@ -1779,10 +1779,10 @@ return [
|
||||
'updated_currency' => 'Currency :name updated',
|
||||
'ask_site_owner' => 'Please ask :owner to add, remove or edit currencies.',
|
||||
'currencies_intro' => 'Firefly III supports various currencies which you can set and enable here.',
|
||||
'currencies_switch_default' => 'You can switch the native currency for your current administration on the "Financial administrations"-page.',
|
||||
'currencies_switch_default' => 'You can switch the primary currency for your current administration on the "Financial administrations"-page.',
|
||||
'make_default_currency' => 'Make default',
|
||||
'default_currency' => 'default',
|
||||
'native_currency_button' => 'native',
|
||||
'primary_currency_button' => 'primary',
|
||||
'currency_is_disabled' => 'Disabled',
|
||||
'enable_currency' => 'Enable',
|
||||
'disable_currency' => 'Disable',
|
||||
|
@@ -26,7 +26,7 @@ declare(strict_types=1);
|
||||
|
||||
return [
|
||||
// new user:
|
||||
'administration_currency' => 'Native currency',
|
||||
'administration_currency' => 'Primary currency',
|
||||
'bank_name' => 'Bank name',
|
||||
'bank_balance' => 'Balance',
|
||||
'current_balance' => 'Current balance',
|
||||
|
@@ -29,7 +29,7 @@ return [
|
||||
'icon' => 'Icon',
|
||||
'id' => 'ID',
|
||||
'create_date' => 'Created at',
|
||||
'native_currency' => 'Native currency',
|
||||
'primary_currency' => 'Primary currency',
|
||||
'update_date' => 'Updated at',
|
||||
'updated_at' => 'Updated at',
|
||||
'balance_before' => 'Balance before',
|
||||
|
@@ -141,7 +141,7 @@ return [
|
||||
'not_in' => 'The selected :attribute is invalid.',
|
||||
'numeric' => 'The :attribute must be a number.',
|
||||
'scientific_notation' => 'The :attribute cannot use the scientific notation.',
|
||||
'numeric_native' => 'The native amount must be a number.',
|
||||
'numeric_primary' => 'The primary currency amount must be a number.',
|
||||
'numeric_destination' => 'The destination amount must be a number.',
|
||||
'numeric_source' => 'The source amount must be a number.',
|
||||
'generic_invalid' => 'This value is invalid.',
|
||||
|
@@ -15,9 +15,9 @@
|
||||
{{ trans('firefly.chart_account_in_period', {
|
||||
balance: formatAmountBySymbol(balances.balance, currency.symbol, currency.decimal_places, true),
|
||||
name: account.name|escape, start: start.isoFormat(monthAndDayFormat), end: end.isoFormat(monthAndDayFormat) })|raw }}
|
||||
{% elseif balances.native_balance %}
|
||||
{% elseif balances.pc_balance %}
|
||||
{{ trans('firefly.chart_account_in_period', {
|
||||
balance: formatAmountBySymbol(balances.native_balance, defaultCurrency.symbol, defaultCurrency.decimal_places, true),
|
||||
balance: formatAmountBySymbol(balances.pc_balance, primaryCurrency.symbol, primaryCurrency.decimal_places, true),
|
||||
name: account.name|escape, start: start.isoFormat(monthAndDayFormat), end: end.isoFormat(monthAndDayFormat) })|raw }}
|
||||
{% endif %}
|
||||
</h3>
|
||||
@@ -148,8 +148,8 @@
|
||||
<h3 class="box-title">{{ 'transactions'|_ }}
|
||||
{% if balances.balance %}
|
||||
({{ formatAmountBySymbol(balances.balance, currency.symbol, currency.decimal_places, true)|raw }})
|
||||
{% elseif balances.native_balance %}
|
||||
({{ formatAmountBySymbol(balances.native_balance, defaultCurrency.symbol, defaultCurrency.decimal_places, true)|raw }})
|
||||
{% elseif balances.pc_balance %}
|
||||
({{ formatAmountBySymbol(balances.pc_balance, primaryCurrency.symbol, primaryCurrency.decimal_places, true)|raw }})
|
||||
{% endif %}
|
||||
</h3>
|
||||
</div>
|
||||
|
@@ -17,7 +17,7 @@
|
||||
</div>
|
||||
<div class="box-body">
|
||||
{{ ExpandedForm.text('name') }}
|
||||
{{ CurrencyForm.currencyList('transaction_currency_id', defaultCurrency.id) }}
|
||||
{{ CurrencyForm.currencyList('transaction_currency_id', primaryCurrency.id) }}
|
||||
{{ ExpandedForm.amountNoCurrency('amount_min') }}
|
||||
{{ ExpandedForm.amountNoCurrency('amount_max') }}
|
||||
{{ ExpandedForm.date('date',phpdate('Y-m-d')) }}
|
||||
|
@@ -29,11 +29,11 @@
|
||||
<td colspan="2">
|
||||
{% set lowAmount = formatAmountByCurrency(object.data.currency,object.data.amount_min) %}
|
||||
{% set highAmount = formatAmountByCurrency(object.data.currency,object.data.amount_max) %}
|
||||
{% if(0 != object.data.native_amount_min) %}
|
||||
{% set lowAmount = lowAmount ~ ' (' ~ formatAmountByCode(object.data.native_amount_min, defaultCurrency.code) ~ ')' %}
|
||||
{% if(0 != object.data.pc_amount_min) %}
|
||||
{% set lowAmount = lowAmount ~ ' (' ~ formatAmountByCode(object.data.pc_amount_min, primaryCurrency.code) ~ ')' %}
|
||||
{% endif %}
|
||||
{% if(0 != object.data.native_amount_max) %}
|
||||
{% set highAmount = highAmount ~ ' (' ~ formatAmountByCode(object.data.native_amount_max, defaultCurrency.code) ~ ')' %}
|
||||
{% if(0 != object.data.pc_amount_max) %}
|
||||
{% set highAmount = highAmount ~ ' (' ~ formatAmountByCode(object.data.pc_amount_max, primaryCurrency.code) ~ ')' %}
|
||||
{% endif %}
|
||||
{{ trans('firefly.match_between_amounts', {low: lowAmount, high: highAmount })|raw }}
|
||||
{{ 'repeats'|_ }}
|
||||
@@ -67,9 +67,9 @@
|
||||
<td>
|
||||
{% for avg in yearAverage %}
|
||||
{{ formatAmountBySymbol(avg.avg, avg.currency_symbol, avg.currency_decimal_places, true) }}
|
||||
{% if convertToNative and 0 != avg.native_avg %}
|
||||
({{ formatAmountBySymbol(avg.native_avg,
|
||||
defaultCurrency.symbol, defaultCurrency.decimal_places, true) }})
|
||||
{% if convertToPrimary and 0 != avg.pc_avg %}
|
||||
({{ formatAmountBySymbol(avg.pc_avg,
|
||||
primaryCurrency.symbol, primaryCurrency.decimal_places, true) }})
|
||||
{% endif %}
|
||||
<br>
|
||||
|
||||
@@ -81,9 +81,9 @@
|
||||
<td>
|
||||
{% for avg in overallAverage %}
|
||||
{{ formatAmountBySymbol(avg.avg, avg.currency_symbol, avg.currency_decimal_places, true) }}
|
||||
{% if convertToNative and 0 != avg.native_avg %}
|
||||
({{ formatAmountBySymbol(avg.native_avg,
|
||||
defaultCurrency.symbol, defaultCurrency.decimal_places, true) }})
|
||||
{% if convertToPrimary and 0 != avg.pc_avg %}
|
||||
({{ formatAmountBySymbol(avg.pc_avg,
|
||||
primaryCurrency.symbol, primaryCurrency.decimal_places, true) }})
|
||||
{% endif %}
|
||||
<br>
|
||||
{% endfor %}
|
||||
@@ -185,7 +185,7 @@
|
||||
|
||||
{% block scripts %}
|
||||
<script type="text/javascript" nonce="{{ JS_NONCE }}">
|
||||
var billCurrencySymbol = "{{ convertToNative ? defaultCurrency.symbol : object.data.currency.symbol }}";
|
||||
var billCurrencySymbol = "{{ convertToPrimary ? primaryCurrency.symbol : object.data.currency.symbol }}";
|
||||
var billUrl = '{{ route('chart.bill.single', [object.data.id]) }}';
|
||||
</script>
|
||||
<script type="text/javascript" src="v1/js/lib/Chart.bundle.min.js?v={{ FF_VERSION }}" nonce="{{ JS_NONCE }}"></script>
|
||||
|
@@ -55,7 +55,7 @@
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">
|
||||
{{ trans('firefly.total_available_budget_in_currency', {currency: defaultCurrency.name}) }}
|
||||
{{ trans('firefly.total_available_budget_in_currency', {currency: primaryCurrency.name}) }}
|
||||
<br>
|
||||
<small>{{ trans('firefly.between_dates_breadcrumb', {start: start.isoFormat(monthAndDayFormat), end: end.isoFormat(monthAndDayFormat)}) }}</small>
|
||||
</h3>
|
||||
@@ -65,8 +65,8 @@
|
||||
{# info about the amount budgeted #}
|
||||
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
|
||||
<small>{{ 'budgeted'|_ }} ({{ 'see_below'|_ }}):
|
||||
<span class="budgeted_amount" data-value="{{ budgeted }}" data-id="0" data-currency="{{ defaultCurrency.id }}">
|
||||
{{ formatAmountBySymbol(budgeted, defaultCurrency.symbol, defaultCurrency.decimal_places) }}
|
||||
<span class="budgeted_amount" data-value="{{ budgeted }}" data-id="0" data-currency="{{ primaryCurrency.id }}">
|
||||
{{ formatAmountBySymbol(budgeted, primaryCurrency.symbol, primaryCurrency.decimal_places) }}
|
||||
</span>
|
||||
</small>
|
||||
</div>
|
||||
@@ -75,8 +75,8 @@
|
||||
<small class="available_bar"
|
||||
data-id="0">{{ trans('firefly.available_between', {start: start.isoFormat(monthAndDayFormat), end: end.isoFormat(monthAndDayFormat) }) }}
|
||||
:
|
||||
<span class="available_amount" data-id="0" data-value="0" data-currency="{{ defaultCurrency.id }}"
|
||||
data-value="0">{{ formatAmountBySymbol(0, defaultCurrency.symbol, defaultCurrency.decimal_places, true) }}</span>
|
||||
<span class="available_amount" data-id="0" data-value="0" data-currency="{{ primaryCurrency.id }}"
|
||||
data-value="0">{{ formatAmountBySymbol(0, primaryCurrency.symbol, primaryCurrency.decimal_places, true) }}</span>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
@@ -84,7 +84,7 @@
|
||||
<div class="row spentInfo" data-id="0" data-value="{{ spent }}">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
<small>{{ trans('firefly.spent_between', {start: start.isoFormat(monthAndDayFormat), end: end.isoFormat(monthAndDayFormat)}) }}
|
||||
: {{ formatAmountBySymbol(spent, defaultCurrency.symbol, defaultCurrency.decimal_places) }} </small>
|
||||
: {{ formatAmountBySymbol(spent, primaryCurrency.symbol, primaryCurrency.decimal_places) }} </small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -116,8 +116,8 @@
|
||||
<small>{{ 'budgeted'|_ }}:
|
||||
<span class="text-success money-positive budgeted_amount" data-id="{{ budget.id }}" data-currency="{{ budget.transaction_currency.id }}">
|
||||
{{ formatAmountBySymbol(budget.budgeted, budget.transaction_currency.symbol, budget.transaction_currency.decimal_places, false) }}
|
||||
{% if null != budget.native_budgeted %}
|
||||
({{ formatAmountBySymbol(budget.native_budgeted, defaultCurrency.symbol, defaultCurrency.decimal_places, false) }})
|
||||
{% if null != budget.pc_budgeted %}
|
||||
({{ formatAmountBySymbol(budget.pc_budgeted, primaryCurrency.symbol, primaryCurrency.decimal_places, false) }})
|
||||
{% endif %}
|
||||
</span>
|
||||
</small>
|
||||
@@ -130,8 +130,8 @@
|
||||
<span class="available_amount" data-id="{{ budget.id }}" data-currency="{{ budget.transaction_currency.id }}"
|
||||
data-value="{{ budget.amount }}">
|
||||
{{ formatAmountBySymbol(budget.amount, budget.transaction_currency.symbol, budget.transaction_currency.decimal_places, true) }}
|
||||
{% if(convertToNative and 0 != budget.native_amount) %}
|
||||
({{ formatAmountBySymbol(budget.native_amount, defaultCurrency.symbol, defaultCurrency.decimal_places, true) }})
|
||||
{% if(convertToPrimary and 0 != budget.pc_amount) %}
|
||||
({{ formatAmountBySymbol(budget.pc_amount, primaryCurrency.symbol, primaryCurrency.decimal_places, true) }})
|
||||
{% endif %}
|
||||
|
||||
</span>
|
||||
@@ -265,10 +265,10 @@
|
||||
<td>
|
||||
{% if 0==budget.budgeted|length %}
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">{{ defaultCurrency.symbol }}</div>
|
||||
<input type="hidden" name="balance_currency_id" value="{{ defaultCurrency.id }}"/>
|
||||
<div class="input-group-addon">{{ primaryCurrency.symbol }}</div>
|
||||
<input type="hidden" name="balance_currency_id" value="{{ primaryCurrency.id }}"/>
|
||||
<input class="form-control budget_amount" data-original="0" data-id="{{ budget.id }}"
|
||||
data-currency="{{ defaultCurrency.id }}" data-limit="0" value="0" autocomplete="off" min="0" name="amount"
|
||||
data-currency="{{ primaryCurrency.id }}" data-limit="0" value="0" autocomplete="off" min="0" name="amount"
|
||||
type="number">
|
||||
</div>
|
||||
<span class="text-danger budget_warning" data-id="{{ budget.id }}" data-budgetLimit="{{ budgetLimit.id }}"
|
||||
|
@@ -158,18 +158,18 @@
|
||||
<td style="width:33%;">{{ 'amount'|_ }}</td>
|
||||
<td>
|
||||
{{ formatAmountBySymbol(limit.amount, limit.transactionCurrency.symbol, limit.transactionCurrency.decimal_places) }}
|
||||
{% if convertToNative and 0 != limit.native_amount %}
|
||||
({{ formatAmountBySymbol(limit.native_amount, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{% if convertToPrimary and 0 != limit.pc_amount %}
|
||||
({{ formatAmountBySymbol(limit.pc_amount, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:33%;">{{ 'spent'|_ }}</td>
|
||||
<td>
|
||||
{% if convertToNative %}
|
||||
{% if convertToPrimary %}
|
||||
{{ formatAmountBySymbol(limit.spent, limit.transactionCurrency.symbol, limit.transactionCurrency.decimal_places) }}
|
||||
{% if limit.native_spent %}
|
||||
({{ formatAmountBySymbol(limit.native_spent, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{% if limit.pc_spent %}
|
||||
({{ formatAmountBySymbol(limit.pc_spent, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ formatAmountBySymbol(limit.spent, limit.transactionCurrency.symbol, limit.transactionCurrency.decimal_places) }}
|
||||
|
@@ -63,8 +63,8 @@
|
||||
<span class="text-muted">
|
||||
{% endif %}
|
||||
{{ currency.name }} ({{ currency.code }}) ({{ currency.symbol|raw }})
|
||||
{% if currency.id == defaultCurrency.id %}
|
||||
<span class="label label-success" id="default-currency">{{ 'native_currency_button'|_ }}</span>
|
||||
{% if currency.id == primaryCurrency.id %}
|
||||
<span class="label label-success" id="default-currency">{{ 'primary_currency_button'|_ }}</span>
|
||||
{% endif %}
|
||||
{% if currency.userGroupEnabled == false %}
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
class="btn btn-default dropdown-toggle currency-dropdown" id="currency_dropdown_{{ name }}"
|
||||
data-toggle="dropdown"
|
||||
aria-expanded="false">
|
||||
<span id="currency_select_symbol_{{ name }}">{{ defaultCurrency.symbol|raw }}</span> <span
|
||||
<span id="currency_select_symbol_{{ name }}">{{ primaryCurrency.symbol|raw }}</span> <span
|
||||
class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu currency-dropdown-menu" role="menu">
|
||||
@@ -30,5 +30,5 @@
|
||||
{% include 'form.feedback' %}
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="amount_currency_id_{{ name }}" value="{{ defaultCurrency.id }}"/>
|
||||
<input type="hidden" name="amount_currency_id_{{ name }}" value="{{ primaryCurrency.id }}"/>
|
||||
</div>
|
||||
|
@@ -10,8 +10,8 @@
|
||||
<div class="progress-bar" role="progressbar" aria-valuenow="{{ entry.percentage }}" aria-valuemin="0" aria-valuemax="100"
|
||||
style="width: {{ entry.percentage }}%;">
|
||||
{% if entry.percentage >=20 %}
|
||||
{% if convertToNative and 0 != avg.native_amount %}
|
||||
{{ formatAmountBySymbol(entry.native_amount, entry.native_currency_symbol, entry.native_currency_decimal_places, false) }}
|
||||
{% if convertToPrimary and 0 != avg.pc_amount %}
|
||||
{{ formatAmountBySymbol(entry.pc_amount, entry.primary_currency_symbol, entry.primary_currency_decimal_places, false) }}
|
||||
({{ formatAmountBySymbol(entry.amount, entry.currency_symbol, entry.currency_decimal_places, false) }})
|
||||
{% else %}
|
||||
{{ formatAmountBySymbol(entry.amount, entry.currency_symbol, entry.currency_decimal_places, false) }}
|
||||
@@ -20,8 +20,8 @@
|
||||
</div>
|
||||
{% if entry.percentage < 20 %}
|
||||
|
||||
{% if convertToNative and 0 != avg.native_amount %}
|
||||
{{ formatAmountBySymbol(entry.native_amount, entry.native_currency_symbol, entry.native_currency_decimal_places, false) }}
|
||||
{% if convertToPrimary and 0 != avg.pc_amount %}
|
||||
{{ formatAmountBySymbol(entry.pc_amount, entry.primary_currency_symbol, entry.primary_currency_decimal_places, false) }}
|
||||
({{ formatAmountBySymbol(entry.amount, entry.currency_symbol, entry.currency_decimal_places, false) }})
|
||||
{% else %}
|
||||
{{ formatAmountBySymbol(entry.amount, entry.currency_symbol, entry.currency_decimal_places, false) }}
|
||||
|
@@ -69,12 +69,12 @@
|
||||
{% for key, balance in account.endBalances %}
|
||||
<span title="{{ key }}">
|
||||
{% if 'balance' == key %}
|
||||
{% if not convertToNative %}
|
||||
{% if not convertToPrimary %}
|
||||
{{ formatAmountBySymbol(balance, account.currency.symbol, account.currency.decimal_places) }}
|
||||
{% endif %}
|
||||
{% elseif 'native_balance' == key %}
|
||||
{% if convertToNative %}
|
||||
{{ formatAmountBySymbol(balance, defaultCurrency.symbol, defaultCurrency.decimal_places) }}
|
||||
{% elseif 'pc_balance' == key %}
|
||||
{% if convertToPrimary %}
|
||||
{{ formatAmountBySymbol(balance, primaryCurrency.symbol, primaryCurrency.decimal_places) }}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
({{ formatAmountByCode(balance, key) }})
|
||||
@@ -117,7 +117,7 @@
|
||||
<span style="margin-right:5px;">
|
||||
{% for key, balance in account.differences %}
|
||||
<span title="{{ key }}">
|
||||
{% if 'balance' == key or 'native_balance' == key %}
|
||||
{% if 'balance' == key or 'pc_balance' == key %}
|
||||
{{ formatAmountBySymbol(balance, account.currency.symbol, account.currency.currency.decimal_places) }}
|
||||
|
||||
{% else %}
|
||||
|
@@ -68,8 +68,8 @@
|
||||
>
|
||||
~ {{ formatAmountBySymbol((entry.amount_max + entry.amount_min)/2, entry.currency_symbol, entry.currency_decimal_places) }}
|
||||
|
||||
{% if '0' != entry.native_amount_max %}
|
||||
(~ {{ formatAmountBySymbol((entry.native_amount_max + entry.native_amount_min)/2, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{% if '0' != entry.pc_amount_max %}
|
||||
(~ {{ formatAmountBySymbol((entry.pc_amount_max + entry.pc_amount_min)/2, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
</span>
|
||||
</td>
|
||||
|
@@ -12,8 +12,8 @@
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and null != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% if convertToPrimary and null != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount*-1, primaryCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% endif %}
|
||||
|
||||
{% elseif transaction.transaction_type_type == 'Transfer' %}
|
||||
@@ -24,16 +24,16 @@
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and null != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% if convertToPrimary and null != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount*-1, primaryCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places, false) }}
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and null != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% if convertToPrimary and null != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount*-1, primaryCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{# transfer to #}
|
||||
@@ -44,16 +44,16 @@
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and null != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% if convertToPrimary and null != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount*-1, primaryCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and null != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% if convertToPrimary and null != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount, primaryCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% elseif transaction.transaction_type_type == 'Reconciliation' %}
|
||||
@@ -62,16 +62,16 @@
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and null != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% if convertToPrimary and null != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount*-1, primaryCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and null != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% if convertToPrimary and null != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount, primaryCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
@@ -79,8 +79,8 @@
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and null != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount, defaultCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% if convertToPrimary and null != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount, primaryCurrency.symbol, foreign_currency_.decimal_places) }})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</span>
|
||||
|
@@ -63,23 +63,23 @@
|
||||
{% for sum in group.sums %}
|
||||
{% if group.transaction_type == 'Deposit' %}
|
||||
{{ formatAmountBySymbol(sum.amount*-1, sum.currency_symbol, sum.currency_decimal_places) }}
|
||||
{% if convertToNative and 0 != sum.native_amount %}
|
||||
({{ formatAmountBySymbol(sum.native_amount*-1, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{% if convertToPrimary and 0 != sum.pc_amount %}
|
||||
({{ formatAmountBySymbol(sum.pc_amount*-1, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
{% if loop.index != group.sums|length %},{% endif %}
|
||||
|
||||
{% elseif group.transaction_type == 'Transfer' %}
|
||||
<span class="text-info money-transfer">
|
||||
{{ formatAmountBySymbol(sum.amount*-1, sum.currency_symbol, sum.currency_decimal_places, false) }}
|
||||
{% if convertToNative and 0 != sum.native_amount %}
|
||||
({{ formatAmountBySymbol(sum.native_amount*-1, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{% if convertToPrimary and 0 != sum.pc_amount %}
|
||||
({{ formatAmountBySymbol(sum.pc_amount*-1, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
{% if loop.index != group.sums|length %},{% endif %}
|
||||
</span>
|
||||
{% else %}
|
||||
{{ formatAmountBySymbol(sum.amount, sum.currency_symbol, sum.currency_decimal_places) }}
|
||||
{% if convertToNative and 0 != sum.native_amount %}
|
||||
({{ formatAmountBySymbol(sum.native_amount*-1, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{% if convertToPrimary and 0 != sum.pc_amount %}
|
||||
({{ formatAmountBySymbol(sum.pc_amount*-1, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
{% if loop.index != group.sums|length %},{% endif %}
|
||||
{% endif %}
|
||||
@@ -172,9 +172,9 @@
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{# native amount of deposit #}
|
||||
{% if convertToNative and 0 != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{# primary currency amount of deposit #}
|
||||
{% if convertToPrimary and 0 != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount*-1, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
{# transfer #}
|
||||
{% elseif transaction.transaction_type_type == 'Transfer' %}
|
||||
@@ -187,9 +187,9 @@
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places, false) }})
|
||||
{% endif %}
|
||||
|
||||
{# native amount of transfer #}
|
||||
{% if convertToNative and 0 != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{# primary currency amount of transfer #}
|
||||
{% if convertToPrimary and 0 != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount*-1, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
</span>
|
||||
{# opening balance #}
|
||||
@@ -199,16 +199,16 @@
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and 0 != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{% if convertToPrimary and 0 != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount*-1, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and 0 != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{% if convertToPrimary and 0 != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{# reconciliation #}
|
||||
@@ -218,16 +218,16 @@
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and 0 != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{% if convertToPrimary and 0 != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount*-1, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ formatAmountBySymbol(transaction.amount, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and 0 != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{% if convertToPrimary and 0 != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{# liability credit #}
|
||||
@@ -237,16 +237,16 @@
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and 0 != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{% if convertToPrimary and 0 != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{{ formatAmountBySymbol(transaction.amount*-1, transaction.currency_symbol, transaction.currency_decimal_places) }}
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount*-1, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{% if convertToNative and 0 != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount*-1, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{% if convertToPrimary and 0 != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount*-1, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -260,9 +260,9 @@
|
||||
{% if null != transaction.foreign_amount %}
|
||||
({{ formatAmountBySymbol(transaction.foreign_amount, transaction.foreign_currency_symbol, transaction.foreign_currency_decimal_places) }})
|
||||
{% endif %}
|
||||
{# native amount of withdrawal #}
|
||||
{% if convertToNative and 0 != transaction.native_amount %}
|
||||
({{ formatAmountBySymbol(transaction.native_amount, defaultCurrency.symbol, defaultCurrency.decimal_places) }})
|
||||
{# primary currency amount of withdrawal #}
|
||||
{% if convertToPrimary and 0 != transaction.pc_amount %}
|
||||
({{ formatAmountBySymbol(transaction.pc_amount, primaryCurrency.symbol, primaryCurrency.decimal_places) }})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
|
@@ -145,12 +145,12 @@
|
||||
<td>{{ user.user_flags | raw }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Native currency</td>
|
||||
<td>{{ user.native.code }}</td>
|
||||
<td>Primary currency</td>
|
||||
<td>{{ user.primary.code }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Convert to native currency?</td>
|
||||
<td>{% if user.convert_to_native %}Enabled{% else %}Disabled{% endif %}</td>
|
||||
<td>Convert to primary currency?</td>
|
||||
<td>{% if user.convert_to_primary %}Enabled{% else %}Disabled{% endif %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Session start</td>
|
||||
|
@@ -100,14 +100,14 @@
|
||||
{{ ExpandedForm.date('fiscalYearStart',fiscalYearStart,{ 'label' : 'pref_fiscal_year_start_label'|_ }) }}
|
||||
</div>
|
||||
|
||||
{# conversion back to native #}
|
||||
{# conversion back to primary currency #}
|
||||
{% if config('cer.enabled') %}
|
||||
<div class="preferences-box">
|
||||
<h3>{{ 'pref_convert_to_native'|_ }}</h3>
|
||||
<h3>{{ 'pref_convert_to_primary'|_ }}</h3>
|
||||
<p class="text-info">
|
||||
{{ 'pref_convert_to_native_help'|_ }}
|
||||
{{ 'pref_convert_to_primary_help'|_ }}
|
||||
</p>
|
||||
{{ ExpandedForm.checkbox('convertToNative','1',convertToNative,{ 'label' : 'pref_convert_native_help'|_ }) }}
|
||||
{{ ExpandedForm.checkbox('convertToPrimary','1',convertToPrimary,{ 'label' : 'pref_convert_primary_help'|_ }) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@@ -91,7 +91,7 @@
|
||||
|
||||
{{ ExpandedForm.text('transaction_description') }}
|
||||
{# transaction information (mandatory) #}
|
||||
{{ CurrencyForm.currencyList('transaction_currency_id', defaultCurrency.id) }}
|
||||
{{ CurrencyForm.currencyList('transaction_currency_id', primaryCurrency.id) }}
|
||||
{{ ExpandedForm.amountNoCurrency('amount') }}
|
||||
|
||||
{# source account if withdrawal, or if transfer: #}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script type="text/javascript" nonce="{{ JS_NONCE }}">
|
||||
var allowedOpposingTypes = {{ allowedOpposingTypes|json_encode|raw }};
|
||||
var accountToTypes = {{ accountToTypes|json_encode|raw }};
|
||||
var defaultCurrency = {{ defaultCurrency.toArray()|json_encode|raw }};
|
||||
var primaryCurrency = {{ primaryCurrency.toArray()|json_encode|raw }};
|
||||
var cashAccountId = {{ cash.id }};
|
||||
var previousUrl = '{{ previousUrl }}';
|
||||
window.sourceId = {{ sourceId }};
|
||||
|
@@ -13,7 +13,7 @@
|
||||
<script type="text/javascript" nonce="{{ JS_NONCE }}">
|
||||
var allowedOpposingTypes = {{ allowedOpposingTypes|json_encode|raw }};
|
||||
var accountToTypes = {{ accountToTypes|json_encode|raw }};
|
||||
var defaultCurrency = {{ defaultCurrency.toArray()|json_encode|raw }};
|
||||
var primaryCurrency = {{ primaryCurrency.toArray()|json_encode|raw }};
|
||||
var allowedSourceDests = {{ allowedSourceDests|json_encode|raw }};
|
||||
var expectedSourceTypes = {{ expectedSourceTypes|json_encode|raw }};
|
||||
var cashAccountId = {{ cash.id }};
|
||||
|
@@ -59,11 +59,11 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-4 col-form-label">Convert to native</label>
|
||||
<label class="col-sm-4 col-form-label">Convert to primary</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="form-check form-switch form-check-inline">
|
||||
<label>
|
||||
<input class="form-check-input" x-model="convertToNative" type="checkbox" @change="saveNativeSettings"> <span
|
||||
<input class="form-check-input" x-model="convertToPrimary" type="checkbox" @change="savePrimarySettings"> <span
|
||||
>Yes no</span>
|
||||
</label>
|
||||
</div>
|
||||
|
@@ -75,7 +75,7 @@
|
||||
<ul class="list-unstyled list-no-margin">
|
||||
<template x-for="transaction in group.transactions">
|
||||
<li>
|
||||
@include('partials.elements.amount', ['convertToNative' => true,'type' => 'transaction.type','amount' => 'transaction.amount','native' => 'transaction.amount'])
|
||||
@include('partials.elements.amount', ['convertToPrimary' => true,'type' => 'transaction.type','amount' => 'transaction.amount','primary' => 'transaction.amount'])
|
||||
</li>
|
||||
</template>
|
||||
</ul>
|
||||
|
@@ -1,38 +1,38 @@
|
||||
@if($convertToNative)
|
||||
<template x-if="convertToNative">
|
||||
@if($convertToPrimary)
|
||||
<template x-if="convertToPrimary">
|
||||
<span>
|
||||
<template x-if="{{ $native }}_raw < 0">
|
||||
<template x-if="{{ $primary }}_raw < 0">
|
||||
<span class="text-danger">
|
||||
<span x-text="{{ $native }}"></span>
|
||||
<span x-text="{{ $primary }}"></span>
|
||||
</span>
|
||||
</template>
|
||||
<template x-if="{{ $native }}_raw >= 0">
|
||||
<template x-if="{{ $primary }}_raw >= 0">
|
||||
<template x-if="'transfer' === {{ $type }}">
|
||||
<span class="text-primary">
|
||||
<span x-text="{{ $native }}"></span>
|
||||
<span x-text="{{ $primary }}"></span>
|
||||
</span>
|
||||
</template>
|
||||
<template x-if="'transfer' !== {{ $type }}">
|
||||
<span class="text-success">
|
||||
<span x-text="{{ $native }}"></span>
|
||||
<span x-text="{{ $primary }}"></span>
|
||||
</span>
|
||||
</template>
|
||||
</template>
|
||||
</span>
|
||||
</template>
|
||||
<template x-if="!convertToNative">
|
||||
<template x-if="!convertToPrimary">
|
||||
<span>
|
||||
<template x-if="{{ $amount }}_raw < 0">
|
||||
|
||||
<span>
|
||||
<template x-if="'transfer' === {{ $type }}">
|
||||
<span class="text-primary">
|
||||
<span x-text="{{ $native }}"></span>
|
||||
<span x-text="{{ $primary }}"></span>
|
||||
</span>
|
||||
</template>
|
||||
<template x-if="'transfer' !== {{ $type }}">
|
||||
<span class="text-danger">
|
||||
<span x-text="{{ $native }}"></span>
|
||||
<span x-text="{{ $primary }}"></span>
|
||||
</span>
|
||||
</template>
|
||||
</span>
|
||||
@@ -43,12 +43,12 @@
|
||||
<span>
|
||||
<template x-if="'transfer' === {{ $type }}">
|
||||
<span class="text-primary">
|
||||
<span x-text="{{ $native }}"></span>
|
||||
<span x-text="{{ $primary }}"></span>
|
||||
</span>
|
||||
</template>
|
||||
<template x-if="'transfer' !== {{ $type }}">
|
||||
<span class="text-success">
|
||||
<span x-text="{{ $native }}"></span>
|
||||
<span x-text="{{ $primary }}"></span>
|
||||
</span>
|
||||
</template>
|
||||
</span>
|
||||
|
@@ -8,8 +8,8 @@
|
||||
<!-- is no longer loading currencies -->
|
||||
<template x-if="!formStates.loadingCurrencies">
|
||||
<select class="form-control" :id="'currency_code_' + index" x-model="transaction.currency_code">
|
||||
<template x-for="currency in formData.nativeCurrencies">
|
||||
<option :selected="currency.id == formData.defaultCurrency.id"
|
||||
<template x-for="currency in formData.primaryCurrencies">
|
||||
<option :selected="currency.id == formData.primaryCurrency.id"
|
||||
:label="currency.name" :value="currency.code"
|
||||
x-text="currency.name"></option>
|
||||
</template>
|
||||
|
Reference in New Issue
Block a user