refactor(kapital-bank): drop redundant Default Company field
System is single-company; Default Company on Kapital Bank Settings duplicated what ERPNext already exposes via Global Defaults. Removed the field and replaced all settings/doc.default_company reads with erpnext.get_default_company() (used by Bank Account creation for accounts/cards, Journal Entry / Payment Entry / Bank Transaction creation during reconcile). Existing column on the singleton table is left in place — Frappe just ignores it.
This commit is contained in:
parent
c9032df3bf
commit
5462c55cd3
|
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
import re
|
||||
import erpnext
|
||||
import frappe
|
||||
from datetime import datetime
|
||||
from frappe.utils import cint, flt
|
||||
|
|
@ -931,13 +932,13 @@ def create_unmapped_accounts(settings_name=None):
|
|||
return {"success": True, "created_count": 0, "message": "No unmapped accounts to create"}
|
||||
|
||||
default_bank = doc.default_bank
|
||||
default_company = doc.default_company
|
||||
default_company = erpnext.get_default_company()
|
||||
|
||||
# Bank Account requires both Company and Bank — surface a clear message
|
||||
# instead of ERPNext's mandatory-field error mid-creation.
|
||||
if any(not frappe.db.exists("Bank Account", {"bank_account_no": r.iban}) for r in unmapped):
|
||||
if not default_company:
|
||||
return {"success": False, "message": "Set a Default Company on Kapital Bank Settings before creating Bank Accounts."}
|
||||
return {"success": False, "message": "Set a Default Company in Global Defaults before creating Bank Accounts."}
|
||||
if not default_bank:
|
||||
return {"success": False, "message": "Set a Default Bank on Kapital Bank Settings before creating Bank Accounts."}
|
||||
|
||||
|
|
@ -1058,11 +1059,11 @@ def create_unmapped_cards(settings_name=None):
|
|||
return {"success": True, "created_count": 0, "message": "No unmapped cards to create"}
|
||||
|
||||
default_bank = doc.default_bank
|
||||
default_company = doc.default_company
|
||||
default_company = erpnext.get_default_company()
|
||||
|
||||
if any(not frappe.db.exists("Bank Account", {"bank_account_no": r.account_number}) for r in unmapped):
|
||||
if not default_company:
|
||||
return {"success": False, "message": "Set a Default Company on Kapital Bank Settings before creating Bank Accounts."}
|
||||
return {"success": False, "message": "Set a Default Company in Global Defaults before creating Bank Accounts."}
|
||||
if not default_bank:
|
||||
return {"success": False, "message": "Set a Default Bank on Kapital Bank Settings before creating Bank Accounts."}
|
||||
|
||||
|
|
@ -1750,14 +1751,13 @@ def _import_one_transaction(txn_data, settings, purpose_rules, purpose_threshold
|
|||
}
|
||||
|
||||
if doc_type == "Journal Entry":
|
||||
import erpnext
|
||||
from erpnext.setup.utils import get_exchange_rate
|
||||
|
||||
# Create Journal Entry
|
||||
je = frappe.new_doc("Journal Entry")
|
||||
je.voucher_type = "Bank Entry"
|
||||
je.posting_date = parsed_date
|
||||
je.company = settings.default_company
|
||||
je.company = erpnext.get_default_company()
|
||||
je.cheque_no = ref_no
|
||||
je.cheque_date = parsed_date
|
||||
je.user_remark = purpose
|
||||
|
|
@ -1765,7 +1765,7 @@ def _import_one_transaction(txn_data, settings, purpose_rules, purpose_threshold
|
|||
|
||||
# Compute per-account amounts with proper multi-currency handling
|
||||
currency_precision = cint(frappe.db.get_single_value("System Settings", "currency_precision") or 2)
|
||||
company_currency = erpnext.get_company_currency(settings.default_company)
|
||||
company_currency = erpnext.get_company_currency(erpnext.get_default_company())
|
||||
txn_currency = (txn_data.get("currency") or company_currency).strip()
|
||||
|
||||
pf_account = frappe.get_cached_value("Account", paid_from, ["account_type", "account_currency"], as_dict=True) or {}
|
||||
|
|
@ -1871,7 +1871,7 @@ def _import_one_transaction(txn_data, settings, purpose_rules, purpose_threshold
|
|||
# Create Payment Entry
|
||||
pe = frappe.new_doc("Payment Entry")
|
||||
pe.payment_type = payment_type
|
||||
pe.company = settings.default_company
|
||||
pe.company = erpnext.get_default_company()
|
||||
pe.posting_date = parsed_date
|
||||
pe.paid_from = paid_from
|
||||
pe.paid_to = paid_to
|
||||
|
|
@ -2302,7 +2302,7 @@ def _import_one_bank_transaction(txn_data, settings, voen_to_party, name_to_part
|
|||
bt.description = txn_data.get("full_description") or purpose
|
||||
bt.reference_number = ref_no
|
||||
bt.transaction_id = ref_no
|
||||
bt.company = settings.default_company
|
||||
bt.company = erpnext.get_default_company()
|
||||
bt.bank_party_name = contr_name or purpose
|
||||
|
||||
bt.bank_account = bank_account
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
"settings_tab",
|
||||
"is_active",
|
||||
"default_login",
|
||||
"default_company",
|
||||
"company_code",
|
||||
"default_bank",
|
||||
"general_section",
|
||||
|
|
@ -70,12 +69,6 @@
|
|||
"label": "Default Login",
|
||||
"options": "Kapital Bank Login"
|
||||
},
|
||||
{
|
||||
"fieldname": "default_company",
|
||||
"fieldtype": "Link",
|
||||
"label": "Default Company",
|
||||
"options": "Company"
|
||||
},
|
||||
{
|
||||
"fieldname": "company_code",
|
||||
"fieldtype": "Data",
|
||||
|
|
|
|||
Loading…
Reference in New Issue