mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
[Fix] HR Fixes (#14511)
* Payroll Entry - fix in db query * Salary Structure Assignment - Company read_only = 1 * Fixes in hr util and benefit claim * Employee Benefit Application - Late application - fix
This commit is contained in:
@@ -105,29 +105,30 @@ def get_max_benefits_remaining(employee, on_date, payroll_period):
|
|||||||
# Get all salary slip flexi amount in the payroll period
|
# Get all salary slip flexi amount in the payroll period
|
||||||
prev_sal_slip_flexi_total = get_sal_slip_total_benefit_given(employee, payroll_period_obj)
|
prev_sal_slip_flexi_total = get_sal_slip_total_benefit_given(employee, payroll_period_obj)
|
||||||
|
|
||||||
# Check salary structure hold depends_on_lwp component
|
if prev_sal_slip_flexi_total > 0:
|
||||||
# If yes then find the amount per day of each component and find the sum
|
# Check salary structure hold depends_on_lwp component
|
||||||
sal_struct_name = get_assigned_salary_structure(employee, on_date)
|
# If yes then find the amount per day of each component and find the sum
|
||||||
if sal_struct_name:
|
sal_struct_name = get_assigned_salary_structure(employee, on_date)
|
||||||
sal_struct = frappe.get_doc("Salary Structure", sal_struct_name)
|
if sal_struct_name:
|
||||||
for sal_struct_row in sal_struct.get("earnings"):
|
sal_struct = frappe.get_doc("Salary Structure", sal_struct_name)
|
||||||
salary_component = frappe.get_doc("Salary Component", sal_struct_row.salary_component)
|
for sal_struct_row in sal_struct.get("earnings"):
|
||||||
if salary_component.depends_on_lwp == 1 and salary_component.is_pro_rata_applicable == 1:
|
salary_component = frappe.get_doc("Salary Component", sal_struct_row.salary_component)
|
||||||
have_depends_on_lwp = True
|
if salary_component.depends_on_lwp == 1 and salary_component.is_pro_rata_applicable == 1:
|
||||||
benefit_amount = get_benefit_pro_rata_ratio_amount(sal_struct, salary_component.max_benefit_amount)
|
have_depends_on_lwp = True
|
||||||
amount_per_day = benefit_amount / payroll_period_days
|
benefit_amount = get_benefit_pro_rata_ratio_amount(sal_struct, salary_component.max_benefit_amount)
|
||||||
per_day_amount_total += amount_per_day
|
amount_per_day = benefit_amount / payroll_period_days
|
||||||
|
per_day_amount_total += amount_per_day
|
||||||
|
|
||||||
# Then the sum multiply with the no of lwp in that period
|
# Then the sum multiply with the no of lwp in that period
|
||||||
# Include that amount to the prev_sal_slip_flexi_total to get the actual
|
# Include that amount to the prev_sal_slip_flexi_total to get the actual
|
||||||
if have_depends_on_lwp and per_day_amount_total > 0:
|
if have_depends_on_lwp and per_day_amount_total > 0:
|
||||||
holidays = get_holidays_for_employee(employee, payroll_period_obj.start_date, on_date)
|
holidays = get_holidays_for_employee(employee, payroll_period_obj.start_date, on_date)
|
||||||
working_days = date_diff(on_date, payroll_period_obj.start_date) + 1
|
working_days = date_diff(on_date, payroll_period_obj.start_date) + 1
|
||||||
leave_days = calculate_lwp(employee, payroll_period_obj.start_date, holidays, working_days)
|
leave_days = calculate_lwp(employee, payroll_period_obj.start_date, holidays, working_days)
|
||||||
leave_days_amount = leave_days * per_day_amount_total
|
leave_days_amount = leave_days * per_day_amount_total
|
||||||
prev_sal_slip_flexi_total += leave_days_amount
|
prev_sal_slip_flexi_total += leave_days_amount
|
||||||
|
|
||||||
return max_benefits - prev_sal_slip_flexi_total
|
return max_benefits - prev_sal_slip_flexi_total
|
||||||
return max_benefits
|
return max_benefits
|
||||||
|
|
||||||
def calculate_lwp(employee, start_date, holidays, working_days):
|
def calculate_lwp(employee, start_date, holidays, working_days):
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ class EmployeeBenefitClaim(Document):
|
|||||||
if not max_benefits or max_benefits <= 0:
|
if not max_benefits or max_benefits <= 0:
|
||||||
frappe.throw(_("Employee {0} has no maximum benefit amount").format(self.employee))
|
frappe.throw(_("Employee {0} has no maximum benefit amount").format(self.employee))
|
||||||
payroll_period = get_payroll_period(self.claim_date, self.claim_date, frappe.db.get_value("Employee", self.employee, "company"))
|
payroll_period = get_payroll_period(self.claim_date, self.claim_date, frappe.db.get_value("Employee", self.employee, "company"))
|
||||||
|
if not payroll_period:
|
||||||
|
frappe.throw(_("{0} is not in a valid Payroll Period").format(self.claim_date))
|
||||||
self.validate_max_benefit_for_component(payroll_period)
|
self.validate_max_benefit_for_component(payroll_period)
|
||||||
self.validate_max_benefit_for_sal_struct(max_benefits)
|
self.validate_max_benefit_for_sal_struct(max_benefits)
|
||||||
self.validate_benefit_claim_amount(max_benefits, payroll_period)
|
self.validate_benefit_claim_amount(max_benefits, payroll_period)
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class PayrollEntry(Document):
|
|||||||
select
|
select
|
||||||
name from `tabSalary Structure`
|
name from `tabSalary Structure`
|
||||||
where
|
where
|
||||||
docstatus != 2 and
|
docstatus = 1 and
|
||||||
is_active = 'Yes'
|
is_active = 'Yes'
|
||||||
and company = %(company)s and
|
and company = %(company)s and
|
||||||
ifnull(salary_slip_based_on_timesheet,0) = %(salary_slip_based_on_timesheet)s
|
ifnull(salary_slip_based_on_timesheet,0) = %(salary_slip_based_on_timesheet)s
|
||||||
@@ -47,8 +47,7 @@ class PayrollEntry(Document):
|
|||||||
from
|
from
|
||||||
`tabEmployee` t1, `tabSalary Structure Assignment` t2
|
`tabEmployee` t1, `tabSalary Structure Assignment` t2
|
||||||
where
|
where
|
||||||
t1.docstatus!=2
|
t1.name = t2.employee
|
||||||
and t1.name = t2.employee
|
|
||||||
and t2.docstatus = 1
|
and t2.docstatus = 1
|
||||||
%s """% cond, {"sal_struct": sal_struct, "from_date": self.start_date, "to_date": self.end_date}, as_dict=True)
|
%s """% cond, {"sal_struct": sal_struct, "from_date": self.start_date, "to_date": self.end_date}, as_dict=True)
|
||||||
return emp_list
|
return emp_list
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -42,16 +43,17 @@
|
|||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fetch_from": "employee.employee_name",
|
"fetch_from": "employee.employee_name",
|
||||||
"fieldname": "employee_name",
|
"fieldname": "employee_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@@ -75,48 +77,50 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fetch_from": "employee.department",
|
"fetch_from": "employee.department",
|
||||||
"fieldname": "department",
|
"fieldname": "department",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Department",
|
"label": "Department",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"options": "Department",
|
"options": "Department",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"remember_last_selected_value": 0,
|
"remember_last_selected_value": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_in_quick_entry": 0,
|
||||||
"bold": 0,
|
"allow_on_submit": 0,
|
||||||
"collapsible": 0,
|
"bold": 0,
|
||||||
"columns": 0,
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
"fieldname": "salary_structure",
|
"fieldname": "salary_structure",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@@ -140,11 +144,12 @@
|
|||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -170,11 +175,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -201,11 +207,12 @@
|
|||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 1,
|
"allow_on_submit": 1,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -232,11 +239,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -258,17 +266,18 @@
|
|||||||
"precision": "",
|
"precision": "",
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"print_hide_if_no_value": 0,
|
"print_hide_if_no_value": 0,
|
||||||
"read_only": 0,
|
"read_only": 1,
|
||||||
"remember_last_selected_value": 0,
|
"remember_last_selected_value": 0,
|
||||||
"report_hide": 0,
|
"report_hide": 0,
|
||||||
"reqd": 0,
|
"reqd": 1,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -294,11 +303,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -325,11 +335,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -355,11 +366,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -386,11 +398,12 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
@@ -417,7 +430,7 @@
|
|||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"search_index": 0,
|
"search_index": 0,
|
||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -431,7 +444,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-05-17 11:25:20.009793",
|
"modified": "2018-06-13 16:18:19.784377",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Salary Structure Assignment",
|
"name": "Salary Structure Assignment",
|
||||||
|
|||||||
Reference in New Issue
Block a user