Skip to content

Firefly III: a personal finances manager

Expand edit/create

James Cole3dcb4feae26e
diff --git a/app/Http/Controllers/Recurring/IndexController.php b/app/Http/Controllers/Recurring/IndexController.php
index da82d97e5f..e9e11f5734 100644
--- a/app/Http/Controllers/Recurring/IndexController.php
+++ b/app/Http/Controllers/Recurring/IndexController.php
@@ -100,7 +100,6 @@ final class IndexController extends Controller
/** @var RecurrenceTransformer $transformer */
$transformer = app(RecurrenceTransformer::class);
- $transformer->setParameters(new ParameterBag());
$recurring = [];
diff --git a/app/Support/Http/Controllers/GetConfigurationData.php b/app/Support/Http/Controllers/GetConfigurationData.php
index b0fdfc1358..857571bfff 100644
--- a/app/Support/Http/Controllers/GetConfigurationData.php
+++ b/app/Support/Http/Controllers/GetConfigurationData.php
@@ -212,7 +212,7 @@ trait GetConfigurationData
protected function verifyRecurringCronJob(): void
{
- $config = AppConfiguration::get('last_rt_job', 0);
+ $config = AppConfiguration::get(sprintf('last_rt_job_%d', auth()->user()->id), 0);
$lastTime = (int) $config?->data;
$now = Carbon::now()->getTimestamp();
Log::debug(sprintf('verifyRecurringCronJob: last time is %d ("%s"), now is %d', $lastTime, $config?->data, $now));
diff --git a/resources/assets/v3/js/pages/transactions/create.js b/resources/assets/v3/js/pages/transactions/create.js
index fd9a5a0bca..094da62455 100644
--- a/resources/assets/v3/js/pages/transactions/create.js
+++ b/resources/assets/v3/js/pages/transactions/create.js
@@ -62,6 +62,7 @@ import {saveNewLink} from "./shared/save-new-link.js";
import {redirectAfterTransactionLinks} from './shared/redirect-after-transaction-links.js';
import {processTransactionLinks} from './shared/process-transaction-links.js';
import {addTabListener} from "./shared/add-tab-listener.js";
+import {autoStep} from "./shared/auto-step.js";
let create = function () {
return {
@@ -196,6 +197,7 @@ let create = function () {
processTransactionLinks: processTransactionLinks,
redirectAfterTransactionLinks: redirectAfterTransactionLinks,
addTabListener: addTabListener,
+ autoStep: autoStep,
filterForeignCurrencies(code) {
let list = [];
@@ -257,40 +259,7 @@ let create = function () {
//console.log('Switched to new tab!', event.target.dataset.index);
},
- // this method automatically calls some
- // "next steps", whenever the state of the form loads or changes.
- // used during the init phase of the form.
- autoStep() {
- // check if custom field "links" is enabled and if so, load the link types and save them in formData.
- if (null === this.formStates.loadingLinks && this.formBehaviour.customFields.hasOwnProperty('links') && true === this.formBehaviour.customFields.links) {
- this.formStates.loadingLinks = true;
- loadLinkTypes().then(data => {
- for (let i = 0; i < data.length; i++) {
- if (data.hasOwnProperty(i)) {
- let current = data[i];
- current.id = parseInt(current.id);
- this.formData.linkTypes.push(current);
- }
- }
- this.formStates.loadingLinks = false;
- this.autoStep(); // yes, recurring.
-
- });
- }
- if (this.formBehaviour.customFields.hasOwnProperty('links') && false === this.formBehaviour.customFields.links) {
- this.formStates.storedLinks = true;
- this.formStates.loadingLinks = false;
- }
- // check if the transaction is loaded and also the transaction links AND the field is enabled, then load the autocomplete for links.
- if (false === this.formStates.loadingTransaction && false === this.formStates.loadingLinks && this.formBehaviour.customFields.hasOwnProperty('links') && true === this.formBehaviour.customFields.links) {
- for(let i = 0; i < this.entries.length; i++) {
- if(this.entries.hasOwnProperty(i)) {
- this.createLinkAutocomplete('links_modal_search_' + i, 'api/v1/autocomplete/transactions-with-meta');
- }
- }
- }
- },
init() {
@@ -334,7 +303,7 @@ let create = function () {
document.addEventListener('upload-success', (event) => {
console.log('Now in event listener "upload-success"');
this.processUpload(event);
- document.querySelectorAll("input[type=file]").value = "";
+ document.querySelectorAll("input[type=file]").forEach(input => input.value = "");
});
document.addEventListener('upload-error', (event) => {
diff --git a/resources/assets/v3/js/pages/transactions/edit.js b/resources/assets/v3/js/pages/transactions/edit.js
index b2e65301e1..1548f43b9d 100644
--- a/resources/assets/v3/js/pages/transactions/edit.js
+++ b/resources/assets/v3/js/pages/transactions/edit.js
@@ -55,7 +55,6 @@ import {onMapClick} from './shared/on-map-click.js';
import {onMapZoom} from './shared/on-map-zoom.js';
import {clearLocation} from './shared/clear-location.js';
import {removeSplit} from "./shared/remove-split.js";
-import {loadLinkTypes} from "./shared/load-link-types.js";
import {loadTransactionLinks} from './shared/load-transaction-links.js';
import {createLinkAutocomplete} from "./shared/create-link-autocomplete.js";
import {editLink} from "./shared/edit-link.js";
@@ -66,6 +65,7 @@ import {saveNewLink} from "./shared/save-new-link.js";
import {processTransactionLinks} from "./shared/process-transaction-links.js";
import {redirectAfterTransactionLinks} from "./shared/redirect-after-transaction-links.js";
import {addTabListener} from "./shared/add-tab-listener.js";
+import {autoStep} from "./shared/auto-step.js";
const urls = getUrls();
@@ -88,7 +88,9 @@ let transactions = function () {
loadingCurrencies: true,
loadingBudgets: true,
loadingPiggyBanks: true,
+ loadingLinks: null,
loadingSubscriptions: true,
+ loadingTransaction: true,
isSubmitting: false,
returnHereButton: false,
saveAsNewButton: false, // edit form only
@@ -182,6 +184,7 @@ let transactions = function () {
redirectAfterTransactionLinks: redirectAfterTransactionLinks,
loadTransactionLinks: loadTransactionLinks,
addTabListener: addTabListener,
+ autoStep: autoStep,
// part of the account selection auto-complete
@@ -212,6 +215,7 @@ let transactions = function () {
const getter = new Get();
getter.show(groupId, {}).then((response) => {
const data = response.data.data;
+ this.formStates.loadingTransaction = false;
this.groupProperties.id = parseInt(data.id);
this.groupProperties.transactionType = data.attributes.transactions[0].type.toLowerCase();
this.groupProperties.title = data.attributes.group_title ?? data.attributes.transactions[0].description;
@@ -242,7 +246,7 @@ let transactions = function () {
}
}
}
-
+ this.autoStep();
// remove waiting thing.
this.notifications.wait.show = false;
}).then(() => {
@@ -276,6 +280,7 @@ let transactions = function () {
}
});
}, 150);
+ this.autoStep();
});
},
@@ -294,82 +299,42 @@ let transactions = function () {
this.formData.enabledCurrencies = data.enabledCurrencies;
this.formData.primaryCurrencies = data.primaryCurrencies;
this.formData.foreignCurrencies = data.foreignCurrencies;
+ this.autoStep();
this.getTransactionGroup();
+ this.autoStep();
});
loadBudgets(true).then(data => {
this.formData.budgets = data;
this.formStates.loadingBudgets = false;
+ this.autoStep();
});
loadPiggyBanks().then(data => {
this.formData.piggyBanks = data;
this.formStates.loadingPiggyBanks = false;
+ this.autoStep();
});
loadSubscriptions(true).then(data => {
this.formData.subscriptions = data;
this.formStates.loadingSubscriptions = false;
+ this.autoStep();
});
// load custom field preference and enable/disable those fields.
this.loadCustomFields().then(data => {
this.formBehaviour.customFields = data;
- // linked-transactions-search
- if (true === data.links) {
- loadLinkTypes().then(data => {
- //console.log(data);
- for (let i = 0; i < data.length; i++) {
- if (data.hasOwnProperty(i)) {
- let current = data[i];
- current.id = parseInt(current.id);
- this.formData.linkTypes.push(current);
- }
- }
- this.formStates.loadingLinks = false;
-
- for(let i = 0; i < this.entries.length; i++) {
- this.links[i] = []; // empty set of links.
- // then fill the set using the ID.
- this.loadTransactionLinks(i, this.entries[i].transaction_journal_id);
- }
-
- });
- }
- if (false === data.links) {
- this.formStates.storedLinks = true;
- }
+ this.autoStep();
});
- // document.addEventListener('transaction-group-loaded', (event) => {
- // this.createLinkAutocompletes();
- // this.createLinkAutocomplete('links_modal_search_0', 'api/v1/autocomplete/transactions-with-meta');
- // this.entries[event.detail.index].latitude = event.detail.latitude;
- // this.entries[event.detail.index].longitude = event.detail.longitude;
- // });
-
-
// add some event listeners
document.addEventListener('upload-success', (event) => {
this.processUpload(event);
- document.querySelectorAll("input[type=file]").value = "";
+ document.querySelectorAll("input[type=file]").forEach(input => input.value = "");
});
document.addEventListener('upload-error', (event) => {
this.processUploadError(event);
});
-
-
- // document.addEventListener('location-set', (event) => {
- // this.entries[event.detail.index].hasLocation = true;
- // this.entries[event.detail.index].latitude = event.detail.latitude;
- // this.entries[event.detail.index].longitude = event.detail.longitude;
- // this.entries[event.detail.index].zoom_level = event.detail.zoomLevel;
- // });
-
- // document.addEventListener('location-zoom', (event) => {
- // console.log('this happens?');
- // this.entries[event.detail.index].hasLocation = true;
- // this.entries[event.detail.index].zoom_level = event.detail.zoomLevel;
- // });
},
diff --git a/resources/assets/v3/js/pages/transactions/shared/auto-step.js b/resources/assets/v3/js/pages/transactions/shared/auto-step.js
new file mode 100644
index 0000000000..85a309bfe4
--- /dev/null
+++ b/resources/assets/v3/js/pages/transactions/shared/auto-step.js
@@ -0,0 +1,61 @@
+/*
+ * autostep.js
+ * Copyright (c) 2026 [email protected]
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+// this method automatically calls some
+// "next steps", whenever the state of the form loads or changes.
+// used during the init phase of the form.
+import {loadLinkTypes} from "./load-link-types.js";
+
+export function autoStep() {
+ // check if custom field "links" is enabled and if so, load the link types and save them in formData.
+ if (null === this.formStates.loadingLinks && this.formBehaviour.customFields.hasOwnProperty('links') && true === this.formBehaviour.customFields.links) {
+ this.formStates.loadingLinks = true;
+ loadLinkTypes().then(data => {
+ console.log('done loadLinkTypes()');
+ for (let i = 0; i < data.length; i++) {
+ if (data.hasOwnProperty(i)) {
+ let current = data[i];
+ current.id = parseInt(current.id);
+ this.formData.linkTypes.push(current);
+ }
+ }
+ this.formStates.loadingLinks = false;
+ this.autoStep(); // yes, recurring.
+
+ });
+ }
+ if (this.formBehaviour.customFields.hasOwnProperty('links') && false === this.formBehaviour.customFields.links) {
+ this.formStates.storedLinks = true;
+ this.formStates.loadingLinks = false;
+ }
+ // check if the transaction is loaded and also the transaction links AND the field is enabled, then load the autocomplete for links.
+ if (false === this.formStates.loadingTransaction && false === this.formStates.loadingLinks && this.formBehaviour.customFields.hasOwnProperty('links') && true === this.formBehaviour.customFields.links) {
+ for(let i = 0; i < this.entries.length; i++) {
+ if(this.entries.hasOwnProperty(i)) {
+ this.createLinkAutocomplete('links_modal_search_' + i, 'api/v1/autocomplete/transactions-with-meta');
+ if(0 !== parseInt(this.entries[i].transaction_journal_id)) {
+ // load the links for this transaction journal.
+ this.loadTransactionLinks(i, parseInt(this.entries[i].transaction_journal_id));
+ }
+ }
+ }
+ }
+
+}