Subscriptions belong to a company; BroV owns its Keychain token

- ops: subscriptions get a client (company) column (migrated in place); the brain fills it
  from «компания сага / для планеты»; /subs and «Весь план» group by company with
  per-company monthly totals; the company shows in agenda rows and the calendar.
- BroV: the API token handed over in ops-token.import is saved by BroV itself, so the
  Keychain item belongs to BroV and macOS stops asking for the password.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maksarsanjeev
2026-10-10 03:42:41 +03:00
parent 36326ba0b6
commit 18aed2beb9
8 changed files with 161 additions and 55 deletions
+16 -10
View File
@@ -2,7 +2,7 @@
from datetime import date
from html import escape
from .core import ru_day
from .core import client_name, ru_day
ICON = {"task": "📌", "sub": "💳", "routine": "🔁"}
@@ -23,7 +23,7 @@ def human_day(iso: str, today: date) -> str:
def item_line(it: dict, today: date) -> str:
extra = f" — {it['amount']:g} {it['currency']}" if it["kind"] == "sub" else ""
client = f" [{it['client']}]" if it.get("client") else ""
client = f" [{client_name(it['client'])}]" if it.get("client") else ""
return f"{ICON[it['kind']]} {escape(it['title'])}{client}{extra} · {human_day(it['date'], today)}"
@@ -49,20 +49,26 @@ def tree(nodes: list, depth: int = 0) -> list[str]:
mark = "⏱" if t["running"] else ("▶️" if t["status"] == "doing" else "▫️")
due = f" · до {ru_day(t['due'])}" if t["due"] else ""
mins = f" · {t['minutes']} мин" if t["minutes"] else ""
client = f" [{t['client']}]" if t["client"] else ""
client = f" [{client_name(t['client'])}]" if t["client"] else ""
out.append(f"{' ' * depth}{mark} #{t['id']} {escape(t['title'])}{client}{due}{mins}")
out += tree(t["children"], depth + 1)
return out
def subs(rows: list, monthly: dict, today: date) -> str:
def subs(rows: list, by_client: dict, today: date) -> str:
"""Grouped by company, each with its monthly total."""
if not rows:
return "Подписок пока нет. Скажи, например: «хостинг 900 рублей в месяц, списание 15-го»."
lines = [f"💳 {escape(s['name'])} — {s['amount']:g} {s['currency']} / "
f"{s['every'] if s['every'] > 1 else ''}{ {'day':'день','week':'нед.','month':'мес.','year':'год'}[s['period']] }"
f" · {human_day(s['next_date'], today)}" for s in rows]
lines.append("\nВ месяц: " + ", ".join(f"{v:g} {k}" for k, v in monthly.items()))
return "\n".join(lines)
return "Подписок пока нет. Скажи, например: «Claude Code 20 $ в месяц, списание 25-го, компания Сага»."
per = {"day": "день", "week": "нед.", "month": "мес.", "year": "год"}
out = []
for client in sorted({s["client"] for s in rows}, key=lambda c: (c == "", c)):
total = ", ".join(f"{v:g} {k}" for k, v in by_client.get(client, {}).items())
out.append(f"\n<b>{escape(client_name(client) or 'Без компании')}</b> — {total} в мес.")
for s in (x for x in rows if x["client"] == client):
every = f"{s['every']} " if s["every"] > 1 else ""
out.append(f"💳 {escape(s['name'])} — {s['amount']:g} {s['currency']} / {every}{per[s['period']]}"
f" · {human_day(s['next_date'], today)}")
return "\n".join(out).strip()
def routines(rows: list, today: date) -> str: