Skip to content

Commit

Permalink
chore: Make auto matching party configurable
Browse files Browse the repository at this point in the history
- Checkbox in Accounts settings "Enable Automatic Party Matching"
- Check before invoking automatching methods
- misc: Remove TODO comments
  • Loading branch information
marination committed Apr 4, 2023
1 parent 3360455 commit aea4315
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
18 changes: 16 additions & 2 deletions erpnext/accounts/doctype/accounts_settings/accounts_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down Expand Up @@ -368,14 +370,26 @@
"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",
"idx": 1,
"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",
Expand Down
13 changes: 4 additions & 9 deletions erpnext/accounts/doctype/bank_transaction/bank_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@


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))

def on_submit(self):
self.clear_linked_payment_entries()
self.set_status()

self.auto_set_party()
if frappe.db.get_single_value("Accounts Settings", "enable_party_matching"):
self.auto_set_party()

_saving_flag = False

Expand All @@ -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.db.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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit aea4315

Please sign in to comment.