From 20fba91c3f3ea897c9b8738eeebef14013d58ff1 Mon Sep 17 00:00:00 2001 From: marination Date: Tue, 4 Apr 2023 19:56:21 +0530 Subject: [PATCH] chore: Make auto matching party configurable - Checkbox in Accounts settings "Enable Automatic Party Matching" - Check before invoking automatching methods - misc: Remove TODO comments --- .../accounts_settings/accounts_settings.json | 18 ++++++++++++++++-- .../bank_transaction/bank_transaction.py | 13 ++++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json index c0eed18ad1be4..259612e0e479a 100644 --- a/erpnext/accounts/doctype/accounts_settings/accounts_settings.json +++ b/erpnext/accounts/doctype/accounts_settings/accounts_settings.json @@ -59,7 +59,9 @@ "frozen_accounts_modifier", "report_settings_sb", "tab_break_dpet", - "show_balance_in_coa" + "show_balance_in_coa", + "banking_tab", + "enable_party_matching" ], "fields": [ { @@ -368,6 +370,18 @@ "fieldname": "book_tax_discount_loss", "fieldtype": "Check", "label": "Book Tax Loss on Early Payment Discount" + }, + { + "fieldname": "banking_tab", + "fieldtype": "Tab Break", + "label": "Banking" + }, + { + "default": "0", + "description": "Auto match and set the Party in Bank Transactions", + "fieldname": "enable_party_matching", + "fieldtype": "Check", + "label": "Enable Automatic Party Matching" } ], "icon": "icon-cog", @@ -375,7 +389,7 @@ "index_web_pages_for_search": 1, "issingle": 1, "links": [], - "modified": "2023-03-28 09:50:20.375233", + "modified": "2023-04-04 16:20:41.330039", "modified_by": "Administrator", "module": "Accounts", "name": "Accounts Settings", diff --git a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py index 6a094915b7524..cc72fdca41142 100644 --- a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py +++ b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py @@ -8,12 +8,6 @@ class BankTransaction(StatusUpdater): - # TODO - # On submit/update after submit - # - Create/Update a Bank Party Map record - # - User can edit after submit. - # - If changes in party/party name after submit, edit bank party map (which should edit all transactions with same account no/iban/bank party name) - def after_insert(self): self.unallocated_amount = abs(flt(self.withdrawal) - flt(self.deposit)) @@ -21,7 +15,8 @@ def on_submit(self): self.clear_linked_payment_entries() self.set_status() - self.auto_set_party() + if frappe.get_single_value("Accounts Settings", "enable_party_matching"): + self.auto_set_party() _saving_flag = False @@ -34,7 +29,8 @@ def on_update_after_submit(self): self.update_allocations() self._saving_flag = False - self.update_automatch_bank_party_mapper() + if frappe.get_single_value("Accounts Settings", "enable_party_matching"): + self.update_automatch_bank_party_mapper() def on_cancel(self): self.clear_linked_payment_entries(for_cancel=True) @@ -157,7 +153,6 @@ def clear_linked_payment_entry(self, payment_entry, for_cancel=False): ) def auto_set_party(self): - # TODO: check if enabled from erpnext.accounts.doctype.bank_transaction.auto_match_party import AutoMatchParty if self.party_type and self.party: