diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py index 4213d478ce1..0ed30eaee52 100644 --- a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py +++ b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.py @@ -601,6 +601,7 @@ def calculate_exchange_rate_using_last_gle(company, account, party_type, party): .select(gl.voucher_type, gl.voucher_no) .where(Criterion.all(conditions)) .orderby(gl.posting_date, order=Order.desc) + .orderby(gl.name, order=Order.desc) .limit(1) .run()[0] ) @@ -615,6 +616,7 @@ def calculate_exchange_rate_using_last_gle(company, account, party_type, party): (gl.voucher_type == voucher_type) & (gl.voucher_no == voucher_no) & (gl.account == account) ) .orderby(gl.posting_date, order=Order.desc) + .orderby(gl.name, order=Order.desc) .limit(1) .run()[0][0] )