Revised the #isQueryMatched method to match the current net balance instead of the net balance but the current form in the JavaScript OriginalLineItem class.

This commit is contained in:
依瑪貓 2023-03-24 07:47:41 +08:00
parent c865141583
commit c8504bcbf5
2 changed files with 15 additions and 2 deletions

View File

@ -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):

View File

@ -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.
*