Subscriptions: «Оплачено?» → paid status → «repeat?»; edit and create everything
- ops: paying marks the current charge paid (paid_for, persisted) instead of jumping to the next date; repeat_sub moves to the next period or closes the subscription. Paid-and-undecided subscriptions leave reminders and show in agenda['paid']. update_sub can set paid; tasks reopen when their status goes back; delete for subs and routines (BroV only, /api/delete); /api/tasks?all=1 and /api/subs?all=1. - Bot: «₽ Оплачено?» on reminders, then «🔁 Да, <date> / Нет, закрыть»; after paying by text it asks the same with buttons. - BroV: «Оплачено?» everywhere; «Оплачено — повторить?» section under the notch; «Весь план»: forms to edit or create tasks (title, description, status, due, company), subscriptions (amount, currency, period, date, reminder, company, paid, active) and routines, delete with confirmation, «+» per list, done tasks on demand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+45
-5
@@ -46,13 +46,52 @@ class Tasks(unittest.TestCase):
|
||||
|
||||
|
||||
class Subs(unittest.TestCase):
|
||||
def test_pay_moves_next_date_past_today(self):
|
||||
def test_paid_then_repeat_or_close(self):
|
||||
o = fresh()
|
||||
long_ago = (o.today() - timedelta(days=70)).isoformat()
|
||||
s = o.add_sub("Хостинг", 900, long_ago)
|
||||
due = (o.today() + timedelta(days=2)).isoformat()
|
||||
s = o.add_sub("Claude", 20, due, currency="USD", client="saga")
|
||||
self.assertFalse(s["paid"])
|
||||
self.assertEqual([x["id"] for x in o.agenda()["soon"]], [s["id"]])
|
||||
s = o.pay_sub(s["id"])
|
||||
self.assertGreater(date.fromisoformat(s["next_date"]), o.today())
|
||||
self.assertTrue(s["paid"]) # status persists
|
||||
self.assertTrue(o.sub(s["id"])["paid"])
|
||||
self.assertEqual(o.pay_sub(s["id"])["id"], s["id"]) # paying twice records once
|
||||
self.assertEqual(o.con.execute("SELECT COUNT(*) FROM payments").fetchone()[0], 1)
|
||||
a = o.agenda()
|
||||
self.assertEqual([x["id"] for x in a["paid"]], [s["id"]])
|
||||
self.assertEqual(a["soon"], [])
|
||||
self.assertEqual([x for x in o.due_reminders() if x["kind"] == "sub"], [])
|
||||
s = o.repeat_sub(s["id"], True)
|
||||
self.assertEqual(s["next_date"], add_period(date.fromisoformat(due), "month").isoformat())
|
||||
self.assertFalse(s["paid"])
|
||||
o.pay_sub(s["id"])
|
||||
s = o.repeat_sub(s["id"], False)
|
||||
self.assertFalse(s["active"])
|
||||
self.assertEqual(o.subs(), [])
|
||||
|
||||
def test_late_repeat_jumps_past_today(self):
|
||||
o = fresh()
|
||||
s = o.add_sub("Хостинг", 900, (o.today() - timedelta(days=70)).isoformat())
|
||||
o.pay_sub(s["id"])
|
||||
s = o.repeat_sub(s["id"])
|
||||
self.assertGreaterEqual(date.fromisoformat(s["next_date"]), o.today())
|
||||
|
||||
def test_edit_everything(self):
|
||||
o = fresh()
|
||||
t = o.add_task("x")
|
||||
o.update_task(t["id"], title="Новое", notes="тело", status="done", due="2026-12-01", client="home")
|
||||
self.assertEqual(o.task(t["id"])["status"], "done")
|
||||
o.update_task(t["id"], status="todo")
|
||||
self.assertIsNone(o.task(t["id"])["done_at"])
|
||||
s = o.add_sub("y", 1, "2026-12-01")
|
||||
o.update_sub(s["id"], paid=True)
|
||||
self.assertTrue(o.sub(s["id"])["paid"])
|
||||
o.update_sub(s["id"], paid=False, amount=5, next_date="2026-12-05")
|
||||
self.assertEqual((o.sub(s["id"])["paid"], o.sub(s["id"])["amount"]), (False, 5))
|
||||
o.delete_sub(s["id"])
|
||||
r = o.add_routine("z", 3)
|
||||
o.delete_routine(r["id"])
|
||||
self.assertEqual((o.subs(active_only=False), o.routines()), ([], []))
|
||||
|
||||
def test_monthly_cost(self):
|
||||
o = fresh()
|
||||
@@ -91,7 +130,8 @@ class Brain(unittest.TestCase):
|
||||
{"op": "delete_everything"},
|
||||
{"op": "add_sub", "name": "Домен", "amount": 1200, "next_date": "2026-11-15", "period": "year"}
|
||||
], "reply": "Записал"}''')
|
||||
lines = brain.apply_plan(o, plan)
|
||||
paid = []
|
||||
lines = brain.apply_plan(o, plan, paid)
|
||||
self.assertTrue(lines[1].startswith("+ задача #2 Купить свитч (подзадача #1)"))
|
||||
self.assertTrue(lines[2].startswith("✗"))
|
||||
self.assertEqual(o.subs()[0]["name"], "Домен")
|
||||
|
||||
Reference in New Issue
Block a user