[fixes] added filters company and currency to get account, removed account name wise comparison
This commit is contained in:
parent
f54be2c7f0
commit
4a6bbf9b72
@ -479,15 +479,13 @@ def get_outstanding_invoices(party_type, party, account, condition=None):
|
||||
return outstanding_invoices
|
||||
|
||||
|
||||
def get_account(account_type=None, root_type=None, is_group=None, account_name=None):
|
||||
def get_account(account_type=None, root_type=None, is_group=None, account_currency=None, company=None):
|
||||
"""return account based on matching conditions"""
|
||||
if account_name:
|
||||
if not frappe.db.get_value("Account", {"account_name": account_name}):
|
||||
return False
|
||||
else:
|
||||
return frappe.get_doc("Account", {
|
||||
"account_type": account_type or '',
|
||||
"root_type": root_type or '',
|
||||
"is_group": is_group or 0,
|
||||
"account_name": account_name or ''
|
||||
})
|
||||
return frappe.db.get_value("Account", {
|
||||
"account_type": account_type or '',
|
||||
"root_type": root_type or '',
|
||||
"is_group": is_group or 0,
|
||||
"account_currency": account_currency or frappe.defaults.get_defaults().currency,
|
||||
"company": company or frappe.defaults.get_defaults().company
|
||||
}, "name")
|
||||
|
@ -329,7 +329,8 @@ def get_debtors_account(cart_settings):
|
||||
|
||||
account_name = _("Debtors ({0})".format(payment_gateway_account_currency))
|
||||
|
||||
debtors_account = get_account("Receivable", "Asset", is_group=0, account_name=account_name)
|
||||
debtors_account = get_account("Receivable", "Asset", is_group=0,\
|
||||
account_currency=payment_gateway_account_currency, company=cart_settings.company)
|
||||
|
||||
if not debtors_account:
|
||||
debtors_account = frappe.get_doc({
|
||||
@ -337,8 +338,7 @@ def get_debtors_account(cart_settings):
|
||||
"account_type": "Receivable",
|
||||
"root_type": "Asset",
|
||||
"is_group": 0,
|
||||
"parent_account": get_account(root_type="Asset", is_group=1, \
|
||||
account_name=_("Accounts Receivable")).name,
|
||||
"parent_account": get_account(root_type="Asset", is_group=1, company=cart_settings.company),
|
||||
"account_name": account_name,
|
||||
"currency": payment_gateway_account_currency
|
||||
}).insert(ignore_permissions=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user