test: Recurring Additional salary

This commit is contained in:
Anurag Mishra 2020-02-20 19:33:27 +05:30
parent 885ab5dc66
commit 1663f66e6d
3 changed files with 46 additions and 7 deletions

View File

@ -54,10 +54,10 @@ def get_additional_salary_component(employee, start_date, end_date, component_ty
from `tabAdditional Salary` from `tabAdditional Salary`
where employee=%(employee)s where employee=%(employee)s
and docstatus = 1 and docstatus = 1
and (payroll_date between %(from_date)s and %(to_date)s) and (
or ( payroll_date between %(from_date)s and %(to_date)s
(from_date between %(from_date)s and %(to_date)s) or
or(to_date between %(from_date)s and %(to_date)s) from_date <= %(to_date)s and to_date >= %(to_date)s
) )
and type = %(component_type)s and type = %(component_type)s
group by salary_component, overwrite_salary_structure_amount group by salary_component, overwrite_salary_structure_amount

View File

@ -3,6 +3,45 @@
# See license.txt # See license.txt
from __future__ import unicode_literals from __future__ import unicode_literals
import unittest import unittest
import frappe, erpnext
from frappe.utils import nowdate, add_days
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_slip.test_salary_slip import make_employee_salary_slip
class TestAdditionalSalary(unittest.TestCase): class TestAdditionalSalary(unittest.TestCase):
pass
def setUp(self):
from erpnext.hr.doctype.salary_slip.test_salary_slip import TestSalarySlip
TestSalarySlip().setUp()
def test_recurring_additional_salary(self):
emp_id = make_employee("test_additional@salary.com")
frappe.db.set_value("Employee", emp_id, "relieving_date", add_days(nowdate(), 1800))
add_sal = get_additional_salary(emp_id)
ss = make_employee_salary_slip("test_additional@salary.com", "Monthly")
for earning in ss.earnings:
if earning.salary_component == "Recurring Salary Component":
amount = earning.amount
salary_component = earning.salary_component
self.assertEqual(amount, add_sal.amount)
self.assertEqual(salary_component, add_sal.salary_component)
def get_additional_salary(emp_id):
create_salary_component("Recurring Salary Component")
add_sal = frappe.new_doc("Additional Salary")
add_sal.employee = emp_id
add_sal.salary_component = "Recurring Salary Component"
add_sal.is_recurring = 1
add_sal.from_date = add_days(nowdate(), -50)
add_sal.to_date = add_days(nowdate(), 180)
add_sal.amount = 5000
add_sal.save()
add_sal.submit()
return add_sal

View File

@ -51,7 +51,7 @@ def make_employee(user, company=None):
"doctype": "User", "doctype": "User",
"email": user, "email": user,
"first_name": user, "first_name": user,
"new_password": "password", "new_password": "qwerty123@12435",
"roles": [{"doctype": "Has Role", "role": "Employee"}] "roles": [{"doctype": "Has Role", "role": "Employee"}]
}).insert() }).insert()