From 34f63c1cdfcb88d99aab93b1328b15135fb55c4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 18 Mar 2023 18:55:31 +0800 Subject: [PATCH] Renamed the "isOriginalEntry", "is-original-entry", "is_original_entry", and "isOriginalEntry()" methods and properties of journal entries to "isNeedOffset", "is-need-offset", "is_need_offset", and "isNeedOffset()", to be clear and understandable. --- src/accounting/models.py | 6 +++--- src/accounting/static/js/journal-entry-editor.js | 2 +- src/accounting/static/js/transaction-form.js | 4 ++-- .../expense/include/form-currency-item.html | 2 +- .../transaction/include/detail-entries.html | 2 +- .../transaction/include/form-entry-item.html | 4 ++-- .../income/include/form-currency-item.html | 2 +- .../transfer/include/form-currency-item.html | 4 ++-- src/accounting/transaction/forms/journal_entry.py | 12 ++++++------ 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/accounting/models.py b/src/accounting/models.py index befb901..c35edf1 100644 --- a/src/accounting/models.py +++ b/src/accounting/models.py @@ -681,10 +681,10 @@ class JournalEntry(db.Model): return self.amount if self.is_debit else None @property - def is_original_entry(self) -> bool: - """Returns whether the entry is an original entry. + def is_need_offset(self) -> bool: + """Returns whether the entry needs offset. - :return: True if the entry is an original entry, or False otherwise. + :return: True if the entry needs offset, or False otherwise. """ if not self.account.is_offset_needed: return False diff --git a/src/accounting/static/js/journal-entry-editor.js b/src/accounting/static/js/journal-entry-editor.js index 3326e55..e25f0a1 100644 --- a/src/accounting/static/js/journal-entry-editor.js +++ b/src/accounting/static/js/journal-entry-editor.js @@ -549,7 +549,7 @@ class JournalEntryEditor { this.entry = entry; this.#side = entry.side; this.entryType = this.#side.entryType; - this.isNeedOffset = entry.isOriginalEntry(); + this.isNeedOffset = entry.isNeedOffset(); if (originalEntryId === "") { this.#originalEntryContainer.classList.add("d-none"); this.#originalEntryControl.classList.remove("accounting-not-empty"); diff --git a/src/accounting/static/js/transaction-form.js b/src/accounting/static/js/transaction-form.js index cabd355..4628827 100644 --- a/src/accounting/static/js/transaction-form.js +++ b/src/accounting/static/js/transaction-form.js @@ -893,8 +893,8 @@ class JournalEntrySubForm { * * @return {boolean} true if the entry is an original entry, or false otherwise */ - isOriginalEntry() { - return "isOriginalEntry" in this.element.dataset; + isNeedOffset() { + return "isNeedOffset" in this.element.dataset; } /** diff --git a/src/accounting/templates/accounting/transaction/expense/include/form-currency-item.html b/src/accounting/templates/accounting/transaction/expense/include/form-currency-item.html index 8d0daaf..308a137 100644 --- a/src/accounting/templates/accounting/transaction/expense/include/form-currency-item.html +++ b/src/accounting/templates/accounting/transaction/expense/include/form-currency-item.html @@ -59,7 +59,7 @@ First written: 2023/2/25 original_entry_id_data = entry_form.original_entry_id.data|accounting_default, original_entry_date = entry_form.original_entry_date|accounting_default, original_entry_text = entry_form.original_entry_text|accounting_default, - is_original_entry = entry_form.is_original_entry, + is_need_offset = entry_form.is_need_offset, offset_entries = entry_form.offsets, offset_total = entry_form.offset_total|accounting_default("0"), net_balance_data = entry_form.net_balance, diff --git a/src/accounting/templates/accounting/transaction/include/detail-entries.html b/src/accounting/templates/accounting/transaction/include/detail-entries.html index de25204..55c439b 100644 --- a/src/accounting/templates/accounting/transaction/include/detail-entries.html +++ b/src/accounting/templates/accounting/transaction/include/detail-entries.html @@ -35,7 +35,7 @@ First written: 2023/3/14 {% endif %} - {% if entry.is_original_entry %} + {% if entry.is_need_offset %}
{% if entry.offsets %}
diff --git a/src/accounting/templates/accounting/transaction/include/form-entry-item.html b/src/accounting/templates/accounting/transaction/include/form-entry-item.html index 2831e60..b462baf 100644 --- a/src/accounting/templates/accounting/transaction/include/form-entry-item.html +++ b/src/accounting/templates/accounting/transaction/include/form-entry-item.html @@ -20,7 +20,7 @@ Author: imacat@mail.imacat.idv.tw (imacat) First written: 2023/2/25 #} {#
    For SonarQube not to complain about incorrect HTML #} -
  • +
  • {% if entry_id %} {% endif %} @@ -37,7 +37,7 @@ First written: 2023/2/25
    {% if original_entry_text %}{{ A_("Offset %(entry)s", entry=original_entry_text) }}{% endif %}
    -
    +
    {% if offset_entries %}
    {{ A_("Offsets") }}
    diff --git a/src/accounting/templates/accounting/transaction/income/include/form-currency-item.html b/src/accounting/templates/accounting/transaction/income/include/form-currency-item.html index 940a25f..326631d 100644 --- a/src/accounting/templates/accounting/transaction/income/include/form-currency-item.html +++ b/src/accounting/templates/accounting/transaction/income/include/form-currency-item.html @@ -59,7 +59,7 @@ First written: 2023/2/25 original_entry_id_data = entry_form.original_entry_id.data|accounting_default, original_entry_date = entry_form.original_entry_date|accounting_default, original_entry_text = entry_form.original_entry_text|accounting_default, - is_original_entry = entry_form.is_original_entry, + is_need_offset = entry_form.is_need_offset, offset_entries = entry_form.offsets, offset_total = entry_form.offset_total|accounting_default("0"), net_balance_data = entry_form.net_balance, diff --git a/src/accounting/templates/accounting/transaction/transfer/include/form-currency-item.html b/src/accounting/templates/accounting/transaction/transfer/include/form-currency-item.html index 764968f..9c089a1 100644 --- a/src/accounting/templates/accounting/transaction/transfer/include/form-currency-item.html +++ b/src/accounting/templates/accounting/transaction/transfer/include/form-currency-item.html @@ -61,7 +61,7 @@ First written: 2023/2/25 original_entry_id_data = entry_form.original_entry_id.data|accounting_default, original_entry_date = entry_form.original_entry_date|accounting_default, original_entry_text = entry_form.original_entry_text|accounting_default, - is_original_entry = entry_form.is_original_entry, + is_need_offset = entry_form.is_need_offset, offset_entries = entry_form.offsets, offset_total = entry_form.offset_total|accounting_default, net_balance_data = entry_form.net_balance, @@ -109,7 +109,7 @@ First written: 2023/2/25 original_entry_id_data = entry_form.original_entry_id.data|accounting_default, original_entry_date = entry_form.original_entry_date|accounting_default, original_entry_text = entry_form.original_entry_text|accounting_default, - is_original_entry = entry_form.is_original_entry, + is_need_offset = entry_form.is_need_offset, offset_entries = entry_form.offsets, offset_total = entry_form.offset_total|accounting_default("0"), net_balance_data = entry_form.net_balance, diff --git a/src/accounting/transaction/forms/journal_entry.py b/src/accounting/transaction/forms/journal_entry.py index 015658c..c317bbd 100644 --- a/src/accounting/transaction/forms/journal_entry.py +++ b/src/accounting/transaction/forms/journal_entry.py @@ -345,10 +345,10 @@ class JournalEntryForm(FlaskForm): else str(self.__original_entry) @property - def is_original_entry(self) -> bool: - """Returns whether the entry is an original entry. + def is_need_offset(self) -> bool: + """Returns whether the entry needs offset. - :return: True if the entry is an original entry, or False otherwise. + :return: True if the entry needs offset, or False otherwise. """ if self.account_code.data is None: return False @@ -371,7 +371,7 @@ class JournalEntryForm(FlaskForm): """ if not hasattr(self, "__offsets"): def get_offsets() -> list[JournalEntry]: - if not self.is_original_entry or self.eid.data is None: + if not self.is_need_offset or self.eid.data is None: return [] return JournalEntry.query\ .filter(JournalEntry.original_entry_id == self.eid.data)\ @@ -390,7 +390,7 @@ class JournalEntryForm(FlaskForm): """ if not hasattr(self, "__offset_total"): def get_offset_total(): - if not self.is_original_entry or self.eid.data is None: + if not self.is_need_offset or self.eid.data is None: return None is_debit: bool = isinstance(self, DebitEntryForm) return sum([x.amount if x.is_debit != is_debit else -x.amount @@ -404,7 +404,7 @@ class JournalEntryForm(FlaskForm): :return: The net balance. """ - if not self.is_original_entry or self.eid.data is None \ + if not self.is_need_offset or self.eid.data is None \ or self.amount.data is None: return None return self.amount.data - self.offset_total