diff --git a/src/accounting/models.py b/src/accounting/models.py index f0f9cd8..3d23706 100644 --- a/src/accounting/models.py +++ b/src/accounting/models.py @@ -653,8 +653,8 @@ class VoucherLineItem(db.Model): """The account ID.""" account = db.relationship(Account, back_populates="line_items", lazy=False) """The account.""" - summary = db.Column(db.String, nullable=True) - """The summary.""" + description = db.Column(db.String, nullable=True) + """The description.""" amount = db.Column(db.Numeric(14, 2), nullable=False) """The amount.""" @@ -666,10 +666,10 @@ class VoucherLineItem(db.Model): if not hasattr(self, "__str"): from accounting.template_filters import format_date, format_amount setattr(self, "__str", - gettext("%(date)s %(summary)s %(amount)s", + gettext("%(date)s %(description)s %(amount)s", date=format_date(self.voucher.date), - summary="" if self.summary is None - else self.summary, + description="" if self.description is None + else self.description, amount=format_amount(self.amount))) return getattr(self, "__str") @@ -753,8 +753,8 @@ class VoucherLineItem(db.Model): return str(whole) + str(abs(frac))[1:] voucher_day: date = self.voucher.date - summary: str = "" if self.summary is None else self.summary - return ([summary], + description: str = "" if self.description is None else self.description + return ([description], [str(voucher_day.year), "{}/{}".format(voucher_day.year, voucher_day.month), "{}/{}".format(voucher_day.month, voucher_day.day), diff --git a/src/accounting/report/reports/income_expenses.py b/src/accounting/report/reports/income_expenses.py index 30b3c92..77d1568 100644 --- a/src/accounting/report/reports/income_expenses.py +++ b/src/accounting/report/reports/income_expenses.py @@ -57,8 +57,8 @@ class ReportLineItem: """The date.""" self.account: Account | None = None """The account.""" - self.summary: str | None = None - """The summary.""" + self.description: str | None = None + """The description.""" self.income: Decimal | None = None """The income amount.""" self.expense: Decimal | None = None @@ -72,7 +72,7 @@ class ReportLineItem: if line_item is not None: self.date = line_item.voucher.date self.account = line_item.account - self.summary = line_item.summary + self.description = line_item.description self.income = None if line_item.is_debit else line_item.amount self.expense = line_item.amount if line_item.is_debit else None self.note = line_item.voucher.note @@ -131,7 +131,7 @@ class LineItemCollector: line_item.is_brought_forward = True line_item.date = self.__period.start line_item.account = Account.accumulated_change() - line_item.summary = gettext("Brought forward") + line_item.description = gettext("Brought forward") if balance > 0: line_item.income = balance elif balance < 0: @@ -184,7 +184,7 @@ class LineItemCollector: return None line_item: ReportLineItem = ReportLineItem() line_item.is_total = True - line_item.summary = gettext("Total") + line_item.description = gettext("Total") line_item.income = sum([x.income for x in self.line_items if x.income is not None]) line_item.expense = sum([x.expense for x in self.line_items @@ -215,7 +215,7 @@ class CSVRow(BaseCSVRow): def __init__(self, voucher_date: date | str | None, account: str | None, - summary: str | None, + description: str | None, income: str | Decimal | None, expense: str | Decimal | None, balance: str | Decimal | None, @@ -224,7 +224,7 @@ class CSVRow(BaseCSVRow): :param voucher_date: The voucher date. :param account: The account. - :param summary: The summary. + :param description: The description. :param income: The income. :param expense: The expense. :param balance: The balance. @@ -234,8 +234,8 @@ class CSVRow(BaseCSVRow): """The date.""" self.account: str | None = account """The account.""" - self.summary: str | None = summary - """The summary.""" + self.description: str | None = description + """The description.""" self.income: str | Decimal | None = income """The income.""" self.expense: str | Decimal | None = expense @@ -251,7 +251,7 @@ class CSVRow(BaseCSVRow): :return: The values of the row. """ - return [self.date, self.account, self.summary, + return [self.date, self.account, self.description, self.income, self.expense, self.balance, self.note] @@ -405,18 +405,18 @@ class IncomeExpenses(BaseReport): :return: The CSV rows. """ rows: list[CSVRow] = [CSVRow(gettext("Date"), gettext("Account"), - gettext("Summary"), gettext("Income"), + gettext("Description"), gettext("Income"), gettext("Expense"), gettext("Balance"), gettext("Note"))] if self.__brought_forward is not None: rows.append(CSVRow(self.__brought_forward.date, str(self.__brought_forward.account).title(), - self.__brought_forward.summary, + self.__brought_forward.description, self.__brought_forward.income, self.__brought_forward.expense, self.__brought_forward.balance, None)) - rows.extend([CSVRow(x.date, str(x.account).title(), x.summary, + rows.extend([CSVRow(x.date, str(x.account).title(), x.description, x.income, x.expense, x.balance, x.note) for x in self.__line_items]) if self.__total is not None: diff --git a/src/accounting/report/reports/journal.py b/src/accounting/report/reports/journal.py index aa30c38..4ae6dd0 100644 --- a/src/accounting/report/reports/journal.py +++ b/src/accounting/report/reports/journal.py @@ -53,8 +53,8 @@ class ReportLineItem: """The account.""" self.account: Account = line_item.account """The account.""" - self.summary: str | None = line_item.summary - """The summary.""" + self.description: str | None = line_item.description + """The description.""" self.debit: Decimal | None = line_item.debit """The debit amount.""" self.credit: Decimal | None = line_item.credit @@ -69,14 +69,14 @@ class CSVRow(BaseCSVRow): def __init__(self, voucher_date: str | date, currency: str, account: str, - summary: str | None, + description: str | None, debit: str | Decimal | None, credit: str | Decimal | None, note: str | None): """Constructs a row in the CSV. :param voucher_date: The voucher date. - :param summary: The summary. + :param description: The description. :param debit: The debit amount. :param credit: The credit amount. :param note: The note. @@ -87,8 +87,8 @@ class CSVRow(BaseCSVRow): """The currency.""" self.account: str = account """The account.""" - self.summary: str | None = summary - """The summary.""" + self.description: str | None = description + """The description.""" self.debit: str | Decimal | None = debit """The debit amount.""" self.credit: str | Decimal | None = credit @@ -102,7 +102,7 @@ class CSVRow(BaseCSVRow): :return: The values of the row. """ - return [self.date, self.currency, self.account, self.summary, + return [self.date, self.currency, self.account, self.description, self.debit, self.credit, self.note] @@ -152,11 +152,11 @@ def get_csv_rows(line_items: list[VoucherLineItem]) -> list[CSVRow]: :return: The CSV rows. """ rows: list[CSVRow] = [CSVRow(gettext("Date"), gettext("Currency"), - gettext("Account"), gettext("Summary"), + gettext("Account"), gettext("Description"), gettext("Debit"), gettext("Credit"), gettext("Note"))] rows.extend([CSVRow(x.voucher.date, x.currency.code, - str(x.account).title(), x.summary, + str(x.account).title(), x.description, x.debit, x.credit, x.voucher.note) for x in line_items]) return rows diff --git a/src/accounting/report/reports/ledger.py b/src/accounting/report/reports/ledger.py index 3163fc0..fe1a41b 100644 --- a/src/accounting/report/reports/ledger.py +++ b/src/accounting/report/reports/ledger.py @@ -54,8 +54,8 @@ class ReportLineItem: """Whether this is the total line item.""" self.date: date | None = None """The date.""" - self.summary: str | None = None - """The summary.""" + self.description: str | None = None + """The description.""" self.debit: Decimal | None = None """The debit amount.""" self.credit: Decimal | None = None @@ -68,7 +68,7 @@ class ReportLineItem: """The URL to the voucher line item.""" if line_item is not None: self.date = line_item.voucher.date - self.summary = line_item.summary + self.description = line_item.description self.debit = line_item.amount if line_item.is_debit else None self.credit = None if line_item.is_debit else line_item.amount self.note = line_item.voucher.note @@ -126,7 +126,7 @@ class LineItemCollector: line_item: ReportLineItem = ReportLineItem() line_item.is_brought_forward = True line_item.date = self.__period.start - line_item.summary = gettext("Brought forward") + line_item.description = gettext("Brought forward") if balance > 0: line_item.debit = balance elif balance < 0: @@ -163,7 +163,7 @@ class LineItemCollector: return None line_item: ReportLineItem = ReportLineItem() line_item.is_total = True - line_item.summary = gettext("Total") + line_item.description = gettext("Total") line_item.debit = sum([x.debit for x in self.line_items if x.debit is not None]) line_item.credit = sum([x.credit for x in self.line_items @@ -195,7 +195,7 @@ class CSVRow(BaseCSVRow): """A row in the CSV.""" def __init__(self, voucher_date: date | str | None, - summary: str | None, + description: str | None, debit: str | Decimal | None, credit: str | Decimal | None, balance: str | Decimal | None, @@ -203,7 +203,7 @@ class CSVRow(BaseCSVRow): """Constructs a row in the CSV. :param voucher_date: The voucher date. - :param summary: The summary. + :param description: The description. :param debit: The debit amount. :param credit: The credit amount. :param balance: The balance. @@ -211,8 +211,8 @@ class CSVRow(BaseCSVRow): """ self.date: date | str | None = voucher_date """The date.""" - self.summary: str | None = summary - """The summary.""" + self.description: str | None = description + """The description.""" self.debit: str | Decimal | None = debit """The debit amount.""" self.credit: str | Decimal | None = credit @@ -228,7 +228,7 @@ class CSVRow(BaseCSVRow): :return: The values of the row. """ - return [self.date, self.summary, + return [self.date, self.description, self.debit, self.credit, self.balance, self.note] @@ -357,17 +357,17 @@ class Ledger(BaseReport): :return: The CSV rows. """ - rows: list[CSVRow] = [CSVRow(gettext("Date"), gettext("Summary"), + rows: list[CSVRow] = [CSVRow(gettext("Date"), gettext("Description"), gettext("Debit"), gettext("Credit"), gettext("Balance"), gettext("Note"))] if self.__brought_forward is not None: rows.append(CSVRow(self.__brought_forward.date, - self.__brought_forward.summary, + self.__brought_forward.description, self.__brought_forward.debit, self.__brought_forward.credit, self.__brought_forward.balance, None)) - rows.extend([CSVRow(x.date, x.summary, + rows.extend([CSVRow(x.date, x.description, x.debit, x.credit, x.balance, x.note) for x in self.__line_items]) if self.__total is not None: diff --git a/src/accounting/report/reports/search.py b/src/accounting/report/reports/search.py index 91a9fdf..45e7ae0 100644 --- a/src/accounting/report/reports/search.py +++ b/src/accounting/report/reports/search.py @@ -57,7 +57,7 @@ class LineItemCollector: conditions: list[sa.BinaryExpression] = [] for k in keywords: sub_conditions: list[sa.BinaryExpression] \ - = [VoucherLineItem.summary.contains(k), + = [VoucherLineItem.description.contains(k), VoucherLineItem.account_id.in_( self.__get_account_condition(k)), VoucherLineItem.currency_code.in_( diff --git a/src/accounting/static/js/summary-editor.js b/src/accounting/static/js/description-editor.js similarity index 82% rename from src/accounting/static/js/summary-editor.js rename to src/accounting/static/js/description-editor.js index a08fe07..6906eff 100644 --- a/src/accounting/static/js/summary-editor.js +++ b/src/accounting/static/js/description-editor.js @@ -1,5 +1,5 @@ /* The Mia! Accounting Flask Project - * summary-editor.js: The JavaScript for the summary editor + * description-editor.js: The JavaScript for the description editor */ /* Copyright (c) 2023 imacat. @@ -23,10 +23,10 @@ "use strict"; /** - * A summary editor. + * A description editor. * */ -class SummaryEditor { +class DescriptionEditor { /** * The line item editor @@ -35,7 +35,7 @@ class SummaryEditor { #lineItemEditor; /** - * The summary editor form + * The description editor form * @type {HTMLFormElement} */ #form; @@ -47,7 +47,7 @@ class SummaryEditor { prefix; /** - * The modal of the summary editor + * The modal of the description editor * @type {HTMLDivElement} */ #modal; @@ -65,10 +65,10 @@ class SummaryEditor { currentTab; /** - * The summary input + * The description input * @type {HTMLInputElement} */ - summary; + description; /** * The button to the original line item selector @@ -107,7 +107,7 @@ class SummaryEditor { tabPlanes = {}; /** - * Constructs a summary editor. + * Constructs a description editor. * * @param lineItemEditor {VoucherLineItemEditor} the line item editor * @param side {string} the side, either "debit" or "credit" @@ -115,10 +115,10 @@ class SummaryEditor { constructor(lineItemEditor, side) { this.#lineItemEditor = lineItemEditor; this.side = side; - this.prefix = "accounting-summary-editor-" + side; + this.prefix = "accounting-description-editor-" + side; this.#form = document.getElementById(this.prefix); this.#modal = document.getElementById(this.prefix + "-modal"); - this.summary = document.getElementById(this.prefix + "-summary"); + this.description = document.getElementById(this.prefix + "-description"); this.#offsetButton = document.getElementById(this.prefix + "-offset"); this.number = document.getElementById(this.prefix + "-annotation-number"); this.note = document.getElementById(this.prefix + "-annotation-note"); @@ -131,7 +131,7 @@ class SummaryEditor { } this.currentTab = this.tabPlanes.general; this.#initializeSuggestedAccounts(); - this.summary.onchange = () => this.#onSummaryChange(); + this.description.onchange = () => this.#onDescriptionChange(); this.#offsetButton.onclick = () => this.#lineItemEditor.originalLineItemSelector.onOpen(); this.#form.onsubmit = () => { if (this.currentTab.validate()) { @@ -142,11 +142,11 @@ class SummaryEditor { } /** - * The callback when the summary input is changed. + * The callback when the description input is changed. * */ - #onSummaryChange() { - this.summary.value = this.summary.value.trim(); + #onDescriptionChange() { + this.description.value = this.description.value.trim(); for (const tabPlane of [this.tabPlanes.bus, this.tabPlanes.travel, this.tabPlanes.general]) { if (tabPlane.populate()) { break; @@ -209,34 +209,34 @@ class SummaryEditor { } /** - * Submits the summary. + * Submits the description. * */ #submit() { bootstrap.Modal.getOrCreateInstance(this.#modal).hide(); if (this.#selectedAccount !== null) { - this.#lineItemEditor.saveSummaryWithAccount(this.summary.value, this.#selectedAccount.dataset.code, this.#selectedAccount.dataset.text, this.#selectedAccount.classList.contains("accounting-account-is-need-offset")); + this.#lineItemEditor.saveDescriptionWithAccount(this.description.value, this.#selectedAccount.dataset.code, this.#selectedAccount.dataset.text, this.#selectedAccount.classList.contains("accounting-account-is-need-offset")); } else { - this.#lineItemEditor.saveSummary(this.summary.value); + this.#lineItemEditor.saveDescription(this.description.value); } } /** - * The callback when the summary editor is shown. + * The callback when the description editor is shown. * */ onOpen() { this.#reset(); - this.summary.value = this.#lineItemEditor.summary === null? "": this.#lineItemEditor.summary; - this.#onSummaryChange(); + this.description.value = this.#lineItemEditor.description === null? "": this.#lineItemEditor.description; + this.#onDescriptionChange(); } /** - * Resets the summary editor. + * Resets the description editor. * */ #reset() { - this.summary.value = ""; + this.description.value = ""; for (const tabPlane of Object.values(this.tabPlanes)) { tabPlane.reset(); } @@ -244,16 +244,16 @@ class SummaryEditor { } /** - * Returns the summary editor instances. + * Returns the description editor instances. * * @param lineItemEditor {VoucherLineItemEditor} the line item editor - * @return {{debit: SummaryEditor, credit: SummaryEditor}} + * @return {{debit: DescriptionEditor, credit: DescriptionEditor}} */ static getInstances(lineItemEditor) { const editors = {} - const forms = Array.from(document.getElementsByClassName("accounting-summary-editor")); + const forms = Array.from(document.getElementsByClassName("accounting-description-editor")); for (const form of forms) { - editors[form.dataset.side] = new SummaryEditor(lineItemEditor, form.dataset.side); + editors[form.dataset.side] = new DescriptionEditor(lineItemEditor, form.dataset.side); } return editors; } @@ -268,8 +268,8 @@ class SummaryEditor { class TabPlane { /** - * The parent summary editor - * @type {SummaryEditor} + * The parent description editor + * @type {DescriptionEditor} */ editor; @@ -294,7 +294,7 @@ class TabPlane { /** * Constructs a tab plane. * - * @param editor {SummaryEditor} the parent summary editor + * @param editor {DescriptionEditor} the parent description editor */ constructor(editor) { this.editor = editor; @@ -320,9 +320,9 @@ class TabPlane { reset() { throw new Error("Method not implemented."); } /** - * Populates the tab plane with the summary input. + * Populates the tab plane with the description input. * - * @return {boolean} true if the summary input matches this tab, or false otherwise + * @return {boolean} true if the description input matches this tab, or false otherwise * @abstract */ populate() { throw new Error("Method not implemented."); } @@ -383,7 +383,7 @@ class TagTabPlane extends TabPlane { /** * Constructs a tab plane. * - * @param editor {SummaryEditor} the parent summary editor + * @param editor {DescriptionEditor} the parent description editor * @override */ constructor(editor) { @@ -395,7 +395,7 @@ class TagTabPlane extends TabPlane { this.initializeTagButtons(); this.tag.onchange = () => { this.onTagChange(); - this.updateSummary(); + this.updateDescription(); }; } @@ -424,11 +424,11 @@ class TagTabPlane extends TabPlane { } /** - * Updates the summary according to the input in the tab plane. + * Updates the description according to the input in the tab plane. * * @abstract */ - updateSummary() { throw new Error("Method not implemented."); } + updateDescription() { throw new Error("Method not implemented."); } /** * Switches to the tab plane. @@ -461,7 +461,7 @@ class TagTabPlane extends TabPlane { tagButton.classList.add("btn-primary"); this.tag.value = tagButton.dataset.value; this.editor.filterSuggestedAccounts(tagButton); - this.updateSummary(); + this.updateDescription(); }; } } @@ -532,28 +532,28 @@ class GeneralTagTab extends TagTabPlane { }; /** - * Updates the summary according to the input in the tab plane. + * Updates the description according to the input in the tab plane. * * @override */ - updateSummary() { - const pos = this.editor.summary.value.indexOf("—"); + updateDescription() { + const pos = this.editor.description.value.indexOf("—"); const prefix = this.tag.value === ""? "": this.tag.value + "—"; if (pos === -1) { - this.editor.summary.value = prefix + this.editor.summary.value; + this.editor.description.value = prefix + this.editor.description.value; } else { - this.editor.summary.value = prefix + this.editor.summary.value.substring(pos + 1); + this.editor.description.value = prefix + this.editor.description.value.substring(pos + 1); } } /** - * Populates the tab plane with the summary input. + * Populates the tab plane with the description input. * - * @return {boolean} true if the summary input matches this tab, or false otherwise + * @return {boolean} true if the description input matches this tab, or false otherwise * @override */ populate() { - const found = this.editor.summary.value.match(/^([^—]+)—/); + const found = this.editor.description.value.match(/^([^—]+)—/); if (found === null) { return false; } @@ -622,7 +622,7 @@ class GeneralTripTab extends TagTabPlane { /** * Constructs a tab plane. * - * @param editor {SummaryEditor} the parent summary editor + * @param editor {DescriptionEditor} the parent description editor * @override */ constructor(editor) { @@ -635,7 +635,7 @@ class GeneralTripTab extends TagTabPlane { this.#directionButtons = Array.from(document.getElementsByClassName(this.prefix + "-direction")); this.#from.onchange = () => { this.#from.value = this.#from.value.trim(); - this.updateSummary(); + this.updateDescription(); this.validateFrom(); }; for (const directionButton of this.#directionButtons) { @@ -646,12 +646,12 @@ class GeneralTripTab extends TagTabPlane { } directionButton.classList.remove("btn-outline-primary"); directionButton.classList.add("btn-primary"); - this.updateSummary(); + this.updateDescription(); }; } this.#to.onchange = () => { this.#to.value = this.#to.value.trim(); - this.updateSummary(); + this.updateDescription(); this.validateTo(); }; } @@ -667,11 +667,11 @@ class GeneralTripTab extends TagTabPlane { }; /** - * Updates the summary according to the input in the tab plane. + * Updates the description according to the input in the tab plane. * * @override */ - updateSummary() { + updateDescription() { let direction; for (const directionButton of this.#directionButtons) { if (directionButton.classList.contains("btn-primary")) { @@ -679,7 +679,7 @@ class GeneralTripTab extends TagTabPlane { break; } } - this.editor.summary.value = this.tag.value + "—" + this.#from.value + direction + this.#to.value; + this.editor.description.value = this.tag.value + "—" + this.#from.value + direction + this.#to.value; } /** @@ -707,13 +707,13 @@ class GeneralTripTab extends TagTabPlane { } /** - * Populates the tab plane with the summary input. + * Populates the tab plane with the description input. * - * @return {boolean} true if the summary input matches this tab, or false otherwise + * @return {boolean} true if the description input matches this tab, or false otherwise * @override */ populate() { - const found = this.editor.summary.value.match(/^([^—]+)—([^—→↔]+)([→↔])(.+?)(?:[*×]\d+)?(?:\([^()]+\))?$/); + const found = this.editor.description.value.match(/^([^—]+)—([^—→↔]+)([→↔])(.+?)(?:[*×]\d+)?(?:\([^()]+\))?$/); if (found === null) { return false; } @@ -834,7 +834,7 @@ class BusTripTab extends TagTabPlane { /** * Constructs a tab plane. * - * @param editor {SummaryEditor} the parent summary editor + * @param editor {DescriptionEditor} the parent description editor * @override */ constructor(editor) { @@ -847,17 +847,17 @@ class BusTripTab extends TagTabPlane { this.#toError = document.getElementById(this.prefix + "-to-error") this.#route.onchange = () => { this.#route.value = this.#route.value.trim(); - this.updateSummary(); + this.updateDescription(); this.validateRoute(); }; this.#from.onchange = () => { this.#from.value = this.#from.value.trim(); - this.updateSummary(); + this.updateDescription(); this.validateFrom(); }; this.#to.onchange = () => { this.#to.value = this.#to.value.trim(); - this.updateSummary(); + this.updateDescription(); this.validateTo(); }; } @@ -873,12 +873,12 @@ class BusTripTab extends TagTabPlane { }; /** - * Updates the summary according to the input in the tab plane. + * Updates the description according to the input in the tab plane. * * @override */ - updateSummary() { - this.editor.summary.value = this.tag.value + "—" + this.#route.value + "—" + this.#from.value + "→" + this.#to.value; + updateDescription() { + this.editor.description.value = this.tag.value + "—" + this.#route.value + "—" + this.#from.value + "→" + this.#to.value; } /** @@ -900,13 +900,13 @@ class BusTripTab extends TagTabPlane { } /** - * Populates the tab plane with the summary input. + * Populates the tab plane with the description input. * - * @return {boolean} true if the summary input matches this tab, or false otherwise + * @return {boolean} true if the description input matches this tab, or false otherwise * @override */ populate() { - const found = this.editor.summary.value.match(/^([^—]+)—([^—]+)—([^—→]+)→(.+?)(?:[*×]\d+)?(?:\([^()]+\))?$/); + const found = this.editor.description.value.match(/^([^—]+)—([^—]+)—([^—→]+)→(.+?)(?:[*×]\d+)?(?:\([^()]+\))?$/); if (found === null) { return false; } @@ -1001,7 +1001,7 @@ class RegularPaymentTab extends TabPlane { /** * Constructs a tab plane. * - * @param editor {SummaryEditor} the parent summary editor + * @param editor {DescriptionEditor} the parent description editor * @override */ constructor(editor) { @@ -1033,9 +1033,9 @@ class RegularPaymentTab extends TabPlane { } /** - * Populates the tab plane with the summary input. + * Populates the tab plane with the description input. * - * @return {boolean} true if the summary input matches this tab, or false otherwise + * @return {boolean} true if the description input matches this tab, or false otherwise * @override */ populate() { @@ -1063,15 +1063,15 @@ class AnnotationTab extends TabPlane { /** * Constructs a tab plane. * - * @param editor {SummaryEditor} the parent summary editor + * @param editor {DescriptionEditor} the parent description editor * @override */ constructor(editor) { super(editor); - this.editor.number.onchange = () => this.updateSummary(); + this.editor.number.onchange = () => this.updateDescription(); this.editor.note.onchange = () => { this.editor.note.value = this.editor.note.value.trim(); - this.updateSummary(); + this.updateDescription(); }; } @@ -1086,20 +1086,20 @@ class AnnotationTab extends TabPlane { }; /** - * Updates the summary according to the input in the tab plane. + * Updates the description according to the input in the tab plane. * * @override */ - updateSummary() { - const found = this.editor.summary.value.match(/^(.*?)(?:[*×]\d+)?(?:\([^()]+\))?$/); + updateDescription() { + const found = this.editor.description.value.match(/^(.*?)(?:[*×]\d+)?(?:\([^()]+\))?$/); if (found !== null) { - this.editor.summary.value = found[1]; + this.editor.description.value = found[1]; } if (parseInt(this.editor.number.value) > 1) { - this.editor.summary.value = this.editor.summary.value + "×" + this.editor.number.value; + this.editor.description.value = this.editor.description.value + "×" + this.editor.number.value; } if (this.editor.note.value !== "") { - this.editor.summary.value = this.editor.summary.value + "(" + this.editor.note.value + ")"; + this.editor.description.value = this.editor.description.value + "(" + this.editor.note.value + ")"; } } @@ -1114,25 +1114,25 @@ class AnnotationTab extends TabPlane { } /** - * Populates the tab plane with the summary input. + * Populates the tab plane with the description input. * - * @return {boolean} true if the summary input matches this tab, or false otherwise + * @return {boolean} true if the description input matches this tab, or false otherwise * @override */ populate() { - const found = this.editor.summary.value.match(/^(.*?)(?:[*×](\d+))?(?:\(([^()]+)\))?$/); - this.editor.summary.value = found[1]; + const found = this.editor.description.value.match(/^(.*?)(?:[*×](\d+))?(?:\(([^()]+)\))?$/); + this.editor.description.value = found[1]; if (found[2] === undefined || parseInt(found[2]) === 1) { this.editor.number.value = ""; } else { this.editor.number.value = found[2]; - this.editor.summary.value = this.editor.summary.value + "×" + this.editor.number.value; + this.editor.description.value = this.editor.description.value + "×" + this.editor.number.value; } if (found[3] === undefined) { this.editor.note.value = ""; } else { this.editor.note.value = found[3]; - this.editor.summary.value = this.editor.summary.value + "(" + this.editor.note.value + ")"; + this.editor.description.value = this.editor.description.value + "(" + this.editor.note.value + ")"; } return true; } diff --git a/src/accounting/static/js/original-line-item-selector.js b/src/accounting/static/js/original-line-item-selector.js index 54ec92f..7d2b506 100644 --- a/src/accounting/static/js/original-line-item-selector.js +++ b/src/accounting/static/js/original-line-item-selector.js @@ -244,10 +244,10 @@ class OriginalLineItem { accountText; /** - * The summary + * The description * @type {string} */ - summary; + description; /** * The net balance, without the offset amounts on the form @@ -294,7 +294,7 @@ class OriginalLineItem { this.#currencyCode = element.dataset.currencyCode; this.accountCode = element.dataset.accountCode; this.accountText = element.dataset.accountText; - this.summary = element.dataset.summary; + this.description = element.dataset.description; this.bareNetBalance = new Decimal(element.dataset.netBalance); this.netBalance = this.bareNetBalance; this.netBalanceText = document.getElementById("accounting-original-line-item-selector-option-" + this.id + "-net-balance"); diff --git a/src/accounting/static/js/voucher-form.js b/src/accounting/static/js/voucher-form.js index 72fe0d5..39d3036 100644 --- a/src/accounting/static/js/voucher-form.js +++ b/src/accounting/static/js/voucher-form.js @@ -808,16 +808,16 @@ class LineItemSubForm { #accountText; /** - * The summary + * The description * @type {HTMLInputElement} */ - #summary; + #description; /** - * The text display of the summary + * The text display of the description * @type {HTMLDivElement} */ - #summaryText; + #descriptionText; /** * The ID of the original line item @@ -873,8 +873,8 @@ class LineItemSubForm { this.no = document.getElementById(this.#prefix + "-no"); this.#accountCode = document.getElementById(this.#prefix + "-account-code"); this.#accountText = document.getElementById(this.#prefix + "-account-text"); - this.#summary = document.getElementById(this.#prefix + "-summary"); - this.#summaryText = document.getElementById(this.#prefix + "-summary-text"); + this.#description = document.getElementById(this.#prefix + "-description"); + this.#descriptionText = document.getElementById(this.#prefix + "-description-text"); this.#originalLineItemId = document.getElementById(this.#prefix + "-original-line-item-id"); this.#originalLineItemText = document.getElementById(this.#prefix + "-original-line-item-text"); this.#offsets = document.getElementById(this.#prefix + "-offsets"); @@ -925,12 +925,12 @@ class LineItemSubForm { } /** - * Returns the summary. + * Returns the description. * - * @return {string|null} the summary + * @return {string|null} the description */ - getSummary() { - return this.#summary.value === ""? null: this.#summary.value; + getDescription() { + return this.#description.value === ""? null: this.#description.value; } /** @@ -1014,8 +1014,8 @@ class LineItemSubForm { this.#accountCode.value = editor.accountCode === null? "": editor.accountCode; this.#accountCode.dataset.text = editor.accountText === null? "": editor.accountText; this.#accountText.innerText = editor.accountText === null? "": editor.accountText; - this.#summary.value = editor.summary === null? "": editor.summary; - this.#summaryText.innerText = editor.summary === null? "": editor.summary; + this.#description.value = editor.description === null? "": editor.description; + this.#descriptionText.innerText = editor.description === null? "": editor.description; this.#amount.value = editor.amount; this.#amountText.innerText = formatDecimal(new Decimal(editor.amount)); this.validate(); diff --git a/src/accounting/static/js/voucher-line-item-editor.js b/src/accounting/static/js/voucher-line-item-editor.js index 6cf00e4..cb74ae3 100644 --- a/src/accounting/static/js/voucher-line-item-editor.js +++ b/src/accounting/static/js/voucher-line-item-editor.js @@ -89,22 +89,22 @@ class VoucherLineItemEditor { #originalLineItemDelete; /** - * The control of the summary + * The control of the description * @type {HTMLDivElement} */ - #summaryControl; + #descriptionControl; /** - * The summary + * The description * @type {HTMLDivElement} */ - #summaryText; + #descriptionText; /** - * The error message of the summary + * The error message of the description * @type {HTMLDivElement} */ - #summaryError; + #descriptionError; /** * The control of the account @@ -185,10 +185,10 @@ class VoucherLineItemEditor { accountText = null; /** - * The summary + * The description * @type {string|null} */ - summary = null; + description = null; /** * The amount @@ -197,10 +197,10 @@ class VoucherLineItemEditor { amount = ""; /** - * The summary editors - * @type {{debit: SummaryEditor, credit: SummaryEditor}} + * The description editors + * @type {{debit: DescriptionEditor, credit: DescriptionEditor}} */ - #summaryEditors; + #descriptionEditors; /** * The account selectors @@ -228,20 +228,20 @@ class VoucherLineItemEditor { this.#originalLineItemText = document.getElementById(this.#prefix + "-original-line-item"); this.#originalLineItemError = document.getElementById(this.#prefix + "-original-line-item-error"); this.#originalLineItemDelete = document.getElementById(this.#prefix + "-original-line-item-delete"); - this.#summaryControl = document.getElementById(this.#prefix + "-summary-control"); - this.#summaryText = document.getElementById(this.#prefix + "-summary"); - this.#summaryError = document.getElementById(this.#prefix + "-summary-error"); + this.#descriptionControl = document.getElementById(this.#prefix + "-description-control"); + this.#descriptionText = document.getElementById(this.#prefix + "-description"); + this.#descriptionError = document.getElementById(this.#prefix + "-description-error"); this.#accountControl = document.getElementById(this.#prefix + "-account-control"); this.#accountText = document.getElementById(this.#prefix + "-account"); this.#accountError = document.getElementById(this.#prefix + "-account-error") this.#amountInput = document.getElementById(this.#prefix + "-amount"); this.#amountError = document.getElementById(this.#prefix + "-amount-error"); - this.#summaryEditors = SummaryEditor.getInstances(this); + this.#descriptionEditors = DescriptionEditor.getInstances(this); this.#accountSelectors = AccountSelector.getInstances(this); this.originalLineItemSelector = new OriginalLineItemSelector(this); this.#originalLineItemControl.onclick = () => this.originalLineItemSelector.onOpen() this.#originalLineItemDelete.onclick = () => this.clearOriginalLineItem(); - this.#summaryControl.onclick = () => this.#summaryEditors[this.side].onOpen(); + this.#descriptionControl.onclick = () => this.#descriptionEditors[this.side].onOpen(); this.#accountControl.onclick = () => this.#accountSelectors[this.side].onOpen(); this.#amountInput.onchange = () => this.#validateAmount(); this.#element.onsubmit = () => { @@ -270,14 +270,14 @@ class VoucherLineItemEditor { this.originalLineItemDate = originalLineItem.date; this.originalLineItemText = originalLineItem.text; this.#originalLineItemText.innerText = originalLineItem.text; - this.#setEnableSummaryAccount(false); - if (originalLineItem.summary === "") { - this.#summaryControl.classList.remove("accounting-not-empty"); + this.#setEnableDescriptionAccount(false); + if (originalLineItem.description === "") { + this.#descriptionControl.classList.remove("accounting-not-empty"); } else { - this.#summaryControl.classList.add("accounting-not-empty"); + this.#descriptionControl.classList.add("accounting-not-empty"); } - this.summary = originalLineItem.summary === ""? null: originalLineItem.summary; - this.#summaryText.innerText = originalLineItem.summary; + this.description = originalLineItem.description === ""? null: originalLineItem.description; + this.#descriptionText.innerText = originalLineItem.description; this.#accountControl.classList.add("accounting-not-empty"); this.accountCode = originalLineItem.accountCode; this.accountText = originalLineItem.accountText; @@ -300,7 +300,7 @@ class VoucherLineItemEditor { this.originalLineItemDate = null; this.originalLineItemText = null; this.#originalLineItemText.innerText = ""; - this.#setEnableSummaryAccount(true); + this.#setEnableDescriptionAccount(true); this.#accountControl.classList.remove("accounting-not-empty"); this.accountCode = null; this.accountText = null; @@ -318,38 +318,38 @@ class VoucherLineItemEditor { } /** - * Saves the summary from the summary editor. + * Saves the description from the description editor. * - * @param summary {string} the summary + * @param description {string} the description */ - saveSummary(summary) { - if (summary === "") { - this.#summaryControl.classList.remove("accounting-not-empty"); + saveDescription(description) { + if (description === "") { + this.#descriptionControl.classList.remove("accounting-not-empty"); } else { - this.#summaryControl.classList.add("accounting-not-empty"); + this.#descriptionControl.classList.add("accounting-not-empty"); } - this.summary = summary === ""? null: summary; - this.#summaryText.innerText = summary; - this.#validateSummary(); + this.description = description === ""? null: description; + this.#descriptionText.innerText = description; + this.#validateDescription(); bootstrap.Modal.getOrCreateInstance(this.#modal).show(); } /** - * Saves the summary with the suggested account from the summary editor. + * Saves the description with the suggested account from the description editor. * - * @param summary {string} the summary + * @param description {string} the description * @param accountCode {string} the account code * @param accountText {string} the account text * @param isAccountNeedOffset {boolean} true if the line items in the account need offset, or false otherwise */ - saveSummaryWithAccount(summary, accountCode, accountText, isAccountNeedOffset) { + saveDescriptionWithAccount(description, accountCode, accountText, isAccountNeedOffset) { this.isNeedOffset = isAccountNeedOffset; this.#accountControl.classList.add("accounting-not-empty"); this.accountCode = accountCode; this.accountText = accountText; this.#accountText.innerText = accountText; this.#validateAccount(); - this.saveSummary(summary) + this.saveDescription(description) } /** @@ -389,7 +389,7 @@ class VoucherLineItemEditor { #validate() { let isValid = true; isValid = this.#validateOriginalLineItem() && isValid; - isValid = this.#validateSummary() && isValid; + isValid = this.#validateDescription() && isValid; isValid = this.#validateAccount() && isValid; isValid = this.#validateAmount() && isValid return isValid; @@ -408,14 +408,14 @@ class VoucherLineItemEditor { } /** - * Validates the summary. + * Validates the description. * * @return {boolean} true if valid, or false otherwise * @private */ - #validateSummary() { - this.#summaryText.classList.remove("is-invalid"); - this.#summaryError.innerText = ""; + #validateDescription() { + this.#descriptionText.classList.remove("is-invalid"); + this.#descriptionError.innerText = ""; return true; } @@ -492,12 +492,12 @@ class VoucherLineItemEditor { this.originalLineItemDate = null; this.originalLineItemText = null; this.#originalLineItemText.innerText = ""; - this.#setEnableSummaryAccount(true); - this.#summaryControl.classList.remove("accounting-not-empty"); - this.#summaryControl.classList.remove("is-invalid"); - this.summary = null; - this.#summaryText.innerText = "" - this.#summaryError.innerText = "" + this.#setEnableDescriptionAccount(true); + this.#descriptionControl.classList.remove("accounting-not-empty"); + this.#descriptionControl.classList.remove("is-invalid"); + this.description = null; + this.#descriptionText.innerText = "" + this.#descriptionError.innerText = "" this.#accountControl.classList.remove("accounting-not-empty"); this.#accountControl.classList.remove("is-invalid"); this.accountCode = null; @@ -532,14 +532,14 @@ class VoucherLineItemEditor { this.#originalLineItemContainer.classList.remove("d-none"); this.#originalLineItemControl.classList.add("accounting-not-empty"); } - this.#setEnableSummaryAccount(!lineItem.isMatched && this.originalLineItemId === null); - this.summary = lineItem.getSummary(); - if (this.summary === null) { - this.#summaryControl.classList.remove("accounting-not-empty"); + this.#setEnableDescriptionAccount(!lineItem.isMatched && this.originalLineItemId === null); + this.description = lineItem.getDescription(); + if (this.description === null) { + this.#descriptionControl.classList.remove("accounting-not-empty"); } else { - this.#summaryControl.classList.add("accounting-not-empty"); + this.#descriptionControl.classList.add("accounting-not-empty"); } - this.#summaryText.innerText = this.summary === null? "": this.summary; + this.#descriptionText.innerText = this.description === null? "": this.description; if (lineItem.getAccountCode() === null) { this.#accountControl.classList.remove("accounting-not-empty"); } else { @@ -568,25 +568,25 @@ class VoucherLineItemEditor { } /** - * Sets the enable status of the summary and account. + * Sets the enable status of the description and account. * * @param isEnabled {boolean} true to enable, or false otherwise */ - #setEnableSummaryAccount(isEnabled) { + #setEnableDescriptionAccount(isEnabled) { if (isEnabled) { - this.#summaryControl.dataset.bsToggle = "modal"; - this.#summaryControl.dataset.bsTarget = "#accounting-summary-editor-" + this.#sideSubForm.side + "-modal"; - this.#summaryControl.classList.remove("accounting-disabled"); - this.#summaryControl.classList.add("accounting-clickable"); + this.#descriptionControl.dataset.bsToggle = "modal"; + this.#descriptionControl.dataset.bsTarget = "#accounting-description-editor-" + this.#sideSubForm.side + "-modal"; + this.#descriptionControl.classList.remove("accounting-disabled"); + this.#descriptionControl.classList.add("accounting-clickable"); this.#accountControl.dataset.bsToggle = "modal"; this.#accountControl.dataset.bsTarget = "#accounting-account-selector-" + this.#sideSubForm.side + "-modal"; this.#accountControl.classList.remove("accounting-disabled"); this.#accountControl.classList.add("accounting-clickable"); } else { - this.#summaryControl.dataset.bsToggle = ""; - this.#summaryControl.dataset.bsTarget = ""; - this.#summaryControl.classList.add("accounting-disabled"); - this.#summaryControl.classList.remove("accounting-clickable"); + this.#descriptionControl.dataset.bsToggle = ""; + this.#descriptionControl.dataset.bsTarget = ""; + this.#descriptionControl.classList.add("accounting-disabled"); + this.#descriptionControl.classList.remove("accounting-clickable"); this.#accountControl.dataset.bsToggle = ""; this.#accountControl.dataset.bsTarget = ""; this.#accountControl.classList.add("accounting-disabled"); diff --git a/src/accounting/templates/accounting/report/include/income-expenses-row-desktop.html b/src/accounting/templates/accounting/report/include/income-expenses-row-desktop.html index 1c38071..f3da34e 100644 --- a/src/accounting/templates/accounting/report/include/income-expenses-row-desktop.html +++ b/src/accounting/templates/accounting/report/include/income-expenses-row-desktop.html @@ -21,7 +21,7 @@ First written: 2023/3/8 #}