[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
|
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"""
|
"""return account based on matching conditions"""
|
||||||
if account_name:
|
return frappe.db.get_value("Account", {
|
||||||
if not frappe.db.get_value("Account", {"account_name": account_name}):
|
"account_type": account_type or '',
|
||||||
return False
|
"root_type": root_type or '',
|
||||||
else:
|
"is_group": is_group or 0,
|
||||||
return frappe.get_doc("Account", {
|
"account_currency": account_currency or frappe.defaults.get_defaults().currency,
|
||||||
"account_type": account_type or '',
|
"company": company or frappe.defaults.get_defaults().company
|
||||||
"root_type": root_type or '',
|
}, "name")
|
||||||
"is_group": is_group or 0,
|
|
||||||
"account_name": account_name or ''
|
|
||||||
})
|
|
@ -329,7 +329,8 @@ def get_debtors_account(cart_settings):
|
|||||||
|
|
||||||
account_name = _("Debtors ({0})".format(payment_gateway_account_currency))
|
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:
|
if not debtors_account:
|
||||||
debtors_account = frappe.get_doc({
|
debtors_account = frappe.get_doc({
|
||||||
@ -337,8 +338,7 @@ def get_debtors_account(cart_settings):
|
|||||||
"account_type": "Receivable",
|
"account_type": "Receivable",
|
||||||
"root_type": "Asset",
|
"root_type": "Asset",
|
||||||
"is_group": 0,
|
"is_group": 0,
|
||||||
"parent_account": get_account(root_type="Asset", is_group=1, \
|
"parent_account": get_account(root_type="Asset", is_group=1, company=cart_settings.company),
|
||||||
account_name=_("Accounts Receivable")).name,
|
|
||||||
"account_name": account_name,
|
"account_name": account_name,
|
||||||
"currency": payment_gateway_account_currency
|
"currency": payment_gateway_account_currency
|
||||||
}).insert(ignore_permissions=True)
|
}).insert(ignore_permissions=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user