Catch some amounts

This commit is contained in:
James Cole
2023-12-29 19:59:19 +01:00
parent e47110607c
commit 33b95b9371
20 changed files with 161 additions and 154 deletions

View File

@@ -62,10 +62,10 @@ class AccountBalanceGrouped
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'native_id' => (string)$currency['native_id'],
'native_symbol' => $currency['native_symbol'],
'native_code' => $currency['native_code'],
'native_decimal_places' => $currency['native_decimal_places'],
'native_currency_id' => (string)$currency['native_currency_id'],
'native_currency_symbol' => $currency['native_currency_symbol'],
'native_currency_code' => $currency['native_currency_code'],
'native_currency_decimal_places' => $currency['native_currency_decimal_places'],
'start' => $this->start->toAtomString(),
'end' => $this->end->toAtomString(),
'period' => $this->preferredRange,
@@ -78,10 +78,10 @@ class AccountBalanceGrouped
'currency_symbol' => $currency['currency_symbol'],
'currency_code' => $currency['currency_code'],
'currency_decimal_places' => $currency['currency_decimal_places'],
'native_id' => (string)$currency['native_id'],
'native_symbol' => $currency['native_symbol'],
'native_code' => $currency['native_code'],
'native_decimal_places' => $currency['native_decimal_places'],
'native_currency_id' => (string)$currency['native_currency_id'],
'native_currency_symbol' => $currency['native_currency_symbol'],
'native_currency_code' => $currency['native_currency_code'],
'native_currency_decimal_places' => $currency['native_currency_decimal_places'],
'start' => $this->start->toAtomString(),
'end' => $this->end->toAtomString(),
'period' => $this->preferredRange,
@@ -138,10 +138,10 @@ class AccountBalanceGrouped
'currency_name' => $journal['currency_name'],
'currency_decimal_places' => $journal['currency_decimal_places'],
// native currency info (could be the same)
'native_id' => (string)$this->default->id,
'native_code' => $this->default->code,
'native_symbol' => $this->default->symbol,
'native_decimal_places' => $this->default->decimal_places,
'native_currency_id' => (string)$this->default->id,
'native_currency_code' => $this->default->code,
'native_currency_symbol' => $this->default->symbol,
'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.
@@ -214,11 +214,11 @@ class AccountBalanceGrouped
'currency_code' => $default->code,
'currency_name' => $default->name,
'currency_decimal_places' => $default->decimal_places,
'native_id' => (string)$defaultCurrencyId,
'native_symbol' => $default->symbol,
'native_code' => $default->code,
'native_name' => $default->name,
'native_decimal_places' => $default->decimal_places,
'native_currency_id' => (string)$defaultCurrencyId,
'native_currency_symbol' => $default->symbol,
'native_currency_code' => $default->code,
'native_currency_name' => $default->name,
'native_currency_decimal_places' => $default->decimal_places,
];
}

View File

@@ -50,8 +50,8 @@ trait CleansChartData
if (array_key_exists('currency_id', $array)) {
$array['currency_id'] = (string)$array['currency_id'];
}
if (array_key_exists('native_id', $array)) {
$array['native_id'] = (string)$array['native_id'];
if (array_key_exists('native_currency_id', $array)) {
$array['native_currency_id'] = (string)$array['native_currency_id'];
}
if (!array_key_exists('start', $array)) {
throw new FireflyException(sprintf('Data-set "%s" is missing the "start"-variable.', $index));

View File

@@ -58,10 +58,10 @@ trait ConvertsExchangeRates
$native = app('amount')->getDefaultCurrency();
$currency = $this->getCurrency((int)$set['currency_id']);
if ($native->id === $currency->id) {
$set['native_id'] = (string)$currency->id;
$set['native_code'] = $currency->code;
$set['native_symbol'] = $currency->symbol;
$set['native_decimal_places'] = $currency->decimal_places;
$set['native_currency_id'] = (string)$currency->id;
$set['native_currency_code'] = $currency->code;
$set['native_currency_symbol'] = $currency->symbol;
$set['native_currency_decimal_places'] = $currency->decimal_places;
return $set;
}
@@ -112,20 +112,20 @@ trait ConvertsExchangeRates
$amount = $this->convertAmount($entry['sum'], $currency, $native);
$entry['converted'] = true;
$entry['native_sum'] = $amount;
$entry['native_id'] = (string)$native->id;
$entry['native_name'] = $native->name;
$entry['native_symbol'] = $native->symbol;
$entry['native_code'] = $native->code;
$entry['native_decimal_places'] = $native->decimal_places;
$entry['native_currency_id'] = (string)$native->id;
$entry['native_currency_name'] = $native->name;
$entry['native_currency_symbol'] = $native->symbol;
$entry['native_currency_code'] = $native->code;
$entry['native_currency_decimal_places'] = $native->decimal_places;
}
if ($currency->id === $native->id) {
$entry['converted'] = false;
$entry['native_sum'] = $entry['sum'];
$entry['native_id'] = (string)$native->id;
$entry['native_name'] = $native->name;
$entry['native_symbol'] = $native->symbol;
$entry['native_code'] = $native->code;
$entry['native_decimal_places'] = $native->decimal_places;
$entry['native_currency_id'] = (string)$native->id;
$entry['native_currency_name'] = $native->name;
$entry['native_currency_symbol'] = $native->symbol;
$entry['native_currency_code'] = $native->code;
$entry['native_currency_decimal_places'] = $native->decimal_places;
}
$return[] = $entry;
}