autosort: Fix bug where transactions get sorted even with --dry-run
This commit is contained in:
parent
bc832fd488
commit
ed668a1348
1 changed files with 4 additions and 4 deletions
|
@ -27,7 +27,7 @@ def command(profile, dry_run, verbose):
|
||||||
|
|
||||||
unsorted = session.query(Transaction).filter(Transaction.category_id == None).all()
|
unsorted = session.query(Transaction).filter(Transaction.category_id == None).all()
|
||||||
print("Found {} unsorted transcations".format(len(unsorted)))
|
print("Found {} unsorted transcations".format(len(unsorted)))
|
||||||
matched = 0
|
new = []
|
||||||
|
|
||||||
for t in unsorted:
|
for t in unsorted:
|
||||||
cat_name = apply_rules(t, rules)
|
cat_name = apply_rules(t, rules)
|
||||||
|
@ -39,13 +39,13 @@ def command(profile, dry_run, verbose):
|
||||||
cat_id = session.query(Category).filter(Category.name == cat_name).first()
|
cat_id = session.query(Category).filter(Category.name == cat_name).first()
|
||||||
if not cat_id:
|
if not cat_id:
|
||||||
cat_id = add_category(cat_name, profile, session)
|
cat_id = add_category(cat_name, profile, session)
|
||||||
matched += 1
|
|
||||||
t.category_id = cat_id
|
t.category_id = cat_id
|
||||||
session.add(t)
|
new.append(t)
|
||||||
print_verbose(verbose, "-" * 90)
|
print_verbose(verbose, "-" * 90)
|
||||||
|
|
||||||
print(f"Automatically matched {matched} transactions")
|
print(f"Automatically matched {len(new)} transactions")
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
|
session.bulk_save_object(new)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue