From c8504bcbf566bf5524dbc38acef329831ae46a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Fri, 24 Mar 2023 07:47:41 +0800 Subject: [PATCH] Revised the #isQueryMatched method to match the current net balance instead of the net balance but the current form in the JavaScript OriginalLineItem class. --- src/accounting/models.py | 3 +-- .../static/js/original-line-item-selector.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/accounting/models.py b/src/accounting/models.py index 32e8e76..a5b29a2 100644 --- a/src/accounting/models.py +++ b/src/accounting/models.py @@ -781,8 +781,7 @@ class JournalEntryLineItem(db.Model): "{}/{}/{}".format(journal_entry_day.year, journal_entry_day.month, journal_entry_day.day), - format_amount(self.amount), - format_amount(self.net_balance)] + format_amount(self.amount)] class Option(db.Model): diff --git a/src/accounting/static/js/original-line-item-selector.js b/src/accounting/static/js/original-line-item-selector.js index 24b62ec..84edf0a 100644 --- a/src/accounting/static/js/original-line-item-selector.js +++ b/src/accounting/static/js/original-line-item-selector.js @@ -366,6 +366,9 @@ class OriginalLineItem { if (query === "") { return true; } + if (this.#getNetBalanceForQuery().includes(query.toLowerCase())) { + return true; + } for (const queryValue of this.#queryValues) { if (queryValue.toLowerCase().includes(query.toLowerCase())) { return true; @@ -374,6 +377,17 @@ class OriginalLineItem { return false; } + /** + * Returns the net balance in the format for query match. + * + * @return {string} the net balance in the format for query match + */ + #getNetBalanceForQuery() { + const frac = this.netBalance.modulo(1); + const whole = Number(this.netBalance.minus(frac)); + return String(whole) + String(frac).substring(1); + } + /** * Sets whether the option is shown. *