fix: Patch and tests
This commit is contained in:
parent
5a1a765ebf
commit
672b74d89c
@ -7,14 +7,13 @@ import frappe, erpnext
|
|||||||
from frappe.utils import nowdate, add_days
|
from frappe.utils import nowdate, add_days
|
||||||
from erpnext.hr.doctype.employee.test_employee import make_employee
|
from erpnext.hr.doctype.employee.test_employee import make_employee
|
||||||
from erpnext.hr.doctype.salary_component.test_salary_component import create_salary_component
|
from erpnext.hr.doctype.salary_component.test_salary_component import create_salary_component
|
||||||
from erpnext.hr.doctype.salary_slip.test_salary_slip import make_employee_salary_slip
|
from erpnext.hr.doctype.salary_slip.test_salary_slip import make_employee_salary_slip, setup_test
|
||||||
|
|
||||||
|
|
||||||
class TestAdditionalSalary(unittest.TestCase):
|
class TestAdditionalSalary(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
from erpnext.hr.doctype.salary_slip.test_salary_slip import TestSalarySlip
|
setup_test()
|
||||||
TestSalarySlip().setUp()
|
|
||||||
|
|
||||||
def test_recurring_additional_salary(self):
|
def test_recurring_additional_salary(self):
|
||||||
emp_id = make_employee("test_additional@salary.com")
|
emp_id = make_employee("test_additional@salary.com")
|
||||||
|
|||||||
@ -18,19 +18,7 @@ from erpnext.hr.doctype.employee_tax_exemption_declaration.test_employee_tax_exe
|
|||||||
|
|
||||||
class TestSalarySlip(unittest.TestCase):
|
class TestSalarySlip(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
make_earning_salary_component(setup=True, company_list=["_Test Company"])
|
setup_test()
|
||||||
make_deduction_salary_component(setup=True, company_list=["_Test Company"])
|
|
||||||
|
|
||||||
for dt in ["Leave Application", "Leave Allocation", "Salary Slip", "Attendance"]:
|
|
||||||
frappe.db.sql("delete from `tab%s`" % dt)
|
|
||||||
|
|
||||||
self.make_holiday_list()
|
|
||||||
|
|
||||||
frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Slip Test Holiday List")
|
|
||||||
frappe.db.set_value("HR Settings", None, "email_salary_slip_to_employee", 0)
|
|
||||||
frappe.db.set_value('HR Settings', None, 'leave_status_notification_template', None)
|
|
||||||
frappe.db.set_value('HR Settings', None, 'leave_approval_notification_template', None)
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0)
|
frappe.db.set_value("HR Settings", None, "include_holidays_in_total_working_days", 0)
|
||||||
frappe.set_user("Administrator")
|
frappe.set_user("Administrator")
|
||||||
@ -374,19 +362,6 @@ class TestSalarySlip(unittest.TestCase):
|
|||||||
# undelete fixture data
|
# undelete fixture data
|
||||||
frappe.db.rollback()
|
frappe.db.rollback()
|
||||||
|
|
||||||
def make_holiday_list(self):
|
|
||||||
fiscal_year = get_fiscal_year(nowdate(), company=erpnext.get_default_company())
|
|
||||||
if not frappe.db.get_value("Holiday List", "Salary Slip Test Holiday List"):
|
|
||||||
holiday_list = frappe.get_doc({
|
|
||||||
"doctype": "Holiday List",
|
|
||||||
"holiday_list_name": "Salary Slip Test Holiday List",
|
|
||||||
"from_date": fiscal_year[1],
|
|
||||||
"to_date": fiscal_year[2],
|
|
||||||
"weekly_off": "Sunday"
|
|
||||||
}).insert()
|
|
||||||
holiday_list.get_weekly_off_dates()
|
|
||||||
holiday_list.save()
|
|
||||||
|
|
||||||
def make_activity_for_employee(self):
|
def make_activity_for_employee(self):
|
||||||
activity_type = frappe.get_doc("Activity Type", "_Test Activity Type")
|
activity_type = frappe.get_doc("Activity Type", "_Test Activity Type")
|
||||||
activity_type.billing_rate = 50
|
activity_type.billing_rate = 50
|
||||||
@ -703,3 +678,30 @@ def make_leave_application(employee, from_date, to_date, leave_type, company=Non
|
|||||||
leave_approver = 'test@example.com'
|
leave_approver = 'test@example.com'
|
||||||
))
|
))
|
||||||
leave_application.submit()
|
leave_application.submit()
|
||||||
|
|
||||||
|
def setup_test():
|
||||||
|
make_earning_salary_component(setup=True, company_list=["_Test Company"])
|
||||||
|
make_deduction_salary_component(setup=True, company_list=["_Test Company"])
|
||||||
|
|
||||||
|
for dt in ["Leave Application", "Leave Allocation", "Salary Slip", "Attendance"]:
|
||||||
|
frappe.db.sql("delete from `tab%s`" % dt)
|
||||||
|
|
||||||
|
make_holiday_list()
|
||||||
|
|
||||||
|
frappe.db.set_value("Company", erpnext.get_default_company(), "default_holiday_list", "Salary Slip Test Holiday List")
|
||||||
|
frappe.db.set_value("HR Settings", None, "email_salary_slip_to_employee", 0)
|
||||||
|
frappe.db.set_value('HR Settings', None, 'leave_status_notification_template', None)
|
||||||
|
frappe.db.set_value('HR Settings', None, 'leave_approval_notification_template', None)
|
||||||
|
|
||||||
|
def make_holiday_list():
|
||||||
|
fiscal_year = get_fiscal_year(nowdate(), company=erpnext.get_default_company())
|
||||||
|
if not frappe.db.get_value("Holiday List", "Salary Slip Test Holiday List"):
|
||||||
|
holiday_list = frappe.get_doc({
|
||||||
|
"doctype": "Holiday List",
|
||||||
|
"holiday_list_name": "Salary Slip Test Holiday List",
|
||||||
|
"from_date": fiscal_year[1],
|
||||||
|
"to_date": fiscal_year[2],
|
||||||
|
"weekly_off": "Sunday"
|
||||||
|
}).insert()
|
||||||
|
holiday_list.get_weekly_off_dates()
|
||||||
|
holiday_list.save()
|
||||||
|
|||||||
@ -678,4 +678,4 @@ erpnext.patches.v13_0.move_tax_slabs_from_payroll_period_to_income_tax_slab #123
|
|||||||
erpnext.patches.v12_0.fix_quotation_expired_status
|
erpnext.patches.v12_0.fix_quotation_expired_status
|
||||||
erpnext.patches.v12_0.update_appointment_reminder_scheduler_entry
|
erpnext.patches.v12_0.update_appointment_reminder_scheduler_entry
|
||||||
erpnext.patches.v12_0.retain_permission_rules_for_video_doctype
|
erpnext.patches.v12_0.retain_permission_rules_for_video_doctype
|
||||||
erpnext.patches.v13_0.patch_to_fix_reverse_linking_in_additional_salary_encashment_and_incentive #gyhdghksdhsjsd
|
erpnext.patches.v13_0.patch_to_fix_reverse_linking_in_additional_salary_encashment_and_incentive
|
||||||
|
|||||||
@ -3,10 +3,25 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
|
if not frappe.db.table_exists("Additional Salary"):
|
||||||
|
return
|
||||||
|
|
||||||
additional_salaries = frappe.get_all("Additional Salary", fields = ['name', "salary_slip", "type", "salary_component"], group_by = 'salary_slip')
|
for doctype in ("Additional Salary", "Leave Encashment", "Employee Incentive", "Salary Detail"):
|
||||||
leave_encashments = frappe.get_all("Leave Encashment", fields = ["name","additional_salary"])
|
frappe.reload_doc("hr", "doctype", doctype)
|
||||||
employee_incentives = frappe.get_all("Employee Incentive", fields= ["name", "additional_salary"])
|
|
||||||
|
additional_salaries = frappe.get_all("Additional Salary",
|
||||||
|
fields = ['name', "salary_slip", "type", "salary_component"],
|
||||||
|
filters = {'salary_slip': ['!=', '']},
|
||||||
|
group_by = 'salary_slip'
|
||||||
|
)
|
||||||
|
leave_encashments = frappe.get_all("Leave Encashment",
|
||||||
|
fields = ["name","additional_salary"],
|
||||||
|
filters = {'additional_salary': ['!=', '']}
|
||||||
|
)
|
||||||
|
employee_incentives = frappe.get_all("Employee Incentive",
|
||||||
|
fields= ["name", "additional_salary"],
|
||||||
|
filters = {'additional_salary': ['!=', '']}
|
||||||
|
)
|
||||||
|
|
||||||
for incentive in employee_incentives:
|
for incentive in employee_incentives:
|
||||||
frappe.db.sql(""" UPDATE `tabAdditional Salary`
|
frappe.db.sql(""" UPDATE `tabAdditional Salary`
|
||||||
@ -26,10 +41,12 @@ def execute():
|
|||||||
for salary in additional_salaries:
|
for salary in additional_salaries:
|
||||||
comp_type = "earnings" if salary['type'] == 'Earning' else 'deductions'
|
comp_type = "earnings" if salary['type'] == 'Earning' else 'deductions'
|
||||||
if salary["salary_slip"] and salary_slips.count(salary["salary_slip"]) == 1:
|
if salary["salary_slip"] and salary_slips.count(salary["salary_slip"]) == 1:
|
||||||
frappe.db.sql(""" UPDATE `tabsalary Detail`
|
frappe.db.sql("""
|
||||||
|
UPDATE `tabSalary Detail`
|
||||||
SET additional_salary = %s
|
SET additional_salary = %s
|
||||||
WHERE parenttype = 'Salary Slip'
|
WHERE parenttype = 'Salary Slip'
|
||||||
and parentfield = %s
|
and parentfield = %s
|
||||||
and parent = %s
|
and parent = %s
|
||||||
and salary_component = %s""", (salary["name"], comp_type, salary["salary_slip"], salary["salary_component"]))
|
and salary_component = %s
|
||||||
|
""", (salary["name"], comp_type, salary["salary_slip"], salary["salary_component"]))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user