From 2f9d2e36cb03ba8f6e15357a2177643f10a2d8fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Mon, 3 Apr 2023 09:27:34 +0800 Subject: [PATCH] Revised the parameters of the saveDescriptionWithAccount method of the JavaScript JournalEntryLineItemEditor class to accept an DescriptionEditorAccount instance instead of the individual account values. --- src/accounting/static/js/description-editor.js | 2 +- .../static/js/journal-entry-line-item-editor.js | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/accounting/static/js/description-editor.js b/src/accounting/static/js/description-editor.js index d1e46a3..ae9f790 100644 --- a/src/accounting/static/js/description-editor.js +++ b/src/accounting/static/js/description-editor.js @@ -264,7 +264,7 @@ class DescriptionEditor { #submit() { bootstrap.Modal.getOrCreateInstance(this.#modal).hide(); if (this.#selectedAccount !== null) { - this.lineItemEditor.saveDescriptionWithAccount(this.description.value, this.#selectedAccount.code, this.#selectedAccount.text, this.#selectedAccount.isNeedOffset); + this.lineItemEditor.saveDescriptionWithAccount(this.description.value, this.#selectedAccount); } else { this.lineItemEditor.saveDescription(this.description.value); } 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 3015054..5afb66b 100644 --- a/src/accounting/static/js/journal-entry-line-item-editor.js +++ b/src/accounting/static/js/journal-entry-line-item-editor.js @@ -334,14 +334,12 @@ class JournalEntryLineItemEditor { * Saves the description with the suggested account from the description editor. * * @param description {string} the description - * @param accountCode {string} the account code - * @param accountText {string} the account text - * @param isAccountNeedOffset {boolean} true if the line items in the account need offset, or false otherwise + * @param account {DescriptionEditorAccount} the suggested account */ - saveDescriptionWithAccount(description, accountCode, accountText, isAccountNeedOffset) { + saveDescriptionWithAccount(description, account) { this.#accountControl.classList.add("accounting-not-empty"); - this.account = new JournalEntryAccount(accountCode, accountText, isAccountNeedOffset); - this.#accountText.innerText = accountText; + this.account = account.copy(); + this.#accountText.innerText = account.text; this.#validateAccount(); this.saveDescription(description) }