diff --git a/src/accounting/static/js/journal-entry-form.js b/src/accounting/static/js/journal-entry-form.js index 5bdb2ae..1a56735 100644 --- a/src/accounting/static/js/journal-entry-form.js +++ b/src/accounting/static/js/journal-entry-form.js @@ -207,8 +207,8 @@ class JournalEntryForm { * @return {string[]} the account codes used in the form */ getAccountCodesUsed(debitCredit) { - return this.getLineItems(debitCredit).map((lineItem) => lineItem.accountCode) - .filter((code) => code !== null); + return this.getLineItems(debitCredit).filter((lineItem) => lineItem.account !== null) + .map((lineItem) => lineItem.account.code); } /** @@ -940,15 +940,6 @@ class LineItemSubForm { this.#no.value = String(siblings.indexOf(this.#element) + 1); } - /** - * Returns whether the line item needs offset. - * - * @return {boolean} true if the line item needs offset, or false otherwise - */ - get isNeedOffset() { - return "isNeedOffset" in this.#element.dataset; - } - /** * Returns the ID of the original line item. * @@ -986,21 +977,12 @@ class LineItemSubForm { } /** - * Returns the account code. + * Returns the account. * - * @return {string|null} the account code + * @return {JournalEntryAccount|null} the account */ - get accountCode() { - return this.#accountCode.value === ""? null: this.#accountCode.value; - } - - /** - * Returns the account text. - * - * @return {string|null} the account text - */ - get accountText() { - return this.#accountCode.dataset.text === ""? null: this.#accountCode.dataset.text; + get account() { + return this.#accountCode.value === null? null: new JournalEntryAccount(this.#accountCode.value, this.#accountCode.dataset.text, "isNeedOffset" in this.#element.dataset); } /** 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 fdaf5f9..c10013a 100644 --- a/src/accounting/static/js/journal-entry-line-item-editor.js +++ b/src/accounting/static/js/journal-entry-line-item-editor.js @@ -517,12 +517,12 @@ class JournalEntryLineItemEditor { this.#descriptionControl.classList.add("accounting-not-empty"); } this.#descriptionText.innerText = this.description === null? "": this.description; - if (lineItem.accountCode === null) { + this.account = lineItem.account; + if (this.account === null) { this.#accountControl.classList.remove("accounting-not-empty"); } else { this.#accountControl.classList.add("accounting-not-empty"); } - this.account = new JournalEntryAccount(lineItem.accountCode, lineItem.accountText, lineItem.isNeedOffset); this.#accountText.innerText = this.account.text; this.#amountInput.value = lineItem.amount === null? "": String(lineItem.amount); const maxAmount = this.#getMaxAmount();