mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Rename "native" to "primary".
This commit is contained in:
@@ -105,7 +105,7 @@ class CreateController extends Controller
|
||||
$request->session()->flash(
|
||||
'preFilled',
|
||||
[
|
||||
'currency_id' => $this->defaultCurrency->id,
|
||||
'currency_id' => $this->primaryCurrency->id,
|
||||
'include_net_worth' => $hasOldInput ? (bool) $request->old('include_net_worth') : true,
|
||||
]
|
||||
);
|
||||
|
@@ -125,7 +125,7 @@ class EditController extends Controller
|
||||
$openingBalanceAmount = '';
|
||||
}
|
||||
$openingBalanceDate = $repository->getOpeningBalanceDate($account);
|
||||
$currency = $this->repository->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
$currency = $this->repository->getAccountCurrency($account) ?? $this->primaryCurrency;
|
||||
|
||||
// include this account in net-worth charts?
|
||||
$includeNetWorth = $repository->getMetaValue($account, 'include_net_worth');
|
||||
|
@@ -104,14 +104,14 @@ class IndexController extends Controller
|
||||
function (Account $account) use ($activities, $startBalances, $endBalances): void {
|
||||
$currency = $this->repository->getAccountCurrency($account);
|
||||
$account->lastActivityDate = $this->isInArrayDate($activities, $account->id);
|
||||
$account->startBalances = Steam::filterAccountBalance($startBalances[$account->id] ?? [], $account, $this->convertToNative, $currency);
|
||||
$account->endBalances = Steam::filterAccountBalance($endBalances[$account->id] ?? [], $account, $this->convertToNative, $currency);
|
||||
$account->startBalances = Steam::filterAccountBalance($startBalances[$account->id] ?? [], $account, $this->convertToPrimary, $currency);
|
||||
$account->endBalances = Steam::filterAccountBalance($endBalances[$account->id] ?? [], $account, $this->convertToPrimary, $currency);
|
||||
$account->differences = $this->subtract($account->startBalances, $account->endBalances);
|
||||
$account->interest = Steam::bcround($this->repository->getMetaValue($account, 'interest'), 4);
|
||||
$account->interestPeriod = (string) trans(sprintf('firefly.interest_calc_%s', $this->repository->getMetaValue($account, 'interest_period')));
|
||||
$account->accountTypeString = (string) trans(sprintf('firefly.account_type_%s', $account->accountType->type));
|
||||
$account->current_debt = '0';
|
||||
$account->currency = $currency ?? $this->defaultCurrency;
|
||||
$account->currency = $currency ?? $this->primaryCurrency;
|
||||
$account->iban = implode(' ', str_split((string) $account->iban, 4));
|
||||
}
|
||||
);
|
||||
@@ -183,8 +183,8 @@ class IndexController extends Controller
|
||||
$interest = '' === $interest ? '0' : $interest;
|
||||
$currency = $this->repository->getAccountCurrency($account);
|
||||
|
||||
$account->startBalances = Steam::filterAccountBalance($startBalances[$account->id] ?? [], $account, $this->convertToNative, $currency);
|
||||
$account->endBalances = Steam::filterAccountBalance($endBalances[$account->id] ?? [], $account, $this->convertToNative, $currency);
|
||||
$account->startBalances = Steam::filterAccountBalance($startBalances[$account->id] ?? [], $account, $this->convertToPrimary, $currency);
|
||||
$account->endBalances = Steam::filterAccountBalance($endBalances[$account->id] ?? [], $account, $this->convertToPrimary, $currency);
|
||||
$account->differences = $this->subtract($account->startBalances, $account->endBalances);
|
||||
$account->lastActivityDate = $this->isInArrayDate($activities, $account->id);
|
||||
$account->interest = Steam::bcround($interest, 4);
|
||||
@@ -195,7 +195,7 @@ class IndexController extends Controller
|
||||
$account->location = $this->repository->getLocation($account);
|
||||
$account->liability_direction = $this->repository->getMetaValue($account, 'liability_direction');
|
||||
$account->current_debt = $this->repository->getMetaValue($account, 'current_debt') ?? '-';
|
||||
$account->currency = $currency ?? $this->defaultCurrency;
|
||||
$account->currency = $currency ?? $this->primaryCurrency;
|
||||
$account->iban = implode(' ', str_split((string) $account->iban, 4));
|
||||
|
||||
|
||||
|
@@ -87,7 +87,7 @@ class ReconcileController extends Controller
|
||||
|
||||
return redirect(route('accounts.index', [config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type))]));
|
||||
}
|
||||
$currency = $this->accountRepos->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
$currency = $this->accountRepos->getAccountCurrency($account) ?? $this->primaryCurrency;
|
||||
|
||||
// no start or end:
|
||||
$range = app('navigation')->getViewRange(false);
|
||||
@@ -204,7 +204,7 @@ class ReconcileController extends Controller
|
||||
}
|
||||
|
||||
$reconciliation = $this->accountRepos->getReconciliation($account);
|
||||
$currency = $this->accountRepos->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
$currency = $this->accountRepos->getAccountCurrency($account) ?? $this->primaryCurrency;
|
||||
$source = $reconciliation;
|
||||
$destination = $account;
|
||||
if (1 === bccomp($difference, '0')) {
|
||||
|
@@ -108,7 +108,7 @@ class ShowController extends Controller
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$accountCurrency = $this->repository->getAccountCurrency($account);
|
||||
$currency = $accountCurrency ?? $this->defaultCurrency;
|
||||
$currency = $accountCurrency ?? $this->primaryCurrency;
|
||||
$fStart = $start->isoFormat($this->monthAndDayFormat);
|
||||
$fEnd = $end->isoFormat($this->monthAndDayFormat);
|
||||
$subTitle = (string) trans('firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $fStart, 'end' => $fEnd]);
|
||||
@@ -165,7 +165,7 @@ class ShowController extends Controller
|
||||
}
|
||||
|
||||
Log::debug(sprintf('show: Call finalAccountBalance with date/time "%s"', $now->toIso8601String()));
|
||||
$balances = Steam::filterAccountBalance(Steam::finalAccountBalance($account, $now), $account, $this->convertToNative, $accountCurrency);
|
||||
$balances = Steam::filterAccountBalance(Steam::finalAccountBalance($account, $now), $account, $this->convertToPrimary, $accountCurrency);
|
||||
|
||||
return view(
|
||||
'accounts.show',
|
||||
@@ -212,7 +212,7 @@ class ShowController extends Controller
|
||||
$subTitleIcon = config('firefly.subIconsByIdentifier.'.$account->accountType->type);
|
||||
$page = (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$currency = $this->repository->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
$currency = $this->repository->getAccountCurrency($account) ?? $this->primaryCurrency;
|
||||
$subTitle = (string) trans('firefly.all_journals_for_account', ['name' => $account->name]);
|
||||
$periods = new Collection();
|
||||
|
||||
@@ -232,7 +232,7 @@ class ShowController extends Controller
|
||||
$showAll = true;
|
||||
// correct
|
||||
Log::debug(sprintf('showAll: Call finalAccountBalance with date/time "%s"', $end->toIso8601String()));
|
||||
$balances = Steam::filterAccountBalance(Steam::finalAccountBalance($account, $end), $account, $this->convertToNative, $accountCurrency);
|
||||
$balances = Steam::filterAccountBalance(Steam::finalAccountBalance($account, $end), $account, $this->convertToPrimary, $accountCurrency);
|
||||
|
||||
return view(
|
||||
'accounts.show',
|
||||
|
@@ -77,7 +77,7 @@ class CreateController extends Controller
|
||||
$periods[$current] = (string) trans('firefly.repeat_freq_'.$current);
|
||||
}
|
||||
$subTitle = (string) trans('firefly.create_new_bill');
|
||||
$defaultCurrency = $this->defaultCurrency;
|
||||
$defaultCurrency = $this->primaryCurrency;
|
||||
|
||||
// put previous url in session if not redirect from store (not "create another").
|
||||
if (true !== session('bills.create.fromStore')) {
|
||||
|
@@ -88,7 +88,7 @@ class EditController extends Controller
|
||||
$bill->amount_min = app('steam')->bcround($bill->amount_min, $bill->transactionCurrency->decimal_places);
|
||||
$bill->amount_max = app('steam')->bcround($bill->amount_max, $bill->transactionCurrency->decimal_places);
|
||||
$rules = $this->repository->getRulesForBill($bill);
|
||||
$defaultCurrency = $this->defaultCurrency;
|
||||
$defaultCurrency = $this->primaryCurrency;
|
||||
|
||||
// code to handle active-checkboxes
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
|
@@ -91,8 +91,8 @@ class IndexController extends Controller
|
||||
$admin = auth()->user();
|
||||
$enrichment = new SubscriptionEnrichment();
|
||||
$enrichment->setUser($admin);
|
||||
$enrichment->setConvertToNative($this->convertToNative);
|
||||
$enrichment->setNative($this->defaultCurrency);
|
||||
$enrichment->setConvertToPrimary($this->convertToPrimary);
|
||||
$enrichment->setPrimary($this->primaryCurrency);
|
||||
$enrichment->setStart($tempStart);
|
||||
$enrichment->setEnd($end);
|
||||
$collection = $enrichment->enrich($collection);
|
||||
@@ -100,8 +100,8 @@ class IndexController extends Controller
|
||||
|
||||
$parameters->set('start', $tempStart);
|
||||
$parameters->set('end', $end);
|
||||
$parameters->set('convertToNative', $this->convertToNative);
|
||||
$parameters->set('defaultCurrency', $this->defaultCurrency);
|
||||
$parameters->set('convertToPrimary', $this->convertToPrimary);
|
||||
$parameters->set('defaultCurrency', $this->primaryCurrency);
|
||||
|
||||
/** @var BillTransformer $transformer */
|
||||
$transformer = app(BillTransformer::class);
|
||||
@@ -130,7 +130,7 @@ class IndexController extends Controller
|
||||
'bills' => [],
|
||||
];
|
||||
|
||||
$currency = $bill->transactionCurrency ?? $this->defaultCurrency;
|
||||
$currency = $bill->transactionCurrency ?? $this->primaryCurrency;
|
||||
$array['currency_id'] = $currency->id;
|
||||
$array['currency_name'] = $currency->name;
|
||||
$array['currency_symbol'] = $currency->symbol;
|
||||
|
@@ -149,8 +149,8 @@ class ShowController extends Controller
|
||||
$admin = auth()->user();
|
||||
$enrichment = new SubscriptionEnrichment();
|
||||
$enrichment->setUser($admin);
|
||||
$enrichment->setConvertToNative($this->convertToNative);
|
||||
$enrichment->setNative($this->defaultCurrency);
|
||||
$enrichment->setConvertToPrimary($this->convertToPrimary);
|
||||
$enrichment->setPrimary($this->primaryCurrency);
|
||||
$enrichment->setStart($start);
|
||||
$enrichment->setEnd($end);
|
||||
$bill = $enrichment->enrichSingle($bill);
|
||||
|
@@ -89,7 +89,7 @@ class CreateController extends Controller
|
||||
|
||||
$preFilled = [
|
||||
'auto_budget_period' => $hasOldInput ? (bool) $request->old('auto_budget_period') : 'monthly',
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $this->defaultCurrency->id,
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $this->primaryCurrency->id,
|
||||
];
|
||||
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
|
@@ -94,7 +94,7 @@ class EditController extends Controller
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $budget->active,
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $this->defaultCurrency->id,
|
||||
'auto_budget_currency_id' => $hasOldInput ? (int) $request->old('auto_budget_currency_id') : $this->primaryCurrency->id,
|
||||
];
|
||||
if ($autoBudget instanceof AutoBudget) {
|
||||
$amount = $hasOldInput ? $request->old('auto_budget_amount') : $autoBudget->amount;
|
||||
|
@@ -119,14 +119,14 @@ class IndexController extends Controller
|
||||
// get all available budgets:
|
||||
$availableBudgets = $this->getAllAvailableBudgets($start, $end);
|
||||
// get all active budgets:
|
||||
$budgets = $this->getAllBudgets($start, $end, $currencies, $this->defaultCurrency);
|
||||
$budgets = $this->getAllBudgets($start, $end, $currencies, $this->primaryCurrency);
|
||||
$sums = $this->getSums($budgets);
|
||||
|
||||
// get budgeted for default currency:
|
||||
if (0 === count($availableBudgets)) {
|
||||
$budgeted = $this->blRepository->budgeted($start, $end, $this->defaultCurrency);
|
||||
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $this->defaultCurrency);
|
||||
$spent = $spentArr[$this->defaultCurrency->id]['sum'] ?? '0';
|
||||
$budgeted = $this->blRepository->budgeted($start, $end, $this->primaryCurrency);
|
||||
$spentArr = $this->opsRepository->sumExpenses($start, $end, null, null, $this->primaryCurrency);
|
||||
$spent = $spentArr[$this->primaryCurrency->id]['sum'] ?? '0';
|
||||
unset($spentArr);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ class IndexController extends Controller
|
||||
|
||||
// get all inactive budgets, and simply list them:
|
||||
$inactive = $this->repository->getInactiveBudgets();
|
||||
$defaultCurrency = $this->defaultCurrency;
|
||||
$defaultCurrency = $this->primaryCurrency;
|
||||
|
||||
return view(
|
||||
'budgets.index',
|
||||
@@ -179,11 +179,11 @@ class IndexController extends Controller
|
||||
// spent in period:
|
||||
$spentArr = $this->opsRepository->sumExpenses($entry->start_date, $entry->end_date, null, null, $entry->transactionCurrency, false);
|
||||
$array['spent'] = $spentArr[$entry->transaction_currency_id]['sum'] ?? '0';
|
||||
$array['native_spent'] = $this->convertToNative && $entry->transaction_currency_id !== $this->defaultCurrency->id ? $converter->convert($entry->transactionCurrency, $this->defaultCurrency, $entry->start_date, $array['spent']) : null;
|
||||
$array['pc_spent'] = $this->convertToPrimary && $entry->transaction_currency_id !== $this->primaryCurrency->id ? $converter->convert($entry->transactionCurrency, $this->primaryCurrency, $entry->start_date, $array['spent']) : null;
|
||||
// budgeted in period:
|
||||
$budgeted = $this->blRepository->budgeted($entry->start_date, $entry->end_date, $entry->transactionCurrency);
|
||||
$array['budgeted'] = $budgeted;
|
||||
$array['native_budgeted'] = $this->convertToNative && $entry->transaction_currency_id !== $this->defaultCurrency->id ? $converter->convert($entry->transactionCurrency, $this->defaultCurrency, $entry->start_date, $budgeted) : null;
|
||||
$array['pc_budgeted'] = $this->convertToPrimary && $entry->transaction_currency_id !== $this->primaryCurrency->id ? $converter->convert($entry->transactionCurrency, $this->primaryCurrency, $entry->start_date, $budgeted) : null;
|
||||
// this time, because of complex sums, use the currency converter.
|
||||
|
||||
|
||||
|
@@ -188,8 +188,8 @@ class ShowController extends Controller
|
||||
'currency' => $budgetLimit->transactionCurrency->name,
|
||||
]
|
||||
);
|
||||
if ($this->convertToNative) {
|
||||
$currencySymbol = $this->defaultCurrency->symbol;
|
||||
if ($this->convertToPrimary) {
|
||||
$currencySymbol = $this->primaryCurrency->symbol;
|
||||
}
|
||||
|
||||
// collector:
|
||||
|
@@ -96,7 +96,7 @@ class AccountController extends Controller
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
$cache->addProperty('chart.account.expense-accounts');
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
@@ -132,19 +132,19 @@ class AccountController extends Controller
|
||||
* @var string $endBalance
|
||||
*/
|
||||
foreach ($expenses as $key => $endBalance) {
|
||||
if (!$this->convertToNative && 'native_balance' === $key) {
|
||||
if (!$this->convertToPrimary && 'pc_balance' === $key) {
|
||||
// Log::debug(sprintf('[a] Will skip expense array "%s"', $key));
|
||||
|
||||
continue;
|
||||
}
|
||||
if ($this->convertToNative && 'native_balance' !== $key) {
|
||||
if ($this->convertToPrimary && 'pc_balance' !== $key) {
|
||||
// Log::debug(sprintf('[b] Will skip expense array "%s"', $key));
|
||||
|
||||
continue;
|
||||
}
|
||||
// Log::debug(sprintf('Will process expense array "%s" with amount %s', $key, $endBalance));
|
||||
$searchCode = $this->convertToNative ? $this->defaultCurrency->code : $key;
|
||||
$searchCode = 'balance' === $searchCode || 'native_balance' === $searchCode ? $this->defaultCurrency->code : $searchCode;
|
||||
$searchCode = $this->convertToPrimary ? $this->primaryCurrency->code : $key;
|
||||
$searchCode = 'balance' === $searchCode || 'pc_balance' === $searchCode ? $this->primaryCurrency->code : $searchCode;
|
||||
// Log::debug(sprintf('Search code is %s', $searchCode));
|
||||
// see if there is an accompanying start amount.
|
||||
// grab the difference and find the currency.
|
||||
@@ -433,7 +433,7 @@ class AccountController extends Controller
|
||||
$cache->addProperty('chart.account.period');
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
$cache->addProperty($account->id);
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
@@ -453,8 +453,8 @@ class AccountController extends Controller
|
||||
$format = (string) trans('config.month_and_day_js', [], $locale);
|
||||
$accountCurrency = $this->accountRepository->getAccountCurrency($account);
|
||||
|
||||
$range = Steam::finalAccountBalanceInRange($account, $start, $end, $this->convertToNative);
|
||||
$range = Steam::filterAccountBalances($range, $account, $this->convertToNative, $accountCurrency);
|
||||
$range = Steam::finalAccountBalanceInRange($account, $start, $end, $this->convertToPrimary);
|
||||
$range = Steam::filterAccountBalances($range, $account, $this->convertToPrimary, $accountCurrency);
|
||||
|
||||
// temp, get end balance.
|
||||
Log::debug(sprintf('period: Call finalAccountBalance with date/time "%s"', $end->toIso8601String()));
|
||||
@@ -462,7 +462,7 @@ class AccountController extends Controller
|
||||
Log::debug('END temp get end balance done');
|
||||
|
||||
$previous = array_values($range)[0];
|
||||
$accountCurrency ??= $this->defaultCurrency; // do this AFTER getting the balances.
|
||||
$accountCurrency ??= $this->primaryCurrency; // do this AFTER getting the balances.
|
||||
Log::debug('Start chart loop.');
|
||||
|
||||
$newRange = [];
|
||||
@@ -510,7 +510,7 @@ class AccountController extends Controller
|
||||
$chartData = [];
|
||||
|
||||
foreach ($return as $key => $info) {
|
||||
if ('balance' !== $key && 'native_balance' !== $key) {
|
||||
if ('balance' !== $key && 'pc_balance' !== $key) {
|
||||
// assume it's a currency:
|
||||
$setCurrency = $this->currencyRepository->findByCode((string) $key);
|
||||
$info['currency_symbol'] = $setCurrency->symbol;
|
||||
@@ -522,10 +522,10 @@ class AccountController extends Controller
|
||||
$info['currency_code'] = $accountCurrency->code;
|
||||
$info['label'] = sprintf('%s (%s)', $account->name, $accountCurrency->symbol);
|
||||
}
|
||||
if ('native_balance' === $key) {
|
||||
$info['currency_symbol'] = $this->defaultCurrency->symbol;
|
||||
$info['currency_code'] = $this->defaultCurrency->code;
|
||||
$info['label'] = sprintf('%s (%s) (%s)', $account->name, (string) trans('firefly.sum'), $this->defaultCurrency->symbol);
|
||||
if ('pc_balance' === $key) {
|
||||
$info['currency_symbol'] = $this->primaryCurrency->symbol;
|
||||
$info['currency_code'] = $this->primaryCurrency->code;
|
||||
$info['label'] = sprintf('%s (%s) (%s)', $account->name, (string) trans('firefly.sum'), $this->primaryCurrency->symbol);
|
||||
}
|
||||
$chartData[] = $info;
|
||||
}
|
||||
@@ -578,7 +578,7 @@ class AccountController extends Controller
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
$cache->addProperty('chart.account.revenue-accounts');
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
@@ -615,19 +615,19 @@ class AccountController extends Controller
|
||||
* @var string $endBalance
|
||||
*/
|
||||
foreach ($expenses as $key => $endBalance) {
|
||||
if (!$this->convertToNative && 'native_balance' === $key) {
|
||||
if (!$this->convertToPrimary && 'pc_balance' === $key) {
|
||||
// Log::debug(sprintf('[a] Will skip expense array "%s"', $key));
|
||||
|
||||
continue;
|
||||
}
|
||||
if ($this->convertToNative && 'native_balance' !== $key) {
|
||||
if ($this->convertToPrimary && 'pc_balance' !== $key) {
|
||||
// Log::debug(sprintf('[b] Will skip expense array "%s"', $key));
|
||||
|
||||
continue;
|
||||
}
|
||||
// Log::debug(sprintf('Will process expense array "%s" with amount %s', $key, $endBalance));
|
||||
$searchCode = $this->convertToNative ? $this->defaultCurrency->code : $key;
|
||||
$searchCode = 'balance' === $searchCode || 'native_balance' === $searchCode ? $this->defaultCurrency->code : $searchCode;
|
||||
$searchCode = $this->convertToPrimary ? $this->primaryCurrency->code : $key;
|
||||
$searchCode = 'balance' === $searchCode || 'pc_balance' === $searchCode ? $this->primaryCurrency->code : $searchCode;
|
||||
// Log::debug(sprintf('Search code is %s', $searchCode));
|
||||
// see if there is an accompanying start amount.
|
||||
// grab the difference and find the currency.
|
||||
|
@@ -109,7 +109,7 @@ class BillController extends Controller
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty('chart.bill.single');
|
||||
$cache->addProperty($bill->id);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
@@ -134,8 +134,8 @@ class BillController extends Controller
|
||||
}
|
||||
);
|
||||
$currency = $bill->transactionCurrency;
|
||||
if ($this->convertToNative) {
|
||||
$currency = $this->defaultCurrency;
|
||||
if ($this->convertToPrimary) {
|
||||
$currency = $this->primaryCurrency;
|
||||
}
|
||||
|
||||
$chartData = [
|
||||
@@ -164,7 +164,7 @@ class BillController extends Controller
|
||||
$currencyId = $bill->transaction_currency_id;
|
||||
$amountMin = $bill->amount_min;
|
||||
$amountMax = $bill->amount_max;
|
||||
if ($this->convertToNative && $currencyId !== $this->defaultCurrency->id) {
|
||||
if ($this->convertToPrimary && $currencyId !== $this->primaryCurrency->id) {
|
||||
$amountMin = $bill->native_amount_min;
|
||||
$amountMax = $bill->native_amount_max;
|
||||
}
|
||||
@@ -178,11 +178,11 @@ class BillController extends Controller
|
||||
$chartData[2]['entries'][$date] = '0';
|
||||
}
|
||||
$amount = bcmul((string) $journal['amount'], '-1');
|
||||
if ($this->convertToNative && $currencyId !== $journal['currency_id']) {
|
||||
$amount = bcmul($journal['native_amount'] ?? '0', '-1');
|
||||
if ($this->convertToPrimary && $currencyId !== $journal['currency_id']) {
|
||||
$amount = bcmul($journal['pc_amount'] ?? '0', '-1');
|
||||
}
|
||||
if ($this->convertToNative && $currencyId === $journal['foreign_currency_id']) {
|
||||
$amount = bcmul((string) $journal['foreign_amount'], '-1');
|
||||
if ($this->convertToPrimary && $currencyId === $journal['foreign_currency_id']) {
|
||||
$amount = bcmul((string) $journal['pc_amount'], '-1');
|
||||
}
|
||||
|
||||
$chartData[2]['entries'][$date] = bcadd($chartData[2]['entries'][$date], $amount); // amount of journal
|
||||
|
@@ -91,7 +91,7 @@ class BudgetController extends Controller
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
$cache->addProperty('chart.budget.budget');
|
||||
$cache->addProperty($budget->id);
|
||||
|
||||
@@ -108,7 +108,7 @@ class BudgetController extends Controller
|
||||
while ($end >= $loopStart) {
|
||||
/** @var Carbon $loopEnd */
|
||||
$loopEnd = app('navigation')->endOfPeriod($loopStart, $step);
|
||||
$spent = $this->opsRepository->sumExpenses($loopStart, $loopEnd, null, $collection); // this method already converts to native.
|
||||
$spent = $this->opsRepository->sumExpenses($loopStart, $loopEnd, null, $collection); // this method already converts to primary currency.
|
||||
$label = trim((string) app('navigation')->periodShow($loopStart, $step));
|
||||
|
||||
foreach ($spent as $row) {
|
||||
@@ -157,7 +157,7 @@ class BudgetController extends Controller
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
$cache->addProperty('chart.budget.budget.limit');
|
||||
$cache->addProperty($budgetLimit->id);
|
||||
$cache->addProperty($budget->id);
|
||||
@@ -170,14 +170,14 @@ class BudgetController extends Controller
|
||||
$amount = $budgetLimit->amount ?? '0';
|
||||
$budgetCollection = new Collection([$budget]);
|
||||
$currency = $budgetLimit->transactionCurrency;
|
||||
if ($this->convertToNative) {
|
||||
if ($this->convertToPrimary) {
|
||||
$amount = $budgetLimit->native_amount ?? $amount;
|
||||
$currency = $this->defaultCurrency;
|
||||
$currency = $this->primaryCurrency;
|
||||
}
|
||||
|
||||
while ($start <= $end) {
|
||||
$current = clone $start;
|
||||
$expenses = $this->opsRepository->sumExpenses($current, $current, null, $budgetCollection, $budgetLimit->transactionCurrency, $this->convertToNative);
|
||||
$expenses = $this->opsRepository->sumExpenses($current, $current, null, $budgetCollection, $budgetLimit->transactionCurrency, $this->convertToPrimary);
|
||||
$spent = $expenses[$currency->id]['sum'] ?? '0';
|
||||
$amount = bcadd((string) $amount, $spent);
|
||||
$format = $start->isoFormat((string) trans('config.month_and_day_js', [], $locale));
|
||||
@@ -205,7 +205,7 @@ class BudgetController extends Controller
|
||||
$budgetLimitId = $budgetLimit instanceof BudgetLimit ? $budgetLimit->id : 0;
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($budget->id);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
$cache->addProperty($budgetLimitId);
|
||||
$cache->addProperty('chart.budget.expense-asset');
|
||||
$start = session('first', today(config('app.timezone'))->startOfYear());
|
||||
@@ -237,16 +237,16 @@ class BudgetController extends Controller
|
||||
$code = $journal['currency_code'];
|
||||
$name = $journal['currency_name'];
|
||||
|
||||
// if convert to native, use the native things, unless it's the foreign amount which is in the native currency.
|
||||
if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['source_account_id'], $this->defaultCurrency->id);
|
||||
$symbol = $this->defaultCurrency->symbol;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$amount = $journal['native_amount'];
|
||||
// if convert to primary, use the primary things, unless it's the foreign amount which is in the primary currency.
|
||||
if ($this->convertToPrimary && $journal['currency_id'] !== $this->primaryCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['source_account_id'], $this->primaryCurrency->id);
|
||||
$symbol = $this->primaryCurrency->symbol;
|
||||
$code = $this->primaryCurrency->code;
|
||||
$name = $this->primaryCurrency->name;
|
||||
$amount = $journal['pc_amount'];
|
||||
}
|
||||
|
||||
if ($journal['foreign_currency_id'] === $this->defaultCurrency->id) {
|
||||
if ($journal['foreign_currency_id'] === $this->primaryCurrency->id) {
|
||||
$amount = $journal['foreign_amount'];
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ class BudgetController extends Controller
|
||||
$budgetLimitId = $budgetLimit instanceof BudgetLimit ? $budgetLimit->id : 0;
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($budget->id);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
$cache->addProperty($budgetLimitId);
|
||||
$cache->addProperty('chart.budget.expense-category');
|
||||
$start = session('first', today(config('app.timezone'))->startOfYear());
|
||||
@@ -315,22 +315,22 @@ class BudgetController extends Controller
|
||||
$code = $journal['currency_code'];
|
||||
$name = $journal['currency_name'];
|
||||
$amount = $journal['amount'];
|
||||
// if convert to native, use the native things, unless it's the foreign amount which is in the native currency.
|
||||
if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id
|
||||
// if convert to primary, use the primary things, unless it's the foreign amount which is in the primary currency.
|
||||
if ($this->convertToPrimary && $journal['currency_id'] !== $this->primaryCurrency->id && $journal['foreign_currency_id'] !== $this->primaryCurrency->id
|
||||
) {
|
||||
$key = sprintf('%d-%d', $journal['category_id'], $this->defaultCurrency->id);
|
||||
$symbol = $this->defaultCurrency->symbol;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$amount = $journal['native_amount'];
|
||||
$key = sprintf('%d-%d', $journal['category_id'], $this->primaryCurrency->id);
|
||||
$symbol = $this->primaryCurrency->symbol;
|
||||
$code = $this->primaryCurrency->code;
|
||||
$name = $this->primaryCurrency->name;
|
||||
$amount = $journal['pc_amount'];
|
||||
}
|
||||
|
||||
if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id
|
||||
if ($this->convertToPrimary && $journal['currency_id'] !== $this->primaryCurrency->id && $journal['foreign_currency_id'] === $this->primaryCurrency->id
|
||||
) {
|
||||
$key = sprintf('%d-%d', $journal['category_id'], $this->defaultCurrency->id);
|
||||
$symbol = $this->defaultCurrency->symbol;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$key = sprintf('%d-%d', $journal['category_id'], $this->primaryCurrency->id);
|
||||
$symbol = $this->primaryCurrency->symbol;
|
||||
$code = $this->primaryCurrency->code;
|
||||
$name = $this->primaryCurrency->name;
|
||||
$amount = $journal['foreign_amount'];
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ class BudgetController extends Controller
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($budget->id);
|
||||
$cache->addProperty($budgetLimitId);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
$cache->addProperty('chart.budget.expense-expense');
|
||||
$start = session('first', today(config('app.timezone'))->startOfYear());
|
||||
$end = today();
|
||||
@@ -400,20 +400,20 @@ class BudgetController extends Controller
|
||||
$code = $journal['currency_code'];
|
||||
$name = $journal['currency_name'];
|
||||
|
||||
// if convert to native, use the native things, unless it's the foreign amount which is in the native currency.
|
||||
if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] !== $this->defaultCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['destination_account_id'], $this->defaultCurrency->id);
|
||||
$symbol = $this->defaultCurrency->symbol;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
$amount = $journal['native_amount'];
|
||||
// if convert to primary, use the primary things, unless it's the foreign amount which is in the primary currency.
|
||||
if ($this->convertToPrimary && $journal['currency_id'] !== $this->primaryCurrency->id && $journal['foreign_currency_id'] !== $this->primaryCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['destination_account_id'], $this->primaryCurrency->id);
|
||||
$symbol = $this->primaryCurrency->symbol;
|
||||
$code = $this->primaryCurrency->code;
|
||||
$name = $this->primaryCurrency->name;
|
||||
$amount = $journal['pc_amount'];
|
||||
}
|
||||
|
||||
if ($this->convertToNative && $journal['currency_id'] !== $this->defaultCurrency->id && $journal['foreign_currency_id'] === $this->defaultCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['destination_account_id'], $this->defaultCurrency->id);
|
||||
$symbol = $this->defaultCurrency->symbol;
|
||||
$code = $this->defaultCurrency->code;
|
||||
$name = $this->defaultCurrency->name;
|
||||
if ($this->convertToPrimary && $journal['currency_id'] !== $this->primaryCurrency->id && $journal['foreign_currency_id'] === $this->primaryCurrency->id) {
|
||||
$key = sprintf('%d-%d', $journal['destination_account_id'], $this->primaryCurrency->id);
|
||||
$symbol = $this->primaryCurrency->symbol;
|
||||
$code = $this->primaryCurrency->code;
|
||||
$name = $this->primaryCurrency->name;
|
||||
$amount = $journal['foreign_amount'];
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ class BudgetController extends Controller
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
$cache->addProperty('chart.budget.frontpage');
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
@@ -466,8 +466,8 @@ class BudgetController extends Controller
|
||||
$chartGenerator->setUser(auth()->user());
|
||||
$chartGenerator->setStart($start);
|
||||
$chartGenerator->setEnd($end);
|
||||
$chartGenerator->convertToNative = $this->convertToNative;
|
||||
$chartGenerator->default = $this->defaultCurrency;
|
||||
$chartGenerator->convertToPrimary = $this->convertToPrimary;
|
||||
$chartGenerator->default = $this->primaryCurrency;
|
||||
|
||||
$chartData = $chartGenerator->generate();
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
|
@@ -73,7 +73,7 @@ class CategoryController extends Controller
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty('chart.category.all');
|
||||
$cache->addProperty($category->id);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
@@ -87,7 +87,7 @@ class CategoryController extends Controller
|
||||
|
||||
/** @var WholePeriodChartGenerator $chartGenerator */
|
||||
$chartGenerator = app(WholePeriodChartGenerator::class);
|
||||
$chartGenerator->convertToNative = $this->convertToNative;
|
||||
$chartGenerator->convertToPrimary = $this->convertToPrimary;
|
||||
|
||||
$chartData = $chartGenerator->generate($category, $start, $end);
|
||||
$data = $this->generator->multiSet($chartData);
|
||||
@@ -113,7 +113,7 @@ class CategoryController extends Controller
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
$cache->addProperty('chart.category.frontpage');
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
@@ -139,7 +139,7 @@ class CategoryController extends Controller
|
||||
$cache->addProperty('chart.category.period');
|
||||
$cache->addProperty($accounts->pluck('id')->toArray());
|
||||
$cache->addProperty($category);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
}
|
||||
|
@@ -108,7 +108,7 @@ class ReportController extends Controller
|
||||
// loop result, add to array.
|
||||
/** @var array $netWorthItem */
|
||||
foreach ($result as $key => $netWorthItem) {
|
||||
if ('native' === $key) {
|
||||
if ('primary' === $key) {
|
||||
continue;
|
||||
}
|
||||
$currencyId = $netWorthItem['currency_id'];
|
||||
|
@@ -55,9 +55,9 @@ abstract class Controller extends BaseController
|
||||
|
||||
// fails on PHP < 8.4
|
||||
public protected(set) string $name;
|
||||
protected bool $convertToNative = false;
|
||||
protected bool $convertToPrimary = false;
|
||||
protected string $dateTimeFormat;
|
||||
protected ?TransactionCurrency $defaultCurrency;
|
||||
protected ?TransactionCurrency $primaryCurrency;
|
||||
protected string $monthAndDayFormat;
|
||||
protected string $monthFormat;
|
||||
protected string $redirectUrl = '/';
|
||||
@@ -125,19 +125,19 @@ abstract class Controller extends BaseController
|
||||
$this->monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);
|
||||
$this->dateTimeFormat = (string) trans('config.date_time_js', [], $locale);
|
||||
$darkMode = 'browser';
|
||||
$this->defaultCurrency = null;
|
||||
$this->primaryCurrency = null;
|
||||
// get shown-intro-preference:
|
||||
if (auth()->check()) {
|
||||
$this->defaultCurrency = Amount::getPrimaryCurrency();
|
||||
$this->primaryCurrency = Amount::getPrimaryCurrency();
|
||||
$language = Steam::getLanguage();
|
||||
$locale = Steam::getLocale();
|
||||
$darkMode = app('preferences')->get('darkMode', 'browser')->data;
|
||||
$this->convertToNative = Amount::convertToPrimary();
|
||||
$this->convertToPrimary = Amount::convertToPrimary();
|
||||
$page = $this->getPageName();
|
||||
$shownDemo = $this->hasSeenDemo();
|
||||
View::share('language', $language);
|
||||
View::share('locale', $locale);
|
||||
View::share('convertToNative', $this->convertToNative);
|
||||
View::share('convertToPrimary', $this->convertToPrimary);
|
||||
View::share('shownDemo', $shownDemo);
|
||||
View::share('current_route_name', $page);
|
||||
View::share('original_route_name', Route::currentRouteName());
|
||||
|
@@ -285,8 +285,8 @@ class DebugController extends Controller
|
||||
'user_count' => User::count(),
|
||||
'user_flags' => $userFlags,
|
||||
'user_agent' => $userAgent,
|
||||
'native' => Amount::getPrimaryCurrency(),
|
||||
'convert_to_native' => Amount::convertToPrimary(),
|
||||
'primary' => Amount::getPrimaryCurrency(),
|
||||
'convert_to_primary' => Amount::convertToPrimary(),
|
||||
'locale_attempts' => $localeAttempts,
|
||||
'locale' => Steam::getLocale(),
|
||||
'language' => Steam::getLanguage(),
|
||||
|
@@ -55,7 +55,7 @@ class JavascriptController extends Controller
|
||||
foreach ($accounts as $account) {
|
||||
$accountId = $account->id;
|
||||
$currency = (int) $repository->getMetaValue($account, 'currency_id');
|
||||
$currency = 0 === $currency ? $this->defaultCurrency->id : $currency;
|
||||
$currency = 0 === $currency ? $this->primaryCurrency->id : $currency;
|
||||
$entry = ['preferredCurrency' => $currency, 'name' => $account->name];
|
||||
$data['accounts'][$accountId] = $entry;
|
||||
}
|
||||
@@ -95,9 +95,9 @@ class JavascriptController extends Controller
|
||||
public function variables(Request $request, AccountRepositoryInterface $repository): Response
|
||||
{
|
||||
$account = $repository->find((int) $request->get('account'));
|
||||
$currency = $this->defaultCurrency;
|
||||
$currency = $this->primaryCurrency;
|
||||
if ($account instanceof Account) {
|
||||
$currency = $repository->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
$currency = $repository->getAccountCurrency($account) ?? $this->primaryCurrency;
|
||||
}
|
||||
$locale = app('steam')->getLocale();
|
||||
$accounting = app('amount')->getJsConfig();
|
||||
|
@@ -68,7 +68,7 @@ class BoxController extends Controller
|
||||
$cache = new CacheProperties();
|
||||
$cache->addProperty($start);
|
||||
$cache->addProperty($end);
|
||||
$cache->addProperty($this->convertToNative);
|
||||
$cache->addProperty($this->convertToPrimary);
|
||||
$cache->addProperty('box-balance');
|
||||
if ($cache->has()) {
|
||||
return response()->json($cache->get());
|
||||
@@ -77,7 +77,7 @@ class BoxController extends Controller
|
||||
$incomes = [];
|
||||
$expenses = [];
|
||||
$sums = [];
|
||||
$currency = $this->defaultCurrency;
|
||||
$currency = $this->primaryCurrency;
|
||||
|
||||
// collect income of user:
|
||||
/** @var GroupCollectorInterface $collector */
|
||||
@@ -89,7 +89,7 @@ class BoxController extends Controller
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($set as $journal) {
|
||||
$currencyId = $this->convertToNative && $this->defaultCurrency->id !== (int) $journal['currency_id'] ? $this->defaultCurrency->id : (int) $journal['currency_id'];
|
||||
$currencyId = $this->convertToPrimary && $this->primaryCurrency->id !== (int) $journal['currency_id'] ? $this->primaryCurrency->id : (int) $journal['currency_id'];
|
||||
$amount = Amount::getAmountFromJournal($journal);
|
||||
$incomes[$currencyId] ??= '0';
|
||||
$incomes[$currencyId] = bcadd($incomes[$currencyId], (string) app('steam')->positive($amount));
|
||||
@@ -107,7 +107,7 @@ class BoxController extends Controller
|
||||
|
||||
/** @var array $journal */
|
||||
foreach ($set as $journal) {
|
||||
$currencyId = $this->convertToNative ? $this->defaultCurrency->id : (int) $journal['currency_id'];
|
||||
$currencyId = $this->convertToPrimary ? $this->primaryCurrency->id : (int) $journal['currency_id'];
|
||||
$amount = Amount::getAmountFromJournal($journal);
|
||||
$expenses[$currencyId] ??= '0';
|
||||
$expenses[$currencyId] = bcadd($expenses[$currencyId], $amount);
|
||||
@@ -124,10 +124,10 @@ class BoxController extends Controller
|
||||
$expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);
|
||||
}
|
||||
if (0 === count($sums)) {
|
||||
$currency = $this->defaultCurrency;
|
||||
$sums[$this->defaultCurrency->id] = app('amount')->formatAnything($this->defaultCurrency, '0', false);
|
||||
$incomes[$this->defaultCurrency->id] = app('amount')->formatAnything($this->defaultCurrency, '0', false);
|
||||
$expenses[$this->defaultCurrency->id] = app('amount')->formatAnything($this->defaultCurrency, '0', false);
|
||||
$currency = $this->primaryCurrency;
|
||||
$sums[$this->primaryCurrency->id] = app('amount')->formatAnything($this->primaryCurrency, '0', false);
|
||||
$incomes[$this->primaryCurrency->id] = app('amount')->formatAnything($this->primaryCurrency, '0', false);
|
||||
$expenses[$this->primaryCurrency->id] = app('amount')->formatAnything($this->primaryCurrency, '0', false);
|
||||
}
|
||||
|
||||
$response = [
|
||||
@@ -182,7 +182,7 @@ class BoxController extends Controller
|
||||
$netWorthSet = $netWorthHelper->byAccounts($filtered, $date);
|
||||
$return = [];
|
||||
foreach ($netWorthSet as $key => $data) {
|
||||
if ('native' === $key) {
|
||||
if ('primary' === $key) {
|
||||
continue;
|
||||
}
|
||||
$return[$data['currency_id']] = app('amount')->formatFlat($data['currency_symbol'], $data['currency_decimal_places'], $data['balance'], false);
|
||||
|
@@ -45,14 +45,12 @@ class FrontpageController extends Controller
|
||||
{
|
||||
$set = $repository->getPiggyBanks();
|
||||
$info = [];
|
||||
$native = Amount::getPrimaryCurrency();
|
||||
$convertToNative = Amount::convertToPrimary();
|
||||
|
||||
|
||||
/** @var PiggyBank $piggyBank */
|
||||
foreach ($set as $piggyBank) {
|
||||
$amount = $repository->getCurrentAmount($piggyBank);
|
||||
$nativeAmount = $repository->getCurrentNativeAmount($piggyBank);
|
||||
$pcAmount = $repository->getCurrentPrimaryCurrencyAmount($piggyBank);
|
||||
if (1 === bccomp($amount, '0')) {
|
||||
// percentage!
|
||||
$pct = 0;
|
||||
@@ -64,15 +62,15 @@ class FrontpageController extends Controller
|
||||
'id' => $piggyBank->id,
|
||||
'name' => $piggyBank->name,
|
||||
'amount' => $amount,
|
||||
'native_amount' => $nativeAmount,
|
||||
'pc_amount' => $pcAmount,
|
||||
'target' => $piggyBank->target_amount,
|
||||
'native_target' => $piggyBank->native_target_amount,
|
||||
'pc_target' => $piggyBank->native_target_amount,
|
||||
'percentage' => $pct,
|
||||
// currency:
|
||||
'currency_symbol' => $piggyBank->transactionCurrency->symbol,
|
||||
'currency_decimal_places' => $piggyBank->transactionCurrency->decimal_places,
|
||||
'native_currency_symbol' => $native->symbol,
|
||||
'native_currency_decimal_places' => $native->decimal_places,
|
||||
'primary_currency_symbol' => $this->primaryCurrency->symbol,
|
||||
'primary_currency_decimal_places' => $this->primaryCurrency->decimal_places,
|
||||
|
||||
];
|
||||
|
||||
@@ -89,7 +87,9 @@ class FrontpageController extends Controller
|
||||
$html = '';
|
||||
if (0 !== count($info)) {
|
||||
try {
|
||||
$html = view('json.piggy-banks', compact('info', 'convertToNative', 'native'))->render();
|
||||
$convertToPrimary = $this->convertToPrimary;
|
||||
$primary = $this->primaryCurrency;
|
||||
$html = view('json.piggy-banks', compact('info', 'convertToPrimary', 'primary'))->render();
|
||||
} catch (Throwable $e) {
|
||||
app('log')->error(sprintf('Cannot render json.piggy-banks: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
|
@@ -74,7 +74,7 @@ class ReconcileController extends Controller
|
||||
{
|
||||
$startBalance = $request->get('startBalance');
|
||||
$endBalance = $request->get('endBalance');
|
||||
$accountCurrency = $this->accountRepos->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
$accountCurrency = $this->accountRepos->getAccountCurrency($account) ?? $this->primaryCurrency;
|
||||
$amount = '0';
|
||||
$clearedAmount = '0';
|
||||
|
||||
@@ -195,7 +195,7 @@ class ReconcileController extends Controller
|
||||
$startDate = clone $start;
|
||||
$startDate->subDay();
|
||||
|
||||
$currency = $this->accountRepos->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
$currency = $this->accountRepos->getAccountCurrency($account) ?? $this->primaryCurrency;
|
||||
// correct
|
||||
Log::debug(sprintf('transactions: Call finalAccountBalance with date/time "%s"', $startDate->toIso8601String()));
|
||||
Log::debug(sprintf('transactions2: Call finalAccountBalance with date/time "%s"', $end->toIso8601String()));
|
||||
|
@@ -148,7 +148,7 @@ class IndexController extends Controller
|
||||
// enrich each account.
|
||||
$enrichment = new AccountEnrichment();
|
||||
$enrichment->setUser(auth()->user());
|
||||
$enrichment->setNative($this->defaultCurrency);
|
||||
$enrichment->setPrimary($this->primaryCurrency);
|
||||
$return = [];
|
||||
|
||||
/** @var PiggyBank $piggy */
|
||||
|
@@ -112,7 +112,7 @@ class PreferencesController extends Controller
|
||||
$darkMode = Preferences::get('darkMode', 'browser')->data;
|
||||
$customFiscalYear = Preferences::get('customFiscalYear', 0)->data;
|
||||
$fiscalYearStartStr = Preferences::get('fiscalYearStart', '01-01')->data;
|
||||
$convertToNative = $this->convertToNative;
|
||||
$convertToPrimary = $this->convertToPrimary;
|
||||
if (is_array($fiscalYearStartStr)) {
|
||||
$fiscalYearStartStr = '01-01';
|
||||
}
|
||||
@@ -198,7 +198,7 @@ class PreferencesController extends Controller
|
||||
'darkMode',
|
||||
'availableDarkModes',
|
||||
'notifications',
|
||||
'convertToNative',
|
||||
'convertToPrimary',
|
||||
'slackUrl',
|
||||
'locales',
|
||||
'locale',
|
||||
@@ -265,15 +265,15 @@ class PreferencesController extends Controller
|
||||
Preferences::set('ntfy_auth', $all['ntfy_auth'] ?? false);
|
||||
}
|
||||
|
||||
// convert native
|
||||
$convertToNative = 1 === (int) $request->get('convertToNative');
|
||||
if ($convertToNative && !$this->convertToNative) {
|
||||
// convert primary
|
||||
$convertToPrimary = 1 === (int) $request->get('convertToPrimary');
|
||||
if ($convertToPrimary && !$this->convertToPrimary) {
|
||||
// set to true!
|
||||
Log::debug('User sets convertToNative to true.');
|
||||
Preferences::set('convert_to_native', $convertToNative);
|
||||
Log::debug('User sets convertToPrimary to true.');
|
||||
Preferences::set('convert_to_primary', $convertToPrimary);
|
||||
event(new UserGroupChangedDefaultCurrency(auth()->user()->userGroup));
|
||||
}
|
||||
Preferences::set('convert_to_native', $convertToNative);
|
||||
Preferences::set('convert_to_primary', $convertToPrimary);
|
||||
|
||||
// custom fiscal year
|
||||
$customFiscalYear = 1 === (int) $request->get('customFiscalYear');
|
||||
|
@@ -84,7 +84,7 @@ class CreateController extends Controller
|
||||
{
|
||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
||||
$bills = app('expandedform')->makeSelectListWithEmpty($this->billRepository->getActiveBills());
|
||||
$defaultCurrency = $this->defaultCurrency;
|
||||
$defaultCurrency = $this->primaryCurrency;
|
||||
$tomorrow = today(config('app.timezone'));
|
||||
$oldRepetitionType = $request->old('repetition_type');
|
||||
$tomorrow->addDay();
|
||||
@@ -129,7 +129,7 @@ class CreateController extends Controller
|
||||
{
|
||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
||||
$bills = app('expandedform')->makeSelectListWithEmpty($this->billRepository->getActiveBills());
|
||||
$defaultCurrency = $this->defaultCurrency;
|
||||
$defaultCurrency = $this->primaryCurrency;
|
||||
$tomorrow = today(config('app.timezone'));
|
||||
$oldRepetitionType = $request->old('repetition_type');
|
||||
$tomorrow->addDay();
|
||||
|
@@ -228,7 +228,7 @@ class ConvertController extends Controller
|
||||
$date = today()->endOfDay();
|
||||
Log::debug(sprintf('getLiabilities: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$balance = Steam::finalAccountBalance($account, $date)['balance'];
|
||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $this->primaryCurrency;
|
||||
$role = 'l_'.$account->accountType->type;
|
||||
$key = (string) trans('firefly.opt_group_'.$role);
|
||||
$grouped[$key][$account->id] = $account->name.' ('.app('amount')->formatAnything($currency, $balance, false).')';
|
||||
@@ -252,7 +252,7 @@ class ConvertController extends Controller
|
||||
$date = today()->endOfDay();
|
||||
Log::debug(sprintf('getAssetAccounts: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||
$balance = Steam::finalAccountBalance($account, $date)['balance'];
|
||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $this->defaultCurrency;
|
||||
$currency = $this->accountRepository->getAccountCurrency($account) ?? $this->primaryCurrency;
|
||||
$role = (string) $this->accountRepository->getMetaValue($account, 'account_role');
|
||||
if ('' === $role) {
|
||||
$role = 'no_account_type';
|
||||
|
@@ -117,7 +117,7 @@ class CreateController extends Controller
|
||||
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
|
||||
$allowedOpposingTypes = config('firefly.allowed_opposing_types');
|
||||
$accountToTypes = config('firefly.account_to_transaction');
|
||||
$defaultCurrency = $this->defaultCurrency;
|
||||
$defaultCurrency = $this->primaryCurrency;
|
||||
$previousUrl = $this->rememberPreviousUrl('transactions.create.url');
|
||||
$parts = parse_url((string) $previousUrl);
|
||||
$search = sprintf('?%s', $parts['query'] ?? '');
|
||||
|
@@ -84,7 +84,7 @@ class EditController extends Controller
|
||||
$title = $transactionGroup->transactionJournals()->count() > 1 ? $transactionGroup->title : $transactionGroup->transactionJournals()->first()->description;
|
||||
$subTitle = (string) trans('firefly.edit_transaction_title', ['description' => $title]);
|
||||
$subTitleIcon = 'fa-plus';
|
||||
$defaultCurrency = $this->defaultCurrency;
|
||||
$defaultCurrency = $this->primaryCurrency;
|
||||
$cash = $repository->getCashAccount();
|
||||
$previousUrl = $this->rememberPreviousUrl('transactions.edit.url');
|
||||
$parts = parse_url((string) $previousUrl);
|
||||
|
@@ -74,10 +74,10 @@ class IndexController extends Controller
|
||||
// order so default and enabled are on top:
|
||||
$collection = $collection->sortBy(
|
||||
static function (TransactionCurrency $currency) {
|
||||
$native = true === $currency->userGroupNative ? 0 : 1;
|
||||
$primary = true === $currency->userGroupNative ? 0 : 1;
|
||||
$enabled = true === $currency->userGroupEnabled ? 0 : 1;
|
||||
|
||||
return sprintf('%s-%s-%s', $native, $enabled, $currency->code);
|
||||
return sprintf('%s-%s-%s', $primary, $enabled, $currency->code);
|
||||
}
|
||||
);
|
||||
$total = $collection->count();
|
||||
|
Reference in New Issue
Block a user