YTD and MTD Messed up in Salary Slip

The filter for YTD, MTD etc are based on employee name. This seems like an amateur mistake. It should be based on employee id.

(cherry picked from commit efc292a5ddc00e433d75b87d6b3378455bac4438)
This commit is contained in:
Govind S Menokee 2021-10-19 12:49:00 +05:30 committed by mergify-bot
parent 9a409df8fa
commit 4f2cf43db7

View File

@ -1244,7 +1244,7 @@ class SalarySlip(TransactionBase):
salary_slip_sum = frappe.get_list('Salary Slip', salary_slip_sum = frappe.get_list('Salary Slip',
fields = ['sum(net_pay) as net_sum', 'sum(gross_pay) as gross_sum'], fields = ['sum(net_pay) as net_sum', 'sum(gross_pay) as gross_sum'],
filters = {'employee_name' : self.employee_name, filters = {'employee' : self.employee,
'start_date' : ['>=', period_start_date], 'start_date' : ['>=', period_start_date],
'end_date' : ['<', period_end_date], 'end_date' : ['<', period_end_date],
'name': ['!=', self.name], 'name': ['!=', self.name],
@ -1264,7 +1264,7 @@ class SalarySlip(TransactionBase):
first_day_of_the_month = get_first_day(self.start_date) first_day_of_the_month = get_first_day(self.start_date)
salary_slip_sum = frappe.get_list('Salary Slip', salary_slip_sum = frappe.get_list('Salary Slip',
fields = ['sum(net_pay) as sum'], fields = ['sum(net_pay) as sum'],
filters = {'employee_name' : self.employee_name, filters = {'employee' : self.employee,
'start_date' : ['>=', first_day_of_the_month], 'start_date' : ['>=', first_day_of_the_month],
'end_date' : ['<', self.start_date], 'end_date' : ['<', self.start_date],
'name': ['!=', self.name], 'name': ['!=', self.name],
@ -1288,13 +1288,13 @@ class SalarySlip(TransactionBase):
INNER JOIN `tabSalary Slip` as salary_slip INNER JOIN `tabSalary Slip` as salary_slip
ON detail.parent = salary_slip.name ON detail.parent = salary_slip.name
WHERE WHERE
salary_slip.employee_name = %(employee_name)s salary_slip.employee = %(employee)s
AND detail.salary_component = %(component)s AND detail.salary_component = %(component)s
AND salary_slip.start_date >= %(period_start_date)s AND salary_slip.start_date >= %(period_start_date)s
AND salary_slip.end_date < %(period_end_date)s AND salary_slip.end_date < %(period_end_date)s
AND salary_slip.name != %(docname)s AND salary_slip.name != %(docname)s
AND salary_slip.docstatus = 1""", AND salary_slip.docstatus = 1""",
{'employee_name': self.employee_name, 'component': component.salary_component, 'period_start_date': period_start_date, {'employee': self.employee, 'component': component.salary_component, 'period_start_date': period_start_date,
'period_end_date': period_end_date, 'docname': self.name} 'period_end_date': period_end_date, 'docname': self.name}
) )