Skip to content

Commit

Permalink
feat: grade
Browse files Browse the repository at this point in the history
  • Loading branch information
fproldan committed Oct 28, 2024
1 parent f0bcdb6 commit 34bf98b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ frappe.ui.form.on('Process Sales Commission', {
},
branch: function(frm) {
get_sales_persons(frm)
},
grade: function(frm) {
get_sales_persons(frm)
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"field_order": [
"company",
"department",
"grade",
"column_break_3",
"designation",
"branch",
Expand Down Expand Up @@ -146,12 +147,18 @@
"label": "Vendedores",
"options": "Process Sales Commission Sales Person",
"reqd": 1
},
{
"fieldname": "grade",
"fieldtype": "Link",
"label": "Grado",
"options": "Employee Grade"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
"modified": "2024-10-09 17:30:15.732976",
"modified": "2024-10-28 09:35:07.474736",
"modified_by": "Administrator",
"module": "Payroll",
"name": "Process Sales Commission",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def process_sales_commission(self):

def get_sales_persons_list(self, sales_persons):
sales_persons_list = sales_persons
if not any([self.department, self.designation, self.branch]):
if not any([self.department, self.designation, self.branch, self.grade]):
return sales_persons_list

sales_persons_emp = frappe.get_all("Sales Person", filters={"name": ["in", sales_persons]}, fields=["employee"], pluck="employee")
Expand All @@ -48,6 +48,8 @@ def get_sales_persons_list(self, sales_persons):
emp_filters["designation"] = self.designation
if self.branch:
emp_filters["branch"] = self.branch
if self.grade:
emp_filters["grade"] = self.grade

sales_persons_list = frappe.get_all("Employee", filters=emp_filters)
for person in sales_persons:
Expand All @@ -67,6 +69,9 @@ def get_sales_persons_list(self, sales_persons):
if self.branch and self.branch != employee_details["branch"]:
sales_persons_list.remove(person)
continue
if self.grade and self.grade != employee_details["grade"]:
sales_persons_list.remove(person)
continue

def map_sales_persons_details(self, sales_persons, sales_persons_details):
sales_persons_details_map = {}
Expand Down Expand Up @@ -115,6 +120,8 @@ def get_sales_persons(self):
employee_filters["designation"] = self.designation
if self.branch:
employee_filters["branch"] = self.branch
if self.grade:
employee_filters["grade"] = self.grade

employees = frappe.get_all("Employee", filters=employee_filters, pluck="name")
for sales_person in frappe.get_all(
Expand Down

0 comments on commit 34bf98b

Please sign in to comment.