mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
Rename "native" references to "primary" or "pc".
This commit is contained in:
@@ -99,7 +99,7 @@ class AccountController extends Controller
|
|||||||
// this one is correct.
|
// this one is correct.
|
||||||
Log::debug(sprintf('accounts: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
Log::debug(sprintf('accounts: Call finalAccountBalance with date/time "%s"', $date->toIso8601String()));
|
||||||
$balance = Steam::finalAccountBalance($account, $date);
|
$balance = Steam::finalAccountBalance($account, $date);
|
||||||
$key = $this->convertToPrimary && $currency->id !== $this->primaryCurrency->id ? 'native_balance' : 'balance';
|
$key = $this->convertToPrimary && $currency->id !== $this->primaryCurrency->id ? 'pc_balance' : 'balance';
|
||||||
$useCurrency = $this->convertToPrimary && $currency->id !== $this->primaryCurrency->id ? $this->primaryCurrency : $currency;
|
$useCurrency = $this->convertToPrimary && $currency->id !== $this->primaryCurrency->id ? $this->primaryCurrency : $currency;
|
||||||
$amount = $balance[$key] ?? '0';
|
$amount = $balance[$key] ?? '0';
|
||||||
$nameWithBalance = sprintf(
|
$nameWithBalance = sprintf(
|
||||||
|
@@ -87,7 +87,7 @@ class AccountController extends Controller
|
|||||||
// move date to end of day
|
// move date to end of day
|
||||||
$queryParameters['start']->startOfDay();
|
$queryParameters['start']->startOfDay();
|
||||||
$queryParameters['end']->endOfDay();
|
$queryParameters['end']->endOfDay();
|
||||||
Log::debug(sprintf('dashboard(), convert to native: %s', var_export($this->convertToPrimary, true)));
|
Log::debug(sprintf('dashboard(), convert to primary: %s', var_export($this->convertToPrimary, true)));
|
||||||
|
|
||||||
// loop each account, and collect info:
|
// loop each account, and collect info:
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
@@ -111,7 +111,7 @@ class AccountController extends Controller
|
|||||||
|
|
||||||
|
|
||||||
$previous = array_values($range)[0]['balance'];
|
$previous = array_values($range)[0]['balance'];
|
||||||
$nativePrevious = null;
|
$pcPrevious = null;
|
||||||
if (!$currency instanceof TransactionCurrency) {
|
if (!$currency instanceof TransactionCurrency) {
|
||||||
$currency = $this->default;
|
$currency = $this->default;
|
||||||
}
|
}
|
||||||
@@ -132,12 +132,12 @@ class AccountController extends Controller
|
|||||||
'entries' => [],
|
'entries' => [],
|
||||||
];
|
];
|
||||||
if ($this->convertToPrimary) {
|
if ($this->convertToPrimary) {
|
||||||
$currentSet['native_entries'] = [];
|
$currentSet['pc_entries'] = [];
|
||||||
$currentSet['native_currency_id'] = (string)$this->primaryCurrency->id;
|
$currentSet['primary_currency_id'] = (string)$this->primaryCurrency->id;
|
||||||
$currentSet['native_currency_code'] = $this->primaryCurrency->code;
|
$currentSet['primary_currency_code'] = $this->primaryCurrency->code;
|
||||||
$currentSet['native_currency_symbol'] = $this->primaryCurrency->symbol;
|
$currentSet['primary_currency_symbol'] = $this->primaryCurrency->symbol;
|
||||||
$currentSet['native_currency_decimal_places'] = $this->primaryCurrency->decimal_places;
|
$currentSet['primary_currency_decimal_places'] = $this->primaryCurrency->decimal_places;
|
||||||
$nativePrevious = array_values($range)[0]['native_balance'];
|
$pcPrevious = array_values($range)[0]['pc_balance'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -149,12 +149,12 @@ class AccountController extends Controller
|
|||||||
$currentSet['entries'][$label] = $balance;
|
$currentSet['entries'][$label] = $balance;
|
||||||
|
|
||||||
|
|
||||||
// do the same for the native balance, if relevant:
|
// do the same for the primary currency balance, if relevant:
|
||||||
$nativeBalance = null;
|
$pcBalance = null;
|
||||||
if ($this->convertToPrimary) {
|
if ($this->convertToPrimary) {
|
||||||
$nativeBalance = array_key_exists($format, $range) ? $range[$format]['native_balance'] : $nativePrevious;
|
$pcBalance = array_key_exists($format, $range) ? $range[$format]['pc_balance'] : $pcPrevious;
|
||||||
$nativePrevious = $nativeBalance;
|
$pcPrevious = $pcBalance;
|
||||||
$currentSet['native_entries'][$label] = $nativeBalance;
|
$currentSet['pc_entries'][$label] = $pcBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentStart->addDay();
|
$currentStart->addDay();
|
||||||
@@ -195,7 +195,7 @@ class AccountController extends Controller
|
|||||||
$currentStart = clone $start;
|
$currentStart = clone $start;
|
||||||
$range = Steam::finalAccountBalanceInRange($account, $start, clone $end, $this->convertToPrimary);
|
$range = Steam::finalAccountBalanceInRange($account, $start, clone $end, $this->convertToPrimary);
|
||||||
$previous = array_values($range)[0]['balance'];
|
$previous = array_values($range)[0]['balance'];
|
||||||
$nativePrevious = null;
|
$pcPrevious = null;
|
||||||
$currentSet = [
|
$currentSet = [
|
||||||
'label' => $account->name,
|
'label' => $account->name,
|
||||||
'currency_id' => (string)$currency->id,
|
'currency_id' => (string)$currency->id,
|
||||||
@@ -209,18 +209,18 @@ class AccountController extends Controller
|
|||||||
'entries' => [],
|
'entries' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
// add "native_entries" if convertToNative is true:
|
// add "pc_entries" if convertToPrimary is true:
|
||||||
if ($this->convertToPrimary) {
|
if ($this->convertToPrimary) {
|
||||||
$currentSet['native_entries'] = [];
|
$currentSet['pc_entries'] = [];
|
||||||
$currentSet['native_currency_id'] = (string)$this->primaryCurrency->id;
|
$currentSet['primary_currency_id'] = (string)$this->primaryCurrency->id;
|
||||||
$currentSet['native_currency_code'] = $this->primaryCurrency->code;
|
$currentSet['primary_currency_code'] = $this->primaryCurrency->code;
|
||||||
$currentSet['native_currency_symbol'] = $this->primaryCurrency->symbol;
|
$currentSet['primary_currency_symbol'] = $this->primaryCurrency->symbol;
|
||||||
$currentSet['native_currency_decimal_places'] = $this->primaryCurrency->decimal_places;
|
$currentSet['primary_currency_decimal_places'] = $this->primaryCurrency->decimal_places;
|
||||||
$nativePrevious = array_values($range)[0]['native_balance'];
|
$pcPrevious = array_values($range)[0]['pc_balance'];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// also get the native balance if convertToNative is true:
|
// also get the primary balance if convertToPrimary is true:
|
||||||
while ($currentStart <= $end) {
|
while ($currentStart <= $end) {
|
||||||
$format = $currentStart->format('Y-m-d');
|
$format = $currentStart->format('Y-m-d');
|
||||||
$label = $currentStart->toAtomString();
|
$label = $currentStart->toAtomString();
|
||||||
@@ -230,12 +230,12 @@ class AccountController extends Controller
|
|||||||
$previous = $balance;
|
$previous = $balance;
|
||||||
$currentSet['entries'][$label] = $balance;
|
$currentSet['entries'][$label] = $balance;
|
||||||
|
|
||||||
// do the same for the native balance, if relevant:
|
// do the same for the primary balance, if relevant:
|
||||||
$nativeBalance = null;
|
$pcBalance = null;
|
||||||
if ($this->convertToPrimary) {
|
if ($this->convertToPrimary) {
|
||||||
$nativeBalance = array_key_exists($format, $range) ? $range[$format]['native_balance'] : $nativePrevious;
|
$pcBalance = array_key_exists($format, $range) ? $range[$format]['pc_balance'] : $pcPrevious;
|
||||||
$nativePrevious = $nativeBalance;
|
$pcPrevious = $pcBalance;
|
||||||
$currentSet['native_entries'][$label] = $nativeBalance;
|
$currentSet['pc_entries'][$label] = $pcBalance;
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentStart->addDay();
|
$currentStart->addDay();
|
||||||
|
@@ -264,7 +264,7 @@ class BudgetController extends Controller
|
|||||||
$compare = bccomp($limit->amount, (string)app('steam')->positive($result[$limitCurrencyId]['spent']));
|
$compare = bccomp($limit->amount, (string)app('steam')->positive($result[$limitCurrencyId]['spent']));
|
||||||
$result[$limitCurrencyId]['budgeted'] = $limit->amount;
|
$result[$limitCurrencyId]['budgeted'] = $limit->amount;
|
||||||
if (1 === $compare) {
|
if (1 === $compare) {
|
||||||
// convert this amount into the native currency:
|
// convert this amount into the primary currency:
|
||||||
$result[$limitCurrencyId]['left'] = bcadd($limit->amount, (string)$result[$limitCurrencyId]['spent']);
|
$result[$limitCurrencyId]['left'] = bcadd($limit->amount, (string)$result[$limitCurrencyId]['spent']);
|
||||||
}
|
}
|
||||||
if ($compare <= 0) {
|
if ($compare <= 0) {
|
||||||
|
@@ -69,8 +69,8 @@ class BillController extends Controller
|
|||||||
$bills = $request->getBills();
|
$bills = $request->getBills();
|
||||||
$start = $request->getStart();
|
$start = $request->getStart();
|
||||||
$end = $request->getEnd();
|
$end = $request->getEnd();
|
||||||
$convertToNative = Amount::convertToPrimary();
|
$convertToPrimary = Amount::convertToPrimary();
|
||||||
$default = Amount::getPrimaryCurrency();
|
$primary = Amount::getPrimaryCurrency();
|
||||||
$response = [];
|
$response = [];
|
||||||
|
|
||||||
// get all bills:
|
// get all bills:
|
||||||
@@ -90,14 +90,14 @@ class BillController extends Controller
|
|||||||
$currencyCode = $journal['currency_code'];
|
$currencyCode = $journal['currency_code'];
|
||||||
$field = 'amount';
|
$field = 'amount';
|
||||||
|
|
||||||
// use the native amount if the user wants to convert to native currency
|
// use the primary amount if the user wants to convert to primary currency
|
||||||
if ($convertToNative && $currencyId !== $default->id) {
|
if ($convertToPrimary && $currencyId !== $primary->id) {
|
||||||
$currencyId = $default->id;
|
$currencyId = $primary->id;
|
||||||
$currencyCode = $default->code;
|
$currencyCode = $primary->code;
|
||||||
$field = 'native_amount';
|
$field = 'pc_amount';
|
||||||
}
|
}
|
||||||
// use foreign amount when the foreign currency IS the default currency.
|
// use foreign amount when the foreign currency IS the default currency.
|
||||||
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
|
if ($convertToPrimary && $journal['currency_id'] !== $primary->id && $primary->id === $journal['foreign_currency_id']) {
|
||||||
$field = 'foreign_amount';
|
$field = 'foreign_amount';
|
||||||
}
|
}
|
||||||
Log::debug(sprintf('Journal #%d in bill #%d will use %s (%s %s)', $journal['transaction_group_id'], $billId, $field, $currencyCode, $journal[$field] ?? '0'));
|
Log::debug(sprintf('Journal #%d in bill #%d will use %s (%s %s)', $journal['transaction_group_id'], $billId, $field, $currencyCode, $journal[$field] ?? '0'));
|
||||||
@@ -132,8 +132,8 @@ class BillController extends Controller
|
|||||||
$accounts = $request->getAssetAccounts();
|
$accounts = $request->getAssetAccounts();
|
||||||
$start = $request->getStart();
|
$start = $request->getStart();
|
||||||
$end = $request->getEnd();
|
$end = $request->getEnd();
|
||||||
$convertToNative = Amount::convertToPrimary();
|
$convertToPrimary = Amount::convertToPrimary();
|
||||||
$default = Amount::getPrimaryCurrency();
|
$primary = Amount::getPrimaryCurrency();
|
||||||
$response = [];
|
$response = [];
|
||||||
|
|
||||||
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||||
@@ -148,14 +148,14 @@ class BillController extends Controller
|
|||||||
$currencyCode = $journal['currency_code'];
|
$currencyCode = $journal['currency_code'];
|
||||||
$field = 'amount';
|
$field = 'amount';
|
||||||
|
|
||||||
// use the native amount if the user wants to convert to native currency
|
// use the primary amount if the user wants to convert to primary currency
|
||||||
if ($convertToNative && $currencyId !== $default->id) {
|
if ($convertToPrimary && $currencyId !== $primary->id) {
|
||||||
$currencyId = $default->id;
|
$currencyId = $primary->id;
|
||||||
$currencyCode = $default->code;
|
$currencyCode = $primary->code;
|
||||||
$field = 'native_amount';
|
$field = 'pc_amount';
|
||||||
}
|
}
|
||||||
// use foreign amount when the foreign currency IS the default currency.
|
// use foreign amount when the foreign currency IS the default currency.
|
||||||
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
|
if ($convertToPrimary && $journal['currency_id'] !== $primary->id && $primary->id === $journal['foreign_currency_id']) {
|
||||||
$field = 'foreign_amount';
|
$field = 'foreign_amount';
|
||||||
}
|
}
|
||||||
Log::debug(sprintf('Journal #%d will use %s (%s %s)', $journal['transaction_group_id'], $field, $currencyCode, $journal[$field] ?? '0'));
|
Log::debug(sprintf('Journal #%d will use %s (%s %s)', $journal['transaction_group_id'], $field, $currencyCode, $journal[$field] ?? '0'));
|
||||||
|
@@ -47,8 +47,8 @@ class PeriodController extends Controller
|
|||||||
$start = $request->getStart();
|
$start = $request->getStart();
|
||||||
$end = $request->getEnd();
|
$end = $request->getEnd();
|
||||||
$response = [];
|
$response = [];
|
||||||
$convertToNative = Amount::convertToPrimary();
|
$convertToPrimary = Amount::convertToPrimary();
|
||||||
$default = Amount::getPrimaryCurrency();
|
$primary = Amount::getPrimaryCurrency();
|
||||||
|
|
||||||
// collect all expenses in this period (regardless of type)
|
// collect all expenses in this period (regardless of type)
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
@@ -59,19 +59,19 @@ class PeriodController extends Controller
|
|||||||
$amount = '0';
|
$amount = '0';
|
||||||
$currencyId = (int) $journal['currency_id'];
|
$currencyId = (int) $journal['currency_id'];
|
||||||
$currencyCode = $journal['currency_code'];
|
$currencyCode = $journal['currency_code'];
|
||||||
if ($convertToNative) {
|
if ($convertToPrimary) {
|
||||||
$amount = Amount::getAmountFromJournal($journal);
|
$amount = Amount::getAmountFromJournal($journal);
|
||||||
if ($default->id !== (int) $journal['currency_id'] && $default->id !== (int) $journal['foreign_currency_id']) {
|
if ($primary->id !== (int) $journal['currency_id'] && $primary->id !== (int) $journal['foreign_currency_id']) {
|
||||||
$currencyId = $default->id;
|
$currencyId = $primary->id;
|
||||||
$currencyCode = $default->code;
|
$currencyCode = $primary->code;
|
||||||
}
|
}
|
||||||
if ($default->id !== (int) $journal['currency_id'] && $default->id === (int) $journal['foreign_currency_id']) {
|
if ($primary->id !== (int) $journal['currency_id'] && $primary->id === (int) $journal['foreign_currency_id']) {
|
||||||
$currencyId = $journal['foreign_currency_id'];
|
$currencyId = $journal['foreign_currency_id'];
|
||||||
$currencyCode = $journal['foreign_currency_code'];
|
$currencyCode = $journal['foreign_currency_code'];
|
||||||
}
|
}
|
||||||
Log::debug(sprintf('[a] Add amount %s %s', $currencyCode, $amount));
|
Log::debug(sprintf('[a] Add amount %s %s', $currencyCode, $amount));
|
||||||
}
|
}
|
||||||
if (!$convertToNative) {
|
if (!$convertToPrimary) {
|
||||||
// ignore the amount in foreign currency.
|
// ignore the amount in foreign currency.
|
||||||
Log::debug(sprintf('[b] Add amount %s %s', $currencyCode, $journal['amount']));
|
Log::debug(sprintf('[b] Add amount %s %s', $currencyCode, $journal['amount']));
|
||||||
$amount = $journal['amount'];
|
$amount = $journal['amount'];
|
||||||
|
@@ -68,8 +68,8 @@ class TagController extends Controller
|
|||||||
$start = $request->getStart();
|
$start = $request->getStart();
|
||||||
$end = $request->getEnd();
|
$end = $request->getEnd();
|
||||||
$response = [];
|
$response = [];
|
||||||
$convertToNative = Amount::convertToPrimary();
|
$convertToPrimary = Amount::convertToPrimary();
|
||||||
$default = Amount::getPrimaryCurrency();
|
$primary = Amount::getPrimaryCurrency();
|
||||||
|
|
||||||
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
@@ -83,19 +83,19 @@ class TagController extends Controller
|
|||||||
$amount = '0';
|
$amount = '0';
|
||||||
$currencyId = (int) $journal['currency_id'];
|
$currencyId = (int) $journal['currency_id'];
|
||||||
$currencyCode = $journal['currency_code'];
|
$currencyCode = $journal['currency_code'];
|
||||||
if ($convertToNative) {
|
if ($convertToPrimary) {
|
||||||
$amount = Amount::getAmountFromJournal($journal);
|
$amount = Amount::getAmountFromJournal($journal);
|
||||||
if ($default->id !== (int) $journal['currency_id'] && $default->id !== (int) $journal['foreign_currency_id']) {
|
if ($primary->id !== (int) $journal['currency_id'] && $primary->id !== (int) $journal['foreign_currency_id']) {
|
||||||
$currencyId = $default->id;
|
$currencyId = $primary->id;
|
||||||
$currencyCode = $default->code;
|
$currencyCode = $primary->code;
|
||||||
}
|
}
|
||||||
if ($default->id !== (int) $journal['currency_id'] && $default->id === (int) $journal['foreign_currency_id']) {
|
if ($primary->id !== (int) $journal['currency_id'] && $primary->id === (int) $journal['foreign_currency_id']) {
|
||||||
$currencyId = $journal['foreign_currency_id'];
|
$currencyId = $journal['foreign_currency_id'];
|
||||||
$currencyCode = $journal['foreign_currency_code'];
|
$currencyCode = $journal['foreign_currency_code'];
|
||||||
}
|
}
|
||||||
Log::debug(sprintf('[a] Add amount %s %s', $currencyCode, $amount));
|
Log::debug(sprintf('[a] Add amount %s %s', $currencyCode, $amount));
|
||||||
}
|
}
|
||||||
if (!$convertToNative) {
|
if (!$convertToPrimary) {
|
||||||
// ignore the amount in foreign currency.
|
// ignore the amount in foreign currency.
|
||||||
Log::debug(sprintf('[b] Add amount %s %s', $currencyCode, $journal['amount']));
|
Log::debug(sprintf('[b] Add amount %s %s', $currencyCode, $journal['amount']));
|
||||||
$amount = $journal['amount'];
|
$amount = $journal['amount'];
|
||||||
|
@@ -46,8 +46,8 @@ class PeriodController extends Controller
|
|||||||
$start = $request->getStart();
|
$start = $request->getStart();
|
||||||
$end = $request->getEnd();
|
$end = $request->getEnd();
|
||||||
$response = [];
|
$response = [];
|
||||||
$convertToNative = Amount::convertToPrimary();
|
$convertToPrimary = Amount::convertToPrimary();
|
||||||
$default = Amount::getPrimaryCurrency();
|
$primary = Amount::getPrimaryCurrency();
|
||||||
|
|
||||||
// collect all expenses in this period (regardless of type)
|
// collect all expenses in this period (regardless of type)
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
@@ -57,15 +57,15 @@ class PeriodController extends Controller
|
|||||||
// currency
|
// currency
|
||||||
$currencyId = $journal['currency_id'];
|
$currencyId = $journal['currency_id'];
|
||||||
$currencyCode = $journal['currency_code'];
|
$currencyCode = $journal['currency_code'];
|
||||||
$field = $convertToNative && $currencyId !== $default->id ? 'native_amount' : 'amount';
|
$field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';
|
||||||
|
|
||||||
// perhaps use default currency instead?
|
// perhaps use default currency instead?
|
||||||
if ($convertToNative && $journal['currency_id'] !== $default->id) {
|
if ($convertToPrimary && $journal['currency_id'] !== $primary->id) {
|
||||||
$currencyId = $default->id;
|
$currencyId = $primary->id;
|
||||||
$currencyCode = $default->code;
|
$currencyCode = $primary->code;
|
||||||
}
|
}
|
||||||
// use foreign amount when the foreign currency IS the default currency.
|
// use foreign amount when the foreign currency IS the default currency.
|
||||||
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
|
if ($convertToPrimary && $journal['currency_id'] !== $primary->id && $primary->id === $journal['foreign_currency_id']) {
|
||||||
$field = 'foreign_amount';
|
$field = 'foreign_amount';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -68,8 +68,8 @@ class TagController extends Controller
|
|||||||
$start = $request->getStart();
|
$start = $request->getStart();
|
||||||
$end = $request->getEnd();
|
$end = $request->getEnd();
|
||||||
$response = [];
|
$response = [];
|
||||||
$convertToNative = Amount::convertToPrimary();
|
$convertToPrimary = Amount::convertToPrimary();
|
||||||
$default = Amount::getPrimaryCurrency();
|
$primary = Amount::getPrimaryCurrency();
|
||||||
|
|
||||||
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
@@ -82,15 +82,15 @@ class TagController extends Controller
|
|||||||
// currency
|
// currency
|
||||||
$currencyId = $journal['currency_id'];
|
$currencyId = $journal['currency_id'];
|
||||||
$currencyCode = $journal['currency_code'];
|
$currencyCode = $journal['currency_code'];
|
||||||
$field = $convertToNative && $currencyId !== $default->id ? 'native_amount' : 'amount';
|
$field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';
|
||||||
|
|
||||||
// perhaps use default currency instead?
|
// perhaps use default currency instead?
|
||||||
if ($convertToNative && $journal['currency_id'] !== $default->id) {
|
if ($convertToPrimary && $journal['currency_id'] !== $primary->id) {
|
||||||
$currencyId = $default->id;
|
$currencyId = $primary->id;
|
||||||
$currencyCode = $default->code;
|
$currencyCode = $primary->code;
|
||||||
}
|
}
|
||||||
// use foreign amount when the foreign currency IS the default currency.
|
// use foreign amount when the foreign currency IS the default currency.
|
||||||
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
|
if ($convertToPrimary && $journal['currency_id'] !== $primary->id && $primary->id === $journal['foreign_currency_id']) {
|
||||||
$field = 'foreign_amount';
|
$field = 'foreign_amount';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,8 +46,8 @@ class PeriodController extends Controller
|
|||||||
$start = $request->getStart();
|
$start = $request->getStart();
|
||||||
$end = $request->getEnd();
|
$end = $request->getEnd();
|
||||||
$response = [];
|
$response = [];
|
||||||
$convertToNative = Amount::convertToPrimary();
|
$convertToPrimary = Amount::convertToPrimary();
|
||||||
$default = Amount::getPrimaryCurrency();
|
$primary = Amount::getPrimaryCurrency();
|
||||||
|
|
||||||
// collect all expenses in this period (regardless of type)
|
// collect all expenses in this period (regardless of type)
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
@@ -57,15 +57,15 @@ class PeriodController extends Controller
|
|||||||
// currency
|
// currency
|
||||||
$currencyId = $journal['currency_id'];
|
$currencyId = $journal['currency_id'];
|
||||||
$currencyCode = $journal['currency_code'];
|
$currencyCode = $journal['currency_code'];
|
||||||
$field = $convertToNative && $currencyId !== $default->id ? 'native_amount' : 'amount';
|
$field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';
|
||||||
|
|
||||||
// perhaps use default currency instead?
|
// perhaps use default currency instead?
|
||||||
if ($convertToNative && $journal['currency_id'] !== $default->id) {
|
if ($convertToPrimary && $journal['currency_id'] !== $primary->id) {
|
||||||
$currencyId = $default->id;
|
$currencyId = $primary->id;
|
||||||
$currencyCode = $default->code;
|
$currencyCode = $primary->code;
|
||||||
}
|
}
|
||||||
// use foreign amount when the foreign currency IS the default currency.
|
// use foreign amount when the foreign currency IS the default currency.
|
||||||
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
|
if ($convertToPrimary && $journal['currency_id'] !== $primary->id && $primary->id === $journal['foreign_currency_id']) {
|
||||||
$field = 'foreign_amount';
|
$field = 'foreign_amount';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -66,8 +66,8 @@ class TagController extends Controller
|
|||||||
$start = $request->getStart();
|
$start = $request->getStart();
|
||||||
$end = $request->getEnd();
|
$end = $request->getEnd();
|
||||||
$response = [];
|
$response = [];
|
||||||
$convertToNative = Amount::convertToPrimary();
|
$convertToPrimary = Amount::convertToPrimary();
|
||||||
$default = Amount::getPrimaryCurrency();
|
$primary = Amount::getPrimaryCurrency();
|
||||||
|
|
||||||
|
|
||||||
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
// collect all expenses in this period (regardless of type) by the given bills and accounts.
|
||||||
@@ -81,15 +81,15 @@ class TagController extends Controller
|
|||||||
// currency
|
// currency
|
||||||
$currencyId = $journal['currency_id'];
|
$currencyId = $journal['currency_id'];
|
||||||
$currencyCode = $journal['currency_code'];
|
$currencyCode = $journal['currency_code'];
|
||||||
$field = $convertToNative && $currencyId !== $default->id ? 'native_amount' : 'amount';
|
$field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';
|
||||||
|
|
||||||
// perhaps use default currency instead?
|
// perhaps use default currency instead?
|
||||||
if ($convertToNative && $journal['currency_id'] !== $default->id) {
|
if ($convertToPrimary && $journal['currency_id'] !== $primary->id) {
|
||||||
$currencyId = $default->id;
|
$currencyId = $primary->id;
|
||||||
$currencyCode = $default->code;
|
$currencyCode = $primary->code;
|
||||||
}
|
}
|
||||||
// use foreign amount when the foreign currency IS the default currency.
|
// use foreign amount when the foreign currency IS the default currency.
|
||||||
if ($convertToNative && $journal['currency_id'] !== $default->id && $default->id === $journal['foreign_currency_id']) {
|
if ($convertToPrimary && $journal['currency_id'] !== $primary->id && $primary->id === $journal['foreign_currency_id']) {
|
||||||
$field = 'foreign_amount';
|
$field = 'foreign_amount';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -97,7 +97,7 @@ class ShowController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new AccountEnrichment();
|
$enrichment = new AccountEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$enrichment->setNative($this->primaryCurrency);
|
$enrichment->setPrimary($this->primaryCurrency);
|
||||||
$accounts = $enrichment->enrich($accounts);
|
$accounts = $enrichment->enrich($accounts);
|
||||||
|
|
||||||
// make paginator:
|
// make paginator:
|
||||||
@@ -132,7 +132,7 @@ class ShowController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new AccountEnrichment();
|
$enrichment = new AccountEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$enrichment->setNative($this->primaryCurrency);
|
$enrichment->setPrimary($this->primaryCurrency);
|
||||||
$account = $enrichment->enrichSingle($account);
|
$account = $enrichment->enrichSingle($account);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -76,7 +76,7 @@ class StoreController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new AccountEnrichment();
|
$enrichment = new AccountEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$enrichment->setNative($this->primaryCurrency);
|
$enrichment->setPrimary($this->primaryCurrency);
|
||||||
$account = $enrichment->enrichSingle($account);
|
$account = $enrichment->enrichSingle($account);
|
||||||
|
|
||||||
/** @var AccountTransformer $transformer */
|
/** @var AccountTransformer $transformer */
|
||||||
|
@@ -81,7 +81,7 @@ class UpdateController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new AccountEnrichment();
|
$enrichment = new AccountEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$enrichment->setNative($this->primaryCurrency);
|
$enrichment->setPrimary($this->primaryCurrency);
|
||||||
$account = $enrichment->enrichSingle($account);
|
$account = $enrichment->enrichSingle($account);
|
||||||
|
|
||||||
/** @var AccountTransformer $transformer */
|
/** @var AccountTransformer $transformer */
|
||||||
|
@@ -83,8 +83,8 @@ class ShowController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new SubscriptionEnrichment();
|
$enrichment = new SubscriptionEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$enrichment->setConvertToNative($this->convertToPrimary);
|
$enrichment->setConvertToPrimary($this->convertToPrimary);
|
||||||
$enrichment->setNative($this->primaryCurrency);
|
$enrichment->setPrimary($this->primaryCurrency);
|
||||||
$enrichment->setStart($this->parameters->get('start'));
|
$enrichment->setStart($this->parameters->get('start'));
|
||||||
$enrichment->setEnd($this->parameters->get('end'));
|
$enrichment->setEnd($this->parameters->get('end'));
|
||||||
$bills = $enrichment->enrich($bills);
|
$bills = $enrichment->enrich($bills);
|
||||||
@@ -114,8 +114,8 @@ class ShowController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new SubscriptionEnrichment();
|
$enrichment = new SubscriptionEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$enrichment->setConvertToNative($this->convertToPrimary);
|
$enrichment->setConvertToPrimary($this->convertToPrimary);
|
||||||
$enrichment->setNative($this->primaryCurrency);
|
$enrichment->setPrimary($this->primaryCurrency);
|
||||||
$enrichment->setStart($this->parameters->get('start'));
|
$enrichment->setStart($this->parameters->get('start'));
|
||||||
$enrichment->setEnd($this->parameters->get('end'));
|
$enrichment->setEnd($this->parameters->get('end'));
|
||||||
$bill = $enrichment->enrichSingle($bill);
|
$bill = $enrichment->enrichSingle($bill);
|
||||||
|
@@ -79,8 +79,8 @@ class StoreController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new SubscriptionEnrichment();
|
$enrichment = new SubscriptionEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$enrichment->setConvertToNative($this->convertToPrimary);
|
$enrichment->setConvertToPrimary($this->convertToPrimary);
|
||||||
$enrichment->setNative($this->primaryCurrency);
|
$enrichment->setPrimary($this->primaryCurrency);
|
||||||
$enrichment->setStart($this->parameters->get('start'));
|
$enrichment->setStart($this->parameters->get('start'));
|
||||||
$enrichment->setEnd($this->parameters->get('end'));
|
$enrichment->setEnd($this->parameters->get('end'));
|
||||||
$bill = $enrichment->enrichSingle($bill);
|
$bill = $enrichment->enrichSingle($bill);
|
||||||
|
@@ -74,8 +74,8 @@ class UpdateController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new SubscriptionEnrichment();
|
$enrichment = new SubscriptionEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$enrichment->setConvertToNative($this->convertToPrimary);
|
$enrichment->setConvertToPrimary($this->convertToPrimary);
|
||||||
$enrichment->setNative($this->primaryCurrency);
|
$enrichment->setPrimary($this->primaryCurrency);
|
||||||
$enrichment->setStart($this->parameters->get('start'));
|
$enrichment->setStart($this->parameters->get('start'));
|
||||||
$enrichment->setEnd($this->parameters->get('end'));
|
$enrichment->setEnd($this->parameters->get('end'));
|
||||||
$bill = $enrichment->enrichSingle($bill);
|
$bill = $enrichment->enrichSingle($bill);
|
||||||
|
@@ -85,8 +85,8 @@ class ListController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new SubscriptionEnrichment();
|
$enrichment = new SubscriptionEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$enrichment->setConvertToNative($this->convertToPrimary);
|
$enrichment->setConvertToPrimary($this->convertToPrimary);
|
||||||
$enrichment->setNative($this->primaryCurrency);
|
$enrichment->setPrimary($this->primaryCurrency);
|
||||||
$enrichment->setStart($this->parameters->get('start'));
|
$enrichment->setStart($this->parameters->get('start'));
|
||||||
$enrichment->setEnd($this->parameters->get('end'));
|
$enrichment->setEnd($this->parameters->get('end'));
|
||||||
$bills = $enrichment->enrich($bills);
|
$bills = $enrichment->enrich($bills);
|
||||||
|
@@ -84,7 +84,7 @@ class ListController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new AccountEnrichment();
|
$enrichment = new AccountEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$enrichment->setNative($this->primaryCurrency);
|
$enrichment->setPrimary($this->primaryCurrency);
|
||||||
$accounts = $enrichment->enrich($accounts);
|
$accounts = $enrichment->enrich($accounts);
|
||||||
|
|
||||||
// make paginator:
|
// make paginator:
|
||||||
|
@@ -108,7 +108,7 @@ class ListController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new AccountEnrichment();
|
$enrichment = new AccountEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$enrichment->setNative($this->primaryCurrency);
|
$enrichment->setPrimary($this->primaryCurrency);
|
||||||
$accounts = $enrichment->enrich($accounts);
|
$accounts = $enrichment->enrich($accounts);
|
||||||
|
|
||||||
// make paginator:
|
// make paginator:
|
||||||
@@ -188,8 +188,8 @@ class ListController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new SubscriptionEnrichment();
|
$enrichment = new SubscriptionEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$enrichment->setConvertToNative($this->convertToPrimary);
|
$enrichment->setConvertToPrimary($this->convertToPrimary);
|
||||||
$enrichment->setNative($this->primaryCurrency);
|
$enrichment->setPrimary($this->primaryCurrency);
|
||||||
$enrichment->setStart($this->parameters->get('start'));
|
$enrichment->setStart($this->parameters->get('start'));
|
||||||
$enrichment->setEnd($this->parameters->get('end'));
|
$enrichment->setEnd($this->parameters->get('end'));
|
||||||
$bills = $enrichment->enrichSingle($bills);
|
$bills = $enrichment->enrichSingle($bills);
|
||||||
|
@@ -107,7 +107,7 @@ class ShowController extends Controller
|
|||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = auth()->user();
|
$user = auth()->user();
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
$this->parameters->set('nativeCurrency', $this->primaryCurrency);
|
$this->parameters->set('primaryCurrency', $this->primaryCurrency);
|
||||||
|
|
||||||
// update fields with user info.
|
// update fields with user info.
|
||||||
$currency->refreshForUser($user);
|
$currency->refreshForUser($user);
|
||||||
@@ -122,9 +122,6 @@ class ShowController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This endpoint is documented at:
|
|
||||||
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/currencies/getNativeCurrency
|
|
||||||
*
|
|
||||||
* Show a currency.
|
* Show a currency.
|
||||||
*
|
*
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
|
@@ -99,11 +99,6 @@ class UpdateController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This endpoint is documented at:
|
|
||||||
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/currencies/nativeCurrency
|
|
||||||
*
|
|
||||||
* Make the currency a default currency.
|
|
||||||
*
|
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public function makeDefault(TransactionCurrency $currency): JsonResponse
|
public function makeDefault(TransactionCurrency $currency): JsonResponse
|
||||||
|
@@ -89,7 +89,7 @@ class AccountController extends Controller
|
|||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
$enrichment = new AccountEnrichment();
|
$enrichment = new AccountEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$enrichment->setNative($this->primaryCurrency);
|
$enrichment->setPrimary($this->primaryCurrency);
|
||||||
$accounts = $enrichment->enrich($accounts);
|
$accounts = $enrichment->enrich($accounts);
|
||||||
|
|
||||||
/** @var AccountTransformer $transformer */
|
/** @var AccountTransformer $transformer */
|
||||||
|
@@ -127,13 +127,13 @@ class BasicController extends Controller
|
|||||||
{
|
{
|
||||||
Log::debug('getBalanceInformation');
|
Log::debug('getBalanceInformation');
|
||||||
// some config settings
|
// some config settings
|
||||||
$convertToNative = Amount::convertToPrimary();
|
$convertToPrimary = Amount::convertToPrimary();
|
||||||
$default = Amount::getPrimaryCurrency();
|
$primary = Amount::getPrimaryCurrency();
|
||||||
// prep some arrays:
|
// prep some arrays:
|
||||||
$sums = [];
|
$sums = [];
|
||||||
$return = [];
|
$return = [];
|
||||||
$currencies = [
|
$currencies = [
|
||||||
$default->id => $default,
|
$primary->id => $primary,
|
||||||
];
|
];
|
||||||
|
|
||||||
// collect income of user using the new group collector.
|
// collect income of user using the new group collector.
|
||||||
@@ -151,32 +151,32 @@ class BasicController extends Controller
|
|||||||
$set = $collector->setRange($start, $end)->setPage($this->parameters->get('page'))->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->getExtractedJournals();
|
$set = $collector->setRange($start, $end)->setPage($this->parameters->get('page'))->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->getExtractedJournals();
|
||||||
$expenses = $summarizer->groupByCurrencyId($set, 'negative', false);
|
$expenses = $summarizer->groupByCurrencyId($set, 'negative', false);
|
||||||
|
|
||||||
// if convert to native, do so right now.
|
// if convert to primary, do so right now.
|
||||||
if ($convertToNative) {
|
if ($convertToPrimary) {
|
||||||
$newExpenses = [
|
$newExpenses = [
|
||||||
$default->id => [
|
$primary->id => [
|
||||||
'currency_id' => $default->id,
|
'currency_id' => $primary->id,
|
||||||
'currency_code' => $default->code,
|
'currency_code' => $primary->code,
|
||||||
'currency_symbol' => $default->symbol,
|
'currency_symbol' => $primary->symbol,
|
||||||
'currency_decimal_places' => $default->decimal_places,
|
'currency_decimal_places' => $primary->decimal_places,
|
||||||
'sum' => '0',
|
'sum' => '0',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$newIncomes = [
|
$newIncomes = [
|
||||||
$default->id => [
|
$primary->id => [
|
||||||
'currency_id' => $default->id,
|
'currency_id' => $primary->id,
|
||||||
'currency_code' => $default->code,
|
'currency_code' => $primary->code,
|
||||||
'currency_symbol' => $default->symbol,
|
'currency_symbol' => $primary->symbol,
|
||||||
'currency_decimal_places' => $default->decimal_places,
|
'currency_decimal_places' => $primary->decimal_places,
|
||||||
'sum' => '0',
|
'sum' => '0',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$sums = [
|
$sums = [
|
||||||
$default->id => [
|
$primary->id => [
|
||||||
'currency_id' => $default->id,
|
'currency_id' => $primary->id,
|
||||||
'currency_code' => $default->code,
|
'currency_code' => $primary->code,
|
||||||
'currency_symbol' => $default->symbol,
|
'currency_symbol' => $primary->symbol,
|
||||||
'currency_decimal_places' => $default->decimal_places,
|
'currency_decimal_places' => $primary->decimal_places,
|
||||||
'sum' => '0',
|
'sum' => '0',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@@ -188,36 +188,36 @@ class BasicController extends Controller
|
|||||||
// loop over either one.
|
// loop over either one.
|
||||||
foreach ($array as $entry) {
|
foreach ($array as $entry) {
|
||||||
|
|
||||||
// if it is the native currency already.
|
// if it is the primary currency already.
|
||||||
if ($entry['currency_id'] === $default->id) {
|
if ($entry['currency_id'] === $primary->id) {
|
||||||
$sums[$default->id]['sum'] = bcadd((string) $entry['sum'], $sums[$default->id]['sum']);
|
$sums[$primary->id]['sum'] = bcadd((string) $entry['sum'], $sums[$primary->id]['sum']);
|
||||||
|
|
||||||
// don't forget to add it to newExpenses and newIncome
|
// don't forget to add it to newExpenses and newIncome
|
||||||
if (0 === $index) {
|
if (0 === $index) {
|
||||||
$newExpenses[$default->id]['sum'] = bcadd($newExpenses[$default->id]['sum'], (string) $entry['sum']);
|
$newExpenses[$primary->id]['sum'] = bcadd($newExpenses[$primary->id]['sum'], (string) $entry['sum']);
|
||||||
}
|
}
|
||||||
if (1 === $index) {
|
if (1 === $index) {
|
||||||
$newIncomes[$default->id]['sum'] = bcadd($newIncomes[$default->id]['sum'], (string) $entry['sum']);
|
$newIncomes[$primary->id]['sum'] = bcadd($newIncomes[$primary->id]['sum'], (string) $entry['sum']);
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$currencies[$entry['currency_id']] ??= $this->currencyRepos->find($entry['currency_id']);
|
$currencies[$entry['currency_id']] ??= $this->currencyRepos->find($entry['currency_id']);
|
||||||
$convertedSum = $converter->convert($currencies[$entry['currency_id']], $default, $start, $entry['sum']);
|
$convertedSum = $converter->convert($currencies[$entry['currency_id']], $primary, $start, $entry['sum']);
|
||||||
$sums[$default->id]['sum'] = bcadd($sums[$default->id]['sum'], $convertedSum);
|
$sums[$primary->id]['sum'] = bcadd($sums[$primary->id]['sum'], $convertedSum);
|
||||||
if (0 === $index) {
|
if (0 === $index) {
|
||||||
$newExpenses[$default->id]['sum'] = bcadd($newExpenses[$default->id]['sum'], $convertedSum);
|
$newExpenses[$primary->id]['sum'] = bcadd($newExpenses[$primary->id]['sum'], $convertedSum);
|
||||||
}
|
}
|
||||||
if (1 === $index) {
|
if (1 === $index) {
|
||||||
$newIncomes[$default->id]['sum'] = bcadd($newIncomes[$default->id]['sum'], $convertedSum);
|
$newIncomes[$primary->id]['sum'] = bcadd($newIncomes[$primary->id]['sum'], $convertedSum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$incomes = $newIncomes;
|
$incomes = $newIncomes;
|
||||||
$expenses = $newExpenses;
|
$expenses = $newExpenses;
|
||||||
}
|
}
|
||||||
if (!$convertToNative) {
|
if (!$convertToPrimary) {
|
||||||
foreach ([$expenses, $incomes] as $array) {
|
foreach ([$expenses, $incomes] as $array) {
|
||||||
foreach ($array as $entry) {
|
foreach ($array as $entry) {
|
||||||
$currencyId = $entry['currency_id'];
|
$currencyId = $entry['currency_id'];
|
||||||
@@ -626,7 +626,7 @@ class BasicController extends Controller
|
|||||||
$netWorthSet = $netWorthHelper->byAccounts($filtered, $end);
|
$netWorthSet = $netWorthHelper->byAccounts($filtered, $end);
|
||||||
$return = [];
|
$return = [];
|
||||||
foreach ($netWorthSet as $key => $data) {
|
foreach ($netWorthSet as $key => $data) {
|
||||||
if ('native' === $key) {
|
if ('pc' === $key) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$amount = $data['balance'];
|
$amount = $data['balance'];
|
||||||
|
@@ -85,7 +85,7 @@ class PreferencesController extends Controller
|
|||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
|
||||||
if ('currencyPreference' === $preference->name) {
|
if ('currencyPreference' === $preference->name) {
|
||||||
throw new FireflyException('Please use api/v1/currencies/native instead.');
|
throw new FireflyException('Please use api/v1/currencies/primary instead.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var PreferenceTransformer $transformer */
|
/** @var PreferenceTransformer $transformer */
|
||||||
@@ -132,7 +132,7 @@ class PreferencesController extends Controller
|
|||||||
public function update(PreferenceUpdateRequest $request, Preference $preference): JsonResponse
|
public function update(PreferenceUpdateRequest $request, Preference $preference): JsonResponse
|
||||||
{
|
{
|
||||||
if ('currencyPreference' === $preference->name) {
|
if ('currencyPreference' === $preference->name) {
|
||||||
throw new FireflyException('Please use api/v1/currencies/native instead.');
|
throw new FireflyException('Please use api/v1/currencies/primary instead.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
@@ -40,8 +40,8 @@ class UpdateRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
$fields = [
|
$fields = [
|
||||||
'title' => ['title', 'convertString'],
|
'title' => ['title', 'convertString'],
|
||||||
'native_currency_id' => ['native_currency_id', 'convertInteger'],
|
'primary_currency_id' => ['primary_currency_id', 'convertInteger'],
|
||||||
'native_currency_code' => ['native_currency_code', 'convertString'],
|
'primary_currency_code' => ['primary_currency_code', 'convertString'],
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->getAllData($fields);
|
return $this->getAllData($fields);
|
||||||
@@ -54,8 +54,8 @@ class UpdateRequest extends FormRequest
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => ['required', 'min:1', 'max:255'],
|
'title' => ['required', 'min:1', 'max:255'],
|
||||||
'native_currency_id' => 'exists:transaction_currencies,id',
|
'primary_currency_id' => 'exists:transaction_currencies,id',
|
||||||
'native_currency_code' => 'exists:transaction_currencies,code',
|
'primary_currency_code' => 'exists:transaction_currencies,code',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user