Skip to content

Firefly III: a personal finances manager

Fix #12779

James Coled16d1e9184e6
diff --git a/.editorconfig b/.editorconfig
index 8f0de65c56..4461b57764 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -7,6 +7,7 @@ indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
+max_line_length = 120
[*.md]
trim_trailing_whitespace = false
diff --git a/changelog.md b/changelog.md
index 5219d4b9d6..2a61f757ea 100644
--- a/changelog.md
+++ b/changelog.md
@@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- [Discussion 12760](https://github.com/orgs/firefly-iii/discussions/12760) (419 Page expired when selecting a different date range) started by @wecoyote5
- [Issue 12803](https://github.com/firefly-iii/firefly-iii/issues/12803) (Error "The description.xxxxxx field is required." when mass updating transactions) reported by @andyesten
- [Issue 12781](https://github.com/firefly-iii/firefly-iii/issues/12781) (When mass editing transactions, only the last tag is kept) reported by @bertille-ddp
+- #12779
## v6.7.2 - 2026-09-16
diff --git a/resources/assets/v3/js/api/model/account/get.js b/resources/assets/v3/js/api/model/account/get.js
new file mode 100644
index 0000000000..b86397d6d4
--- /dev/null
+++ b/resources/assets/v3/js/api/model/account/get.js
@@ -0,0 +1,29 @@
+/*
+ * list.js
+ * Copyright (c) 2022 [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/>.
+ */
+
+import { api } from "../../../boot/axios";
+export default class Get {
+ /**
+ * @returns {Promise<AxiosResponse<any>>}
+ */
+ get(id) {
+ return api.get(`/api/v1/accounts/${id}`);
+ }
+}
diff --git a/resources/assets/v3/js/pages/transactions/create.js b/resources/assets/v3/js/pages/transactions/create.js
index 0402518e18..05c13dea00 100644
--- a/resources/assets/v3/js/pages/transactions/create.js
+++ b/resources/assets/v3/js/pages/transactions/create.js
@@ -21,56 +21,54 @@
import "../../boot/bootstrap.js";
import sidebar from "../../pages/shared/sidebar.js";
import dates from "../shared/dates.js";
-import { defaultErrorSet } from "./shared/create-empty-split.js";
-import { parseFromEntries } from "./shared/parse-from-entries.js";
+import {defaultErrorSet} from "./shared/create-empty-split.js";
+import {parseFromEntries} from "./shared/parse-from-entries.js";
import Post from "../../api/model/transaction/post.js";
-import { loadCurrencies } from "./shared/load-currencies.js";
-import { loadBudgets } from "./shared/load-budgets.js";
-import { loadPiggyBanks } from "./shared/load-piggy-banks.js";
-import { loadSubscriptions } from "./shared/load-subscriptions.js";
-import { addAllAutocompleteToForm } from "./shared/add-autocomplete.js";
-import { processAttachments } from "./shared/process-attachments.js";
-import { disableSplitInputs } from "./shared/disable-split-inputs.js";
-import { parseTotalAmount } from "./shared/parse-total-amount.js";
-import { keyUpFromCategory } from "./shared/keyup-from-category.js";
-import { changedAmount } from "./shared/changed-amount.js";
-import { changedForeignAmount } from "./shared/changed-foreign-amount.js";
-import { parseErrors } from "./shared/parse-errors.js";
+import Get from "../../api/model/account/get.js";
+import {loadCurrencies} from "./shared/load-currencies.js";
+import {loadBudgets} from "./shared/load-budgets.js";
+import {loadPiggyBanks} from "./shared/load-piggy-banks.js";
+import {loadSubscriptions} from "./shared/load-subscriptions.js";
+import {addAllAutocompleteToForm} from "./shared/add-autocomplete.js";
+import {processAttachments} from "./shared/process-attachments.js";
+import {disableSplitInputs} from "./shared/disable-split-inputs.js";
+import {parseTotalAmount} from "./shared/parse-total-amount.js";
+import {keyUpFromCategory} from "./shared/keyup-from-category.js";
+import {changedAmount} from "./shared/changed-amount.js";
+import {changedForeignAmount} from "./shared/changed-foreign-amount.js";
+import {parseErrors} from "./shared/parse-errors.js";
import i18next from "i18next";
-import { processUploadError } from "./shared/process-upload-error.js";
-import { showMessageOrRedirectUser } from "./shared/show-message-or-redirect.js";
-import { addSplit } from "./shared/add-split.js";
-import {
- clearDestinationAccount,
- clearSourceAccount,
-} from "./shared/clear-fields.js";
-import { detectTransactionType } from "./shared/detect-transaction-type.js";
-import { determineAmountCurrency } from "./shared/determine-amount-currency.js";
-import { loadCustomFields } from "./shared/load-custom-fields.js";
-import { loadDefaultCoordinates } from "./shared/load-default-coordinates.js";
+import {processUploadError} from "./shared/process-upload-error.js";
+import {showMessageOrRedirectUser} from "./shared/show-message-or-redirect.js";
+import {addSplit} from "./shared/add-split.js";
+import {clearDestinationAccount, clearSourceAccount,} from "./shared/clear-fields.js";
+import {detectTransactionType} from "./shared/detect-transaction-type.js";
+import {determineAmountCurrency} from "./shared/determine-amount-currency.js";
+import {loadCustomFields} from "./shared/load-custom-fields.js";
+import {loadDefaultCoordinates} from "./shared/load-default-coordinates.js";
import "leaflet/dist/leaflet.css";
-import { displayMap } from "./shared/display-map.js";
-import { renderMap } from "./shared/render-map.js";
-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 { createLinkAutocomplete } from "./shared/create-link-autocomplete.js";
-import { editLink } from "./shared/edit-link.js";
-import { switchLink } from "./shared/switch-link.js";
-import { removeLink } from "./shared/remove-link.js";
-import { saveEditedLink } from "./shared/save-edited-link.js";
-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";
-import { respondToTabSwitch } from "./shared/respond-to-tab-switch.js";
-import { loadTransactionLinks } from "./shared/load-transaction-links.js";
+import {displayMap} from "./shared/display-map.js";
+import {renderMap} from "./shared/render-map.js";
+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 {createLinkAutocomplete} from "./shared/create-link-autocomplete.js";
+import {editLink} from "./shared/edit-link.js";
+import {switchLink} from "./shared/switch-link.js";
+import {removeLink} from "./shared/remove-link.js";
+import {saveEditedLink} from "./shared/save-edited-link.js";
+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";
+import {respondToTabSwitch} from "./shared/respond-to-tab-switch.js";
+import {loadTransactionLinks} from "./shared/load-transaction-links.js";
import Alpine from "alpinejs";
-import { keyUpFromSource } from "./shared/keyup-from-source.js";
-import { keyUpFromDestination } from "./shared/keyup-from-destination.js";
-import { keyUpFromDescription } from "./shared/keyup-from-description.js";
+import {keyUpFromSource} from "./shared/keyup-from-source.js";
+import {keyUpFromDestination} from "./shared/keyup-from-destination.js";
+import {keyUpFromDescription} from "./shared/keyup-from-description.js";
import focusFirstInput from "../../shared/focus-first-input.js";
window.enableDates = false;
@@ -285,6 +283,41 @@ let create = function () {
clearCategory(index) {
this.entries[index].category_name = "";
},
+ fillSourceAccount() {
+ this.fillAccount('source', 'source_account');
+ },
+ fillDestinationAccount() {
+ this.fillAccount('destination', 'destination_account');
+ },
+ fillAccount(direction, field) {
+ this.entries[0][field].loading = true;
+ const urlParams = new URLSearchParams(window.location.search);
+ const accountId = parseInt(urlParams.get(direction));
+ if (accountId > 0) {
+ (new Get).get(accountId).then((response) => {
+ // source ID must be asset account or liabilities.
+ let account = response.data.data;
+ let attributes = response.data.data.attributes;
+ if ('asset' !== attributes.type && 'liabilities' !== attributes.type) {
+ return;
+ }
+ let type = 'Asset account';
+ if ('liabilities' === attributes.type) {
+ type = String(attributes.liability_type).charAt(0).toUpperCase() + String(attributes.liability_type).slice(1);
+ }
+ this.entries[0][field] = {
+ id: account.id,
+ loading: false,
+ name: attributes.name,
+ type: type,
+ alpine_name: attributes.name,
+ disabled: false,
+ };
+ });
+ return;
+ }
+ this.entries[0][field].loading = false;
+ },
init() {
this.i18next = i18next;
@@ -299,6 +332,8 @@ let create = function () {
this.formData.foreignCurrencies = data.foreignCurrencies;
this.autoStep();
focusFirstInput();
+ this.fillSourceAccount();
+ this.fillDestinationAccount();
});
loadBudgets(false).then((data) => {
@@ -439,7 +474,7 @@ let create = function () {
};
};
-let comps = { create, sidebar, dates };
+let comps = {create, sidebar, dates};
function loadPage() {
Object.keys(comps).forEach((comp) => {
diff --git a/resources/assets/v3/js/pages/transactions/shared/create-empty-split.js b/resources/assets/v3/js/pages/transactions/shared/create-empty-split.js
index 80717152ef..076943f19a 100644
--- a/resources/assets/v3/js/pages/transactions/shared/create-empty-split.js
+++ b/resources/assets/v3/js/pages/transactions/shared/create-empty-split.js
@@ -26,6 +26,7 @@ export function getAccount() {
name: "",
alpine_name: "",
disabled: false,
+ loading: false,
};
}
diff --git a/resources/assets/v3/js/shared/focus-first-input.js b/resources/assets/v3/js/shared/focus-first-input.js
index d98c1aecd4..94b40bdfcd 100644
--- a/resources/assets/v3/js/shared/focus-first-input.js
+++ b/resources/assets/v3/js/shared/focus-first-input.js
@@ -19,9 +19,7 @@
*/
export default function focusFirstInput() {
- let list = document.querySelectorAll(
- 'div.app-content form input[type="text"]:enabled',
- );
+ let list = document.querySelectorAll('div.app-content form input[type="text"]:enabled',);
if (list.length > 0) {
list[0].focus();
return;
diff --git a/resources/views/partials/form/transaction/destination-account.blade.php b/resources/views/partials/form/transaction/destination-account.blade.php
index 52b59a5acc..4eae162de0 100644
--- a/resources/views/partials/form/transaction/destination-account.blade.php
+++ b/resources/views/partials/form/transaction/destination-account.blade.php
@@ -4,6 +4,12 @@
<em title="{{ __('firefly.destination_account') }}" class="bi bi-arrow-right"></em>
</label>
<div class="col-sm-10">
+ <template x-if="transaction.destination_account.loading">
+ <div class="spinner-border spinner-border-sm" role="status">
+ <span class="visually-hidden">{{ __('firefly.thinking') }}</span>
+ </div>
+ </template>
+ <template x-if="!transaction.destination_account.loading">
<div class="input-group">
<input type="text"
:class="{'is-invalid': transaction.errors.destination_account.length > 0, 'form-control': true, 'ac-dest': true}"
@@ -17,6 +23,7 @@
placeholder="{{ __('firefly.destination_account') }}">
<button tabindex="-1" class="btn btn-outline-secondary" type="button" @click="clearDestinationAccount(index)"><em class="bi bi-trash"></em></button>
</div>
+ </template>
<template x-if="true===transaction.destination_account.disabled">
<div class="small form-control-feedback">
{{ __('firefly.disabled_split_account_dest') }}
diff --git a/resources/views/partials/form/transaction/source-account.blade.php b/resources/views/partials/form/transaction/source-account.blade.php
index 28ff668d79..ff542639fc 100644
--- a/resources/views/partials/form/transaction/source-account.blade.php
+++ b/resources/views/partials/form/transaction/source-account.blade.php
@@ -4,6 +4,12 @@
<em title="{{ __('firefly.source_account') }}" class="bi bi-arrow-left"></em>
</label>
<div class="col-sm-10">
+ <template x-if="transaction.source_account.loading">
+ <div class="spinner-border spinner-border-sm" role="status">
+ <span class="visually-hidden">{{ __('firefly.thinking') }}</span>
+ </div>
+ </template>
+ <template x-if="!transaction.source_account.loading">
<div class="input-group">
<input type="text"
:class="{'is-invalid': transaction.errors.source_account.length > 0, 'form-control': true, 'ac-source': true}"
@@ -17,6 +23,8 @@
placeholder="{{ __('firefly.source_account') }}">
<button tabindex="-1" class="btn btn-outline-secondary" type="button" @click="clearSourceAccount(index)"><em class="bi bi-trash"></em></button>
</div>
+ </template>
+
<template x-if="true===transaction.source_account.disabled">
<div class="small form-control-feedback">
{{ __('firefly.disabled_split_account_src') }}