Skip to content

Commit

Permalink
Tweaked tag finding
Browse files Browse the repository at this point in the history
  • Loading branch information
edelgm6 committed Jan 2, 2025
1 parent 473c68c commit f189b17
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,20 +421,16 @@ def apply_autotags(transactions):
" +", " ", transaction.description.strip().lower()
)

matching_autotag = None
for tag in all_tags:
if tag.search_string.lower() in cleaned_description:
matching_autotag = tag # Return the first matching tag
transaction.suggested_account = tag.account
transaction.prefill = tag.prefill
if tag.transaction_type:
transaction.type = tag.transaction_type
else:
transaction.type = Transaction.TransactionType.PURCHASE
break

if matching_autotag:
transaction.suggested_account = matching_autotag.account
transaction.prefill = matching_autotag.prefill
if matching_autotag.transaction_type:
transaction.type = matching_autotag.transaction_type
else:
transaction.type = Transaction.TransactionType.PURCHASE


class TaxCharge(models.Model):
class Type(models.TextChoices):
Expand Down

0 comments on commit f189b17

Please sign in to comment.