Add menu option to reload rulefile
This commit is contained in:
@@ -70,7 +70,7 @@ class MainWindow(ThemedTk):
|
||||
menu_file.add_command(label="Export Transactions", command=self.do_export_txn)
|
||||
menu_file.add_separator()
|
||||
menu_file.add_command(label="Save Rules", command=self.do_save_rules)
|
||||
# menu_file.add_command(label="Reload Rules", command=self.do_save_rules)
|
||||
menu_file.add_command(label="Reload Rules", command=self.do_reload_rules)
|
||||
menu_file.add_separator()
|
||||
menu_file.add_command(label="Exit", command=lambda: self.destroy())
|
||||
self.menubar.add_cascade(menu=menu_file, label="File")
|
||||
@@ -175,17 +175,22 @@ class MainWindow(ThemedTk):
|
||||
self.ruleset.add_rule(rule)
|
||||
|
||||
# Adding a rule means a full regeneration
|
||||
self.regenerate_rows()
|
||||
|
||||
self.update_status(f"Rule created! {affected} transactions affected.")
|
||||
|
||||
def regenerate_rows(self):
|
||||
"""
|
||||
Fully regenerate rows (incl in the editor) from the ruleset, aside from custom.
|
||||
"""
|
||||
for record in self.rows:
|
||||
if record not in self.custom:
|
||||
txn = self.converter.convert(record, self.ruleset)
|
||||
self.rows[record] = txn
|
||||
|
||||
# Tell the table to regenerate
|
||||
self.rowtree.update_rows(self.rows)
|
||||
self.rebuild_account_cache()
|
||||
|
||||
self.update_status(f"Rule created! {affected} transactions affected.")
|
||||
|
||||
def initial_ingest(self):
|
||||
if self.files:
|
||||
rows = {}
|
||||
@@ -309,4 +314,12 @@ class MainWindow(ThemedTk):
|
||||
self.account_cache.clear()
|
||||
self.account_cache |= cache
|
||||
|
||||
def do_reapply_rules(self): ...
|
||||
def do_reload_rules(self):
|
||||
"""
|
||||
Reload the ruleset (usually from disk).
|
||||
|
||||
This lets us edit the rule table by saving, editing, and loading the rules,
|
||||
even though we don't have a built-in rule editor yet.
|
||||
"""
|
||||
self.ruleset.reload_rules()
|
||||
self.regenerate_rows()
|
||||
|
||||
Reference in New Issue
Block a user