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
This commit is contained in:
Raffael Meyer
2026-02-19 17:20:12 +01:00
committed by GitHub
parent 4561e3a389
commit 387fb1b202
5 changed files with 40 additions and 3 deletions

View File

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

View File

@@ -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",

View File

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

View File

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

View File

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