diff --git a/tests/test_TimeTracker.py b/tests/test_TimeTracker.py index 6ee1f50..8c16be2 100644 --- a/tests/test_TimeTracker.py +++ b/tests/test_TimeTracker.py @@ -317,6 +317,22 @@ def test_recurring_task_new_instance_today_flag(self): # The NEW task MUST be today=False, even if the completed one was today=True self.assertFalse(open_task["today"], "The new recurring instance should not have the 'today' flag set.") + def test_recurring_task_new_instance_copies_note(self): + """Tests that a new instance of a recurring task copies the note from the previous instance.""" + self.tracker.add_main_project("Recurring Note Test") + self.tracker.add_task("Recurring Note Test", "Daily Task", note="Old Note Content", recurring=True) + + # Mark as done and update note at the same time + self.tracker.update_task("Recurring Note Test", "Daily Task", status="done", note="Updated note content") + + # Get all tasks for this project + tasks = self.tracker.list_tasks("Recurring Note Test", status_filter='all') + + open_task = next(t for t in tasks if t["status"] == "open") + + # The NEW task MUST have the updated note + self.assertEqual(open_task["note"], "Updated note content") + def test_list_tasks_done_status(self): """Tests that 'done' tasks are included when filtering for 'open'.""" self.tracker.add_main_project("Main") diff --git a/tt/TimeTracker.py b/tt/TimeTracker.py index b9a3cee..85917ce 100644 --- a/tt/TimeTracker.py +++ b/tt/TimeTracker.py @@ -29,7 +29,7 @@ class TimeTracker: The data is loaded from and saved to a JSON file. """ - VERSION = "3.7.7" + VERSION = "3.7.8" STATUS_OPEN = "open" STATUS_CLOSED = "closed" STATUS_DONE = "done" @@ -676,7 +676,7 @@ def update_task(self, main_project_name, old_task_name, new_task_name=None, due_ is_recurring = recurring if recurring is not None else task.get("recurring", False) if is_completing and is_recurring: - self._create_next_recurring_instance(project, task, due_date, recurring, frequency, userdefined_days) + self._create_next_recurring_instance(project, task, due_date, recurring, frequency, userdefined_days, note) if new_task_name: task["task_name"] = new_task_name @@ -707,10 +707,11 @@ def update_task(self, main_project_name, old_task_name, new_task_name=None, due_ return True return False - def _create_next_recurring_instance(self, project, task, due_date_param, recurring_param, freq_param, ud_days_param): + def _create_next_recurring_instance(self, project, task, due_date_param, recurring_param, freq_param, ud_days_param, note_param=None): freq = freq_param if freq_param is not None else task.get("frequency", "daily") ud_days = ud_days_param if ud_days_param is not None else task.get("userdefined_days", 1) base_due = due_date_param if due_date_param is not None else task.get("due_date") + note = note_param if note_param is not None else task.get("note", "") next_due = self._calculate_next_due_date(base_due, freq, ud_days) @@ -721,7 +722,7 @@ def _create_next_recurring_instance(self, project, task, due_date_param, recurri "status": self.STATUS_OPEN, "due_date": next_due, "today": False, - "note": task.get("note", ""), + "note": note, "recurring": True, "frequency": freq, "userdefined_days": ud_days