Rename many references from native to primary.

This commit is contained in:
James Cole
2025-07-31 20:24:19 +02:00
parent 210bd83bd4
commit 6d3f2bd5e7
59 changed files with 128 additions and 146 deletions

View File

@@ -357,7 +357,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')->getNativeCurrency();
$currency = $this->getAccountCurrency($account) ?? app('amount')->getPrimaryCurrency();
$name = trans('firefly.reconciliation_account_name', ['name' => $account->name, 'currency' => $currency->code]);
/** @var AccountType $type */

View File

@@ -275,7 +275,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
];
$result[$currencyId]['sum'] = bcadd($result[$currencyId]['sum'], (string) $transaction->amount);
$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], $transaction->native_amount ?? '0');
if ($journal->foreign_currency_id === Amount::getNativeCurrency()->id) {
if ($journal->foreign_currency_id === Amount::getPrimaryCurrency()->id) {
$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], (string) $transaction->amount);
}
++$result[$currencyId]['count'];
@@ -411,7 +411,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
];
$result[$currencyId]['sum'] = bcadd($result[$currencyId]['sum'], (string) $transaction->amount);
$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], $transaction->native_amount ?? '0');
if ($journal->foreign_currency_id === Amount::getNativeCurrency()->id) {
if ($journal->foreign_currency_id === Amount::getPrimaryCurrency()->id) {
$result[$currencyId]['native_sum'] = bcadd($result[$currencyId]['native_sum'], (string) $transaction->amount);
}
++$result[$currencyId]['count'];
@@ -534,8 +534,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
Log::debug(sprintf('sumPaidInRange from %s to %s', $start->toW3cString(), $end->toW3cString()));
$bills = $this->getActiveBills();
$return = [];
$convertToNative = Amount::convertToNative($this->user);
$default = app('amount')->getNativeCurrency();
$convertToNative = Amount::convertToPrimary($this->user);
$default = app('amount')->getPrimaryCurrency();
/** @var Bill $bill */
foreach ($bills as $bill) {
@@ -600,8 +600,8 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface
app('log')->debug(sprintf('Now in sumUnpaidInRange("%s", "%s")', $start->format('Y-m-d'), $end->format('Y-m-d')));
$bills = $this->getActiveBills();
$return = [];
$convertToNative = Amount::convertToNative($this->user);
$default = app('amount')->getNativeCurrency();
$convertToNative = Amount::convertToPrimary($this->user);
$default = app('amount')->getPrimaryCurrency();
/** @var Bill $bill */
foreach ($bills as $bill) {

View File

@@ -142,8 +142,8 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface, U
Log::debug(sprintf('Found %d available budgets (already converted)', $availableBudgets->count()));
// use native amount if necessary?
$convertToNative = Amount::convertToNative($this->user);
$default = Amount::getNativeCurrency();
$convertToNative = Amount::convertToPrimary($this->user);
$default = Amount::getPrimaryCurrency();
/** @var AvailableBudget $availableBudget */
foreach ($availableBudgets as $availableBudget) {

View File

@@ -91,7 +91,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface
$limitRepository = app(BudgetLimitRepository::class);
$limitRepository->setUser($this->user);
$budgets = $this->getActiveBudgets();
$defaultCurrency = app('amount')->getNativeCurrency();
$defaultCurrency = app('amount')->getPrimaryCurrency();
$converter = new ExchangeRateConverter();
/** @var Budget $budget */

View File

@@ -142,7 +142,7 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
$array = [];
// if needs conversion to native.
$convertToNative = Amount::convertToNative($this->user);
$convertToNative = Amount::convertToPrimary($this->user);
$nativeCurrency = Amount::getPrimaryCurrencyByUserGroup($this->userGroup);
$currencyId = (int) $nativeCurrency->id;
$currencyCode = $nativeCurrency->code;

View File

@@ -358,8 +358,8 @@ class OperationsRepository implements OperationsRepositoryInterface, UserGroupIn
}
$collector->setCategories($categories);
$journals = $collector->getExtractedJournals();
$convertToNative = Amount::convertToNative($this->user);
$default = Amount::getNativeCurrency();
$convertToNative = Amount::convertToPrimary($this->user);
$default = Amount::getPrimaryCurrency();
$array = [];
foreach ($journals as $journal) {

View File

@@ -71,7 +71,7 @@ class BillRepository implements BillRepositoryInterface
{
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$bills = $this->getActiveBills();
$default = app('amount')->getNativeCurrency();
$default = app('amount')->getPrimaryCurrency();
$return = [];
$converter = new ExchangeRateConverter();
@@ -141,7 +141,7 @@ class BillRepository implements BillRepositoryInterface
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$bills = $this->getActiveBills();
$return = [];
$default = app('amount')->getNativeCurrency();
$default = app('amount')->getPrimaryCurrency();
$converter = new ExchangeRateConverter();
/** @var Bill $bill */

View File

@@ -44,7 +44,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__));
$return = [];
$converter = new ExchangeRateConverter();
$default = app('amount')->getNativeCurrency();
$default = app('amount')->getPrimaryCurrency();
$availableBudgets = $this->userGroup->availableBudgets()
->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))->get()