From 57c8cb0925f126bc2a7b71d06873c414ebf8f796 Mon Sep 17 00:00:00 2001 From: Ali <010109ali@gmail.com> Date: Mon, 16 Mar 2026 17:39:12 +0400 Subject: [PATCH] fix: filter transaction mappings by currency + hide notes from list view - Add currency field to purpose_rules tuple in _build_import_lookups - Filter rules by txn currency in _match_purpose_rules (empty = match all) - Remove in_list_view from notes field so currency column is visible in grid Co-Authored-By: Claude Sonnet 4.6 --- kapital_bank/bank_api.py | 8 ++++++-- .../kapital_bank_transaction_mapping.json | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/kapital_bank/bank_api.py b/kapital_bank/bank_api.py index 0247eed..7135713 100644 --- a/kapital_bank/bank_api.py +++ b/kapital_bank/bank_api.py @@ -1458,6 +1458,7 @@ def _build_import_lookups(settings): getattr(row, "document_type", None) or "Payment Entry", getattr(row, "cost_center", None) or "", bool(getattr(row, "multi_currency", 0)), + (getattr(row, "currency", None) or "").strip().upper(), )) # Each key maps to a dict with optional "Customer" and "Supplier" entries. @@ -1512,8 +1513,9 @@ def _import_one_transaction(txn_data, settings, purpose_rules, purpose_threshold purpose_only_rules = [] counterparty_only_rules = [] fallback_rules = [] + txn_currency = (txn_data.get("currency") or "").strip().upper() for rule in purpose_rules: - keyword, pf, pt, rule_pt, cp_name, cp_voen, cp_type, doc_type, rule_cc, rule_mc = rule + keyword, pf, pt, rule_pt, cp_name, cp_voen, cp_type, doc_type, rule_cc, rule_mc, rule_currency = rule has_keyword = bool(keyword) has_cp = bool(cp_name or cp_voen) if has_keyword and has_cp: @@ -1535,9 +1537,11 @@ def _import_one_transaction(txn_data, settings, purpose_rules, purpose_threshold def _match_purpose_rules(rules, check_counterparty): best_score = 0 best_pf = best_pt = best_doc_type = best_cc = best_mc = None - for keyword, pf, pt, rule_pt, cp_name, cp_voen, cp_type, doc_type, rule_cc, rule_mc in rules: + for keyword, pf, pt, rule_pt, cp_name, cp_voen, cp_type, doc_type, rule_cc, rule_mc, rule_currency in rules: if rule_pt and rule_pt != payment_type: continue + if rule_currency and rule_currency != txn_currency: + continue if check_counterparty and not _counterparty_matches(cp_name, cp_voen): continue if keyword: diff --git a/kapital_bank/kapital_bank/doctype/kapital_bank_transaction_mapping/kapital_bank_transaction_mapping.json b/kapital_bank/kapital_bank/doctype/kapital_bank_transaction_mapping/kapital_bank_transaction_mapping.json index 2190846..dc6f01b 100644 --- a/kapital_bank/kapital_bank/doctype/kapital_bank_transaction_mapping/kapital_bank_transaction_mapping.json +++ b/kapital_bank/kapital_bank/doctype/kapital_bank_transaction_mapping/kapital_bank_transaction_mapping.json @@ -96,13 +96,12 @@ { "fieldname": "notes", "fieldtype": "Data", - "in_list_view": 1, "label": "Notes" } ], "istable": 1, "links": [], - "modified": "2026-03-13 21:17:53.087843", + "modified": "2026-03-16 00:00:00.000000", "modified_by": "Administrator", "module": "Kapital Bank", "name": "Kapital Bank Transaction Mapping",