diff --git a/src/accounting/static/js/description-editor.js b/src/accounting/static/js/description-editor.js index ae9f790..b0a575c 100644 --- a/src/accounting/static/js/description-editor.js +++ b/src/accounting/static/js/description-editor.js @@ -263,11 +263,7 @@ class DescriptionEditor { */ #submit() { bootstrap.Modal.getOrCreateInstance(this.#modal).hide(); - if (this.#selectedAccount !== null) { - this.lineItemEditor.saveDescriptionWithAccount(this.description.value, this.#selectedAccount); - } else { - this.lineItemEditor.saveDescription(this.description.value); - } + this.lineItemEditor.saveDescription(this.description.value, this.#selectedAccount); } /** diff --git a/src/accounting/static/js/journal-entry-line-item-editor.js b/src/accounting/static/js/journal-entry-line-item-editor.js index 5afb66b..355172e 100644 --- a/src/accounting/static/js/journal-entry-line-item-editor.js +++ b/src/accounting/static/js/journal-entry-line-item-editor.js @@ -317,8 +317,15 @@ class JournalEntryLineItemEditor { * Saves the description from the description editor. * * @param description {string} the description + * @param account {DescriptionEditorAccount|null} the suggested account */ - saveDescription(description) { + saveDescription(description, account = null) { + if (account !== null) { + this.#accountControl.classList.add("accounting-not-empty"); + this.account = account.copy(); + this.#accountText.innerText = account.text; + this.#validateAccount(); + } if (description === "") { this.#descriptionControl.classList.remove("accounting-not-empty"); } else { @@ -330,20 +337,6 @@ class JournalEntryLineItemEditor { bootstrap.Modal.getOrCreateInstance(this.modal).show(); } - /** - * Saves the description with the suggested account from the description editor. - * - * @param description {string} the description - * @param account {DescriptionEditorAccount} the suggested account - */ - saveDescriptionWithAccount(description, account) { - this.#accountControl.classList.add("accounting-not-empty"); - this.account = account.copy(); - this.#accountText.innerText = account.text; - this.#validateAccount(); - this.saveDescription(description) - } - /** * Clears the account. *