From bf2f96621d07d519818fbb657da4ef56e9590125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Mon, 13 Mar 2023 23:18:52 +0800 Subject: [PATCH] Revised so that when the account selector finds the codes from the form, the journal entry editor is used to find the form instead of messing-up with the TransactionForm class and its static method that was a shortcut to the private instance method of the same name. --- src/accounting/static/js/account-selector.js | 2 +- src/accounting/static/js/journal-entry-editor.js | 9 +++++++++ src/accounting/static/js/transaction-form.js | 12 +----------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/accounting/static/js/account-selector.js b/src/accounting/static/js/account-selector.js index d975241..26956f0 100644 --- a/src/accounting/static/js/account-selector.js +++ b/src/accounting/static/js/account-selector.js @@ -150,7 +150,7 @@ class AccountSelector { * @return {string[]} the account codes that are used in the form */ #getCodesUsedInForm() { - const inUse = TransactionForm.getAccountCodesUsed(this.#entryType); + const inUse = this.#entryEditor.getTransactionForm().getAccountCodesUsed(this.#entryType); if (this.#entryEditor.getAccountCode() !== null) { inUse.push(this.#entryEditor.getAccountCode()); } diff --git a/src/accounting/static/js/journal-entry-editor.js b/src/accounting/static/js/journal-entry-editor.js index b4dd94b..738c584 100644 --- a/src/accounting/static/js/journal-entry-editor.js +++ b/src/accounting/static/js/journal-entry-editor.js @@ -150,6 +150,15 @@ class JournalEntryEditor { }; } + /** + * Returns the transaction form. + * + * @return {TransactionForm} the transaction form + */ + getTransactionForm() { + return this.#side.currency.form; + } + /** * Saves the summary from the summary editor. * diff --git a/src/accounting/static/js/transaction-form.js b/src/accounting/static/js/transaction-form.js index 32e0dc1..0b2f16e 100644 --- a/src/accounting/static/js/transaction-form.js +++ b/src/accounting/static/js/transaction-form.js @@ -184,7 +184,7 @@ class TransactionForm { * @param entryType {string} the entry type, either "debit" or "credit" * @return {string[]} the account codes used in the form */ - #getAccountCodesUsed(entryType) { + getAccountCodesUsed(entryType) { let inUse = []; for (const currency of this.#currencies) { inUse = inUse.concat(currency.getAccountCodesUsed(entryType)); @@ -280,16 +280,6 @@ class TransactionForm { static initialize() { this.#form = new TransactionForm() } - - /** - * Returns the account codes used in the form. - * - * @param entryType {string} the entry type, either "debit" or "credit" - * @return {string[]} the account codes used in the form - */ - static getAccountCodesUsed(entryType) { - return this.#form.#getAccountCodesUsed(entryType); - } } /**