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

View File

@ -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"],