def get_party_account_currency(party_type, party, company): def generator(): party_account = get_party_account(party_type, party, company) return dataent.db.get_value("Account", party_account, "account_currency", cache=True) return dataent.local_cache("party_account_currency", (party_type, party, company), generator)
def get_account_currency(account): """Helper function to get account currency""" if not account: return def generator(): account_currency, company = dataent.get_cached_value( "Account", account, ["account_currency", "company"]) if not account_currency: account_currency = dataent.get_cached_value( 'Company', company, "default_currency") return account_currency return dataent.local_cache("account_currency", account, generator)
def get_party_gle_account(party_type, party, company): def generator(): existing_gle_account = dataent.db.sql( """select account from `tabGL Entry` where docstatus=1 and company=%(company)s and party_type=%(party_type)s and party=%(party)s limit 1""", { "company": company, "party_type": party_type, "party": party }) return existing_gle_account[0][0] if existing_gle_account else None return dataent.local_cache("party_gle_account", (party_type, party, company), generator, regenerate_if_none=True)
def get_allow_cost_center_in_entry_of_bs_account(): def generator(): return cint(dataent.db.get_value('Accounts Settings', None, 'allow_cost_center_in_entry_of_bs_account')) return dataent.local_cache("get_allow_cost_center_in_entry_of_bs_account", (), generator, regenerate_if_none=True)