added currency to mappings
This commit is contained in:
parent
68c3d7d8a9
commit
3e90e872a1
|
|
@ -1307,6 +1307,7 @@ def get_statement_transactions(from_date, to_date, account_iban, login_name=None
|
|||
"contr_voen": contr_voen,
|
||||
"amount": amount,
|
||||
"currency": currency,
|
||||
"kb_currency": (txn.get("acCcy") or "").strip(),
|
||||
"drcr": dr_cr or "D",
|
||||
"purpose": purpose,
|
||||
"source_type": "account",
|
||||
|
|
@ -2157,6 +2158,10 @@ def _import_one_bank_transaction(txn_data, settings, voen_to_party, name_to_part
|
|||
|
||||
bt.bank_account = bank_account
|
||||
|
||||
kb_currency = (txn_data.get("kb_currency") or "").strip()
|
||||
if kb_currency:
|
||||
bt.kb_currency = kb_currency
|
||||
|
||||
if party_type and erp_party:
|
||||
bt.party_type = party_type
|
||||
bt.party = erp_party
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
"paid_to",
|
||||
"cost_center",
|
||||
"multi_currency",
|
||||
"currency",
|
||||
"notes"
|
||||
],
|
||||
"fields": [
|
||||
|
|
@ -40,6 +41,13 @@
|
|||
"label": "Payment Type",
|
||||
"options": "\nPay\nReceive"
|
||||
},
|
||||
{
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Link",
|
||||
"in_list_view": 1,
|
||||
"label": "Currency",
|
||||
"options": "Currency"
|
||||
},
|
||||
{
|
||||
"fieldname": "counterparty_type",
|
||||
"fieldtype": "Select",
|
||||
|
|
@ -94,7 +102,7 @@
|
|||
],
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2026-03-12 16:52:06.237239",
|
||||
"modified": "2026-03-13 21:17:53.087843",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Kapital Bank",
|
||||
"name": "Kapital Bank Transaction Mapping",
|
||||
|
|
|
|||
|
|
@ -214,6 +214,9 @@ def _find_mapping_for_txn(txn, transaction_mappings, purpose_text_cache):
|
|||
txn_purpose = (txn.get("purpose") or "").lower()
|
||||
txn_party = (txn.get("party") or "").lower()
|
||||
|
||||
bt_name = txn.get("bank_transaction_name")
|
||||
txn_kb_currency = (frappe.db.get_value("Bank Transaction", bt_name, "kb_currency") or "").strip().upper() if bt_name else ""
|
||||
|
||||
both_rules = []
|
||||
purpose_only_rules = []
|
||||
counterparty_only_rules = []
|
||||
|
|
@ -224,6 +227,9 @@ def _find_mapping_for_txn(txn, transaction_mappings, purpose_text_cache):
|
|||
continue
|
||||
if row.payment_type and row.payment_type != payment_type:
|
||||
continue
|
||||
row_currency = (row.currency or "").strip().upper()
|
||||
if row_currency and row_currency != txn_kb_currency:
|
||||
continue
|
||||
|
||||
has_purpose = bool(row.purpose_keyword)
|
||||
has_counterparty = bool(row.counterparty)
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ import frappe
|
|||
|
||||
def after_install():
|
||||
cleanup_payment_entry_custom_fields()
|
||||
ensure_bank_transaction_custom_fields()
|
||||
|
||||
|
||||
def after_migrate():
|
||||
cleanup_payment_entry_custom_fields()
|
||||
ensure_bank_transaction_custom_fields()
|
||||
|
||||
|
||||
KB_FIELDS = [
|
||||
|
|
@ -16,6 +18,20 @@ KB_FIELDS = [
|
|||
]
|
||||
|
||||
|
||||
def ensure_bank_transaction_custom_fields():
|
||||
if not frappe.db.exists("Custom Field", {"dt": "Bank Transaction", "fieldname": "kb_currency"}):
|
||||
cf = frappe.new_doc("Custom Field")
|
||||
cf.dt = "Bank Transaction"
|
||||
cf.fieldname = "kb_currency"
|
||||
cf.fieldtype = "Link"
|
||||
cf.options = "Currency"
|
||||
cf.label = "KB Currency"
|
||||
cf.insert_after = "currency"
|
||||
cf.read_only = 0
|
||||
cf.insert(ignore_permissions=True)
|
||||
frappe.db.commit()
|
||||
|
||||
|
||||
def cleanup_payment_entry_custom_fields():
|
||||
for fieldname in KB_FIELDS:
|
||||
if frappe.db.exists("Custom Field", {"dt": "Payment Entry", "fieldname": fieldname}):
|
||||
|
|
|
|||
Loading…
Reference in New Issue