refactor(bank-statement-importer): drop redundant Default Company field

System is single-company; Default Company on Bank Statement Importer
duplicated what ERPNext already exposes via Global Defaults. Removed
the field and replaced bi.default_company with erpnext.get_default_company()
at the two usage sites (Bank Account creation, Bank Transaction bulk
import). Existing column on tabBank Statement Importer is left in place
— Frappe just ignores it.
This commit is contained in:
Ali 2026-05-18 13:40:53 +00:00
parent 1492573fac
commit 5bff95501f
3 changed files with 8 additions and 11 deletions

View File

@ -207,6 +207,8 @@ def create_unmapped_suppliers(bank_integration):
@frappe.whitelist()
def create_unmapped_accounts(bank_integration):
"""Create Bank Account records for unmapped account_mappings rows."""
import erpnext
bi = frappe.get_doc("Bank Statement Importer", bank_integration)
unmapped = [r for r in bi.account_mappings if not r.bank_account and r.iban]
@ -214,14 +216,14 @@ def create_unmapped_accounts(bank_integration):
return {"success": True, "created_count": 0, "message": "No unmapped accounts to create"}
default_bank = bi.default_bank
default_company = bi.default_company
default_company = erpnext.get_default_company()
# Only need these for accounts that don't already exist as Bank Accounts.
if any(not frappe.db.exists("Bank Account", {"bank_account_no": r.iban}) for r in unmapped):
if not default_company:
frappe.throw(_("Set a Default Company on the Bank Integration before creating Bank Accounts."))
frappe.throw(_("Set a Default Company in Global Defaults before creating Bank Accounts."))
if not default_bank:
frappe.throw(_("Set a Default Bank on the Bank Integration before creating Bank Accounts."))
frappe.throw(_("Set a Default Bank on the Bank Statement Importer before creating Bank Accounts."))
created = 0
for row in unmapped:

View File

@ -101,10 +101,12 @@ def import_bulk_bt(txn_list, bank_integration, bank_account):
def _process_bulk_bt_import(txn_list, bank_integration, bank_account, user):
"""Background job: create one Bank Transaction per row."""
import erpnext
frappe.set_user(user)
bi = frappe.get_doc("Bank Statement Importer", bank_integration)
company = bi.default_company
company = erpnext.get_default_company()
ba_doc = frappe.get_doc("Bank Account", bank_account)
ba_account = ba_doc.account

View File

@ -7,7 +7,6 @@
"field_order": [
"settings_tab",
"bank_name",
"default_company",
"default_bank",
"general_section",
"similarity_threshold_customers",
@ -75,12 +74,6 @@
"reqd": 1,
"unique": 1
},
{
"fieldname": "default_company",
"fieldtype": "Link",
"label": "Default Company",
"options": "Company"
},
{
"fieldname": "default_bank",
"fieldtype": "Link",