mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-22 19:21:23 +00:00
Replace calls to Amount facade.
This commit is contained in:
@@ -63,7 +63,7 @@ class CorrectsCurrencies extends Command
|
||||
$repos = app(CurrencyRepositoryInterface::class);
|
||||
|
||||
// first check if the user has any default currency (not necessarily the case, so can be forced).
|
||||
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($userGroup);
|
||||
$primaryCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($userGroup);
|
||||
|
||||
Log::debug(sprintf('Now correcting currencies for user group #%d', $userGroup->id));
|
||||
$found = [$primaryCurrency->id];
|
||||
|
||||
@@ -133,6 +133,6 @@ class CorrectsOpeningBalanceCurrencies extends Command
|
||||
$repos = app(AccountRepositoryInterface::class);
|
||||
$repos->setUser($account->user);
|
||||
|
||||
return $repos->getAccountCurrency($account) ?? app('amount')->getPrimaryCurrencyByUserGroup($account->userGroup);
|
||||
return $repos->getAccountCurrency($account) ?? \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($account->userGroup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ class UpgradesAccountCurrencies extends Command
|
||||
$accounts = $this->accountRepos->getAccountsByType([AccountTypeEnum::DEFAULT->value, AccountTypeEnum::ASSET->value]);
|
||||
|
||||
// get user's currency preference:
|
||||
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
|
||||
$primaryCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($user->userGroup);
|
||||
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
|
||||
@@ -67,7 +67,7 @@ class UpgradesBudgetLimits extends Command
|
||||
/** @var null|User $user */
|
||||
$user = $budget->user;
|
||||
if (null !== $user) {
|
||||
$currency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
|
||||
$currency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($user->userGroup);
|
||||
$budgetLimit->transaction_currency_id = $currency->id;
|
||||
$budgetLimit->save();
|
||||
$this->friendlyInfo(
|
||||
|
||||
@@ -95,7 +95,7 @@ class UpgradesMultiPiggyBanks extends Command
|
||||
$this->repository->setUser($piggyBank->account->user);
|
||||
$this->accountRepository->setUser($piggyBank->account->user);
|
||||
$repetition = $this->repository->getRepetition($piggyBank, true);
|
||||
$currency = $this->accountRepository->getAccountCurrency($piggyBank->account) ?? app('amount')->getPrimaryCurrencyByUserGroup($piggyBank->account->user->userGroup);
|
||||
$currency = $this->accountRepository->getAccountCurrency($piggyBank->account) ?? \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($piggyBank->account->user->userGroup);
|
||||
|
||||
// update piggy bank to have a currency.
|
||||
$piggyBank->transaction_currency_id = $currency->id;
|
||||
|
||||
@@ -51,7 +51,7 @@ class BillFactory
|
||||
Log::debug(sprintf('Now in %s', __METHOD__), $data);
|
||||
$factory = app(TransactionCurrencyFactory::class);
|
||||
$currency = $factory->find((int) ($data['currency_id'] ?? null), (string) ($data['currency_code'] ?? null))
|
||||
?? app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
?? \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
|
||||
try {
|
||||
$skip = array_key_exists('skip', $data) ? $data['skip'] : 0;
|
||||
|
||||
@@ -126,7 +126,7 @@ class PiggyBankFactory
|
||||
private function getCurrency(array $data): TransactionCurrency
|
||||
{
|
||||
// currency:
|
||||
$primaryCurrency = app('amount')->getPrimaryCurrency();
|
||||
$primaryCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrency();
|
||||
$currency = null;
|
||||
if (array_key_exists('transaction_currency_code', $data)) {
|
||||
$currency = $this->currencyRepository->findByCode((string)($data['transaction_currency_code'] ?? ''));
|
||||
|
||||
@@ -502,7 +502,7 @@ class TransactionJournalFactory
|
||||
$preference = $this->accountRepository->getAccountCurrency($account);
|
||||
if (null === $preference && !$currency instanceof TransactionCurrency) {
|
||||
// return user's default:
|
||||
return app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
return \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
}
|
||||
$result = $preference ?? $currency;
|
||||
Log::debug(sprintf('Currency is now #%d (%s) because of account #%d (%s)', $result->id, $result->code, $account->id, $account->name));
|
||||
|
||||
@@ -144,7 +144,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
|
||||
$dayBeforeBalance = Steam::accountsBalancesOptimized(new Collection()->push($account), $date)[$account->id];
|
||||
|
||||
$startBalance = $dayBeforeBalance['balance'];
|
||||
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
$primaryCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
$currency = $accountRepository->getAccountCurrency($account) ?? $primaryCurrency;
|
||||
|
||||
foreach ($journals as $index => $journal) {
|
||||
|
||||
@@ -52,7 +52,7 @@ class AccountObserver
|
||||
if (!Amount::convertToPrimary($account->user)) {
|
||||
return;
|
||||
}
|
||||
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
$userCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$currency = $repository->getAccountCurrency($account);
|
||||
if (null !== $currency && $currency->id !== $userCurrency->id && '' !== (string) $account->virtual_balance && 0 !== bccomp($account->virtual_balance, '0')) {
|
||||
|
||||
@@ -42,7 +42,7 @@ class AutoBudgetObserver
|
||||
if (!Amount::convertToPrimary($autoBudget->budget->user)) {
|
||||
return;
|
||||
}
|
||||
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($autoBudget->budget->user->userGroup);
|
||||
$userCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($autoBudget->budget->user->userGroup);
|
||||
$autoBudget->native_amount = null;
|
||||
if ($autoBudget->transactionCurrency->id !== $userCurrency->id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
|
||||
@@ -44,7 +44,7 @@ class AvailableBudgetObserver
|
||||
|
||||
return;
|
||||
}
|
||||
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($availableBudget->user->userGroup);
|
||||
$userCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($availableBudget->user->userGroup);
|
||||
$availableBudget->native_amount = null;
|
||||
if ($availableBudget->transactionCurrency->id !== $userCurrency->id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
|
||||
@@ -46,7 +46,7 @@ class BillObserver
|
||||
if (!Amount::convertToPrimary($bill->user)) {
|
||||
return;
|
||||
}
|
||||
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($bill->user->userGroup);
|
||||
$userCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($bill->user->userGroup);
|
||||
$bill->native_amount_min = null;
|
||||
$bill->native_amount_max = null;
|
||||
if ($bill->transactionCurrency->id !== $userCurrency->id) {
|
||||
|
||||
@@ -72,7 +72,7 @@ class BudgetLimitObserver
|
||||
|
||||
return;
|
||||
}
|
||||
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($budgetLimit->budget->user->userGroup);
|
||||
$userCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($budgetLimit->budget->user->userGroup);
|
||||
$budgetLimit->native_amount = null;
|
||||
if ($budgetLimit->transactionCurrency->id !== $userCurrency->id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
|
||||
@@ -48,7 +48,7 @@ class PiggyBankEventObserver
|
||||
if (!Amount::convertToPrimary($user)) {
|
||||
return;
|
||||
}
|
||||
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($event->piggyBank->accounts()->first()->user->userGroup);
|
||||
$userCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($event->piggyBank->accounts()->first()->user->userGroup);
|
||||
$event->native_amount = null;
|
||||
if ($event->piggyBank->transactionCurrency->id !== $userCurrency->id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
|
||||
@@ -49,7 +49,7 @@ class PiggyBankObserver
|
||||
|
||||
return;
|
||||
}
|
||||
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($group);
|
||||
$userCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($group);
|
||||
$piggyBank->native_target_amount = null;
|
||||
if ($piggyBank->transactionCurrency->id !== $userCurrency->id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
|
||||
@@ -52,7 +52,7 @@ class TransactionObserver
|
||||
if (!Amount::convertToPrimary($transaction->transactionJournal->user)) {
|
||||
return;
|
||||
}
|
||||
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($transaction->transactionJournal->user->userGroup);
|
||||
$userCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($transaction->transactionJournal->user->userGroup);
|
||||
$transaction->native_amount = null;
|
||||
$transaction->native_foreign_amount = null;
|
||||
// first normal amount
|
||||
|
||||
@@ -205,14 +205,14 @@ class BudgetLimitController extends Controller
|
||||
// add some extra metadata:
|
||||
$spentArr = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection()->push($budget), $currency);
|
||||
$array['spent'] = $spentArr[$currency->id]['sum'] ?? '0';
|
||||
$array['left_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, bcadd($array['spent'], (string) $array['amount']));
|
||||
$array['amount_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $limit['amount']);
|
||||
$array['left_formatted'] = \FireflyIII\Support\Facades\Amount::formatAnything($limit->transactionCurrency, bcadd($array['spent'], (string) $array['amount']));
|
||||
$array['amount_formatted'] = \FireflyIII\Support\Facades\Amount::formatAnything($limit->transactionCurrency, $limit['amount']);
|
||||
$array['days_left'] = (string) $this->activeDaysLeft($start, $end);
|
||||
// left per day:
|
||||
$array['left_per_day'] = 0 === bccomp('0', $array['days_left']) ? bcadd((string) $array['spent'], (string) $array['amount']) : bcdiv(bcadd((string) $array['spent'], (string) $array['amount']), $array['days_left']);
|
||||
|
||||
// left per day formatted.
|
||||
$array['left_per_day_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $array['left_per_day']);
|
||||
$array['left_per_day_formatted'] = \FireflyIII\Support\Facades\Amount::formatAnything($limit->transactionCurrency, $array['left_per_day']);
|
||||
|
||||
// notes:
|
||||
$array['notes'] = $this->blRepository->getNoteText($limit);
|
||||
@@ -239,8 +239,8 @@ class BudgetLimitController extends Controller
|
||||
$this->blRepository->destroyBudgetLimit($budgetLimit);
|
||||
$array = [
|
||||
'budget_id' => $budgetId,
|
||||
'left_formatted' => app('amount')->formatAnything($currency, '0'),
|
||||
'left_per_day_formatted' => app('amount')->formatAnything($currency, '0'),
|
||||
'left_formatted' => \FireflyIII\Support\Facades\Amount::formatAnything($currency, '0'),
|
||||
'left_per_day_formatted' => \FireflyIII\Support\Facades\Amount::formatAnything($currency, '0'),
|
||||
'transaction_currency_id' => $currency->id,
|
||||
];
|
||||
|
||||
@@ -269,14 +269,14 @@ class BudgetLimitController extends Controller
|
||||
);
|
||||
$daysLeft = $this->activeDaysLeft($limit->start_date, $limit->end_date);
|
||||
$array['spent'] = $spentArr[$budgetLimit->transactionCurrency->id]['sum'] ?? '0';
|
||||
$array['left_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, bcadd($array['spent'], (string) $array['amount']));
|
||||
$array['amount_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $limit['amount']);
|
||||
$array['left_formatted'] = \FireflyIII\Support\Facades\Amount::formatAnything($limit->transactionCurrency, bcadd($array['spent'], (string) $array['amount']));
|
||||
$array['amount_formatted'] = \FireflyIII\Support\Facades\Amount::formatAnything($limit->transactionCurrency, $limit['amount']);
|
||||
$array['days_left'] = (string) $daysLeft;
|
||||
$array['left_per_day'] = 0 === $daysLeft ? bcadd((string) $array['spent'], (string) $array['amount']) : bcdiv(bcadd((string) $array['spent'], (string) $array['amount']), $array['days_left']);
|
||||
|
||||
// left per day formatted.
|
||||
$array['amount'] = Steam::bcround($limit['amount'], $limit->transactionCurrency->decimal_places);
|
||||
$array['left_per_day_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $array['left_per_day']);
|
||||
$array['left_per_day_formatted'] = \FireflyIII\Support\Facades\Amount::formatAnything($limit->transactionCurrency, $array['left_per_day']);
|
||||
if ('true' === $request->get('redirect')) {
|
||||
return redirect(route('budgets.index'));
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ class JavascriptController extends Controller
|
||||
$currency = $repository->getAccountCurrency($account) ?? $this->primaryCurrency;
|
||||
}
|
||||
$locale = Steam::getLocale();
|
||||
$accounting = app('amount')->getJsConfig();
|
||||
$accounting = \FireflyIII\Support\Facades\Amount::getJsConfig();
|
||||
$accounting['frac_digits'] = $currency->decimal_places;
|
||||
$pref = Preferences::get('language', config('firefly.default_language', 'en_US'));
|
||||
$lang = $pref->data;
|
||||
|
||||
@@ -121,15 +121,15 @@ class BoxController extends Controller
|
||||
$keys = array_keys($sums);
|
||||
foreach ($keys as $currencyId) {
|
||||
$currency = $repository->find($currencyId);
|
||||
$sums[$currencyId] = app('amount')->formatAnything($currency, $sums[$currencyId], false);
|
||||
$incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false);
|
||||
$expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false);
|
||||
$sums[$currencyId] = \FireflyIII\Support\Facades\Amount::formatAnything($currency, $sums[$currencyId], false);
|
||||
$incomes[$currencyId] = \FireflyIII\Support\Facades\Amount::formatAnything($currency, $incomes[$currencyId] ?? '0', false);
|
||||
$expenses[$currencyId] = \FireflyIII\Support\Facades\Amount::formatAnything($currency, $expenses[$currencyId] ?? '0', false);
|
||||
}
|
||||
if (0 === count($sums)) {
|
||||
$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);
|
||||
$sums[$this->primaryCurrency->id] = \FireflyIII\Support\Facades\Amount::formatAnything($this->primaryCurrency, '0', false);
|
||||
$incomes[$this->primaryCurrency->id] = \FireflyIII\Support\Facades\Amount::formatAnything($this->primaryCurrency, '0', false);
|
||||
$expenses[$this->primaryCurrency->id] = \FireflyIII\Support\Facades\Amount::formatAnything($this->primaryCurrency, '0', false);
|
||||
}
|
||||
|
||||
$response = [
|
||||
@@ -187,7 +187,7 @@ class BoxController extends Controller
|
||||
if ('primary' === $key) {
|
||||
continue;
|
||||
}
|
||||
$return[$data['currency_id']] = app('amount')->formatFlat($data['currency_symbol'], $data['currency_decimal_places'], $data['balance'], false);
|
||||
$return[$data['currency_id']] = \FireflyIII\Support\Facades\Amount::formatFlat($data['currency_symbol'], $data['currency_decimal_places'], $data['balance'], false);
|
||||
}
|
||||
$return = [
|
||||
'net_worths' => array_values($return),
|
||||
|
||||
@@ -84,9 +84,9 @@ class BudgetController extends Controller
|
||||
return response()->json(
|
||||
[
|
||||
'budgeted' => $budgeted,
|
||||
'budgeted_formatted' => app('amount')->formatAnything($currency, $budgeted, true),
|
||||
'budgeted_formatted' => \FireflyIII\Support\Facades\Amount::formatAnything($currency, $budgeted, true),
|
||||
'available' => $available,
|
||||
'available_formatted' => app('amount')->formatAnything($currency, $available, true),
|
||||
'available_formatted' => \FireflyIII\Support\Facades\Amount::formatAnything($currency, $available, true),
|
||||
'percentage' => $percentage,
|
||||
'currency_id' => $currency->id,
|
||||
'currency_code' => $currency->code,
|
||||
|
||||
@@ -167,7 +167,7 @@ class AmountController extends Controller
|
||||
$piggyBank->refresh();
|
||||
}
|
||||
if (0 !== bccomp($total, '0')) {
|
||||
session()->flash('success', (string) trans('firefly.added_amount_to_piggy', ['amount' => app('amount')->formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => $piggyBank->name]));
|
||||
session()->flash('success', (string) trans('firefly.added_amount_to_piggy', ['amount' => \FireflyIII\Support\Facades\Amount::formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => $piggyBank->name]));
|
||||
Preferences::mark();
|
||||
|
||||
return redirect(route('piggy-banks.index'));
|
||||
@@ -177,7 +177,7 @@ class AmountController extends Controller
|
||||
'error',
|
||||
(string) trans(
|
||||
'firefly.cannot_add_amount_piggy',
|
||||
['amount' => app('amount')->formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => e($piggyBank->name)]
|
||||
['amount' => \FireflyIII\Support\Facades\Amount::formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => e($piggyBank->name)]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -214,7 +214,7 @@ class AmountController extends Controller
|
||||
'success',
|
||||
(string) trans(
|
||||
'firefly.removed_amount_from_piggy',
|
||||
['amount' => app('amount')->formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => $piggyBank->name]
|
||||
['amount' => \FireflyIII\Support\Facades\Amount::formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => $piggyBank->name]
|
||||
)
|
||||
);
|
||||
Preferences::mark();
|
||||
@@ -226,7 +226,7 @@ class AmountController extends Controller
|
||||
'error',
|
||||
(string) trans(
|
||||
'firefly.cannot_remove_from_piggy',
|
||||
['amount' => app('amount')->formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => e($piggyBank->name)]
|
||||
['amount' => \FireflyIII\Support\Facades\Amount::formatAnything($piggyBank->transactionCurrency, $total, false), 'name' => e($piggyBank->name)]
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class TransactionCurrency extends Model
|
||||
public function refreshForUser(User $user): void
|
||||
{
|
||||
$current = $user->userGroup->currencies()->where('transaction_currencies.id', $this->id)->first();
|
||||
$native = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
|
||||
$native = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($user->userGroup);
|
||||
$this->userGroupNative = $native->id === $this->id;
|
||||
$this->userGroupEnabled = null !== $current;
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac
|
||||
if (AccountTypeEnum::ASSET->value !== $account->accountType->type) {
|
||||
throw new FireflyException(sprintf('%s is not an asset account.', $account->name));
|
||||
}
|
||||
$currency = $this->getAccountCurrency($account) ?? app('amount')->getPrimaryCurrency();
|
||||
$currency = $this->getAccountCurrency($account) ?? \FireflyIII\Support\Facades\Amount::getPrimaryCurrency();
|
||||
$name = trans('firefly.reconciliation_account_name', ['name' => $account->name, 'currency' => $currency->code]);
|
||||
|
||||
/** @var AccountType $type */
|
||||
|
||||
@@ -59,7 +59,7 @@ class AccountTasker implements AccountTaskerInterface, UserGroupInterface
|
||||
|
||||
/** @var AccountRepositoryInterface $repository */
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
$primaryCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
|
||||
$return = [
|
||||
'accounts' => [],
|
||||
@@ -146,7 +146,7 @@ class AccountTasker implements AccountTaskerInterface, UserGroupInterface
|
||||
|
||||
private function groupExpenseByDestination(array $array): array
|
||||
{
|
||||
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
$primaryCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
@@ -231,7 +231,7 @@ class AccountTasker implements AccountTaskerInterface, UserGroupInterface
|
||||
|
||||
private function groupIncomeBySource(array $array): array
|
||||
{
|
||||
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
$primaryCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
|
||||
/** @var CurrencyRepositoryInterface $currencyRepos */
|
||||
$currencyRepos = app(CurrencyRepositoryInterface::class);
|
||||
|
||||
@@ -536,7 +536,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
|
||||
$bills = $this->getActiveBills();
|
||||
$return = [];
|
||||
$convertToPrimary = Amount::convertToPrimary($this->user);
|
||||
$primary = app('amount')->getPrimaryCurrency();
|
||||
$primary = \FireflyIII\Support\Facades\Amount::getPrimaryCurrency();
|
||||
|
||||
/** @var Bill $bill */
|
||||
foreach ($bills as $bill) {
|
||||
@@ -602,7 +602,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
|
||||
$bills = $this->getActiveBills();
|
||||
$return = [];
|
||||
$convertToPrimary = Amount::convertToPrimary($this->user);
|
||||
$primary = app('amount')->getPrimaryCurrency();
|
||||
$primary = \FireflyIII\Support\Facades\Amount::getPrimaryCurrency();
|
||||
|
||||
/** @var Bill $bill */
|
||||
foreach ($bills as $bill) {
|
||||
|
||||
@@ -94,7 +94,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
|
||||
$limitRepository = app(BudgetLimitRepository::class);
|
||||
$limitRepository->setUser($this->user);
|
||||
$budgets = $this->getActiveBudgets();
|
||||
$primaryCurrency = app('amount')->getPrimaryCurrency();
|
||||
$primaryCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrency();
|
||||
$converter = new ExchangeRateConverter();
|
||||
|
||||
/** @var Budget $budget */
|
||||
@@ -393,7 +393,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
|
||||
$autoBudget = $this->getAutoBudget($budget);
|
||||
|
||||
// grab default currency:
|
||||
$currency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
$currency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
|
||||
if (!$autoBudget instanceof AutoBudget) {
|
||||
// at this point it's a blind assumption auto_budget_type is 1 or 2.
|
||||
@@ -778,7 +778,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
|
||||
$currency = $repos->findByCode((string) $data['currency_code']);
|
||||
}
|
||||
if (null === $currency) {
|
||||
$currency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
$currency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
}
|
||||
|
||||
$autoBudget = new AutoBudget();
|
||||
|
||||
@@ -240,7 +240,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
|
||||
Log::debug('Grabbing default currency for this user...');
|
||||
|
||||
/** @var null|TransactionCurrency $result */
|
||||
$result = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
$result = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Final result: %s', $result->code));
|
||||
@@ -440,7 +440,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf
|
||||
|
||||
public function makePrimary(TransactionCurrency $currency): void
|
||||
{
|
||||
$current = app('amount')->getPrimaryCurrencyByUserGroup($this->userGroup);
|
||||
$current = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($this->userGroup);
|
||||
Log::debug(sprintf('Enabled + made default currency %s for user #%d', $currency->code, $this->userGroup->id));
|
||||
$this->userGroup->currencies()->detach($currency->id);
|
||||
foreach ($this->userGroup->currencies()->get() as $item) {
|
||||
|
||||
@@ -72,7 +72,7 @@ trait ModifiesPiggyBanks
|
||||
$pivot->native_current_amount = null;
|
||||
|
||||
// also update native_current_amount.
|
||||
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
$userCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
if ($userCurrency->id !== $piggyBank->transaction_currency_id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter->setIgnoreSettings(true);
|
||||
@@ -95,7 +95,7 @@ trait ModifiesPiggyBanks
|
||||
$pivot->native_current_amount = null;
|
||||
|
||||
// also update native_current_amount.
|
||||
$userCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
$userCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
if ($userCurrency->id !== $piggyBank->transaction_currency_id) {
|
||||
$converter = new ExchangeRateConverter();
|
||||
$converter->setIgnoreSettings(true);
|
||||
|
||||
@@ -171,7 +171,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
|
||||
$accountRepos = app(AccountRepositoryInterface::class);
|
||||
$accountRepos->setUser($this->user);
|
||||
|
||||
$primaryCurrency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
$primaryCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
|
||||
Log::debug(sprintf('Piggy bank #%d currency is %s', $piggyBank->id, $piggyBank->transactionCurrency->code));
|
||||
|
||||
@@ -302,7 +302,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte
|
||||
/** @var PiggyBank $piggy */
|
||||
foreach ($set as $piggy) {
|
||||
$currentAmount = $this->getCurrentAmount($piggy);
|
||||
$piggy->name = sprintf('%s (%s)', $piggy->name, app('amount')->formatAnything($piggy->transactionCurrency, $currentAmount, false));
|
||||
$piggy->name = sprintf('%s (%s)', $piggy->name, \FireflyIII\Support\Facades\Amount::formatAnything($piggy->transactionCurrency, $currentAmount, false));
|
||||
}
|
||||
|
||||
return $set;
|
||||
|
||||
@@ -231,7 +231,7 @@ trait AccountServiceTrait
|
||||
// get or grab currency:
|
||||
$currency = $this->accountRepository->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
$currency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
$currency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
}
|
||||
|
||||
// submit to factory:
|
||||
@@ -348,7 +348,7 @@ trait AccountServiceTrait
|
||||
|
||||
if (null === $currency) {
|
||||
// use default currency:
|
||||
$currency = app('amount')->getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
$currency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup);
|
||||
}
|
||||
$currency->enabled = true;
|
||||
$currency->save();
|
||||
@@ -388,7 +388,7 @@ trait AccountServiceTrait
|
||||
// if exists, update:
|
||||
$currency = $this->accountRepository->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
$currency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
$currency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
}
|
||||
|
||||
// simply grab the first journal and change it:
|
||||
@@ -454,7 +454,7 @@ trait AccountServiceTrait
|
||||
// get or grab currency:
|
||||
$currency = $this->accountRepository->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
$currency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
$currency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
}
|
||||
// submit to factory:
|
||||
$submission = [
|
||||
@@ -571,7 +571,7 @@ trait AccountServiceTrait
|
||||
// if exists, update:
|
||||
$currency = $this->accountRepository->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
$currency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
$currency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
}
|
||||
|
||||
// simply grab the first journal and change it:
|
||||
@@ -652,7 +652,7 @@ trait AccountServiceTrait
|
||||
// get or grab currency:
|
||||
$currency = $this->accountRepository->getAccountCurrency($account);
|
||||
if (null === $currency) {
|
||||
$currency = app('amount')->getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
$currency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($account->user->userGroup);
|
||||
}
|
||||
|
||||
// submit to factory:
|
||||
|
||||
@@ -107,7 +107,7 @@ trait RecurringTransactionTrait
|
||||
$currency = $factory->find($array['currency_id'] ?? null, $array['currency_code'] ?? null);
|
||||
$foreignCurrency = $factory->find($array['foreign_currency_id'] ?? null, $array['foreign_currency_code'] ?? null);
|
||||
if (null === $currency) {
|
||||
$currency = app('amount')->getPrimaryCurrencyByUserGroup($recurrence->user->userGroup);
|
||||
$currency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($recurrence->user->userGroup);
|
||||
}
|
||||
|
||||
Log::debug(
|
||||
|
||||
@@ -53,7 +53,7 @@ class BillUpdateService
|
||||
if (array_key_exists('currency_id', $data) || array_key_exists('currency_code', $data)) {
|
||||
$factory = app(TransactionCurrencyFactory::class);
|
||||
$currency = $factory->find((int) ($data['currency_id'] ?? null), $data['currency_code'] ?? null)
|
||||
?? app('amount')->getPrimaryCurrencyByUserGroup($bill->user->userGroup);
|
||||
?? \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($bill->user->userGroup);
|
||||
|
||||
// enable the currency if it isn't.
|
||||
$currency->enabled = true;
|
||||
|
||||
@@ -123,10 +123,10 @@ class CurrencyForm
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['step'] = 'any';
|
||||
$primaryCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
|
||||
$primaryCurrency = $options['currency'] ?? \FireflyIII\Support\Facades\Amount::getPrimaryCurrency();
|
||||
|
||||
/** @var Collection $currencies */
|
||||
$currencies = app('amount')->getAllCurrencies();
|
||||
$currencies = \FireflyIII\Support\Facades\Amount::getAllCurrencies();
|
||||
unset($options['currency'], $options['placeholder']);
|
||||
|
||||
// perhaps the currency has been sent to us in the field $amount_currency_id_$name (amount_currency_id_amount)
|
||||
@@ -176,10 +176,10 @@ class CurrencyForm
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['step'] = 'any';
|
||||
$primaryCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
|
||||
$primaryCurrency = $options['currency'] ?? \FireflyIII\Support\Facades\Amount::getPrimaryCurrency();
|
||||
|
||||
/** @var Collection $currencies */
|
||||
$currencies = app('amount')->getCurrencies();
|
||||
$currencies = \FireflyIII\Support\Facades\Amount::getCurrencies();
|
||||
unset($options['currency'], $options['placeholder']);
|
||||
// perhaps the currency has been sent to us in the field $amount_currency_id_$name (amount_currency_id_amount)
|
||||
$preFilled = session('preFilled');
|
||||
|
||||
@@ -67,7 +67,7 @@ trait ChartGeneration
|
||||
/** @var AccountRepositoryInterface $accountRepos */
|
||||
$accountRepos = app(AccountRepositoryInterface::class);
|
||||
|
||||
$primary = app('amount')->getPrimaryCurrency();
|
||||
$primary = \FireflyIII\Support\Facades\Amount::getPrimaryCurrency();
|
||||
$chartData = [];
|
||||
|
||||
Log::debug(sprintf('Start of accountBalanceChart(list, %s, %s)', $start->format('Y-m-d H:i:s'), $end->format('Y-m-d H:i:s')));
|
||||
|
||||
@@ -136,7 +136,7 @@ class BudgetReportGenerator
|
||||
$this->blRepository->setUser($user);
|
||||
$this->opsRepository->setUser($user);
|
||||
$this->nbRepository->setUser($user);
|
||||
$this->currency = app('amount')->getPrimaryCurrencyByUserGroup($user->userGroup);
|
||||
$this->currency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrencyByUserGroup($user->userGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -180,7 +180,7 @@ class General extends AbstractExtension
|
||||
if ('balance' === $key) {
|
||||
// balance in account currency.
|
||||
if (!$usePrimary) {
|
||||
$strings[] = app('amount')->formatAnything($currency, $balance, false);
|
||||
$strings[] = \FireflyIII\Support\Facades\Amount::formatAnything($currency, $balance, false);
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -188,14 +188,14 @@ class General extends AbstractExtension
|
||||
if ('pc_balance' === $key) {
|
||||
// balance in primary currency.
|
||||
if ($usePrimary) {
|
||||
$strings[] = app('amount')->formatAnything($primary, $balance, false);
|
||||
$strings[] = \FireflyIII\Support\Facades\Amount::formatAnything($primary, $balance, false);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
// for multi currency accounts.
|
||||
if ($usePrimary && $key !== $primary->code) {
|
||||
$strings[] = app('amount')->formatAnything(Amount::getTransactionCurrencyByCode($key), $balance, false);
|
||||
$strings[] = \FireflyIII\Support\Facades\Amount::formatAnything(Amount::getTransactionCurrencyByCode($key), $balance, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ class TransactionGroupTwig extends AbstractExtension
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
$colored = false;
|
||||
}
|
||||
$result = app('amount')->formatFlat($array['foreign_currency_symbol'], (int)$array['foreign_currency_decimal_places'], $amount, $colored);
|
||||
$result = \FireflyIII\Support\Facades\Amount::formatFlat($array['foreign_currency_symbol'], (int)$array['foreign_currency_decimal_places'], $amount, $colored);
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
return sprintf('<span class="text-info money-transfer">%s</span>', $result);
|
||||
}
|
||||
@@ -199,7 +199,7 @@ class TransactionGroupTwig extends AbstractExtension
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
$colored = false;
|
||||
}
|
||||
$result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
|
||||
$result = \FireflyIII\Support\Facades\Amount::formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
return sprintf('<span class="text-info money-transfer">%s</span>', $result);
|
||||
}
|
||||
@@ -230,7 +230,7 @@ class TransactionGroupTwig extends AbstractExtension
|
||||
$colored = false;
|
||||
}
|
||||
|
||||
$result = app('amount')->formatFlat($array['currency_symbol'], (int)$array['currency_decimal_places'], $amount, $colored);
|
||||
$result = \FireflyIII\Support\Facades\Amount::formatFlat($array['currency_symbol'], (int)$array['currency_decimal_places'], $amount, $colored);
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
return sprintf('<span class="text-info money-transfer">%s</span>', $result);
|
||||
}
|
||||
@@ -257,7 +257,7 @@ class TransactionGroupTwig extends AbstractExtension
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
$colored = false;
|
||||
}
|
||||
$result = app('amount')->formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
|
||||
$result = \FireflyIII\Support\Facades\Amount::formatFlat($currency->symbol, $currency->decimal_places, $amount, $colored);
|
||||
if (TransactionTypeEnum::TRANSFER->value === $type) {
|
||||
return sprintf('<span class="text-info money-transfer">%s</span>', $result);
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ trait TransactionValidation
|
||||
|
||||
/** @var AccountRepository $accountRepository */
|
||||
$accountRepository = app(AccountRepositoryInterface::class);
|
||||
$primaryCurrency = app('amount')->getPrimaryCurrency();
|
||||
$primaryCurrency = \FireflyIII\Support\Facades\Amount::getPrimaryCurrency();
|
||||
$sourceCurrency = $accountRepository->getAccountCurrency($source) ?? $primaryCurrency;
|
||||
$destinationCurrency = $accountRepository->getAccountCurrency($destination) ?? $primaryCurrency;
|
||||
// if both accounts have the same currency, continue.
|
||||
|
||||
Reference in New Issue
Block a user