From 7c50f421e19992b8a8022b851e6fb566febd2f1f Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Wed, 22 Jul 2020 18:21:04 +0530 Subject: [PATCH] fix: Move branch code back to bank account (#22725) * fix: Move branch code back to bank account * fix: Patch --- erpnext/accounts/doctype/bank/bank.json | 12 +----------- .../doctype/bank_account/bank_account.json | 9 ++++++++- .../doctype/bank_guarantee/bank_guarantee.js | 2 +- .../payment_request/payment_request.json | 4 ++-- erpnext/patches.txt | 1 + .../move_bank_account_swift_number_to_bank.py | 3 +-- .../v13_0/move_branch_code_to_bank_account.py | 17 +++++++++++++++++ 7 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 erpnext/patches/v13_0/move_branch_code_to_bank_account.py diff --git a/erpnext/accounts/doctype/bank/bank.json b/erpnext/accounts/doctype/bank/bank.json index 99978e657da..56bae72a15b 100644 --- a/erpnext/accounts/doctype/bank/bank.json +++ b/erpnext/accounts/doctype/bank/bank.json @@ -13,7 +13,6 @@ "bank_name", "swift_number", "column_break_1", - "branch_code", "website", "address_and_contact", "address_html", @@ -51,15 +50,6 @@ "fieldtype": "Column Break", "search_index": 1 }, - { - "allow_in_quick_entry": 1, - "fieldname": "branch_code", - "fieldtype": "Data", - "in_list_view": 1, - "in_standard_filter": 1, - "label": "Branch Code", - "unique": 1 - }, { "fieldname": "address_and_contact", "fieldtype": "Section Break", @@ -111,7 +101,7 @@ } ], "links": [], - "modified": "2020-03-25 21:22:33.496264", + "modified": "2020-07-17 14:00:13.105433", "modified_by": "Administrator", "module": "Accounts", "name": "Bank", diff --git a/erpnext/accounts/doctype/bank_account/bank_account.json b/erpnext/accounts/doctype/bank_account/bank_account.json index 65a0a5138cd..b42f1f9d583 100644 --- a/erpnext/accounts/doctype/bank_account/bank_account.json +++ b/erpnext/accounts/doctype/bank_account/bank_account.json @@ -23,6 +23,7 @@ "account_details_section", "iban", "column_break_12", + "branch_code", "bank_account_no", "address_and_contact", "address_html", @@ -197,10 +198,16 @@ "fieldtype": "Data", "label": "Mask", "read_only": 1 + }, + { + "fieldname": "branch_code", + "fieldtype": "Data", + "in_global_search": 1, + "label": "Branch Code" } ], "links": [], - "modified": "2020-04-06 21:00:45.379804", + "modified": "2020-07-17 13:59:50.795412", "modified_by": "Administrator", "module": "Accounts", "name": "Bank Account", diff --git a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js index 065d25e6c34..febf85ca6c1 100644 --- a/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js +++ b/erpnext/accounts/doctype/bank_guarantee/bank_guarantee.js @@ -4,7 +4,7 @@ cur_frm.add_fetch('bank_account','account','account'); cur_frm.add_fetch('bank_account','bank_account_no','bank_account_no'); cur_frm.add_fetch('bank_account','iban','iban'); -cur_frm.add_fetch('bank','branch_code','branch_code'); +cur_frm.add_fetch('bank_account','branch_code','branch_code'); cur_frm.add_fetch('bank','swift_number','swift_number'); frappe.ui.form.on('Bank Guarantee', { diff --git a/erpnext/accounts/doctype/payment_request/payment_request.json b/erpnext/accounts/doctype/payment_request/payment_request.json index eef6be1a7a1..8eadfd0b24a 100644 --- a/erpnext/accounts/doctype/payment_request/payment_request.json +++ b/erpnext/accounts/doctype/payment_request/payment_request.json @@ -211,7 +211,7 @@ "label": "IBAN" }, { - "fetch_from": "bank.branch_code", + "fetch_from": "bank_account.branch_code", "fetch_if_empty": 1, "fieldname": "branch_code", "fieldtype": "Read Only", @@ -352,7 +352,7 @@ "in_create": 1, "is_submittable": 1, "links": [], - "modified": "2020-05-29 17:38:49.392713", + "modified": "2020-07-17 14:06:42.185763", "modified_by": "Administrator", "module": "Accounts", "name": "Payment Request", diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 566b979adef..474c343e1fa 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -709,3 +709,4 @@ erpnext.patches.v13_0.move_payroll_setting_separately_from_hr_settings #22-06-20 erpnext.patches.v13_0.check_is_income_tax_component #22-06-2020 erpnext.patches.v12_0.add_taxjar_integration_field erpnext.patches.v12_0.update_item_tax_template_company +erpnext.patches.v13_0.move_branch_code_to_bank_account diff --git a/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py b/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py index 1ddbae6cd29..a670adebfd6 100644 --- a/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py +++ b/erpnext/patches/v12_0/move_bank_account_swift_number_to_bank.py @@ -7,8 +7,7 @@ def execute(): if frappe.db.table_exists('Bank') and frappe.db.table_exists('Bank Account') and frappe.db.has_column('Bank Account', 'swift_number'): frappe.db.sql(""" UPDATE `tabBank` b, `tabBank Account` ba - SET b.swift_number = ba.swift_number, b.branch_code = ba.branch_code - WHERE b.name = ba.bank + SET b.swift_number = ba.swift_number WHERE b.name = ba.bank """) frappe.reload_doc('accounts', 'doctype', 'bank_account') diff --git a/erpnext/patches/v13_0/move_branch_code_to_bank_account.py b/erpnext/patches/v13_0/move_branch_code_to_bank_account.py new file mode 100644 index 00000000000..833ae2a48fb --- /dev/null +++ b/erpnext/patches/v13_0/move_branch_code_to_bank_account.py @@ -0,0 +1,17 @@ +# Copyright (c) 2019, Frappe and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals + +import frappe + +def execute(): + + frappe.reload_doc('accounts', 'doctype', 'bank_account') + frappe.reload_doc('accounts', 'doctype', 'bank') + + if frappe.db.has_column('Bank', 'branch_code') and frappe.db.has_column('Bank Account', 'branch_code'): + frappe.db.sql("""UPDATE `tabBank` b, `tabBank Account` ba + SET ba.branch_code = b.branch_code + WHERE ba.bank = b.name AND + ifnull(b.branch_code, '') != '' AND ifnull(ba.branch_code, '') = ''""") \ No newline at end of file