chore: move dialog building function to `utils.js` file
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
index b95bb00..6856d25 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js
@@ -194,7 +194,7 @@
 				callback: function(r) {
 					if (r.message) {
 						me.frm.add_custom_button(__("Un-Reconcile"), function() {
-							me.unreconcile_prompt();
+							erpnext.utils.build_unreconcile_dialog(cur_frm);
 						});
 					}
 				}
@@ -202,59 +202,6 @@
 		}
 	}
 
-	unreconcile_prompt() {
-		let child_table_fields = [
-			{ label: __("Voucher Type"), fieldname: "voucher_type", fieldtype: "Dynamic Link", options: "DocType", in_list_view: 1, read_only: 1},
-			{ label: __("Voucher No"), fieldname: "voucher_no", fieldtype: "Link", options: "voucher_type", in_list_view: 1, read_only: 1 },
-			{ label: __("Allocated Amount"), fieldname: "allocated_amount", fieldtype: "Float", in_list_view: 1, read_only: 1 },
-		]
-		let unreconcile_dialog_fields = [
-			{
-				label: __('Allocations'),
-				fieldname: 'allocations',
-				fieldtype: 'Table',
-				read_only: 1,
-				fields: child_table_fields,
-			},
-		];
-
-		// get linked payments
-		frappe.call({
-			"method": "erpnext.accounts.doctype.unreconcile_payments.unreconcile_payments.get_linked_payments_for_doc",
-			"args": {
-				"company": this.frm.doc.company,
-				"doctype": this.frm.doc.doctype,
-				"docname": this.frm.doc.name
-			},
-			callback: function(r) {
-				if (r.message) {
-					// populate child table with allocations
-					unreconcile_dialog_fields[0].data = r.message;
-					unreconcile_dialog_fields[0].get_data = function(){ return r.message};
-
-					let d = new frappe.ui.Dialog({
-						title: 'Un-Reconcile Allocations',
-						fields: unreconcile_dialog_fields,
-						size: 'large',
-						cannot_add_rows: 1,
-						primary_action_label: 'Un-Reconcile',
-						primary_action(values) {
-
-							let selected_allocations = values.allocations.filter(x=>x.__checked);
-							if (selected_allocations.length > 0) {
-								// assuming each row is an individual voucher
-								// pass this to server side method that created unreconcile doc for row
-							} else {
-								frappe.msgprint("No Selection");
-							}
-						}
-					});
-
-					d.show();
-				}
-			}
-		});
-	}
 
 	make_maintenance_schedule() {
 		frappe.model.open_mapped_doc({
diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js
index 89750f8..d3442af 100755
--- a/erpnext/public/js/utils.js
+++ b/erpnext/public/js/utils.js
@@ -769,6 +769,62 @@
 	dialog.show();
 }
 
+erpnext.utils.build_unreconcile_dialog = function(frm) {
+	if (['Sales Invoice', 'Purchase Invoice', 'Payment Entry', 'Journal Entry'].includes(frm.doc.doctype)) {
+		let child_table_fields = [
+			{ label: __("Voucher Type"), fieldname: "voucher_type", fieldtype: "Dynamic Link", options: "DocType", in_list_view: 1, read_only: 1},
+			{ label: __("Voucher No"), fieldname: "voucher_no", fieldtype: "Link", options: "voucher_type", in_list_view: 1, read_only: 1 },
+			{ label: __("Allocated Amount"), fieldname: "allocated_amount", fieldtype: "Float", in_list_view: 1, read_only: 1 },
+		]
+		let unreconcile_dialog_fields = [
+			{
+				label: __('Allocations'),
+				fieldname: 'allocations',
+				fieldtype: 'Table',
+				read_only: 1,
+				fields: child_table_fields,
+			},
+		];
+
+		// get linked payments
+		frappe.call({
+			"method": "erpnext.accounts.doctype.unreconcile_payments.unreconcile_payments.get_linked_payments_for_doc",
+			"args": {
+				"company": frm.doc.company,
+				"doctype": frm.doc.doctype,
+				"docname": frm.doc.name
+			},
+			callback: function(r) {
+				if (r.message) {
+					// populate child table with allocations
+					unreconcile_dialog_fields[0].data = r.message;
+					unreconcile_dialog_fields[0].get_data = function(){ return r.message};
+
+					let d = new frappe.ui.Dialog({
+						title: 'Un-Reconcile Allocations',
+						fields: unreconcile_dialog_fields,
+						size: 'large',
+						cannot_add_rows: 1,
+						primary_action_label: 'Un-Reconcile',
+						primary_action(values) {
+
+							let selected_allocations = values.allocations.filter(x=>x.__checked);
+							if (selected_allocations.length > 0) {
+								// assuming each row is an individual voucher
+								// pass this to server side method that created unreconcile doc for row
+							} else {
+								frappe.msgprint("No Selection");
+							}
+						}
+					});
+
+					d.show();
+				}
+			}
+		});
+	}
+}
+
 erpnext.utils.map_current_doc = function(opts) {
 	function _map() {
 		if($.isArray(cur_frm.doc.items) && cur_frm.doc.items.length > 0) {
@@ -1097,4 +1153,4 @@
 	$btn.on("click", function() {
 		context.show_serial_batch_selector(grid_row.frm, grid_row.doc, "", "", true);
 	});
-}
\ No newline at end of file
+}