diff --git a/src/accounting/base_account/commands.py b/src/accounting/base_account/commands.py index cc06581..28939f7 100644 --- a/src/accounting/base_account/commands.py +++ b/src/accounting/base_account/commands.py @@ -24,6 +24,7 @@ import sqlalchemy as sa from accounting import data_dir from accounting import db from accounting.models import BaseAccount, BaseAccountL10n +from accounting.utils.title_case import title_case def init_base_accounts_command() -> None: @@ -34,7 +35,7 @@ def init_base_accounts_command() -> None: with open(data_dir / "base_accounts.csv") as fp: data: list[dict[str, str]] = [x for x in csv.DictReader(fp)] account_data: list[dict[str, str]] = [{"code": x["code"], - "title_l10n": x["title"]} + "title_l10n": title_case(x["title"])} for x in data] locales: list[str] = [x[5:] for x in data[0] if x.startswith("l10n-")] l10n_data: list[dict[str, str]] = [{"account_code": x["code"], diff --git a/src/accounting/models.py b/src/accounting/models.py index e949fd9..df84366 100644 --- a/src/accounting/models.py +++ b/src/accounting/models.py @@ -54,7 +54,7 @@ class BaseAccount(db.Model): :return: The string representation of the base account. """ - return f"{self.code} {self.title.title()}" + return f"{self.code} {self.title}" @property def title(self) -> str: @@ -151,7 +151,7 @@ class Account(db.Model): :return: The string representation of this account. """ - return f"{self.base_code}-{self.no:03d} {self.title.title()}" + return f"{self.base_code}-{self.no:03d} {self.title}" @property def code(self) -> str: diff --git a/src/accounting/report/reports/balance_sheet.py b/src/accounting/report/reports/balance_sheet.py index 9fc2321..65969b7 100644 --- a/src/accounting/report/reports/balance_sheet.py +++ b/src/accounting/report/reports/balance_sheet.py @@ -454,11 +454,11 @@ class BalanceSheet(BaseReport): :return: The CSV rows for the section. """ rows: list[CSVHalfRow] \ - = [CSVHalfRow(section.title.title.title(), None)] + = [CSVHalfRow(section.title.title, None)] for subsection in section.subsections: - rows.append(CSVHalfRow(f" {subsection.title.title.title()}", None)) + rows.append(CSVHalfRow(f" {subsection.title.title}", None)) for account in subsection.accounts: - rows.append(CSVHalfRow(f" {str(account.account).title()}", + rows.append(CSVHalfRow(f" {str(account.account)}", account.amount)) return rows diff --git a/src/accounting/report/reports/income_expenses.py b/src/accounting/report/reports/income_expenses.py index 9ed35b5..ae5b355 100644 --- a/src/accounting/report/reports/income_expenses.py +++ b/src/accounting/report/reports/income_expenses.py @@ -407,13 +407,13 @@ class IncomeExpenses(BaseReport): gettext("Note"))] if self.__brought_forward is not None: rows.append(CSVRow(self.__brought_forward.date, - str(self.__brought_forward.account).title(), + str(self.__brought_forward.account), 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.description, + rows.extend([CSVRow(x.date, str(x.account), 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/income_statement.py b/src/accounting/report/reports/income_statement.py index 72b451c..c45349a 100644 --- a/src/accounting/report/reports/income_statement.py +++ b/src/accounting/report/reports/income_statement.py @@ -226,12 +226,12 @@ class IncomeStatement(BaseReport): for x in balances})).all() total_titles: dict[str, str] \ - = {"4": gettext("total operating revenue"), - "5": gettext("gross income"), - "6": gettext("operating income"), - "7": gettext("before tax income"), - "8": gettext("after tax income"), - "9": gettext("net income or loss for current period")} + = {"4": gettext("Total Operating Revenue"), + "5": gettext("Gross Income"), + "6": gettext("Operating Income"), + "7": gettext("Before Tax Income"), + "8": gettext("After Tax Income"), + "9": gettext("Net Income or Loss for Current Period")} sections: dict[str, Section] \ = {x.code: Section(x, total_titles[x.code]) for x in titles} @@ -301,14 +301,14 @@ class IncomeStatement(BaseReport): total_str: str = gettext("Total") rows: list[CSVRow] = [CSVRow(None, gettext("Amount"))] for section in self.__sections: - rows.append(CSVRow(str(section.title).title(), None)) + rows.append(CSVRow(str(section.title), None)) for subsection in section.subsections: - rows.append(CSVRow(f" {str(subsection.title).title()}", None)) + rows.append(CSVRow(f" {str(subsection.title)}", None)) for account in subsection.accounts: - rows.append(CSVRow(f" {str(account.account).title()}", + rows.append(CSVRow(f" {str(account.account)}", account.amount)) rows.append(CSVRow(f" {total_str}", subsection.total)) - rows.append(CSVRow(section.accumulated.title.title(), + rows.append(CSVRow(section.accumulated.title, section.accumulated.amount)) rows.append(CSVRow(None, None)) rows = rows[:-1] diff --git a/src/accounting/report/reports/journal.py b/src/accounting/report/reports/journal.py index e86d44b..67bdeb3 100644 --- a/src/accounting/report/reports/journal.py +++ b/src/accounting/report/reports/journal.py @@ -160,7 +160,7 @@ def get_csv_rows(line_items: list[JournalEntryLineItem]) -> list[CSVRow]: gettext("Debit"), gettext("Credit"), gettext("Note"))] rows.extend([CSVRow(x.journal_entry.date, x.currency.code, - str(x.account).title(), x.description, + str(x.account), x.description, x.debit, x.credit, x.journal_entry.note) for x in line_items]) return rows diff --git a/src/accounting/report/reports/trial_balance.py b/src/accounting/report/reports/trial_balance.py index 2a6cce7..50be407 100644 --- a/src/accounting/report/reports/trial_balance.py +++ b/src/accounting/report/reports/trial_balance.py @@ -224,7 +224,7 @@ class TrialBalance(BaseReport): """ rows: list[CSVRow] = [CSVRow(gettext("Account"), gettext("Debit"), gettext("Credit"))] - rows.extend([CSVRow(str(x.account).title(), x.debit, x.credit) + rows.extend([CSVRow(str(x.account), x.debit, x.credit) for x in self.__accounts]) rows.append(CSVRow(gettext("Total"), self.__total.debit, self.__total.credit)) diff --git a/src/accounting/report/reports/unapplied_accounts.py b/src/accounting/report/reports/unapplied_accounts.py index 1b3f3d2..99a22c4 100644 --- a/src/accounting/report/reports/unapplied_accounts.py +++ b/src/accounting/report/reports/unapplied_accounts.py @@ -120,8 +120,7 @@ def get_csv_rows(accounts: list[Account]) -> list[CSVRow]: :return: The CSV rows. """ rows: list[CSVRow] = [CSVRow(gettext("Account"), gettext("Count"))] - rows.extend([CSVRow(str(x).title(), x.count) - for x in accounts]) + rows.extend([CSVRow(str(x), x.count) for x in accounts]) return rows diff --git a/src/accounting/report/reports/unmatched_accounts.py b/src/accounting/report/reports/unmatched_accounts.py index ac83335..4a3d6cb 100644 --- a/src/accounting/report/reports/unmatched_accounts.py +++ b/src/accounting/report/reports/unmatched_accounts.py @@ -120,8 +120,7 @@ def get_csv_rows(accounts: list[Account]) -> list[CSVRow]: :return: The CSV rows. """ rows: list[CSVRow] = [CSVRow(gettext("Account"), gettext("Count"))] - rows.extend([CSVRow(str(x).title(), x.count) - for x in accounts]) + rows.extend([CSVRow(str(x), x.count) for x in accounts]) return rows diff --git a/src/accounting/templates/accounting/account/detail.html b/src/accounting/templates/accounting/account/detail.html index 702855c..4ac1a88 100644 --- a/src/accounting/templates/accounting/account/detail.html +++ b/src/accounting/templates/accounting/account/detail.html @@ -90,7 +90,7 @@ First written: 2023/1/31 {% endif %}