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.
This commit is contained in:
parent
a643d9e811
commit
34f63c1cdf
@ -681,10 +681,10 @@ class JournalEntry(db.Model):
|
|||||||
return self.amount if self.is_debit else None
|
return self.amount if self.is_debit else None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_original_entry(self) -> bool:
|
def is_need_offset(self) -> bool:
|
||||||
"""Returns whether the entry is an original entry.
|
"""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:
|
if not self.account.is_offset_needed:
|
||||||
return False
|
return False
|
||||||
|
@ -549,7 +549,7 @@ class JournalEntryEditor {
|
|||||||
this.entry = entry;
|
this.entry = entry;
|
||||||
this.#side = entry.side;
|
this.#side = entry.side;
|
||||||
this.entryType = this.#side.entryType;
|
this.entryType = this.#side.entryType;
|
||||||
this.isNeedOffset = entry.isOriginalEntry();
|
this.isNeedOffset = entry.isNeedOffset();
|
||||||
if (originalEntryId === "") {
|
if (originalEntryId === "") {
|
||||||
this.#originalEntryContainer.classList.add("d-none");
|
this.#originalEntryContainer.classList.add("d-none");
|
||||||
this.#originalEntryControl.classList.remove("accounting-not-empty");
|
this.#originalEntryControl.classList.remove("accounting-not-empty");
|
||||||
|
@ -893,8 +893,8 @@ class JournalEntrySubForm {
|
|||||||
*
|
*
|
||||||
* @return {boolean} true if the entry is an original entry, or false otherwise
|
* @return {boolean} true if the entry is an original entry, or false otherwise
|
||||||
*/
|
*/
|
||||||
isOriginalEntry() {
|
isNeedOffset() {
|
||||||
return "isOriginalEntry" in this.element.dataset;
|
return "isNeedOffset" in this.element.dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +59,7 @@ First written: 2023/2/25
|
|||||||
original_entry_id_data = entry_form.original_entry_id.data|accounting_default,
|
original_entry_id_data = entry_form.original_entry_id.data|accounting_default,
|
||||||
original_entry_date = entry_form.original_entry_date|accounting_default,
|
original_entry_date = entry_form.original_entry_date|accounting_default,
|
||||||
original_entry_text = entry_form.original_entry_text|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_entries = entry_form.offsets,
|
||||||
offset_total = entry_form.offset_total|accounting_default("0"),
|
offset_total = entry_form.offset_total|accounting_default("0"),
|
||||||
net_balance_data = entry_form.net_balance,
|
net_balance_data = entry_form.net_balance,
|
||||||
|
@ -35,7 +35,7 @@ First written: 2023/3/14
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if entry.is_original_entry %}
|
{% if entry.is_need_offset %}
|
||||||
<div class="fst-italic small accounting-offset-entries">
|
<div class="fst-italic small accounting-offset-entries">
|
||||||
{% if entry.offsets %}
|
{% if entry.offsets %}
|
||||||
<div class="d-flex justify-content-between">
|
<div class="d-flex justify-content-between">
|
||||||
|
@ -20,7 +20,7 @@ Author: imacat@mail.imacat.idv.tw (imacat)
|
|||||||
First written: 2023/2/25
|
First written: 2023/2/25
|
||||||
#}
|
#}
|
||||||
{# <ul> For SonarQube not to complain about incorrect HTML #}
|
{# <ul> For SonarQube not to complain about incorrect HTML #}
|
||||||
<li id="accounting-currency-{{ currency_index }}-{{ entry_type }}-{{ entry_index }}" class="list-group-item list-group-item-action d-flex justify-content-between accounting-currency-{{ currency_index }}-{{ entry_type }} {% if offset_entries %} accounting-matched-entry {% endif %}" data-currency-index="{{ currency_index }}" data-entry-type="{{ entry_type }}" data-entry-index="{{ entry_index }}" {% if is_original_entry %} data-is-original-entry="true" {% endif %}>
|
<li id="accounting-currency-{{ currency_index }}-{{ entry_type }}-{{ entry_index }}" class="list-group-item list-group-item-action d-flex justify-content-between accounting-currency-{{ currency_index }}-{{ entry_type }} {% if offset_entries %} accounting-matched-entry {% endif %}" data-currency-index="{{ currency_index }}" data-entry-type="{{ entry_type }}" data-entry-index="{{ entry_index }}" {% if is_need_offset %} data-is-need-offset="true" {% endif %}>
|
||||||
{% if entry_id %}
|
{% if entry_id %}
|
||||||
<input type="hidden" name="currency-{{ currency_index }}-{{ entry_type }}-{{ entry_index }}-eid" value="{{ entry_id }}">
|
<input type="hidden" name="currency-{{ currency_index }}-{{ entry_type }}-{{ entry_index }}-eid" value="{{ entry_id }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -37,7 +37,7 @@ First written: 2023/2/25
|
|||||||
<div id="accounting-currency-{{ currency_index }}-{{ entry_type }}-{{ entry_index }}-original-entry-text" class="fst-italic small accounting-original-entry {% if not original_entry_text %} d-none {% endif %}">
|
<div id="accounting-currency-{{ currency_index }}-{{ entry_type }}-{{ entry_index }}-original-entry-text" class="fst-italic small accounting-original-entry {% if not original_entry_text %} d-none {% endif %}">
|
||||||
{% if original_entry_text %}{{ A_("Offset %(entry)s", entry=original_entry_text) }}{% endif %}
|
{% if original_entry_text %}{{ A_("Offset %(entry)s", entry=original_entry_text) }}{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div id="accounting-currency-{{ currency_index }}-{{ entry_type }}-{{ entry_index }}-offsets" class="fst-italic small accounting-offset-entries {% if not is_original_entry %} d-none {% endif %}">
|
<div id="accounting-currency-{{ currency_index }}-{{ entry_type }}-{{ entry_index }}-offsets" class="fst-italic small accounting-offset-entries {% if not is_need_offset %} d-none {% endif %}">
|
||||||
{% if offset_entries %}
|
{% if offset_entries %}
|
||||||
<div class="d-flex justify-content-between {% if not offset_entries %} d-none {% endif %}">
|
<div class="d-flex justify-content-between {% if not offset_entries %} d-none {% endif %}">
|
||||||
<div>{{ A_("Offsets") }}</div>
|
<div>{{ A_("Offsets") }}</div>
|
||||||
|
@ -59,7 +59,7 @@ First written: 2023/2/25
|
|||||||
original_entry_id_data = entry_form.original_entry_id.data|accounting_default,
|
original_entry_id_data = entry_form.original_entry_id.data|accounting_default,
|
||||||
original_entry_date = entry_form.original_entry_date|accounting_default,
|
original_entry_date = entry_form.original_entry_date|accounting_default,
|
||||||
original_entry_text = entry_form.original_entry_text|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_entries = entry_form.offsets,
|
||||||
offset_total = entry_form.offset_total|accounting_default("0"),
|
offset_total = entry_form.offset_total|accounting_default("0"),
|
||||||
net_balance_data = entry_form.net_balance,
|
net_balance_data = entry_form.net_balance,
|
||||||
|
@ -61,7 +61,7 @@ First written: 2023/2/25
|
|||||||
original_entry_id_data = entry_form.original_entry_id.data|accounting_default,
|
original_entry_id_data = entry_form.original_entry_id.data|accounting_default,
|
||||||
original_entry_date = entry_form.original_entry_date|accounting_default,
|
original_entry_date = entry_form.original_entry_date|accounting_default,
|
||||||
original_entry_text = entry_form.original_entry_text|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_entries = entry_form.offsets,
|
||||||
offset_total = entry_form.offset_total|accounting_default,
|
offset_total = entry_form.offset_total|accounting_default,
|
||||||
net_balance_data = entry_form.net_balance,
|
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_id_data = entry_form.original_entry_id.data|accounting_default,
|
||||||
original_entry_date = entry_form.original_entry_date|accounting_default,
|
original_entry_date = entry_form.original_entry_date|accounting_default,
|
||||||
original_entry_text = entry_form.original_entry_text|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_entries = entry_form.offsets,
|
||||||
offset_total = entry_form.offset_total|accounting_default("0"),
|
offset_total = entry_form.offset_total|accounting_default("0"),
|
||||||
net_balance_data = entry_form.net_balance,
|
net_balance_data = entry_form.net_balance,
|
||||||
|
@ -345,10 +345,10 @@ class JournalEntryForm(FlaskForm):
|
|||||||
else str(self.__original_entry)
|
else str(self.__original_entry)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_original_entry(self) -> bool:
|
def is_need_offset(self) -> bool:
|
||||||
"""Returns whether the entry is an original entry.
|
"""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:
|
if self.account_code.data is None:
|
||||||
return False
|
return False
|
||||||
@ -371,7 +371,7 @@ class JournalEntryForm(FlaskForm):
|
|||||||
"""
|
"""
|
||||||
if not hasattr(self, "__offsets"):
|
if not hasattr(self, "__offsets"):
|
||||||
def get_offsets() -> list[JournalEntry]:
|
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 []
|
||||||
return JournalEntry.query\
|
return JournalEntry.query\
|
||||||
.filter(JournalEntry.original_entry_id == self.eid.data)\
|
.filter(JournalEntry.original_entry_id == self.eid.data)\
|
||||||
@ -390,7 +390,7 @@ class JournalEntryForm(FlaskForm):
|
|||||||
"""
|
"""
|
||||||
if not hasattr(self, "__offset_total"):
|
if not hasattr(self, "__offset_total"):
|
||||||
def get_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
|
return None
|
||||||
is_debit: bool = isinstance(self, DebitEntryForm)
|
is_debit: bool = isinstance(self, DebitEntryForm)
|
||||||
return sum([x.amount if x.is_debit != is_debit else -x.amount
|
return sum([x.amount if x.is_debit != is_debit else -x.amount
|
||||||
@ -404,7 +404,7 @@ class JournalEntryForm(FlaskForm):
|
|||||||
|
|
||||||
:return: The net balance.
|
: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:
|
or self.amount.data is None:
|
||||||
return None
|
return None
|
||||||
return self.amount.data - self.offset_total
|
return self.amount.data - self.offset_total
|
||||||
|
Loading…
Reference in New Issue
Block a user