mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 18:41:08 +00:00
Fix bad index
This commit is contained in:
@@ -57,36 +57,36 @@ class AccountBalanceGrouped
|
|||||||
foreach ($this->data as $currency) {
|
foreach ($this->data as $currency) {
|
||||||
// income and expense array prepped:
|
// income and expense array prepped:
|
||||||
$income = [
|
$income = [
|
||||||
'label' => 'earned',
|
'label' => 'earned',
|
||||||
'currency_id' => (string)$currency['currency_id'],
|
'currency_id' => (string) $currency['currency_id'],
|
||||||
'currency_symbol' => $currency['currency_symbol'],
|
'currency_symbol' => $currency['currency_symbol'],
|
||||||
'currency_code' => $currency['currency_code'],
|
'currency_code' => $currency['currency_code'],
|
||||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||||
'native_currency_id' => (string)$currency['native_currency_id'],
|
'native_currency_id' => (string) $currency['native_currency_id'],
|
||||||
'native_currency_symbol' => $currency['native_currency_symbol'],
|
'native_currency_symbol' => $currency['native_currency_symbol'],
|
||||||
'native_currency_code' => $currency['native_currency_code'],
|
'native_currency_code' => $currency['native_currency_code'],
|
||||||
'native_currency_decimal_places' => $currency['native_currency_decimal_places'],
|
'native_currency_decimal_places' => $currency['native_currency_decimal_places'],
|
||||||
'start' => $this->start->toAtomString(),
|
'start' => $this->start->toAtomString(),
|
||||||
'end' => $this->end->toAtomString(),
|
'end' => $this->end->toAtomString(),
|
||||||
'period' => $this->preferredRange,
|
'period' => $this->preferredRange,
|
||||||
'entries' => [],
|
'entries' => [],
|
||||||
'native_entries' => [],
|
'native_entries' => [],
|
||||||
];
|
];
|
||||||
$expense = [
|
$expense = [
|
||||||
'label' => 'spent',
|
'label' => 'spent',
|
||||||
'currency_id' => (string)$currency['currency_id'],
|
'currency_id' => (string) $currency['currency_id'],
|
||||||
'currency_symbol' => $currency['currency_symbol'],
|
'currency_symbol' => $currency['currency_symbol'],
|
||||||
'currency_code' => $currency['currency_code'],
|
'currency_code' => $currency['currency_code'],
|
||||||
'currency_decimal_places' => $currency['currency_decimal_places'],
|
'currency_decimal_places' => $currency['currency_decimal_places'],
|
||||||
'native_currency_id' => (string)$currency['native_currency_id'],
|
'native_currency_id' => (string) $currency['native_currency_id'],
|
||||||
'native_currency_symbol' => $currency['native_currency_symbol'],
|
'native_currency_symbol' => $currency['native_currency_symbol'],
|
||||||
'native_currency_code' => $currency['native_currency_code'],
|
'native_currency_code' => $currency['native_currency_code'],
|
||||||
'native_currency_decimal_places' => $currency['native_currency_decimal_places'],
|
'native_currency_decimal_places' => $currency['native_currency_decimal_places'],
|
||||||
'start' => $this->start->toAtomString(),
|
'start' => $this->start->toAtomString(),
|
||||||
'end' => $this->end->toAtomString(),
|
'end' => $this->end->toAtomString(),
|
||||||
'period' => $this->preferredRange,
|
'period' => $this->preferredRange,
|
||||||
'entries' => [],
|
'entries' => [],
|
||||||
'native_entries' => [],
|
'native_entries' => [],
|
||||||
];
|
];
|
||||||
// loop all possible periods between $start and $end, and add them to the correct dataset.
|
// loop all possible periods between $start and $end, and add them to the correct dataset.
|
||||||
$currentStart = clone $this->start;
|
$currentStart = clone $this->start;
|
||||||
@@ -98,8 +98,8 @@ class AccountBalanceGrouped
|
|||||||
$expense['entries'][$label] = app('steam')->bcround($currency[$key]['spent'] ?? '0', $currency['currency_decimal_places']);
|
$expense['entries'][$label] = app('steam')->bcround($currency[$key]['spent'] ?? '0', $currency['currency_decimal_places']);
|
||||||
|
|
||||||
// converted entries
|
// converted entries
|
||||||
$income['native_entries'][$label] = app('steam')->bcround($currency[$key]['native_earned'] ?? '0', $currency['native_decimal_places']);
|
$income['native_entries'][$label] = app('steam')->bcround($currency[$key]['native_earned'] ?? '0', $currency['native_currency_decimal_places']);
|
||||||
$expense['native_entries'][$label] = app('steam')->bcround($currency[$key]['native_spent'] ?? '0', $currency['native_decimal_places']);
|
$expense['native_entries'][$label] = app('steam')->bcround($currency[$key]['native_spent'] ?? '0', $currency['native_currency_decimal_places']);
|
||||||
|
|
||||||
// next loop
|
// next loop
|
||||||
$currentStart = app('navigation')->addPeriod($currentStart, $this->preferredRange, 0);
|
$currentStart = app('navigation')->addPeriod($currentStart, $this->preferredRange, 0);
|
||||||
@@ -126,22 +126,22 @@ class AccountBalanceGrouped
|
|||||||
foreach ($this->journals as $journal) {
|
foreach ($this->journals as $journal) {
|
||||||
// format the date according to the period
|
// format the date according to the period
|
||||||
$period = $journal['date']->format($this->carbonFormat);
|
$period = $journal['date']->format($this->carbonFormat);
|
||||||
$currencyId = (int)$journal['currency_id'];
|
$currencyId = (int) $journal['currency_id'];
|
||||||
$currency = $this->currencies[$currencyId] ?? TransactionCurrency::find($currencyId);
|
$currency = $this->currencies[$currencyId] ?? TransactionCurrency::find($currencyId);
|
||||||
$this->currencies[$currencyId] = $currency; // may just re-assign itself, don't mind.
|
$this->currencies[$currencyId] = $currency; // may just re-assign itself, don't mind.
|
||||||
|
|
||||||
// set the array with monetary info, if it does not exist.
|
// set the array with monetary info, if it does not exist.
|
||||||
$this->data[$currencyId] ??= [
|
$this->data[$currencyId] ??= [
|
||||||
'currency_id' => (string)$currencyId,
|
'currency_id' => (string) $currencyId,
|
||||||
'currency_symbol' => $journal['currency_symbol'],
|
'currency_symbol' => $journal['currency_symbol'],
|
||||||
'currency_code' => $journal['currency_code'],
|
'currency_code' => $journal['currency_code'],
|
||||||
'currency_name' => $journal['currency_name'],
|
'currency_name' => $journal['currency_name'],
|
||||||
'currency_decimal_places' => $journal['currency_decimal_places'],
|
'currency_decimal_places' => $journal['currency_decimal_places'],
|
||||||
// native currency info (could be the same)
|
// native currency info (could be the same)
|
||||||
'native_currency_id' => (string)$this->default->id,
|
'native_currency_id' => (string) $this->default->id,
|
||||||
'native_currency_code' => $this->default->code,
|
'native_currency_code' => $this->default->code,
|
||||||
'native_currency_symbol' => $this->default->symbol,
|
'native_currency_symbol' => $this->default->symbol,
|
||||||
'native_currency_decimal_places' => $this->default->decimal_places,
|
'native_currency_decimal_places' => $this->default->decimal_places,
|
||||||
];
|
];
|
||||||
|
|
||||||
// set the array (in monetary info) with spent/earned in this $period, if it does not exist.
|
// set the array (in monetary info) with spent/earned in this $period, if it does not exist.
|
||||||
@@ -183,7 +183,7 @@ class AccountBalanceGrouped
|
|||||||
$amountConverted = bcmul($amount, $rate);
|
$amountConverted = bcmul($amount, $rate);
|
||||||
|
|
||||||
// perhaps transaction already has the foreign amount in the native currency.
|
// perhaps transaction already has the foreign amount in the native currency.
|
||||||
if ((int)$journal['foreign_currency_id'] === $this->default->id) {
|
if ((int) $journal['foreign_currency_id'] === $this->default->id) {
|
||||||
$amountConverted = $journal['foreign_amount'] ?? '0';
|
$amountConverted = $journal['foreign_amount'] ?? '0';
|
||||||
$amountConverted = 'earned' === $key ? app('steam')->positive($amountConverted) : app('steam')->negative($amountConverted);
|
$amountConverted = 'earned' === $key ? app('steam')->positive($amountConverted) : app('steam')->negative($amountConverted);
|
||||||
}
|
}
|
||||||
@@ -209,16 +209,16 @@ class AccountBalanceGrouped
|
|||||||
$defaultCurrencyId = $default->id;
|
$defaultCurrencyId = $default->id;
|
||||||
$this->currencies = [$default->id => $default]; // currency cache
|
$this->currencies = [$default->id => $default]; // currency cache
|
||||||
$this->data[$defaultCurrencyId] = [
|
$this->data[$defaultCurrencyId] = [
|
||||||
'currency_id' => (string)$defaultCurrencyId,
|
'currency_id' => (string) $defaultCurrencyId,
|
||||||
'currency_symbol' => $default->symbol,
|
'currency_symbol' => $default->symbol,
|
||||||
'currency_code' => $default->code,
|
'currency_code' => $default->code,
|
||||||
'currency_name' => $default->name,
|
'currency_name' => $default->name,
|
||||||
'currency_decimal_places' => $default->decimal_places,
|
'currency_decimal_places' => $default->decimal_places,
|
||||||
'native_currency_id' => (string)$defaultCurrencyId,
|
'native_currency_id' => (string) $defaultCurrencyId,
|
||||||
'native_currency_symbol' => $default->symbol,
|
'native_currency_symbol' => $default->symbol,
|
||||||
'native_currency_code' => $default->code,
|
'native_currency_code' => $default->code,
|
||||||
'native_currency_name' => $default->name,
|
'native_currency_name' => $default->name,
|
||||||
'native_currency_decimal_places' => $default->decimal_places,
|
'native_currency_decimal_places' => $default->decimal_places,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user