Browse Source
* feat: Provision to assign multiple payroll cost centers against a single employee * fix: get fallback cost center from Employee/Department * fix: linter issues * fix: convert raw queries with frappe ORM Co-authored-by: Rucha Mahabal <ruchamahabal2@gmail.com>develop
Rucha Mahabal
3 years ago
committed by
GitHub
15 changed files with 270 additions and 60 deletions
@ -0,0 +1,32 @@ |
|||
import frappe |
|||
|
|||
|
|||
def execute(): |
|||
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"]) |
|||
|
|||
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) |
|||
|
|||
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() |
@ -0,0 +1,43 @@ |
|||
{ |
|||
"actions": [], |
|||
"creation": "2021-12-23 12:44:38.389283", |
|||
"doctype": "DocType", |
|||
"editable_grid": 1, |
|||
"engine": "InnoDB", |
|||
"field_order": [ |
|||
"cost_center", |
|||
"percentage" |
|||
], |
|||
"fields": [ |
|||
{ |
|||
"allow_on_submit": 1, |
|||
"fieldname": "cost_center", |
|||
"fieldtype": "Link", |
|||
"in_list_view": 1, |
|||
"label": "Cost Center", |
|||
"options": "Cost Center", |
|||
"reqd": 1 |
|||
}, |
|||
{ |
|||
"allow_on_submit": 1, |
|||
"fieldname": "percentage", |
|||
"fieldtype": "Int", |
|||
"in_list_view": 1, |
|||
"label": "Percentage (%)", |
|||
"non_negative": 1, |
|||
"reqd": 1 |
|||
} |
|||
], |
|||
"index_web_pages_for_search": 1, |
|||
"istable": 1, |
|||
"links": [], |
|||
"modified": "2021-12-23 17:39:03.410924", |
|||
"modified_by": "Administrator", |
|||
"module": "Payroll", |
|||
"name": "Employee Cost Center", |
|||
"owner": "Administrator", |
|||
"permissions": [], |
|||
"sort_field": "modified", |
|||
"sort_order": "DESC", |
|||
"states": [] |
|||
} |
@ -0,0 +1,9 @@ |
|||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors |
|||
# For license information, please see license.txt |
|||
|
|||
# import frappe |
|||
from frappe.model.document import Document |
|||
|
|||
|
|||
class EmployeeCostCenter(Document): |
|||
pass |
Loading…
Reference in new issue