fix: test cases and codacy
This commit is contained in:
parent
01086ff60c
commit
d4e4316d0b
@ -116,6 +116,8 @@ class Account(NestedSet):
|
||||
doc.update({"company": company, "account_currency": None,
|
||||
"parent": acc_name_map[company], "parent_account": acc_name_map[company]})
|
||||
doc.save()
|
||||
frappe.msgprint(_("Account {0} is added in the child company {1}")
|
||||
.format(doc.name, company))
|
||||
|
||||
def validate_group_or_ledger(self):
|
||||
if self.get("__islocal"):
|
||||
|
@ -20,6 +20,7 @@ class StaffingPlan(Document):
|
||||
self.total_estimated_budget = 0
|
||||
|
||||
for detail in self.get("staffing_details"):
|
||||
self.set_vacancies(detail)
|
||||
self.validate_overlap(detail)
|
||||
self.validate_with_subsidiary_plans(detail)
|
||||
self.validate_with_parent_plan(detail)
|
||||
@ -39,6 +40,15 @@ class StaffingPlan(Document):
|
||||
else: detail.vacancies = detail.number_of_positions = detail.total_estimated_cost = 0
|
||||
self.total_estimated_budget += detail.total_estimated_cost
|
||||
|
||||
def set_vacancies(self, row):
|
||||
if not row.vacancies:
|
||||
current_openings = 0
|
||||
for field in ['current_count', 'current_openings']:
|
||||
if row.get(field):
|
||||
current_openings += row.get(field)
|
||||
|
||||
row.vacancies = row.number_of_positions - current_openings
|
||||
|
||||
def validate_overlap(self, staffing_plan_detail):
|
||||
# Validate if any submitted Staffing Plan exist for any Designations in this plan
|
||||
# and spd.vacancies>0 ?
|
||||
|
@ -18,7 +18,7 @@ class TestStaffingPlan(unittest.TestCase):
|
||||
if frappe.db.exists("Staffing Plan", "Test"):
|
||||
return
|
||||
staffing_plan = frappe.new_doc("Staffing Plan")
|
||||
staffing_plan.company = "_Test Company 3"
|
||||
staffing_plan.company = "_Test Company 10"
|
||||
staffing_plan.name = "Test"
|
||||
staffing_plan.from_date = nowdate()
|
||||
staffing_plan.to_date = add_days(nowdate(), 10)
|
||||
@ -67,7 +67,7 @@ class TestStaffingPlan(unittest.TestCase):
|
||||
if frappe.db.exists("Staffing Plan", "Test 1"):
|
||||
return
|
||||
staffing_plan = frappe.new_doc("Staffing Plan")
|
||||
staffing_plan.company = "_Test Company 3"
|
||||
staffing_plan.company = "_Test Company 10"
|
||||
staffing_plan.name = "Test 1"
|
||||
staffing_plan.from_date = nowdate()
|
||||
staffing_plan.to_date = add_days(nowdate(), 10)
|
||||
@ -85,11 +85,11 @@ def _set_up():
|
||||
make_company()
|
||||
|
||||
def make_company():
|
||||
if frappe.db.exists("Company", "_Test Company 3"):
|
||||
if frappe.db.exists("Company", "_Test Company 10"):
|
||||
return
|
||||
company = frappe.new_doc("Company")
|
||||
company.company_name = "_Test Company 3"
|
||||
company.abbr = "_TC3"
|
||||
company.company_name = "_Test Company 10"
|
||||
company.abbr = "_TC10"
|
||||
company.parent_company = "_Test Company"
|
||||
company.default_currency = "INR"
|
||||
company.country = "India"
|
||||
|
@ -1,66 +1,66 @@
|
||||
[
|
||||
{
|
||||
"abbr": "_TC",
|
||||
"company_name": "_Test Company",
|
||||
"country": "India",
|
||||
"default_currency": "INR",
|
||||
"doctype": "Company",
|
||||
"domain": "Manufacturing",
|
||||
"chart_of_accounts": "Standard",
|
||||
"default_holiday_list": "_Test Holiday List"
|
||||
},
|
||||
{
|
||||
"abbr": "_TC1",
|
||||
"company_name": "_Test Company 1",
|
||||
"country": "United States",
|
||||
"default_currency": "USD",
|
||||
"doctype": "Company",
|
||||
"domain": "Retail",
|
||||
"chart_of_accounts": "Standard",
|
||||
"default_holiday_list": "_Test Holiday List"
|
||||
},
|
||||
{
|
||||
"abbr": "_TC2",
|
||||
"company_name": "_Test Company 2",
|
||||
"default_currency": "EUR",
|
||||
"country": "Germany",
|
||||
"doctype": "Company",
|
||||
"domain": "Retail",
|
||||
"chart_of_accounts": "Standard",
|
||||
"default_holiday_list": "_Test Holiday List"
|
||||
},
|
||||
{
|
||||
"abbr": "_TC3",
|
||||
"company_name": "_Test Company 3",
|
||||
"is_group": 1,
|
||||
"country": "India",
|
||||
"default_currency": "INR",
|
||||
"doctype": "Company",
|
||||
"domain": "Manufacturing",
|
||||
"chart_of_accounts": "Standard",
|
||||
"default_holiday_list": "_Test Holiday List"
|
||||
},
|
||||
{
|
||||
"abbr": "_TC4",
|
||||
"company_name": "_Test Company 4",
|
||||
"parent_company": "_Test Company 3",
|
||||
"is_group": 1,
|
||||
"country": "India",
|
||||
"default_currency": "INR",
|
||||
"doctype": "Company",
|
||||
"domain": "Manufacturing",
|
||||
"chart_of_accounts": "Standard",
|
||||
"default_holiday_list": "_Test Holiday List"
|
||||
},
|
||||
{
|
||||
"abbr": "_TC5",
|
||||
"company_name": "_Test Company 5",
|
||||
"parent_company": "_Test Company 4",
|
||||
"country": "India",
|
||||
"default_currency": "INR",
|
||||
"doctype": "Company",
|
||||
"domain": "Manufacturing",
|
||||
"chart_of_accounts": "Standard",
|
||||
"default_holiday_list": "_Test Holiday List"
|
||||
}
|
||||
{
|
||||
"abbr": "_TC",
|
||||
"company_name": "_Test Company",
|
||||
"country": "India",
|
||||
"default_currency": "INR",
|
||||
"doctype": "Company",
|
||||
"domain": "Manufacturing",
|
||||
"chart_of_accounts": "Standard",
|
||||
"default_holiday_list": "_Test Holiday List"
|
||||
},
|
||||
{
|
||||
"abbr": "_TC1",
|
||||
"company_name": "_Test Company 1",
|
||||
"country": "United States",
|
||||
"default_currency": "USD",
|
||||
"doctype": "Company",
|
||||
"domain": "Retail",
|
||||
"chart_of_accounts": "Standard",
|
||||
"default_holiday_list": "_Test Holiday List"
|
||||
},
|
||||
{
|
||||
"abbr": "_TC2",
|
||||
"company_name": "_Test Company 2",
|
||||
"default_currency": "EUR",
|
||||
"country": "Germany",
|
||||
"doctype": "Company",
|
||||
"domain": "Retail",
|
||||
"chart_of_accounts": "Standard",
|
||||
"default_holiday_list": "_Test Holiday List"
|
||||
},
|
||||
{
|
||||
"abbr": "_TC3",
|
||||
"company_name": "_Test Company 3",
|
||||
"is_group": 1,
|
||||
"country": "India",
|
||||
"default_currency": "INR",
|
||||
"doctype": "Company",
|
||||
"domain": "Manufacturing",
|
||||
"chart_of_accounts": "Standard",
|
||||
"default_holiday_list": "_Test Holiday List"
|
||||
},
|
||||
{
|
||||
"abbr": "_TC4",
|
||||
"company_name": "_Test Company 4",
|
||||
"parent_company": "_Test Company 3",
|
||||
"is_group": 1,
|
||||
"country": "India",
|
||||
"default_currency": "INR",
|
||||
"doctype": "Company",
|
||||
"domain": "Manufacturing",
|
||||
"chart_of_accounts": "Standard",
|
||||
"default_holiday_list": "_Test Holiday List"
|
||||
},
|
||||
{
|
||||
"abbr": "_TC5",
|
||||
"company_name": "_Test Company 5",
|
||||
"parent_company": "_Test Company 4",
|
||||
"country": "India",
|
||||
"default_currency": "INR",
|
||||
"doctype": "Company",
|
||||
"domain": "Manufacturing",
|
||||
"chart_of_accounts": "Standard",
|
||||
"default_holiday_list": "_Test Holiday List"
|
||||
}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user