refactor: support for BFS and DFS
diff --git a/erpnext/accounts/doctype/bisect_accounting_statements/bisect_accounting_statements.json b/erpnext/accounts/doctype/bisect_accounting_statements/bisect_accounting_statements.json
index de7eba7..b2f3c4b 100644
--- a/erpnext/accounts/doctype/bisect_accounting_statements/bisect_accounting_statements.json
+++ b/erpnext/accounts/doctype/bisect_accounting_statements/bisect_accounting_statements.json
@@ -10,10 +10,8 @@
   "from_date",
   "column_break_qxbi",
   "to_date",
-  "section_break_3x70",
-  "period_from",
-  "column_break_5ett",
-  "period_to"
+  "column_break_iwny",
+  "algorithm"
  ],
  "fields": [
   {
@@ -31,29 +29,22 @@
    "label": "To Date"
   },
   {
-   "fieldname": "section_break_3x70",
-   "fieldtype": "Section Break"
+   "default": "BFS",
+   "fieldname": "algorithm",
+   "fieldtype": "Select",
+   "label": "Algorithm",
+   "options": "BFS\nDFS"
   },
   {
-   "fieldname": "period_from",
-   "fieldtype": "Date",
-   "label": "Period From"
-  },
-  {
-   "fieldname": "column_break_5ett",
+   "fieldname": "column_break_iwny",
    "fieldtype": "Column Break"
-  },
-  {
-   "fieldname": "period_to",
-   "fieldtype": "Date",
-   "label": "Period To"
   }
  ],
  "hide_toolbar": 1,
  "index_web_pages_for_search": 1,
  "issingle": 1,
  "links": [],
- "modified": "2023-09-16 08:02:33.472406",
+ "modified": "2023-09-25 10:50:53.887235",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "Bisect Accounting Statements",
diff --git a/erpnext/accounts/doctype/bisect_accounting_statements/bisect_accounting_statements.py b/erpnext/accounts/doctype/bisect_accounting_statements/bisect_accounting_statements.py
index 73a9e71..bdd1809 100644
--- a/erpnext/accounts/doctype/bisect_accounting_statements/bisect_accounting_statements.py
+++ b/erpnext/accounts/doctype/bisect_accounting_statements/bisect_accounting_statements.py
@@ -1,6 +1,7 @@
 # Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors
 # For license information, please see license.txt
 
+from collections import deque
 from math import floor
 
 import frappe
@@ -10,18 +11,49 @@
 
 
 class BisectAccountingStatements(Document):
-	@frappe.whitelist()
-	def bisect(self):
-		period_list = [(getdate(self.from_date), getdate(self.to_date))]
+	def bfs(self):
+		period_list = deque([(getdate(self.from_date), getdate(self.to_date))])
+		periods = []
 		dates = []
 		while period_list:
+			cur_frm_date, cur_to_date = period_list.popleft()
+			delta = cur_to_date - cur_frm_date
+			periods.append((cur_frm_date, cur_to_date, delta))
+			if delta.days == 0:
+				continue
+			else:
+				cur_floor = floor(delta.days / 2)
+				left = (cur_frm_date, (cur_frm_date + relativedelta(days=+cur_floor)))
+				right = ((cur_frm_date + relativedelta(days=+(cur_floor + 1))), cur_to_date)
+				period_list.append(left)
+				period_list.append(right)
+		return periods
+
+	def dfs(self):
+		period_list = [(getdate(self.from_date), getdate(self.to_date))]
+		periods = []
+		while period_list:
 			cur_frm_date, cur_to_date = period_list.pop()
 			delta = cur_to_date - cur_frm_date
-			if not delta.days > 0:
+			periods.append((cur_frm_date, cur_to_date, delta))
+			if delta.days == 0:
 				continue
+			else:
+				cur_floor = floor(delta.days / 2)
+				left = (cur_frm_date, (cur_frm_date + relativedelta(days=+cur_floor)))
+				right = ((cur_frm_date + relativedelta(days=+(cur_floor + 1))), cur_to_date)
+				period_list.append(left)
+				period_list.append(right)
+		return periods
 
-			cur_floor = floor(delta.days / 2)
-			left = (cur_frm_date, (cur_frm_date + relativedelta(days=+cur_floor)))
-			right = ((cur_frm_date + relativedelta(days=+(cur_floor + 1))), cur_to_date)
-			period_list.append(left)
-			period_list.append(right)
+	@frappe.whitelist()
+	def bisect(self):
+		if self.algorithm == "BFS":
+			periods = self.bfs()
+
+		if self.algorithm == "DFS":
+			periods = self.dfs()
+
+		print("Periods: ", len(periods))
+		for x in periods:
+			print(x)