mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-01 04:28:27 +00:00
fix: translate display text passed to validate_expense_account (#43057)
This commit is contained in:
@@ -591,7 +591,7 @@ class PurchaseInvoice(BuyingController):
|
||||
|
||||
def validate_expense_account(self):
|
||||
for item in self.get("items"):
|
||||
validate_account_head(item.idx, item.expense_account, self.company, "Expense")
|
||||
validate_account_head(item.idx, item.expense_account, self.company, _("Expense"))
|
||||
|
||||
def set_against_expense_account(self, force=False):
|
||||
against_accounts = []
|
||||
|
||||
@@ -376,7 +376,7 @@ class SalesInvoice(SellingController):
|
||||
|
||||
def validate_income_account(self):
|
||||
for item in self.get("items"):
|
||||
validate_account_head(item.idx, item.income_account, self.company, "Income")
|
||||
validate_account_head(item.idx, item.income_account, self.company, _("Income"))
|
||||
|
||||
def set_tax_withholding(self):
|
||||
if self.get("is_opening") == "Yes":
|
||||
|
||||
@@ -69,7 +69,7 @@ def valdiate_taxes_and_charges_template(doc):
|
||||
|
||||
for tax in doc.get("taxes"):
|
||||
validate_taxes_and_charges(tax)
|
||||
validate_account_head(tax.idx, tax.account_head, doc.company)
|
||||
validate_account_head(tax.idx, tax.account_head, doc.company, _("Taxes and Charges"))
|
||||
validate_cost_center(tax, doc)
|
||||
validate_inclusive_tax(tax, doc)
|
||||
|
||||
|
||||
@@ -563,9 +563,11 @@ def validate_party_accounts(doc):
|
||||
|
||||
# validate if account is mapped for same company
|
||||
if account.account:
|
||||
validate_account_head(account.idx, account.account, account.company)
|
||||
validate_account_head(account.idx, account.account, account.company, _("Debtor/Creditor"))
|
||||
if account.advance_account:
|
||||
validate_account_head(account.idx, account.advance_account, account.company)
|
||||
validate_account_head(
|
||||
account.idx, account.advance_account, account.company, _("Debtor/Creditor Advance")
|
||||
)
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
|
||||
@@ -2643,21 +2643,21 @@ def validate_taxes_and_charges(tax):
|
||||
tax.rate = None
|
||||
|
||||
|
||||
def validate_account_head(idx, account, company, context=""):
|
||||
account_company = frappe.get_cached_value("Account", account, "company")
|
||||
is_group = frappe.get_cached_value("Account", account, "is_group")
|
||||
|
||||
if account_company != company:
|
||||
def validate_account_head(idx: int, account: str, company: str, context: str | None = None) -> None:
|
||||
"""Throw a ValidationError if the account belongs to a different company or is a group account."""
|
||||
if company != frappe.get_cached_value("Account", account, "company"):
|
||||
frappe.throw(
|
||||
_("Row {0}: {3} Account {1} does not belong to Company {2}").format(
|
||||
idx, frappe.bold(account), frappe.bold(company), context
|
||||
_("Row {0}: The {3} Account {1} does not belong to the company {2}").format(
|
||||
idx, frappe.bold(account), frappe.bold(company), context or ""
|
||||
),
|
||||
title=_("Invalid Account"),
|
||||
)
|
||||
|
||||
if is_group:
|
||||
if frappe.get_cached_value("Account", account, "is_group"):
|
||||
frappe.throw(
|
||||
_("Row {0}: Account {1} is a Group Account").format(idx, frappe.bold(account)),
|
||||
_(
|
||||
"You selected the account group {1} as {2} Account in row {0}. Please select a single account."
|
||||
).format(idx, frappe.bold(account), context or ""),
|
||||
title=_("Invalid Account"),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user