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:
parent
1492573fac
commit
5bff95501f
|
|
@ -207,6 +207,8 @@ def create_unmapped_suppliers(bank_integration):
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def create_unmapped_accounts(bank_integration):
|
def create_unmapped_accounts(bank_integration):
|
||||||
"""Create Bank Account records for unmapped account_mappings rows."""
|
"""Create Bank Account records for unmapped account_mappings rows."""
|
||||||
|
import erpnext
|
||||||
|
|
||||||
bi = frappe.get_doc("Bank Statement Importer", bank_integration)
|
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]
|
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"}
|
return {"success": True, "created_count": 0, "message": "No unmapped accounts to create"}
|
||||||
|
|
||||||
default_bank = bi.default_bank
|
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.
|
# 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 any(not frappe.db.exists("Bank Account", {"bank_account_no": r.iban}) for r in unmapped):
|
||||||
if not default_company:
|
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:
|
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
|
created = 0
|
||||||
for row in unmapped:
|
for row in unmapped:
|
||||||
|
|
|
||||||
|
|
@ -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):
|
def _process_bulk_bt_import(txn_list, bank_integration, bank_account, user):
|
||||||
"""Background job: create one Bank Transaction per row."""
|
"""Background job: create one Bank Transaction per row."""
|
||||||
|
import erpnext
|
||||||
|
|
||||||
frappe.set_user(user)
|
frappe.set_user(user)
|
||||||
|
|
||||||
bi = frappe.get_doc("Bank Statement Importer", bank_integration)
|
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_doc = frappe.get_doc("Bank Account", bank_account)
|
||||||
ba_account = ba_doc.account
|
ba_account = ba_doc.account
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"settings_tab",
|
"settings_tab",
|
||||||
"bank_name",
|
"bank_name",
|
||||||
"default_company",
|
|
||||||
"default_bank",
|
"default_bank",
|
||||||
"general_section",
|
"general_section",
|
||||||
"similarity_threshold_customers",
|
"similarity_threshold_customers",
|
||||||
|
|
@ -75,12 +74,6 @@
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"unique": 1
|
"unique": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "default_company",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"label": "Default Company",
|
|
||||||
"options": "Company"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "default_bank",
|
"fieldname": "default_bank",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue