fix(exchange-rate-revaluation): change create to view button on creation of journal entry (#18201)

diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js
index dad75b4..0d5456e 100644
--- a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js
+++ b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js
@@ -21,9 +21,29 @@
 
 	refresh: function(frm) {
 		if(frm.doc.docstatus==1) {
-			frm.add_custom_button(__('Create Journal Entry'), function() {
-				return frm.events.make_jv(frm);
-			});
+			frappe.db.get_value("Journal Entry Account", {
+				'reference_type': 'Exchange Rate Revaluation',
+				'reference_name': frm.doc.name,
+				'docstatus': 1
+			}, "sum(debit) as sum", (r) =>{
+				let total_amt = 0;
+				frm.doc.accounts.forEach(d=> {
+					total_amt = total_amt + d['new_balance_in_base_currency'];
+				});
+				if(total_amt === r.sum) {
+					frm.add_custom_button(__("Journal Entry"), function(){
+						frappe.route_options = {
+							'reference_type': 'Exchange Rate Revaluation',
+							'reference_name': frm.doc.name
+						};
+						frappe.set_route("List", "Journal Entry");
+					}, __("View"));
+				} else {
+					frm.add_custom_button(__('Create Journal Entry'), function() {
+						return frm.events.make_jv(frm);
+					});
+				}
+			}, 'Journal Entry');
 		}
 	},