T9: Excel as the model authoring surface

- ExcelRepository: canonical columns with ru/en aliases, date/number normalization
  (Excel dates, DD.MM.YYYY, '1 234,56', currency symbols, parentheses), account
  name->UUID resolution, per-row errors with sheet!row, warnings for formulas
  without cached values, duplicate names and default exchange rates
- ExcelTemplate: skeleton generator (number/date formats, dropdowns for currency,
  frequency en/ru and account, 'Инструкция' sheet); ship data/model_template.xlsx
- CLI: cf template-xlsx [--force]; cf import-xlsx --dry-run with rich error table,
  import writes nothing when the file has errors
- RecurringCashflow.account (empty = all accounts) + name/UUID matching in forecast;
  cf config recurring-add --account, account column in info/recurring-list
- Forecast: runs are idempotent, 'Итог: Баланс' sums all accounts of the last month
- README: 'Сборка модели в Excel' section
- ruff check . clean (9 pre-existing import/line-length findings fixed)
- MetaAgent: T9 archived, req-T9 approved, manifest/checkpoints/state synced

118 tests pass
This commit is contained in:
oqyude committed 2026-11-11 15:40:37 +03:00
1 parent b90ca4c282
commit cdda703b37
39 files changed
+2181 -198

No files matched your search

+16 -4
View File
@@ -13,7 +13,7 @@ from domain import (
Transaction,
)
from infrastructure.cli.i18n import t
from infrastructure.cli.services import load_model, save_model
from infrastructure.cli.services import account_label, load_model, save_model
app = typer.Typer(name="config", help=t("config.help"))
console = Console()
@@ -242,12 +242,19 @@ def recurring_add(
frequency: str = typer.Option("monthly", "--frequency", "-f", help=t("cmd.config.recurring_add.opt.frequency")),
start_date: str = typer.Option("", "--start", "-s", help=t("cmd.config.recurring_add.opt.start")),
end_date: str = typer.Option("", "--end", "-e", help=t("cmd.config.recurring_add.opt.end")),
account: str = typer.Option("", "--account", "-a", help=t("cmd.config.recurring_add.opt.account")),
) -> None:
"""Добавить регулярный платёж"""
model = load_model()
account_id = ""
if account:
account_id = _resolve_account_id(model, account) or ""
if not account_id:
console.print(f"[red]{t('cmd.config.recurring_add.err', account=account)}[/red]")
raise typer.Exit(1)
rc = RecurringCashflow(
start_date=start_date or "", end_date=end_date or "",
frequency=frequency, amount=amount, category=category,
frequency=frequency, amount=amount, category=category, account=account_id,
)
model.recurring.append(rc)
save_model(model)
@@ -266,6 +273,7 @@ def recurring_list() -> None:
return
table = Table(title=t("table.recurring.title"))
table.add_column(t("table.recurring.col.id"), style="dim")
table.add_column(t("table.recurring.col.account"))
table.add_column(t("table.recurring.col.start"))
table.add_column(t("table.recurring.col.end"))
table.add_column(t("table.recurring.col.period"))
@@ -273,7 +281,8 @@ def recurring_list() -> None:
table.add_column(t("table.recurring.col.category"))
for r in model.recurring:
amount_str = CurrencyConverter.format_money(r.amount, model.base_currency)
row = (str(r.id)[:8], r.start_date, r.end_date, r.frequency, amount_str, r.category)
owner = account_label(model, r.account, empty=t("table.recurring.all_accounts"))
row = (str(r.id)[:8], owner, r.start_date, r.end_date, r.frequency, amount_str, r.category)
table.add_row(*row)
console.print(table)
@@ -410,8 +419,11 @@ def liability_remove(
def _resolve_account_id(model, identifier: str) -> str | None:
value = (identifier or "").strip()
if not value:
return None
for a in model.accounts:
if str(a.id) == identifier or a.name == identifier:
if value == str(a.id) or value.casefold() == a.name.strip().casefold():
return str(a.id)
return None