Virgil Dupras committed 1a252cb

[#317 state:fixed] Materialize local schedule edits instead of creating exceptions in that schedule.

Comments (0)

Files changed (4)

             if global_scope:
-                transaction.recurrence.add_exception(transaction)
+                transaction.recurrence.delete(transaction)
+                materialized = transaction.replicate()
+                self.transactions.add(materialized)
             if transaction not in self.transactions:


             self.rtype2desc[RepeatType.WeekdayLast] = ''
     #--- Public
-    def add_exception(self, spawn):
-        self.date2exception[spawn.recurrence_date] = spawn
     def affected_accounts(self):
         result = self.ref.affected_accounts()
         for exception in self._all_exceptions():
             if exception is not None and date >= spawn.recurrence_date:
                 del self.date2exception[date]
         self.date2globalchange[spawn.recurrence_date] = spawn
-        self.date2exception[spawn.recurrence_date] = spawn
     def delete(self, spawn):


         eq_(budget1.start_date, budget2.start_date)
         eq_(budget1.stop_date, budget2.stop_date)
         eq_(budget1.repeat_every, budget2.repeat_every)
+def print_table(table, extra_attrs=[]):
+    def getval(row, attrname):
+        try:
+            return str(row.get_cell_value(attrname))
+        except AttributeError:
+            return 'N/A'
+    attrs = table.columns.colnames + extra_attrs
+    print('|'.join(attrs))
+    for row in table:
+        print('|'.join(getval(row, attrname) for attrname in attrs))
+    print("--- Row Count: {} ---".format(len(table)))


     eq_(app.ttable[1].description, 'foobaz')
-def test_change_spawn(app):
-    # changing a spawn adds an exception to the recurrence (even if the date is changed)
+def test_change_spawn_materializes_it(app):
+    # changing a spawn deletes the spawn and adds a new normal transaction instead.[1])
     app.ttable[1].date = '17/09/2008'
     app.ttable[1].description = 'changed'
-    eq_(app.ttable.row_count, 6) # the spawn wasn't added to the tlist as a normal txn
-    assert app.ttable[1].recurrent
+    eq_(app.ttable.row_count, 6)
+    assert not app.ttable[1].recurrent
     eq_(app.ttable[1].date, '17/09/2008')
     eq_(app.ttable[1].description, 'changed')
     # change again[1])
     app.ttable[1].date = '17/09/2008'
+    # XXX The line below could eventually be removed. It's only there because there's a glitch
+    # causing our selection to be lost on spawn materialization.
     eq_(app.ttable.row_count, 5)
     eq_(app.ttable[1].date, '19/09/2008')
     eq_(app.ttable[1].date, '16/09/2008')
-def test_delete_spawn_with_global_scope_after_change(app):
-    # A bug would cause the stop_date to be ineffective if a change had been made at a later date
-    app.ttable[3].description = 'changed'
-    app.ttable.save_edits()
-    app.doc_gui.query_for_schedule_scope_result = ScheduleScope.Global
-    app.ttable.delete()
-    eq_(app.ttable.row_count, 2)
 def test_etable_attrs(app):
     eq_(app.etable_count(), 6) # same thing in etable
     app.ttable[3].to = 'account2'
+    # We set a 'from' to avoid have the transaction deleted from the reassignment.
+    app.ttable[3].from_ = 'account'
     eq_(app.ttable[3].to, 'account2')
 def test_save_load_schedule_with_local_changes(app):
-    # Previously, exceptions would lose their recurrent status after a reload
-    # Also, later, local changes would be lost at reload
+    # Ensure that save_and_load preserves correct status.
     newapp = app.save_and_load()
-    assert newapp.ttable[2].recurrent
+    assert not newapp.ttable[2].recurrent
     eq_(newapp.ttable[2].description, 'changed')
 #--- Schedule with global change
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.