fix: linter issues

This commit is contained in:
Rucha Mahabal
2021-12-28 08:54:05 +05:30
parent 3c8ed4f737
commit 8226ea65c8
5 changed files with 35 additions and 33 deletions

View File

@@ -1,31 +1,32 @@
import frappe
def execute():
frappe.reload_doc('payroll', 'doctype', 'employee_cost_center')
frappe.reload_doc('payroll', 'doctype', 'salary_structure_assignment')
frappe.reload_doc('payroll', 'doctype', 'employee_cost_center')
frappe.reload_doc('payroll', 'doctype', 'salary_structure_assignment')
employees = frappe.get_all("Employee", fields=["department", "payroll_cost_center", "name"])
employees = frappe.get_all("Employee", fields=["department", "payroll_cost_center", "name"])
employee_cost_center = {}
for d in employees:
cost_center = d.payroll_cost_center
if not cost_center and d.department:
cost_center = frappe.get_cached_value("Department", d.department, "payroll_cost_center")
employee_cost_center = {}
for d in employees:
cost_center = d.payroll_cost_center
if not cost_center and d.department:
cost_center = frappe.get_cached_value("Department", d.department, "payroll_cost_center")
if cost_center:
employee_cost_center.setdefault(d.name, cost_center)
if cost_center:
employee_cost_center.setdefault(d.name, cost_center)
salary_structure_assignments = frappe.get_all("Salary Structure Assignment",
filters = {"docstatus": ["!=", 2]},
fields=["name", "employee"])
salary_structure_assignments = frappe.get_all("Salary Structure Assignment",
filters = {"docstatus": ["!=", 2]},
fields=["name", "employee"])
for d in salary_structure_assignments:
cost_center = employee_cost_center.get(d.employee)
if cost_center:
assignment = frappe.get_doc("Salary Structure Assignment", d.name)
if not assignment.get("payroll_cost_centers"):
assignment.append("payroll_cost_centers", {
"cost_center": cost_center,
"percentage": 100
})
assignment.save()
for d in salary_structure_assignments:
cost_center = employee_cost_center.get(d.employee)
if cost_center:
assignment = frappe.get_doc("Salary Structure Assignment", d.name)
if not assignment.get("payroll_cost_centers"):
assignment.append("payroll_cost_centers", {
"cost_center": cost_center,
"percentage": 100
})
assignment.save()

View File

@@ -4,5 +4,6 @@
# import frappe
from frappe.model.document import Document
class EmployeeCostCenter(Document):
pass

View File

@@ -5,7 +5,7 @@
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import getdate, flt
from frappe.utils import flt, getdate
class DuplicateAssignment(frappe.ValidationError): pass
@@ -79,7 +79,6 @@ class SalaryStructureAssignment(Document):
frappe.throw(_("Total percentage against cost centers should be 100"))
def get_assigned_salary_structure(employee, on_date):
if not employee or not on_date:
return None
@@ -93,6 +92,7 @@ def get_assigned_salary_structure(employee, on_date):
})
return salary_structure[0][0] if salary_structure else None
@frappe.whitelist()
def get_employee_currency(employee):
employee_currency = frappe.db.get_value('Salary Structure Assignment', {'employee': employee}, 'currency')