Skip to content

Commit

Permalink
feat: make Bulk Assign Structure a primary button and add Branch filt…
Browse files Browse the repository at this point in the history
…er (#1197)

* feat: add Branch filter and make Bulk Assign Structure the primary action

* fix: anti pattern

* fix: Button label

Co-authored-by: Rucha Mahabal <[email protected]>

* fix: add branch filter to server side

---------

Co-authored-by: Rucha Mahabal <[email protected]>
(cherry picked from commit 85ca6dc)
  • Loading branch information
krantheman authored and mergify[bot] committed Jan 9, 2024
1 parent d273a96 commit 5ae8d45
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
15 changes: 8 additions & 7 deletions hrms/payroll/doctype/salary_structure/salary_structure.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ frappe.ui.form.on("Salary Structure", {
frm.fields_dict['deductions'].grid.set_column_disp("default_amount", false);

if (frm.doc.docstatus === 1) {
frm.add_custom_button(__("Assign to Employees"), function() {
frm.add_custom_button(__("Bulk Assign Structure"), () => {
frm.trigger("assign_to_employees")
}, __("Actions"));
}).addClass("btn-primary");

frm.add_custom_button(__("Assign Salary Structure"), function() {
frm.add_custom_button(__("Assign to Employee"), function() {
let doc = frappe.model.get_new_doc("Salary Structure Assignment");
doc.salary_structure = frm.doc.name;
doc.company = frm.doc.company;
Expand All @@ -127,12 +127,13 @@ frappe.ui.form.on("Salary Structure", {

assign_to_employees:function (frm) {
var d = new frappe.ui.Dialog({
title: __("Assign to Employees"),
title: __("Bulk Salary Structure Assignment"),
fields: [
{fieldname: "sec_break", fieldtype: "Section Break", label: __("Filter Employees By (Optional)")},
{fieldname: "grade", fieldtype: "Link", options: "Employee Grade", label: __("Employee Grade")},
{fieldname:'department', fieldtype:'Link', options: 'Department', label: __('Department')},
{fieldname: "sec_break", fieldtype: "Section Break", label: __("Employee Filters")},
{fieldname: "branch", fieldtype: "Link", options: "Branch", label: __("Branch")},
{fieldname:'designation', fieldtype:'Link', options: 'Designation', label: __('Designation')},
{fieldname:'department', fieldtype:'Link', options: 'Department', label: __('Department')},
{fieldname: "grade", fieldtype: "Link", options: "Employee Grade", label: __("Employee Grade")},
{fieldname:"employee", fieldtype: "Link", options: "Employee", label: __("Employee")},
{fieldname:"payroll_payable_account", fieldtype: "Link", options: "Account", filters: {"company": frm.doc.company, "root_type": "Liability", "is_group": 0, "account_currency": frm.doc.currency}, label: __("Payroll Payable Account")},
{fieldname:'base_variable', fieldtype:'Section Break'},
Expand Down
8 changes: 7 additions & 1 deletion hrms/payroll/doctype/salary_structure/salary_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def get_employees(self, **kwargs):
@frappe.whitelist()
def assign_salary_structure(
self,
branch=None,
grade=None,
department=None,
designation=None,
Expand All @@ -188,7 +189,12 @@ def assign_salary_structure(
income_tax_slab=None,
):
employees = self.get_employees(
company=self.company, grade=grade, department=department, designation=designation, name=employee
company=self.company,
grade=grade,
department=department,
designation=designation,
name=employee,
branch=branch,
)

if employees:
Expand Down

0 comments on commit 5ae8d45

Please sign in to comment.