Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix auto select account
Sander Dorigo839c4018612d
diff --git a/resources/assets/v3/js/pages/transactions/create.js b/resources/assets/v3/js/pages/transactions/create.jsindex e0e2d3035d..70c9e811df 100644--- a/resources/assets/v3/js/pages/transactions/create.js+++ b/resources/assets/v3/js/pages/transactions/create.js@@ -285,7 +285,7 @@ let create = function () {this.fillAccount("destination", "destination_account");},fillAccount(direction, field) {- this.entries[0][field].loading = true;+ // this.entries[0][field].loading = true;const urlParams = new URLSearchParams(window.location.search);const accountId = parseInt(urlParams.get(direction));if (accountId > 0) {@@ -306,10 +306,14 @@ let create = function () {id: account.id,loading: false,name: attributes.name,+ account_currency_code: attributes.currency_code,+ currency_code: attributes.primary_currency_code,type: type,alpine_name: attributes.name,- disabled: false,+ // disabled: false,};+ console.log('Now detect', field, this.entries[0][field]);+ this.detectTransactionType();});return;}diff --git a/resources/assets/v3/js/pages/transactions/shared/detect-transaction-type.js b/resources/assets/v3/js/pages/transactions/shared/detect-transaction-type.jsindex cb33ce33ff..822e6460a7 100644--- a/resources/assets/v3/js/pages/transactions/shared/detect-transaction-type.js+++ b/resources/assets/v3/js/pages/transactions/shared/detect-transaction-type.js@@ -27,6 +27,7 @@ export function detectTransactionType() {this.disableSplitInputs();return;}+ console.log('Detect transaction type of "'+sourceType+'" vs "'+destType+'"');// transfer: both are the same and in strict set of account typesif (sourceType === destType && ["Asset account", "Loan", "Debt", "Mortgage"].includes(sourceType)) {@@ -44,23 +45,15 @@ export function detectTransactionType() {// withdrawals:if ("Asset account" === sourceType && ["Expense account", "Debt", "Loan", "Mortgage"].includes(destType)) {this.groupProperties.transactionType = "withdrawal";- // console.log(- // '[a] Transaction type is detected to be "' +- // this.groupProperties.transactionType +- // '".',- // );- this.determineAmountCurrency(this.entries[0].source_account.currency_code);+ console.log('[a] Transaction type is detected to be "' + this.groupProperties.transactionType + '".',);+ this.determineAmountCurrency(this.entries[0].source_account.account_currency_code);this.disableSplitInputs();return;}if ("Asset account" === sourceType && "unknown" === destType) {this.groupProperties.transactionType = "withdrawal";- // console.log(- // '[b] Transaction type is detected to be "' +- // this.groupProperties.transactionType +- // '".',- // );- this.determineAmountCurrency(this.entries[0].source_account.currency_code);+ console.log('[b] Transaction type is detected to be "' + this.groupProperties.transactionType + '".',);+ this.determineAmountCurrency(this.entries[0].source_account.account_currency_code);this.disableSplitInputs();return;}@@ -71,7 +64,7 @@ export function detectTransactionType() {// this.groupProperties.transactionType +// '".',// );- this.determineAmountCurrency(this.entries[0].source_account.currency_code);+ this.determineAmountCurrency(this.entries[0].source_account.account_currency_code);this.disableSplitInputs();return;}@@ -85,7 +78,7 @@ export function detectTransactionType() {// '".',// );this.disableSplitInputs();- this.determineAmountCurrency(this.entries[0].destination_account.currency_code);+ this.determineAmountCurrency(this.entries[0].destination_account.account_currency_code);return;}if ("unknown" === sourceType && ["Asset account", "Debt", "Loan", "Mortgage"].includes(destType)) {@@ -95,7 +88,7 @@ export function detectTransactionType() {// this.groupProperties.transactionType +// '".',// );- this.determineAmountCurrency(this.entries[0].destination_account.currency_code);+ this.determineAmountCurrency(this.entries[0].destination_account.account_currency_code);this.disableSplitInputs();return;}@@ -103,7 +96,7 @@ export function detectTransactionType() {this.groupProperties.transactionType = "deposit";console.warn('FORCE transaction type to be "' + this.groupProperties.transactionType + '".');this.entries[0].source_account.id = "";- this.determineAmountCurrency(this.entries[0].destination_account.currency_code);+ this.determineAmountCurrency(this.entries[0].destination_account.account_currency_code);this.disableSplitInputs();return;}@@ -114,7 +107,7 @@ export function detectTransactionType() {// this.groupProperties.transactionType +// '".',// );- this.determineAmountCurrency(this.entries[0].destination_account.currency_code);+ this.determineAmountCurrency(this.entries[0].destination_account.account_currency_code);this.disableSplitInputs();return;}diff --git a/resources/assets/v3/js/pages/transactions/shared/keyup-from-category.js b/resources/assets/v3/js/pages/transactions/shared/keyup-from-category.jsindex f16d4f17a6..a7279278e0 100644--- a/resources/assets/v3/js/pages/transactions/shared/keyup-from-category.js+++ b/resources/assets/v3/js/pages/transactions/shared/keyup-from-category.js@@ -19,9 +19,9 @@*/export function keyUpFromCategory(e) {- let target = e.currentTarget.nextSibling;+ let target = null === e.currentTarget ? null : e.currentTarget.nextSibling;setTimeout(() => {- this.formStates.categorySelectVisible = target.classList.contains("show");+ this.formStates.categorySelectVisible = null !== target && Object.hasOwn(target, 'classList') && target.classList.contains("show");}, 600);if (e.key === "Enter" && false === this.formStates.categorySelectVisible) {this.save();diff --git a/resources/assets/v3/js/pages/transactions/shared/keyup-from-description.js b/resources/assets/v3/js/pages/transactions/shared/keyup-from-description.jsindex b50e4d2361..cba51b4bea 100644--- a/resources/assets/v3/js/pages/transactions/shared/keyup-from-description.js+++ b/resources/assets/v3/js/pages/transactions/shared/keyup-from-description.js@@ -19,9 +19,9 @@*/export function keyUpFromDescription(e) {- let target = e.currentTarget.nextSibling;+ let target = null === e.currentTarget ? null : e.currentTarget.nextSibling;setTimeout(() => {- this.formStates.descriptionSelectVisible = target.classList.contains("show");+ this.formStates.descriptionSelectVisible = null !== target && Object.hasOwn(target, 'classList') && target.classList.contains("show");}, 600);if (e.key === "Enter" && false === this.formStates.descriptionSelectVisible) {this.save();diff --git a/resources/assets/v3/js/pages/transactions/shared/keyup-from-destination.js b/resources/assets/v3/js/pages/transactions/shared/keyup-from-destination.jsindex b7803742f4..09002f54c2 100644--- a/resources/assets/v3/js/pages/transactions/shared/keyup-from-destination.js+++ b/resources/assets/v3/js/pages/transactions/shared/keyup-from-destination.js@@ -19,9 +19,9 @@*/export function keyUpFromDestination(e) {- let target = e.currentTarget.nextSibling;+ let target = null === e.currentTarget ? null : e.currentTarget.nextSibling;setTimeout(() => {- this.formStates.destinationSelectVisible = target.classList.contains("show");+ this.formStates.destinationSelectVisible = null !== target && Object.hasOwn(target, 'classList') && target.classList.contains("show");}, 600);if (e.key === "Enter" && false === this.formStates.destinationSelectVisible) {this.save();diff --git a/resources/assets/v3/js/pages/transactions/shared/keyup-from-source.js b/resources/assets/v3/js/pages/transactions/shared/keyup-from-source.jsindex e5e57e0864..5e42b47799 100644--- a/resources/assets/v3/js/pages/transactions/shared/keyup-from-source.js+++ b/resources/assets/v3/js/pages/transactions/shared/keyup-from-source.js@@ -19,9 +19,9 @@*/export function keyUpFromSource(e) {- let target = e.currentTarget.nextSibling;+ let target = null === e.currentTarget ? null : e.currentTarget.nextSibling;setTimeout(() => {- this.formStates.sourceSelectVisible = target.classList.contains("show");+ this.formStates.sourceSelectVisible = null !== target && Object.hasOwn(target, 'classList') && target.classList.contains("show");}, 600);if (e.key === "Enter" && false === this.formStates.sourceSelectVisible) {this.save();