prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Organizational Chart: Total connections includes employees left
  ### Information about bug
  
  <img width="329" alt="Screenshot 2024-03-08 at 11 20 37 AM" src="https://github.com/frappe/hrms/assets/20027965/b88248f8-502e-41fa-ba1a-87c0cd43165a">
  
  The current system displays a total count of connections for each employee, including those who are no longer with the company. However, when viewing the connections, only active employees are shown.
  
  **Expected Output:**
  The count now reflects only active employees, ensuring consistency between the number displayed and the individuals visible upon selecting any employee.
  
  ### Module
  
  HR
  
  ### Version
  
  ERPNext: v14.x.x-develop () (develop)
  
  Frappe Framework: v15.x.x-develop () (develop)
  
  Frappe HR: v16.0.0-dev (develop)
  
  ### Installation method
  
  manual install
  
  ### Relevant log output / Stack trace / Full Error Message.
  
  _No response_
  
  ### Code of Conduct
  
  - [x] I agree to follow this project's Code of Conduct
  
  </issue>
  <code>
  [start of hrms/hr/page/organizational_chart/organizational_chart.py]
  1 import frappe
  2 from frappe.query_builder.functions import Count
  3 
  4 
  5 @frappe.whitelist()
  6 def get_children(parent=None, company=None, exclude_node=None):
  7 	filters = [["status", "=", "Active"]]
  8 	if company and company != "All Companies":
  9 		filters.append(["company", "=", company])
  10 
  11 	if parent and company and parent != company:
  12 		filters.append(["reports_to", "=", parent])
  13 	else:
  14 		filters.append(["reports_to", "=", ""])
  15 
  16 	if exclude_node:
  17 		filters.append(["name", "!=", exclude_node])
  18 
  19 	employees = frappe.get_all(
  20 		"Employee",
  21 		fields=[
  22 			"employee_name as name",
  23 			"name as id",
  24 			"lft",
  25 			"rgt",
  26 			"reports_to",
  27 			"image",
  28 			"designation as title",
  29 		],
  30 		filters=filters,
  31 		order_by="name",
  32 	)
  33 
  34 	for employee in employees:
  35 		employee.connections = get_connections(employee.id, employee.lft, employee.rgt)
  36 		employee.expandable = bool(employee.connections)
  37 
  38 	return employees
  39 
  40 
  41 def get_connections(employee: str, lft: int, rgt: int) -> int:
  42 	Employee = frappe.qb.DocType("Employee")
  43 	query = (
  44 		frappe.qb.from_(Employee)
  45 		.select(Count(Employee.name))
  46 		.where((Employee.lft > lft) & (Employee.rgt < rgt))
  47 	).run()
  48 
  49 	return query[0][0]
  50
  [end of hrms/hr/page/organizational_chart/organizational_chart.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/hrms/hr/page/organizational_chart/organizational_chart.py b/hrms/hr/page/organizational_chart/organizational_chart.py
  --- a/hrms/hr/page/organizational_chart/organizational_chart.py
  +++ b/hrms/hr/page/organizational_chart/organizational_chart.py
  @@ -43,7 +43,7 @@
   	query = (
   		frappe.qb.from_(Employee)
   		.select(Count(Employee.name))
  -		.where((Employee.lft > lft) & (Employee.rgt < rgt))
  +		.where((Employee.lft > lft) & (Employee.rgt < rgt) & (Employee.status == "Active"))
   	).run()
   
   	return query[0][0]
  
verification_info: {"golden_diff": "diff --git a/hrms/hr/page/organizational_chart/organizational_chart.py b/hrms/hr/page/organizational_chart/organizational_chart.py\n--- a/hrms/hr/page/organizational_chart/organizational_chart.py\n+++ b/hrms/hr/page/organizational_chart/organizational_chart.py\n@@ -43,7 +43,7 @@\n \tquery = (\n \t\tfrappe.qb.from_(Employee)\n \t\t.select(Count(Employee.name))\n-\t\t.where((Employee.lft > lft) & (Employee.rgt < rgt))\n+\t\t.where((Employee.lft > lft) & (Employee.rgt < rgt) & (Employee.status == \"Active\"))\n \t).run()\n \n \treturn query[0][0]\n", "issue": "Organizational Chart: Total connections includes employees left\n### Information about bug\n\n<img width=\"329\" alt=\"Screenshot 2024-03-08 at 11 20 37\u202fAM\" src=\"https://github.com/frappe/hrms/assets/20027965/b88248f8-502e-41fa-ba1a-87c0cd43165a\">\r\n\r\nThe current system displays a total count of connections for each employee, including those who are no longer with the company. However, when viewing the connections, only active employees are shown.\r\n\r\n**Expected Output:**\r\nThe count now reflects only active employees, ensuring consistency between the number displayed and the individuals visible upon selecting any employee.\n\n### Module\n\nHR\n\n### Version\n\nERPNext: v14.x.x-develop () (develop)\r\n\r\nFrappe Framework: v15.x.x-develop () (develop)\r\n\r\nFrappe HR: v16.0.0-dev (develop)\n\n### Installation method\n\nmanual install\n\n### Relevant log output / Stack trace / Full Error Message.\n\n_No response_\n\n### Code of Conduct\n\n- [x] I agree to follow this project's Code of Conduct\n", "before_files": [{"content": "import frappe\nfrom frappe.query_builder.functions import Count\n\n\n@frappe.whitelist()\ndef get_children(parent=None, company=None, exclude_node=None):\n\tfilters = [[\"status\", \"=\", \"Active\"]]\n\tif company and company != \"All Companies\":\n\t\tfilters.append([\"company\", \"=\", company])\n\n\tif parent and company and parent != company:\n\t\tfilters.append([\"reports_to\", \"=\", parent])\n\telse:\n\t\tfilters.append([\"reports_to\", \"=\", \"\"])\n\n\tif exclude_node:\n\t\tfilters.append([\"name\", \"!=\", exclude_node])\n\n\temployees = frappe.get_all(\n\t\t\"Employee\",\n\t\tfields=[\n\t\t\t\"employee_name as name\",\n\t\t\t\"name as id\",\n\t\t\t\"lft\",\n\t\t\t\"rgt\",\n\t\t\t\"reports_to\",\n\t\t\t\"image\",\n\t\t\t\"designation as title\",\n\t\t],\n\t\tfilters=filters,\n\t\torder_by=\"name\",\n\t)\n\n\tfor employee in employees:\n\t\temployee.connections = get_connections(employee.id, employee.lft, employee.rgt)\n\t\temployee.expandable = bool(employee.connections)\n\n\treturn employees\n\n\ndef get_connections(employee: str, lft: int, rgt: int) -> int:\n\tEmployee = frappe.qb.DocType(\"Employee\")\n\tquery = (\n\t\tfrappe.qb.from_(Employee)\n\t\t.select(Count(Employee.name))\n\t\t.where((Employee.lft > lft) & (Employee.rgt < rgt))\n\t).run()\n\n\treturn query[0][0]\n", "path": "hrms/hr/page/organizational_chart/organizational_chart.py"}]}