Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: statistical component showing up in salary slip #30

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions hrms/payroll/doctype/salary_slip/salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,10 +633,8 @@ def add_structure_components(self, component_type):

amount = self.eval_condition_and_formula(struct_row, data)
if (
amount
or (struct_row.amount_based_on_formula and amount is not None)
and struct_row.statistical_component == 0
):
amount or (struct_row.amount_based_on_formula and amount is not None)
) and struct_row.statistical_component == 0:
self.update_component_row(struct_row, amount, component_type, data=data)

def get_data_for_eval(self):
Expand Down
33 changes: 28 additions & 5 deletions hrms/payroll/doctype/salary_slip/test_salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,19 @@ def test_payment_days_in_salary_slip_based_on_timesheet(self):

self.assertEqual(salary_slip.payment_days, days_in_month - no_of_holidays - 1)

# gross pay calculation based on attendance (payment days)
gross_pay = 78100 - (
(78000 / (days_in_month - no_of_holidays))
* flt(salary_slip.leave_without_pay + salary_slip.absent_days)
# component calculation based on attendance (payment days)
amount, precision = None, None

for row in salary_slip.earnings:
if row.salary_component == "Basic Salary":
amount = row.amount
precision = row.precision("amount")
break
expected_amount = flt(
(50000 * salary_slip.payment_days / salary_slip.total_working_days), precision
)

self.assertEqual(salary_slip.gross_pay, flt(gross_pay, 2))
self.assertEqual(amount, expected_amount)

@change_settings("Payroll Settings", {"payroll_based_on": "Attendance"})
def test_component_amount_dependent_on_another_payment_days_based_component(self):
Expand Down Expand Up @@ -1026,6 +1032,16 @@ def test_salary_slip_from_timesheet(self):
timesheet = frappe.get_doc("Timesheet", timesheet.name)
self.assertEqual(timesheet.status, "Submitted")

def test_do_not_show_statistical_component_in_slip(self):
make_employee("[email protected]")
new_ss = make_employee_salary_slip(
"[email protected]",
"Monthly",
"Test Payment Based On Attendence",
)
components = [row.salary_component for row in new_ss.get("earnings")]
self.assertNotIn("Statistical Component", components)

def make_activity_for_employee(self):
activity_type = frappe.get_doc("Activity Type", "_Test Activity Type")
activity_type.billing_rate = 50
Expand Down Expand Up @@ -1167,6 +1183,13 @@ def make_earning_salary_component(
"depends_on_payment_days": 0,
},
{"salary_component": "Leave Encashment", "abbr": "LE", "type": "Earning"},
{
"salary_component": "Statistical Component",
"abbr": "SC",
"type": "Earning",
"statistical_component": 1,
"amount": 500,
},
]
if include_flexi_benefits:
data.extend(
Expand Down