Revised to capitalize the account titles when initializing the base accounts instead of when displaying the account titles, so that the titles of the user-added accounts are not capitalized incorrectly.

This commit is contained in:
2023-07-26 20:49:06 +08:00
parent 9ae8c1bce9
commit 5ffd37c859
29 changed files with 134 additions and 56 deletions
@@ -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
@@ -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:
@@ -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]
+1 -1
View File
@@ -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
@@ -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))
@@ -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
@@ -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