Skip to content

Commit

Permalink
fix: staffing plan vacancies data type issue (#25936)
Browse files Browse the repository at this point in the history
* fix: staffing plan vacancies data type issue

* fix: translation issue

* fix: removed greater than 0 condition

* fix: sider

Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>
  • Loading branch information
pateljannat and ruchamahabal authored Jun 23, 2021
1 parent d021db1 commit da66cef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion erpnext/hr/doctype/staffing_plan/staffing_plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ var set_total_estimated_budget = function(frm) {
})
frm.set_value('total_estimated_budget', estimated_budget);
}
}
};
22 changes: 11 additions & 11 deletions erpnext/hr/doctype/staffing_plan/staffing_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def set_total_estimated_budget(self):

detail.total_estimated_cost = 0
if detail.number_of_positions > 0:
if detail.vacancies > 0 and detail.estimated_cost_per_position:
if detail.vacancies and detail.estimated_cost_per_position:
detail.total_estimated_cost = cint(detail.vacancies) * flt(detail.estimated_cost_per_position)

self.total_estimated_budget += detail.total_estimated_cost
Expand Down Expand Up @@ -76,12 +76,12 @@ def validate_with_parent_plan(self, staffing_plan_detail):
if cint(staffing_plan_detail.vacancies) > cint(parent_plan_details[0].vacancies) or \
flt(staffing_plan_detail.total_estimated_cost) > flt(parent_plan_details[0].total_estimated_cost):
frappe.throw(_("You can only plan for upto {0} vacancies and budget {1} \
for {2} as per staffing plan {3} for parent company {4}."
.format(cint(parent_plan_details[0].vacancies),
for {2} as per staffing plan {3} for parent company {4}.").format(
cint(parent_plan_details[0].vacancies),
parent_plan_details[0].total_estimated_cost,
frappe.bold(staffing_plan_detail.designation),
parent_plan_details[0].name,
parent_company)), ParentCompanyError)
parent_company), ParentCompanyError)

#Get vacanices already planned for all companies down the hierarchy of Parent Company
lft, rgt = frappe.get_cached_value('Company', parent_company, ["lft", "rgt"])
Expand All @@ -98,14 +98,14 @@ def validate_with_parent_plan(self, staffing_plan_detail):
(flt(parent_plan_details[0].total_estimated_cost) < \
(flt(staffing_plan_detail.total_estimated_cost) + flt(all_sibling_details.total_estimated_cost))):
frappe.throw(_("{0} vacancies and {1} budget for {2} already planned for subsidiary companies of {3}. \
You can only plan for upto {4} vacancies and and budget {5} as per staffing plan {6} for parent company {3}."
.format(cint(all_sibling_details.vacancies),
You can only plan for upto {4} vacancies and and budget {5} as per staffing plan {6} for parent company {3}.").format(
cint(all_sibling_details.vacancies),
all_sibling_details.total_estimated_cost,
frappe.bold(staffing_plan_detail.designation),
parent_company,
cint(parent_plan_details[0].vacancies),
parent_plan_details[0].total_estimated_cost,
parent_plan_details[0].name)))
parent_plan_details[0].name))

def validate_with_subsidiary_plans(self, staffing_plan_detail):
#Valdate this plan with all child company plan
Expand All @@ -121,11 +121,11 @@ def validate_with_subsidiary_plans(self, staffing_plan_detail):
cint(staffing_plan_detail.vacancies) < cint(children_details.vacancies) or \
flt(staffing_plan_detail.total_estimated_cost) < flt(children_details.total_estimated_cost):
frappe.throw(_("Subsidiary companies have already planned for {1} vacancies at a budget of {2}. \
Staffing Plan for {0} should allocate more vacancies and budget for {3} than planned for its subsidiary companies"
.format(self.company,
Staffing Plan for {0} should allocate more vacancies and budget for {3} than planned for its subsidiary companies").format(
self.company,
cint(children_details.vacancies),
children_details.total_estimated_cost,
frappe.bold(staffing_plan_detail.designation))), SubsidiaryCompanyError)
frappe.bold(staffing_plan_detail.designation)), SubsidiaryCompanyError)

@frappe.whitelist()
def get_designation_counts(designation, company):
Expand Down Expand Up @@ -170,4 +170,4 @@ def get_active_staffing_plan_details(company, designation, from_date=getdate(now
designation, from_date, to_date)

# Only a single staffing plan can be active for a designation on given date
return staffing_plan if staffing_plan else None
return staffing_plan if staffing_plan else None

0 comments on commit da66cef

Please sign in to comment.