frappe / hrms

Open Source HR and Payroll Software
https://frappe.io/hr
GNU General Public License v3.0
1.44k stars 741 forks source link

Payroll: Salary Slip throws error if dates span two Payroll Periods #106

Open theopen-institute opened 3 years ago

theopen-institute commented 3 years ago

Description of the issue

In current versions of ERPNext, Salary Slip will throw an error if the slip accounts for a period of time extending beyond a single Payroll Period.

Steps to reproduce the issue

  1. Create a Payroll Period with a start and an end date.
  2. Create a Salary Slip with start and end dates that are both inside and outside the Payroll Period.
  3. Attempt to save Salary Slip

Observed result

Exception thrown: "Start and end dates not in a valid Payroll Period, cannot calculate Income Tax."

Expected result

Salary Slip is saved successfully.

Additional information

A very simple (though possibly unclean) solution would be to determine Payroll Period on the basis of the end date only. This could be done by changing the line below to payroll_period = get_payroll_period(self.end_date, self.end_date, self.company) .

https://github.com/frappe/erpnext/blob/a31731e73d3faf53b319c9744ef8d9997fd865ce/erpnext/payroll/doctype/salary_slip/salary_slip.py#L446

More broadly, it's arguably more correct to determine which Payroll Period applies not on the basis of start and end dates but rather on the basis of the salary slip's posting date, since employee income taxes are typically calculated on a cash basis. This would represent a more fundamental change, however, with implications for other parts of the Income Tax calculation (especially in calculating the number of remaining sub-periods).

jalajc commented 2 years ago

@ruchamahabal why removed bug label? I am facing the same issue for timesheet based salary slip.