mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-05-03 20:56:21 +00:00
Various code cleanup and fixed alignments.
This commit is contained in:
@@ -45,7 +45,7 @@ trait ConvertsExchangeRates
|
||||
|
||||
// if not enabled, return the same array but without conversion:
|
||||
return $set;
|
||||
$this->enabled = false;
|
||||
$this->enabled = false;
|
||||
if (false === $this->enabled) {
|
||||
$set['converted'] = false;
|
||||
|
||||
@@ -55,8 +55,8 @@ trait ConvertsExchangeRates
|
||||
$set['converted'] = true;
|
||||
|
||||
/** @var TransactionCurrency $native */
|
||||
$native = app('amount')->getDefaultCurrency();
|
||||
$currency = $this->getCurrency((int)$set['currency_id']);
|
||||
$native = app('amount')->getDefaultCurrency();
|
||||
$currency = $this->getCurrency((int)$set['currency_id']);
|
||||
if ($native->id === $currency->id) {
|
||||
$set['native_currency_id'] = (string)$currency->id;
|
||||
$set['native_currency_code'] = $currency->code;
|
||||
@@ -66,9 +66,9 @@ trait ConvertsExchangeRates
|
||||
return $set;
|
||||
}
|
||||
foreach ($set['entries'] as $date => $entry) {
|
||||
$carbon = Carbon::createFromFormat(\DateTimeInterface::ATOM, $date);
|
||||
$rate = $this->getRate($currency, $native, $carbon);
|
||||
$rate = '0' === $rate ? '1' : $rate;
|
||||
$carbon = Carbon::createFromFormat(\DateTimeInterface::ATOM, $date);
|
||||
$rate = $this->getRate($currency, $native, $carbon);
|
||||
$rate = '0' === $rate ? '1' : $rate;
|
||||
app('log')->debug(sprintf('bcmul("%s", "%s")', (string)$entry, $rate));
|
||||
$set['entries'][$date] = (float)bcmul((string)$entry, $rate);
|
||||
}
|
||||
@@ -109,9 +109,9 @@ trait ConvertsExchangeRates
|
||||
foreach ($entries as $entry) {
|
||||
$currency = $this->getCurrency((int)$entry['id']);
|
||||
if ($currency->id !== $native->id) {
|
||||
$amount = $this->convertAmount($entry['sum'], $currency, $native);
|
||||
$entry['converted'] = true;
|
||||
$entry['native_sum'] = $amount;
|
||||
$amount = $this->convertAmount($entry['sum'], $currency, $native);
|
||||
$entry['converted'] = true;
|
||||
$entry['native_sum'] = $amount;
|
||||
$entry['native_currency_id'] = (string)$native->id;
|
||||
$entry['native_currency_name'] = $native->name;
|
||||
$entry['native_currency_symbol'] = $native->symbol;
|
||||
@@ -119,8 +119,8 @@ trait ConvertsExchangeRates
|
||||
$entry['native_currency_decimal_places'] = $native->decimal_places;
|
||||
}
|
||||
if ($currency->id === $native->id) {
|
||||
$entry['converted'] = false;
|
||||
$entry['native_sum'] = $entry['sum'];
|
||||
$entry['converted'] = false;
|
||||
$entry['native_sum'] = $entry['sum'];
|
||||
$entry['native_currency_id'] = (string)$native->id;
|
||||
$entry['native_currency_name'] = $native->name;
|
||||
$entry['native_currency_symbol'] = $native->symbol;
|
||||
|
||||
Reference in New Issue
Block a user