mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Rename default to primary
This commit is contained in:
@@ -44,7 +44,7 @@ class FrontpageChartGenerator
|
||||
use AugumentData;
|
||||
|
||||
public bool $convertToPrimary = false;
|
||||
public TransactionCurrency $defaultCurrency;
|
||||
public TransactionCurrency $primaryCurrency;
|
||||
private AccountRepositoryInterface $accountRepos;
|
||||
private array $currencies;
|
||||
private NoCategoryRepositoryInterface $noCatRepos;
|
||||
|
@@ -61,7 +61,7 @@ class CurrencyForm
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['step'] = 'any';
|
||||
$defaultCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
|
||||
$primaryCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
|
||||
|
||||
/** @var Collection $currencies */
|
||||
$currencies = app('amount')->getCurrencies();
|
||||
@@ -72,15 +72,15 @@ class CurrencyForm
|
||||
$preFilled = [];
|
||||
}
|
||||
$key = 'amount_currency_id_'.$name;
|
||||
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $defaultCurrency->id;
|
||||
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $primaryCurrency->id;
|
||||
|
||||
app('log')->debug(sprintf('Sent currency ID is %d', $sentCurrencyId));
|
||||
|
||||
// find this currency in set of currencies:
|
||||
foreach ($currencies as $currency) {
|
||||
if ($currency->id === $sentCurrencyId) {
|
||||
$defaultCurrency = $currency;
|
||||
app('log')->debug(sprintf('default currency is now %s', $defaultCurrency->code));
|
||||
$primaryCurrency = $currency;
|
||||
app('log')->debug(sprintf('default currency is now %s', $primaryCurrency->code));
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -88,11 +88,11 @@ class CurrencyForm
|
||||
|
||||
// make sure value is formatted nicely:
|
||||
if (null !== $value && '' !== $value) {
|
||||
$value = app('steam')->bcround($value, $defaultCurrency->decimal_places);
|
||||
$value = app('steam')->bcround($value, $primaryCurrency->decimal_places);
|
||||
}
|
||||
|
||||
try {
|
||||
$html = view('form.'.$view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
$html = view('form.'.$view, compact('primaryCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
} catch (Throwable $e) {
|
||||
app('log')->debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
|
||||
$html = 'Could not render currencyField.';
|
||||
@@ -129,7 +129,7 @@ class CurrencyForm
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['step'] = 'any';
|
||||
$defaultCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
|
||||
$primaryCurrency = $options['currency'] ?? app('amount')->getPrimaryCurrency();
|
||||
|
||||
/** @var Collection $currencies */
|
||||
$currencies = app('amount')->getAllCurrencies();
|
||||
@@ -141,15 +141,15 @@ class CurrencyForm
|
||||
$preFilled = [];
|
||||
}
|
||||
$key = 'amount_currency_id_'.$name;
|
||||
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $defaultCurrency->id;
|
||||
$sentCurrencyId = array_key_exists($key, $preFilled) ? (int) $preFilled[$key] : $primaryCurrency->id;
|
||||
|
||||
app('log')->debug(sprintf('Sent currency ID is %d', $sentCurrencyId));
|
||||
|
||||
// find this currency in set of currencies:
|
||||
foreach ($currencies as $currency) {
|
||||
if ($currency->id === $sentCurrencyId) {
|
||||
$defaultCurrency = $currency;
|
||||
app('log')->debug(sprintf('default currency is now %s', $defaultCurrency->code));
|
||||
$primaryCurrency = $currency;
|
||||
app('log')->debug(sprintf('default currency is now %s', $primaryCurrency->code));
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -157,11 +157,11 @@ class CurrencyForm
|
||||
|
||||
// make sure value is formatted nicely:
|
||||
if (null !== $value && '' !== $value) {
|
||||
$value = app('steam')->bcround($value, $defaultCurrency->decimal_places);
|
||||
$value = app('steam')->bcround($value, $primaryCurrency->decimal_places);
|
||||
}
|
||||
|
||||
try {
|
||||
$html = view('form.'.$view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
$html = view('form.'.$view, compact('primaryCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
} catch (Throwable $e) {
|
||||
app('log')->debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
|
||||
$html = 'Could not render currencyField.';
|
||||
|
@@ -202,7 +202,7 @@ trait AugumentData
|
||||
$currency = $entry->transactionCurrency;
|
||||
if ($this->convertToPrimary) {
|
||||
// the sumExpenses method already handles this.
|
||||
$currency = $this->defaultCurrency;
|
||||
$currency = $this->primaryCurrency;
|
||||
}
|
||||
|
||||
// clone because these objects change each other.
|
||||
|
@@ -113,7 +113,7 @@ class Steam
|
||||
|
||||
if (!$convertToPrimary) {
|
||||
if (!$currency instanceof TransactionCurrency) {
|
||||
Log::debug(sprintf('Unset pc_balance and make defaultCurrency balance the balance for account #%d', $account->id));
|
||||
Log::debug(sprintf('Unset pc_balance and make primaryCurrency balance the balance for account #%d', $account->id));
|
||||
$set['balance'] = $set[$primaryCurrency->code] ?? '0';
|
||||
unset($set[$primaryCurrency->code]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user