Merge pull request #35212 from ruthra-kumar/chore_change_throw_to_msgprint

chore: convert throw to msgprint in payment reconciliation job hook
diff --git a/erpnext/accounts/doctype/account/account.py b/erpnext/accounts/doctype/account/account.py
index 0404d1c..e94b7cf 100644
--- a/erpnext/accounts/doctype/account/account.py
+++ b/erpnext/accounts/doctype/account/account.py
@@ -204,8 +204,11 @@
 				)
 
 	def validate_account_currency(self):
+		self.currency_explicitly_specified = True
+
 		if not self.account_currency:
 			self.account_currency = frappe.get_cached_value("Company", self.company, "default_currency")
+			self.currency_explicitly_specified = False
 
 		gl_currency = frappe.db.get_value("GL Entry", {"account": self.name}, "account_currency")
 
@@ -251,8 +254,10 @@
 					{
 						"company": company,
 						# parent account's currency should be passed down to child account's curreny
-						# if it is None, it picks it up from default company currency, which might be unintended
-						"account_currency": erpnext.get_company_currency(company),
+						# if currency explicitly specified by user, child will inherit. else, default currency will be used.
+						"account_currency": self.account_currency
+						if self.currency_explicitly_specified
+						else erpnext.get_company_currency(company),
 						"parent_account": parent_acc_name_map[company],
 					}
 				)
diff --git a/erpnext/accounts/doctype/account/test_account.py b/erpnext/accounts/doctype/account/test_account.py
index 3a360c4..62303bd 100644
--- a/erpnext/accounts/doctype/account/test_account.py
+++ b/erpnext/accounts/doctype/account/test_account.py
@@ -5,10 +5,13 @@
 import unittest
 
 import frappe
+from frappe.test_runner import make_test_records
 
 from erpnext.accounts.doctype.account.account import merge_account, update_account_number
 from erpnext.stock import get_company_default_inventory_account, get_warehouse_account
 
+test_dependencies = ["Company"]
+
 
 class TestAccount(unittest.TestCase):
 	def test_rename_account(self):
@@ -188,6 +191,58 @@
 		frappe.delete_doc("Account", "1234 - Test Rename Sync Account - _TC4")
 		frappe.delete_doc("Account", "1234 - Test Rename Sync Account - _TC5")
 
+	def test_account_currency_sync(self):
+		"""
+		In a parent->child company setup, child should inherit parent account currency if explicitly specified.
+		"""
+
+		make_test_records("Company")
+
+		frappe.local.flags.pop("ignore_root_company_validation", None)
+
+		def create_bank_account():
+			acc = frappe.new_doc("Account")
+			acc.account_name = "_Test Bank JPY"
+
+			acc.parent_account = "Temporary Accounts - _TC6"
+			acc.company = "_Test Company 6"
+			return acc
+
+		acc = create_bank_account()
+		# Explicitly set currency
+		acc.account_currency = "JPY"
+		acc.insert()
+		self.assertTrue(
+			frappe.db.exists(
+				{
+					"doctype": "Account",
+					"account_name": "_Test Bank JPY",
+					"account_currency": "JPY",
+					"company": "_Test Company 7",
+				}
+			)
+		)
+
+		frappe.delete_doc("Account", "_Test Bank JPY - _TC6")
+		frappe.delete_doc("Account", "_Test Bank JPY - _TC7")
+
+		acc = create_bank_account()
+		# default currency is used
+		acc.insert()
+		self.assertTrue(
+			frappe.db.exists(
+				{
+					"doctype": "Account",
+					"account_name": "_Test Bank JPY",
+					"account_currency": "USD",
+					"company": "_Test Company 7",
+				}
+			)
+		)
+
+		frappe.delete_doc("Account", "_Test Bank JPY - _TC6")
+		frappe.delete_doc("Account", "_Test Bank JPY - _TC7")
+
 	def test_child_company_account_rename_sync(self):
 		frappe.local.flags.pop("ignore_root_company_validation", None)
 
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index 76a01db..8a47e1c 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -546,12 +546,13 @@
 				)
 
 			query = query.where(
-				(gl_entry.finance_book.isin([cstr(filters.finance_book), cstr(company_fb)]))
+				(gl_entry.finance_book.isin([cstr(filters.finance_book), cstr(company_fb), ""]))
 				| (gl_entry.finance_book.isnull())
 			)
 		else:
 			query = query.where(
-				(gl_entry.finance_book.isin([cstr(filters.finance_book)])) | (gl_entry.finance_book.isnull())
+				(gl_entry.finance_book.isin([cstr(filters.finance_book), ""]))
+				| (gl_entry.finance_book.isnull())
 			)
 
 	if accounting_dimensions:
diff --git a/erpnext/accounts/report/general_ledger/general_ledger.py b/erpnext/accounts/report/general_ledger/general_ledger.py
index 0b05c11..d47e3da 100644
--- a/erpnext/accounts/report/general_ledger/general_ledger.py
+++ b/erpnext/accounts/report/general_ledger/general_ledger.py
@@ -253,14 +253,14 @@
 					_("To use a different finance book, please uncheck 'Include Default Book Entries'")
 				)
 			else:
-				conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)")
+				conditions.append("(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)")
 		else:
-			conditions.append("(finance_book in (%(company_fb)s) OR finance_book IS NULL)")
+			conditions.append("(finance_book in (%(company_fb)s, '') OR finance_book IS NULL)")
 	else:
 		if filters.get("finance_book"):
-			conditions.append("(finance_book in (%(finance_book)s) OR finance_book IS NULL)")
+			conditions.append("(finance_book in (%(finance_book)s, '') OR finance_book IS NULL)")
 		else:
-			conditions.append("(finance_book IS NULL)")
+			conditions.append("(finance_book in ('') OR finance_book IS NULL)")
 
 	if not filters.get("show_cancelled_entries"):
 		conditions.append("is_cancelled = 0")
diff --git a/erpnext/accounts/report/trial_balance/trial_balance.py b/erpnext/accounts/report/trial_balance/trial_balance.py
index 57dac2a..22bebb7 100644
--- a/erpnext/accounts/report/trial_balance/trial_balance.py
+++ b/erpnext/accounts/report/trial_balance/trial_balance.py
@@ -256,12 +256,12 @@
 			)
 
 		opening_balance = opening_balance.where(
-			(closing_balance.finance_book.isin([cstr(filters.finance_book), cstr(company_fb)]))
+			(closing_balance.finance_book.isin([cstr(filters.finance_book), cstr(company_fb), ""]))
 			| (closing_balance.finance_book.isnull())
 		)
 	else:
 		opening_balance = opening_balance.where(
-			(closing_balance.finance_book.isin([cstr(filters.finance_book)]))
+			(closing_balance.finance_book.isin([cstr(filters.finance_book), ""]))
 			| (closing_balance.finance_book.isnull())
 		)
 
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index 18336d2..f15ac12 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -617,11 +617,15 @@
 
 		if not credit_limit:
 			customer_group = frappe.get_cached_value("Customer", customer, "customer_group")
-			credit_limit = frappe.db.get_value(
+
+			result = frappe.db.get_values(
 				"Customer Credit Limit",
 				{"parent": customer_group, "parenttype": "Customer Group", "company": company},
-				"credit_limit",
+				fieldname=["credit_limit", "bypass_credit_limit_check"],
+				as_dict=True,
 			)
+			if result and not result[0].bypass_credit_limit_check:
+				credit_limit = result[0].credit_limit
 
 	if not credit_limit:
 		credit_limit = frappe.get_cached_value("Company", company, "credit_limit")
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index fc66db2..693fc92 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -286,6 +286,18 @@
 			target.commission_rate = frappe.get_value(
 				"Sales Partner", source.referral_sales_partner, "commission_rate"
 			)
+
+		# sales team
+		for d in customer.get("sales_team"):
+			target.append(
+				"sales_team",
+				{
+					"sales_person": d.sales_person,
+					"allocated_percentage": d.allocated_percentage or None,
+					"commission_rate": d.commission_rate,
+				},
+			)
+
 		target.flags.ignore_permissions = ignore_permissions
 		target.run_method("set_missing_values")
 		target.run_method("calculate_taxes_and_totals")
diff --git a/erpnext/setup/doctype/company/test_records.json b/erpnext/setup/doctype/company/test_records.json
index 19b6ef2..e21bd2a 100644
--- a/erpnext/setup/doctype/company/test_records.json
+++ b/erpnext/setup/doctype/company/test_records.json
@@ -80,5 +80,30 @@
 		"chart_of_accounts": "Standard",
 		"enable_perpetual_inventory": 1,
 		"default_holiday_list": "_Test Holiday List"
+	},
+	{
+		"abbr": "_TC6",
+		"company_name": "_Test Company 6",
+		"is_group": 1,
+		"country": "India",
+		"default_currency": "INR",
+		"doctype": "Company",
+		"domain": "Manufacturing",
+		"chart_of_accounts": "Standard",
+		"default_holiday_list": "_Test Holiday List",
+		"enable_perpetual_inventory": 0
+	},
+	{
+		"abbr": "_TC7",
+		"company_name": "_Test Company 7",
+		"parent_company": "_Test Company 6",
+		"is_group": 1,
+		"country": "United States",
+		"default_currency": "USD",
+		"doctype": "Company",
+		"domain": "Manufacturing",
+		"chart_of_accounts": "Standard",
+		"default_holiday_list": "_Test Holiday List",
+		"enable_perpetual_inventory": 0
 	}
 ]