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