[Fix] Exchange rate revaluation, get entries not working if accounts of the other currency than company currency not available (#16379)

This commit is contained in:
rohitwaghchaure 2019-01-12 17:58:00 +05:30 committed by Rushabh Mehta
parent 5c86cf54a2
commit ba54209c86
2 changed files with 15 additions and 11 deletions

View File

@ -39,6 +39,8 @@ frappe.ui.form.on('Exchange Rate Revaluation', {
});
frm.events.get_total_gain_loss(frm);
refresh_field("accounts");
} else {
frappe.msgprint(__("No records found"));
}
}
});

View File

@ -67,17 +67,19 @@ class ExchangeRateRevaluation(Document):
and account_currency != %s
order by name""",(self.company, company_currency))
account_details = frappe.db.sql("""
select
account, party_type, party, account_currency,
sum(debit_in_account_currency) - sum(credit_in_account_currency) as balance_in_account_currency,
sum(debit) - sum(credit) as balance
from `tabGL Entry`
where account in (%s)
group by account, party_type, party
having sum(debit) != sum(credit)
order by account
""" % ', '.join(['%s']*len(accounts)), tuple(accounts), as_dict=1)
account_details = []
if accounts:
account_details = frappe.db.sql("""
select
account, party_type, party, account_currency,
sum(debit_in_account_currency) - sum(credit_in_account_currency) as balance_in_account_currency,
sum(debit) - sum(credit) as balance
from `tabGL Entry`
where account in (%s)
group by account, party_type, party
having sum(debit) != sum(credit)
order by account
""" % ', '.join(['%s']*len(accounts)), tuple(accounts), as_dict=1)
return account_details