From 387fb1b2022d14e15da9501f96c5324da72f0c59 Mon Sep 17 00:00:00 2001 From: Raffael Meyer <14891507+barredterra@users.noreply.github.com> Date: Thu, 19 Feb 2026 17:20:12 +0100 Subject: [PATCH] feat: add Bank Transaction as Reference Type to Journal Entry Account (#52760) * feat: add Bank Transaction as Reference Type to Journal Entry Account * fix: take care of existing property setters * fix: cancelling Bank Transactions should still be possible * fix: handle blank options in patch * fix: hide Reference Due Date for Bank Transaction --- .../bank_transaction/bank_transaction.py | 2 ++ .../journal_entry_account.json | 6 ++-- .../journal_entry_account.py | 1 + erpnext/patches.txt | 1 + ..._transaction_as_journal_entry_reference.py | 33 +++++++++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 erpnext/patches/v15_0/add_bank_transaction_as_journal_entry_reference.py diff --git a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py index f850749fe4f..44f449ac788 100644 --- a/erpnext/accounts/doctype/bank_transaction/bank_transaction.py +++ b/erpnext/accounts/doctype/bank_transaction/bank_transaction.py @@ -139,6 +139,8 @@ class BankTransaction(Document): self.set_status() def on_cancel(self): + self.ignore_linked_doctypes = ["GL Entry"] + for payment_entry in self.payment_entries: self.delink_payment_entry(payment_entry) diff --git a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json index e9ced989ef7..2896b53f582 100644 --- a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json +++ b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.json @@ -185,7 +185,7 @@ "fieldtype": "Select", "label": "Reference Type", "no_copy": 1, - "options": "\nSales Invoice\nPurchase Invoice\nJournal Entry\nSales Order\nPurchase Order\nExpense Claim\nAsset\nLoan\nPayroll Entry\nEmployee Advance\nExchange Rate Revaluation\nInvoice Discounting\nFees\nFull and Final Statement\nPayment Entry", + "options": "\nSales Invoice\nPurchase Invoice\nJournal Entry\nSales Order\nPurchase Order\nExpense Claim\nAsset\nLoan\nPayroll Entry\nEmployee Advance\nExchange Rate Revaluation\nInvoice Discounting\nFees\nFull and Final Statement\nPayment Entry\nBank Transaction", "search_index": 1 }, { @@ -197,7 +197,7 @@ "search_index": 1 }, { - "depends_on": "eval:doc.reference_type&&!in_list(doc.reference_type, ['Expense Claim', 'Asset', 'Employee Loan', 'Employee Advance'])", + "depends_on": "eval:doc.reference_type&&!in_list(doc.reference_type, ['Expense Claim', 'Asset', 'Employee Loan', 'Employee Advance', 'Bank Transaction'])", "fieldname": "reference_due_date", "fieldtype": "Date", "label": "Reference Due Date", @@ -293,7 +293,7 @@ "idx": 1, "istable": 1, "links": [], - "modified": "2026-02-16 16:04:16.022407", + "modified": "2026-02-19 17:01:22.642454", "modified_by": "Administrator", "module": "Accounts", "name": "Journal Entry Account", diff --git a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.py b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.py index d26224103c0..d73412f8a20 100644 --- a/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.py +++ b/erpnext/accounts/doctype/journal_entry_account/journal_entry_account.py @@ -55,6 +55,7 @@ class JournalEntryAccount(Document): "Fees", "Full and Final Statement", "Payment Entry", + "Bank Transaction", ] user_remark: DF.SmallText | None # end: auto-generated types diff --git a/erpnext/patches.txt b/erpnext/patches.txt index c96f90d8cf3..bbb33de29db 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -412,6 +412,7 @@ erpnext.patches.v15_0.rename_group_by_to_categorize_by execute:frappe.db.set_single_value("Accounts Settings", "receivable_payable_fetch_method", "Buffered Cursor") erpnext.patches.v14_0.set_update_price_list_based_on erpnext.patches.v15_0.update_journal_entry_type +erpnext.patches.v15_0.add_bank_transaction_as_journal_entry_reference erpnext.patches.v15_0.set_grand_total_to_default_mop execute:frappe.db.set_single_value("Accounts Settings", "use_legacy_budget_controller", False) erpnext.patches.v15_0.set_cancelled_status_to_cancelled_pos_invoice diff --git a/erpnext/patches/v15_0/add_bank_transaction_as_journal_entry_reference.py b/erpnext/patches/v15_0/add_bank_transaction_as_journal_entry_reference.py new file mode 100644 index 00000000000..cfac2ab3858 --- /dev/null +++ b/erpnext/patches/v15_0/add_bank_transaction_as_journal_entry_reference.py @@ -0,0 +1,33 @@ +import frappe + + +def execute(): + """Append Bank Transaction in custom reference_type options.""" + new_reference_type = "Bank Transaction" + property_setters = frappe.get_all( + "Property Setter", + filters={ + "doc_type": "Journal Entry Account", + "field_name": "reference_type", + "property": "options", + }, + pluck="name", + ) + + for property_setter in property_setters: + existing_value = frappe.db.get_value("Property Setter", property_setter, "value") or "" + + raw_options = [option.strip() for option in existing_value.split("\n")] + # Preserve a single leading blank (for the empty select option) but drop spurious trailing blanks + options = raw_options[:1] + [o for o in raw_options[1:] if o] + + if new_reference_type in options: + continue + + options.append(new_reference_type) + frappe.db.set_value( + "Property Setter", + property_setter, + "value", + "\n".join(options), + )