Files
nifodea/domain/recurring.py
T
oqyude cdda703b37 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
2026-11-11 15:40:37 +03:00

31 lines
1.0 KiB
Python

from decimal import Decimal
from uuid import UUID, uuid4
from pydantic import BaseModel, Field, field_validator
class RecurringCashflow(BaseModel):
id: UUID = Field(default_factory=uuid4)
start_date: str = ""
end_date: str = ""
frequency: str = "monthly"
amount: Decimal = Field(default=Decimal("0"))
category: str = ""
# Пустая строка = платёж относится ко всем счетам (обратная совместимость).
# Имя счёта или его UUID — платёж учитывается только для этого счёта.
account: str = ""
@field_validator("frequency")
@classmethod
def _frequency_known(cls, v: str) -> str:
if v not in {"daily", "weekly", "monthly", "yearly"}:
raise ValueError(f"unknown frequency: {v}")
return v
@field_validator("amount")
@classmethod
def _amount_nonzero(cls, v: Decimal) -> Decimal:
if v == 0:
raise ValueError("amount must be non-zero")
return v