From 78a9d7794c84433bdb6cbcd89201872b19141908 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 14:57:51 +0800 Subject: [PATCH] Revised the JavaScript OriginalLineItem class to store the form instead of the selector. The selector is only used in the constructor. --- .../static/js/original-line-item-selector.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/accounting/static/js/original-line-item-selector.js b/src/accounting/static/js/original-line-item-selector.js index 117e7c5..c7a6095 100644 --- a/src/accounting/static/js/original-line-item-selector.js +++ b/src/accounting/static/js/original-line-item-selector.js @@ -194,10 +194,10 @@ class OriginalLineItemSelector { class OriginalLineItem { /** - * The original line item selector - * @type {OriginalLineItemSelector} + * The journal entry form + * @type {JournalEntryForm} */ - #selector; + #form; /** * The element @@ -278,7 +278,7 @@ class OriginalLineItem { * @param element {HTMLLIElement} the element */ constructor(selector, element) { - this.#selector = selector; + this.#form = selector.lineItemEditor.form; this.#element = element; this.id = element.dataset.id; this.date = element.dataset.date; @@ -291,7 +291,7 @@ class OriginalLineItem { this.netBalanceText = document.getElementById(`accounting-original-line-item-selector-option-${this.id}-net-balance`); this.text = element.dataset.text; this.#queryValues = JSON.parse(element.dataset.queryValues); - this.#element.onclick = () => this.#selector.lineItemEditor.saveOriginalLineItem(this); + this.#element.onclick = () => selector.lineItemEditor.saveOriginalLineItem(this); } /** @@ -332,7 +332,7 @@ class OriginalLineItem { */ isMatched(debitCredit, currencyCode, query = null) { return this.netBalance.greaterThan(0) - && this.date <= this.#selector.lineItemEditor.form.date + && this.date <= this.#form.date && this.#isDebitCreditMatched(debitCredit) && this.#currencyCode === currencyCode && this.#isQueryMatched(query);