Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

match entry addons with mapping patterns #135

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions icsv2ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,17 +879,19 @@ def get_payee_and_account(entry):
transfer_to = None
transfer_to_file = None
found = False
# Try to match entry desc with mappings patterns
# Try to match entry desc or entry addons with mappings patterns
for m in mappings:
pattern = m.pattern
if isinstance(pattern, str):
if entry.desc == pattern:
if entry.desc == pattern or pattern in list(entry.addons.values()):
payee, account, tags = m.payee, m.account, m.tags
transfer_to, transfer_to_file = m.transfer_to, m.transfer_to_file
found = True # do not break here, later mapping must win
else:
# If the pattern isn't a string it's a regex
match = m.pattern.match(entry.desc)
match_desc = m.pattern.match(entry.desc)
match_addons = m.pattern.match(" ".join(entry.addons.values()))
match = match_desc if match_desc else match_addons
if match:
#if m[0].match(entry.desc):
payee = m.payee
Expand Down