Validate currency of default receivable/payable accounts

This commit is contained in:
Nabin Hait 2015-10-16 13:07:45 +05:30
parent 64fd970a8a
commit 2873f2e7de

View File

@ -217,10 +217,18 @@ def validate_party_accounts(doc):
for account in doc.get("accounts"): for account in doc.get("accounts"):
if account.company in companies: if account.company in companies:
frappe.throw(_("There can only be 1 Account per Company in {0} {1}").format(doc.doctype, doc.name), frappe.throw(_("There can only be 1 Account per Company in {0} {1}")
DuplicatePartyAccountError) .format(doc.doctype, doc.name), DuplicatePartyAccountError)
else: else:
companies.append(account.company) companies.append(account.company)
party_account_currency = frappe.db.get_value("Account", account.account, "account_currency")
existing_gle_currency = get_party_gle_currency(doc.doctype, doc.name, account.company)
if party_account_currency != existing_gle_currency:
frappe.throw(_("Accounting Entry against company: {0} can only be made in currency: {1}, please check default {2} account")
.format(account.company, existing_gle_currency,
"receivable" if doc.doctype=="Customer" else "payable"))
@frappe.whitelist() @frappe.whitelist()
def get_due_date(posting_date, party_type, party, company): def get_due_date(posting_date, party_type, party, company):