feat: ledger merger doctype
diff --git a/erpnext/accounts/doctype/ledger_merge/__init__.py b/erpnext/accounts/doctype/ledger_merge/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/accounts/doctype/ledger_merge/__init__.py
diff --git a/erpnext/accounts/doctype/ledger_merge/ledger_merge.js b/erpnext/accounts/doctype/ledger_merge/ledger_merge.js
new file mode 100644
index 0000000..ff69ddc
--- /dev/null
+++ b/erpnext/accounts/doctype/ledger_merge/ledger_merge.js
@@ -0,0 +1,88 @@
+// Copyright (c) 2021, Wahni Green Technologies Pvt. Ltd. and contributors
+// For license information, please see license.txt
+
+frappe.ui.form.on('Ledger Merge', {
+  setup: function(frm) {
+    frm.set_query("account", function(doc) {
+      if (!doc.company) frappe.throw(__('Please set Company'));
+      if (!doc.root_type) frappe.throw(__('Please set Root Type'));
+      return {
+        filters: {
+          is_group: 0,
+          root_type: doc.root_type,
+          company: doc.company
+        }
+      }
+    });
+
+    frm.set_query('account', 'merge_accounts', function(doc, cdt, cdn) {
+      if (!doc.company) frappe.throw(__('Please set Company'));
+      if (!doc.root_type) frappe.throw(__('Please set Root Type'));
+      if (!doc.account) frappe.throw(__('Please set Account'));
+			return {
+        filters: {
+          is_group: 0,
+          root_type: doc.root_type,
+          name: ["!=", doc.account],
+          company: doc.company
+        }
+      }
+		});
+  },
+
+	refresh: function(frm) {
+    frm.page.hide_icon_group();
+	},
+
+  onload_post_render: function(frm) {
+		frm.trigger('update_primary_action');
+	},
+
+  after_save: function(frm) {
+		frm.trigger('update_primary_action');
+	},
+
+	update_primary_action: function(frm) {
+		if (frm.is_dirty()) {
+			frm.enable_save();
+			return;
+		}
+		frm.disable_save();
+		if (frm.doc.status !== 'Success') {
+			if (!frm.is_new()) {
+				let label =
+					frm.doc.status === 'Pending' ? __('Start Merge') : __('Retry');
+				frm.page.set_primary_action(label, () => frm.events.start_merge(frm));
+			} else {
+				frm.page.set_primary_action(__('Save'), () => frm.save());
+			}
+		}
+	},
+
+  start_merge: function(frm) {
+    console.log('Hi');
+    frm.trigger('set_merge_status');
+  },
+
+  set_merge_status: function(frm) {
+    if (frm.doc.status == "Pending") return;
+    let successful_records = 0;
+    frm.doc.merge_accounts.forEach((row) => {
+			if(row.merged) successful_records += 1;
+		});
+    let message_args = [successful_records, frm.doc.merge_accounts.length];
+    frm.dashboard.set_headline(__('Successfully merged {0} out of {1}.', message_args));
+  }
+});
+
+frappe.ui.form.on('Ledger Merge Accounts', {
+    merge_accounts_add: function(frm, cdt, cdn) {
+      frm.trigger('update_primary_action');
+    },
+    merge_accounts_remove: function(frm, cdt, cdn) {
+      frm.trigger('update_primary_action');
+    },
+    account: function(frm, cdt, cdn) {
+      frm.trigger('update_primary_action');
+    }
+})
diff --git a/erpnext/accounts/doctype/ledger_merge/ledger_merge.json b/erpnext/accounts/doctype/ledger_merge/ledger_merge.json
new file mode 100644
index 0000000..b3652bb
--- /dev/null
+++ b/erpnext/accounts/doctype/ledger_merge/ledger_merge.json
@@ -0,0 +1,109 @@
+{
+ "actions": [],
+ "autoname": "format:{account} merger on {creation}",
+ "creation": "2021-12-09 15:38:04.556584",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "section_break_1",
+  "root_type",
+  "account",
+  "column_break_3",
+  "company",
+  "status",
+  "section_break_5",
+  "merge_accounts"
+ ],
+ "fields": [
+  {
+   "depends_on": "root_type",
+   "fieldname": "account",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Account",
+   "options": "Account",
+   "reqd": 1,
+   "set_only_once": 1
+  },
+  {
+   "fieldname": "section_break_1",
+   "fieldtype": "Section Break"
+  },
+  {
+   "fieldname": "column_break_3",
+   "fieldtype": "Column Break"
+  },
+  {
+   "fieldname": "merge_accounts",
+   "fieldtype": "Table",
+   "label": "Accounts to Merge",
+   "options": "Ledger Merge Accounts",
+   "reqd": 1
+  },
+  {
+   "depends_on": "account",
+   "fieldname": "section_break_5",
+   "fieldtype": "Section Break"
+  },
+  {
+   "fieldname": "company",
+   "fieldtype": "Link",
+   "label": "Company",
+   "options": "Company",
+   "reqd": 1,
+   "set_only_once": 1
+  },
+  {
+   "fieldname": "status",
+   "fieldtype": "Select",
+   "label": "Status",
+   "options": "Pending\nSuccess\nPartial Success\nError",
+   "read_only": 1
+  },
+  {
+   "fieldname": "root_type",
+   "fieldtype": "Select",
+   "label": "Root Type",
+   "options": "\nAsset\nLiability\nIncome\nExpense\nEquity",
+   "reqd": 1,
+   "set_only_once": 1
+  }
+ ],
+ "hide_toolbar": 1,
+ "links": [],
+ "modified": "2021-12-09 18:35:30.720538",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Ledger Merge",
+ "naming_rule": "Expression",
+ "owner": "Administrator",
+ "permissions": [
+  {
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "System Manager",
+   "share": 1,
+   "write": 1
+  },
+  {
+   "create": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Accounts Manager",
+   "share": 1,
+   "write": 1
+  }
+ ],
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/ledger_merge/ledger_merge.py b/erpnext/accounts/doctype/ledger_merge/ledger_merge.py
new file mode 100644
index 0000000..bf12ff5
--- /dev/null
+++ b/erpnext/accounts/doctype/ledger_merge/ledger_merge.py
@@ -0,0 +1,8 @@
+# Copyright (c) 2021, Wahni Green Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+import frappe
+from frappe.model.document import Document
+
+class LedgerMerge(Document):
+	pass
diff --git a/erpnext/accounts/doctype/ledger_merge/test_ledger_merge.py b/erpnext/accounts/doctype/ledger_merge/test_ledger_merge.py
new file mode 100644
index 0000000..c24caed
--- /dev/null
+++ b/erpnext/accounts/doctype/ledger_merge/test_ledger_merge.py
@@ -0,0 +1,8 @@
+# Copyright (c) 2021, Wahni Green Technologies Pvt. Ltd. and Contributors
+# See license.txt
+
+# import frappe
+import unittest
+
+class TestLedgerMerge(unittest.TestCase):
+	pass
diff --git a/erpnext/accounts/doctype/ledger_merge_accounts/__init__.py b/erpnext/accounts/doctype/ledger_merge_accounts/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/accounts/doctype/ledger_merge_accounts/__init__.py
diff --git a/erpnext/accounts/doctype/ledger_merge_accounts/ledger_merge_accounts.json b/erpnext/accounts/doctype/ledger_merge_accounts/ledger_merge_accounts.json
new file mode 100644
index 0000000..f5dab36
--- /dev/null
+++ b/erpnext/accounts/doctype/ledger_merge_accounts/ledger_merge_accounts.json
@@ -0,0 +1,43 @@
+{
+ "actions": [],
+ "allow_rename": 1,
+ "creation": "2021-12-09 15:44:58.033398",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "account",
+  "merged"
+ ],
+ "fields": [
+  {
+   "columns": 8,
+   "fieldname": "account",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Account",
+   "options": "Account",
+   "reqd": 1
+  },
+  {
+   "columns": 2,
+   "default": "0",
+   "fieldname": "merged",
+   "fieldtype": "Check",
+   "in_list_view": 1,
+   "label": "Merged",
+   "read_only": 1
+  }
+ ],
+ "index_web_pages_for_search": 1,
+ "istable": 1,
+ "links": [],
+ "modified": "2021-12-09 15:50:09.047183",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Ledger Merge Accounts",
+ "owner": "Administrator",
+ "permissions": [],
+ "sort_field": "modified",
+ "sort_order": "DESC"
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/ledger_merge_accounts/ledger_merge_accounts.py b/erpnext/accounts/doctype/ledger_merge_accounts/ledger_merge_accounts.py
new file mode 100644
index 0000000..1b37095
--- /dev/null
+++ b/erpnext/accounts/doctype/ledger_merge_accounts/ledger_merge_accounts.py
@@ -0,0 +1,8 @@
+# Copyright (c) 2021, Wahni Green Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+# import frappe
+from frappe.model.document import Document
+
+class LedgerMergeAccounts(Document):
+	pass