Replaced the accountCode and accountText getters with the account getter in the JavaScript LineItemSubForm class.
This commit is contained in:
		| @@ -207,8 +207,8 @@ class JournalEntryForm { | |||||||
|      * @return {string[]} the account codes used in the form |      * @return {string[]} the account codes used in the form | ||||||
|      */ |      */ | ||||||
|     getAccountCodesUsed(debitCredit) { |     getAccountCodesUsed(debitCredit) { | ||||||
|         return this.getLineItems(debitCredit).map((lineItem) => lineItem.accountCode) |         return this.getLineItems(debitCredit).filter((lineItem) => lineItem.account !== null) | ||||||
|             .filter((code) => code !== null); |             .map((lineItem) => lineItem.account.code); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -940,15 +940,6 @@ class LineItemSubForm { | |||||||
|         this.#no.value = String(siblings.indexOf(this.#element) + 1); |         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. |      * 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() { |     get account() { | ||||||
|         return this.#accountCode.value === ""? null: this.#accountCode.value; |         return this.#accountCode.value === null? null: new JournalEntryAccount(this.#accountCode.value, this.#accountCode.dataset.text, "isNeedOffset" in this.#element.dataset); | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Returns the account text. |  | ||||||
|      * |  | ||||||
|      * @return {string|null} the account text |  | ||||||
|      */ |  | ||||||
|     get accountText() { |  | ||||||
|         return this.#accountCode.dataset.text === ""? null: this.#accountCode.dataset.text; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|   | |||||||
| @@ -517,12 +517,12 @@ class JournalEntryLineItemEditor { | |||||||
|             this.#descriptionControl.classList.add("accounting-not-empty"); |             this.#descriptionControl.classList.add("accounting-not-empty"); | ||||||
|         } |         } | ||||||
|         this.#descriptionText.innerText = this.description === null? "": this.description; |         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"); |             this.#accountControl.classList.remove("accounting-not-empty"); | ||||||
|         } else { |         } else { | ||||||
|             this.#accountControl.classList.add("accounting-not-empty"); |             this.#accountControl.classList.add("accounting-not-empty"); | ||||||
|         } |         } | ||||||
|         this.account = new JournalEntryAccount(lineItem.accountCode, lineItem.accountText, lineItem.isNeedOffset); |  | ||||||
|         this.#accountText.innerText = this.account.text; |         this.#accountText.innerText = this.account.text; | ||||||
|         this.#amountInput.value = lineItem.amount === null? "": String(lineItem.amount); |         this.#amountInput.value = lineItem.amount === null? "": String(lineItem.amount); | ||||||
|         const maxAmount = this.#getMaxAmount(); |         const maxAmount = this.#getMaxAmount(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user