Skip to content

Commit 3131b4e

Browse files
authored
Merge pull request #1361 from frappe/version-14-hotfix
chore: release v14
2 parents 95e935b + fe38ef2 commit 3131b4e

File tree

6 files changed

+81
-17
lines changed

6 files changed

+81
-17
lines changed

hrms/hr/doctype/compensatory_leave_request/compensatory_leave_request.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def validate(self):
3232
self.validate_holidays()
3333
self.validate_attendance()
3434
if not self.leave_type:
35-
frappe.throw(_("Leave Type is madatory"))
35+
frappe.throw(_("Leave Type is mandatory"))
3636

3737
def validate_attendance(self):
3838
attendance_records = frappe.get_all(

hrms/hr/doctype/exit_interview/exit_interview.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def get_interviews(interviews):
104104
interviews = json.loads(interviews)
105105

106106
if not len(interviews):
107-
frappe.throw(_("Atleast one interview has to be selected."))
107+
frappe.throw(_("At least one interview has to be selected."))
108108

109109
return interviews
110110

hrms/payroll/doctype/employee_benefit_application/employee_benefit_application.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def validate_duplicate_on_payroll_period(self):
148148
)
149149
if application:
150150
frappe.throw(
151-
_("Employee {0} already submited an apllication {1} for the payroll period {2}").format(
151+
_("Employee {0} already submitted an application {1} for the payroll period {2}").format(
152152
self.employee, application, self.payroll_period
153153
)
154154
)

hrms/payroll/doctype/salary_slip/salary_slip.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1393,10 +1393,15 @@ def calculate_variable_tax(self, tax_component):
13931393
def get_income_tax_slabs(self):
13941394
income_tax_slab, ss_assignment_name = frappe.db.get_value(
13951395
"Salary Structure Assignment",
1396-
{"employee": self.employee, "salary_structure": self.salary_structure, "docstatus": 1},
1396+
{
1397+
"employee": self.employee,
1398+
"salary_structure": self.salary_structure,
1399+
"docstatus": 1,
1400+
"from_date": ("<=", self.end_date),
1401+
},
13971402
["income_tax_slab", "name"],
1403+
order_by="from_date desc",
13981404
)
1399-
14001405
if not income_tax_slab:
14011406
frappe.throw(
14021407
_("Income Tax Slab not set in Salary Structure Assignment: {0}").format(ss_assignment_name)

hrms/payroll/doctype/salary_slip/test_salary_slip.py

+68-11
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040
make_salary_slip_from_timesheet,
4141
)
4242
from hrms.payroll.doctype.salary_structure.salary_structure import make_salary_slip
43-
from hrms.tests.test_utils import get_first_sunday
43+
from hrms.tests.test_utils import create_company, get_first_sunday
44+
45+
HOLIDAY_LIST = "Salary Slip Test Holiday List"
4446

4547

4648
class TestSalarySlip(FrappeTestCase):
@@ -62,9 +64,7 @@ def test_employee_status_inactive(self):
6264
employee_doc.reload()
6365

6466
make_holiday_list()
65-
frappe.db.set_value(
66-
"Company", employee_doc.company, "default_holiday_list", "Salary Slip Test Holiday List"
67-
)
67+
frappe.db.set_value("Company", employee_doc.company, "default_holiday_list", HOLIDAY_LIST)
6868

6969
frappe.db.sql(
7070
"""delete from `tabSalary Structure` where name='Test Inactive Employee Salary Slip'"""
@@ -228,7 +228,7 @@ def test_payment_days_for_mid_joinee_including_holidays_and_unmarked_days(self):
228228

229229
for days in range(date_diff(relieving_date, joining_date) + 1):
230230
date = add_days(joining_date, days)
231-
if not is_holiday("Salary Slip Test Holiday List", date):
231+
if not is_holiday(HOLIDAY_LIST, date):
232232
mark_attendance(new_emp_id, date, "Present", ignore_validate=True)
233233
else:
234234
holidays += 1
@@ -274,7 +274,7 @@ def test_payment_days_for_mid_joinee_excluding_holidays(self):
274274

275275
for days in range(date_diff(relieving_date, joining_date) + 1):
276276
date = add_days(joining_date, days)
277-
if not is_holiday("Salary Slip Test Holiday List", date):
277+
if not is_holiday(HOLIDAY_LIST, date):
278278
mark_attendance(new_emp_id, date, "Present", ignore_validate=True)
279279
else:
280280
holidays += 1
@@ -338,7 +338,7 @@ def test_payment_days_in_salary_slip_based_on_timesheet(self):
338338
emp = make_employee(
339339
340340
company="_Test Company",
341-
holiday_list="Salary Slip Test Holiday List",
341+
holiday_list=HOLIDAY_LIST,
342342
)
343343
frappe.db.set_value("Employee", emp, {"relieving_date": None, "status": "Active"})
344344

@@ -1484,6 +1484,60 @@ def test_variable_tax_component(self):
14841484
self.assertEqual(test_tds.accounts[0].company, salary_slip.company)
14851485
self.assertListEqual(tax_component, ["_Test TDS"])
14861486

1487+
def test_get_income_tax_slabs(self):
1488+
from hrms.payroll.doctype.salary_structure.test_salary_structure import make_salary_structure
1489+
1490+
company = create_company("_Test Tax Slab").name
1491+
frappe.db.delete("Payroll Period", {"company": company})
1492+
employee = make_employee("[email protected]", company=company, holiday_list=HOLIDAY_LIST)
1493+
1494+
fiscal_year = get_fiscal_year(getdate(), as_dict=True)
1495+
year_start, year_end = fiscal_year.year_start_date, fiscal_year.year_end_date
1496+
mid_year = add_months(year_start, 6)
1497+
1498+
payroll_period = create_payroll_period(
1499+
name="Payroll Period Test",
1500+
company=company,
1501+
start_date=year_start,
1502+
end_date=year_end,
1503+
)
1504+
1505+
tax_slabs = []
1506+
salary_structures = []
1507+
for start_date, end_date in [(year_start, mid_year), (mid_year, year_end)]:
1508+
tax_slab = create_tax_slab(
1509+
payroll_period,
1510+
allow_tax_exemption=True,
1511+
currency="INR",
1512+
effective_date=getdate(start_date),
1513+
company=company,
1514+
)
1515+
tax_slabs.append(tax_slab)
1516+
salary_structure = make_salary_structure(
1517+
f"Structure {start_date}",
1518+
"Monthly",
1519+
employee=employee,
1520+
company=company,
1521+
currency="INR",
1522+
from_date=start_date,
1523+
payroll_period=payroll_period,
1524+
allow_duplicate=True,
1525+
)
1526+
salary_structures.append(salary_structure)
1527+
1528+
# fetches the correct tax slab for backdated salary slip
1529+
salary_slip = make_salary_slip(
1530+
salary_structures[0].name, employee=employee, posting_date=year_start
1531+
)
1532+
salary_slip.insert()
1533+
self.assertEqual(salary_slip.get_income_tax_slabs().name, tax_slabs[0])
1534+
1535+
salary_slip = make_salary_slip(
1536+
salary_structures[1].name, employee=employee, posting_date=add_days(mid_year, 1)
1537+
)
1538+
salary_slip.insert()
1539+
self.assertEqual(salary_slip.get_income_tax_slabs().name, tax_slabs[1])
1540+
14871541

14881542
class TestSalarySlipSafeEval(FrappeTestCase):
14891543
def test_safe_eval_for_salary_slip(self):
@@ -1575,10 +1629,13 @@ def make_employee_salary_slip(emp_id, payroll_frequency, salary_structure=None,
15751629
salary_slip_name = frappe.db.get_value("Salary Slip", {"employee": emp_id})
15761630

15771631
if not salary_slip_name:
1578-
salary_slip = make_salary_slip(salary_structure_doc.name, employee=employee.name)
1632+
date = posting_date or nowdate()
1633+
salary_slip = make_salary_slip(
1634+
salary_structure_doc.name, employee=employee.name, posting_date=date
1635+
)
15791636
salary_slip.employee_name = employee.employee_name
15801637
salary_slip.payroll_frequency = payroll_frequency
1581-
salary_slip.posting_date = posting_date or nowdate()
1638+
salary_slip.posting_date = date
15821639
salary_slip.insert()
15831640
else:
15841641
salary_slip = frappe.get_doc("Salary Slip", salary_slip_name)
@@ -2011,7 +2068,7 @@ def setup_test():
20112068
make_payroll_period()
20122069

20132070
frappe.db.set_value(
2014-
"Company", erpnext.get_default_company(), "default_holiday_list", "Salary Slip Test Holiday List"
2071+
"Company", erpnext.get_default_company(), "default_holiday_list", HOLIDAY_LIST
20152072
)
20162073

20172074
frappe.db.set_value("Payroll Settings", None, "email_salary_slip_to_employee", 0)
@@ -2041,7 +2098,7 @@ def make_payroll_period():
20412098

20422099
def make_holiday_list(list_name=None, from_date=None, to_date=None, add_weekly_offs=True):
20432100
fiscal_year = get_fiscal_year(nowdate(), company=erpnext.get_default_company())
2044-
name = list_name or "Salary Slip Test Holiday List"
2101+
name = list_name or HOLIDAY_LIST
20452102

20462103
frappe.delete_doc_if_exists("Holiday List", name, force=True)
20472104

hrms/payroll/doctype/salary_structure/test_salary_structure.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def make_salary_structure(
168168
payroll_period=None,
169169
include_flexi_benefits=False,
170170
base=None,
171+
allow_duplicate=False,
171172
):
172173
if frappe.db.exists("Salary Structure", salary_structure):
173174
frappe.db.delete("Salary Structure", salary_structure)
@@ -196,7 +197,7 @@ def make_salary_structure(
196197
if not dont_submit:
197198
salary_structure_doc.submit()
198199

199-
filters = {"employee": employee, "docstatus": 1}
200+
filters = {"employee": employee, "docstatus": 1, "salary_structure": salary_structure}
200201
if not from_date and payroll_period:
201202
from_date = payroll_period.start_date
202203

@@ -216,6 +217,7 @@ def make_salary_structure(
216217
currency=currency,
217218
payroll_period=payroll_period,
218219
base=base,
220+
allow_duplicate=allow_duplicate,
219221
)
220222

221223
return salary_structure_doc

0 commit comments

Comments
 (0)