Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix #12932
James Colefce079b3ef3b
diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.phpindex 98909b93bf..33d1373d9c 100644--- a/app/Api/V1/Controllers/Chart/AccountController.php+++ b/app/Api/V1/Controllers/Chart/AccountController.php@@ -37,6 +37,7 @@ use FireflyIII\Support\Facades\Steam;use FireflyIII\Support\Http\Api\ApiSupport;use FireflyIII\Support\Http\Api\CleansChartData;use FireflyIII\Support\Http\Api\CollectsAccountsFromFilter;+use FireflyIII\Support\Http\Api\ExchangeRateConverter;use Illuminate\Http\JsonResponse;use Illuminate\Http\Request;use Illuminate\Support\Facades\Log;@@ -147,6 +148,7 @@ final class AccountController extends Controller$rangeVals = array_values($range);$rangeIdx = 0;$rangeCount = count($rangeDates);+ $converter = new ExchangeRateConverter();while ($currentStart <= $params['end']) {$label = $currentStart->toAtomString();@@ -155,14 +157,16 @@ final class AccountController extends Controllerwhile ($rangeIdx < $rangeCount && $rangeDates[$rangeIdx] <= $currentStart) {$previous = $rangeVals[$rangeIdx]['balance'];if ($this->convertToPrimary) {- $pcPrevious = $rangeVals[$rangeIdx]['pc_balance'];+ $pcPrevious = $rangeVals[$rangeIdx]['balance'];}++$rangeIdx;}$currentSet['entries'][$label] = $previous;if ($this->convertToPrimary) {+ $pcPrevious = $converter->convert($currency, $this->primaryCurrency, $currentStart, $previous);$currentSet['pc_entries'][$label] = $pcPrevious;+ // convert for the current moment.}$currentStart = Navigation::addPeriod($currentStart, $period);diff --git a/resources/assets/v3/js/pages/exchange-rates/index.js b/resources/assets/v3/js/pages/exchange-rates/index.jsindex c9ca4f1977..811aa28e72 100644--- a/resources/assets/v3/js/pages/exchange-rates/index.js+++ b/resources/assets/v3/js/pages/exchange-rates/index.js@@ -35,6 +35,10 @@ let index = function () {this.i18next = i18next;this.getCurrencies();},+ notEqualIds(left, right) {+ return parseInt(left) !== parseInt(right);+ },+getCurrencies: function () {this.currencies = [];// start with page one, loop for the rest.diff --git a/resources/assets/v3/js/pages/exchange-rates/rates.js b/resources/assets/v3/js/pages/exchange-rates/rates.jsindex c260221538..6c460a80fb 100644--- a/resources/assets/v3/js/pages/exchange-rates/rates.js+++ b/resources/assets/v3/js/pages/exchange-rates/rates.js@@ -115,8 +115,11 @@ let rates = function () {});}if (0 !== parseInt(this.rates[index].rate_id)) {- // console.log("[a] PUT, not POST.");- new Put().put({ rate: this.rates[index].rate }, { id: this.rates[index].rate_id }).then(() => {+ // console.log("[a] PUT, not POST.", this.rates[index]);+ new Put().put({+ date: this.rates[index].date_field,+ rate: this.rates[index].rate+ }, { id: this.rates[index].rate_id }).then(() => {this.updating = false;});}@@ -140,9 +143,12 @@ let rates = function () {});}if (0 !== parseInt(this.rates[index].inverse_id)) {- // console.log("[b] PUT, not POST.");+ // console.log("[a] PUT, not POST.", this.rates[index]);new Put()- .put({ rate: this.rates[index].inverse }, { id: this.rates[index].inverse_id })+ .put({+ rate: this.rates[index].inverse,+ date: this.rates[index].date_field+ }, { id: this.rates[index].inverse_id }).then(() => {this.updating = false;});diff --git a/resources/views/exchange-rates/index.blade.php b/resources/views/exchange-rates/index.blade.phpindex 33ed2dcb7a..b0931b175e 100644--- a/resources/views/exchange-rates/index.blade.php+++ b/resources/views/exchange-rates/index.blade.php@@ -35,13 +35,13 @@<template x-for="currency in currencies" :key="currency.id"><div class="card mb-2"><div class="card-header">- <h3 class="card-title" x-text="currency.name"></h3>X+ <h3 class="card-title" x-text="currency.name"></h3></div><div class="card-body"><template x-if="currencies.length > 1"><ul><template x-for="sub in currencies" :key="sub.id">- <template x-if="parseInt(sub.id) !== parseInt(currency.id)">+ <template x-if="notEqualIds(currency.id, sub.id)"><li><a :href="'exchange-rates/' + currency.code + '/' + sub.code":title="i18next.t('firefly.exchange_rates_from_to', {from: currency.name, to: sub.name})"diff --git a/resources/views/exchange-rates/rates.blade.php b/resources/views/exchange-rates/rates.blade.phpindex 67065582b0..da38db6aa6 100644--- a/resources/views/exchange-rates/rates.blade.php+++ b/resources/views/exchange-rates/rates.blade.php@@ -83,7 +83,7 @@<td><inputref="date"- :value="rate.date_field"+ x-model="rate.date_field"autocomplete="off"class="form-control"name="date[]"diff --git a/resources/views/partials/form/transaction/location.blade.php b/resources/views/partials/form/transaction/location.blade.phpindex 74b599e020..442fd64952 100644--- a/resources/views/partials/form/transaction/location.blade.php+++ b/resources/views/partials/form/transaction/location.blade.php@@ -1,4 +1,3 @@-<template x-if="true === formBehaviour.customFields.location"><div class="row mb-2"><label :for="'map_' + index" class="col-sm-1 col-form-label d-none d-sm-block">@@ -11,22 +10,34 @@</template><template x-if="true || 0 === index"><div class="col-sm-10">+ <template x-if="null === transaction.longitude"><div x-init="displayMap(index)"- :data-add-marker="transaction.hasLocation ? 'true' : 'false'"- :data-longitude="transaction.longitude ?? formBehaviour.defaultCoordinates.longitude"- :data-latitude="transaction.latitude ?? formBehaviour.defaultCoordinates.latitude"- :data-zoom-level="transaction.zoom_level ?? formBehaviour.defaultCoordinates.zoom_level"+ :data-add-marker="transaction.hasLocation ? 'true' : 'false'"+ :data-longitude="formBehaviour.defaultCoordinates.longitude"+ :data-latitude="formBehaviour.defaultCoordinates.latitude"+ :data-zoom-level="formBehaviour.defaultCoordinates.zoom_level"- :id="'location_map_' + index" class="map-size location-map" :data-index="index"></div>+ :id="'location_map_' + index" class="map-size location-map" :data-index="index">+ </div>+ </template>+ <template x-if="null !== transaction.longitude">+ <div x-init="displayMap(index)"+ :data-add-marker="transaction.hasLocation ? 'true' : 'false'"+ :data-longitude="transaction.longitude"+ :data-latitude="transaction.latitude"+ :data-zoom-level="transaction.zoom_level"+ :id="'location_map_' + index" class="map-size location-map" :data-index="index">+ </div>+ </template><span class="muted small">- <template x-if="!transaction.hasLocation">- <span>{{ __('firefly.click_tap_location') }}</span>- </template>- <template x-if="transaction.hasLocation">- <a :data-index="index" href="#" @click.prevent="clearLocation">{{ __('firefly.clear_location') }}</a>- </template>- </span>- </div>+ <template x-if="!transaction.hasLocation">+ <span>{{ __('firefly.click_tap_location') }}</span>+ </template>+ <template x-if="transaction.hasLocation">+ <a :data-index="index" href="#" @click.prevent="clearLocation">{{ __('firefly.clear_location') }}</a>+ </template>+ </span>+ </div></template></div></template>