Pro-rata component consistency for monthly Salary slip (#14595)

* Pro-rata component consistency for monthly Salary slip

* Resolve merge conflict
diff --git a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
index 45e2d65..273857e 100644
--- a/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
+++ b/erpnext/hr/doctype/employee_benefit_application/employee_benefit_application.py
@@ -164,7 +164,7 @@
 			lwp = cint(leave[0][1]) and (lwp + 0.5) or (lwp + 1)
 	return lwp
 
-def get_benefit_component_amount(employee, start_date, end_date, struct_row, sal_struct, payment_days, working_days):
+def get_benefit_component_amount(employee, start_date, end_date, struct_row, sal_struct, payment_days, working_days, frequency):
 	# Considering there is only one application for an year
 	benefit_application_name = frappe.db.sql("""
 	select name from `tabEmployee Benefit Application`
@@ -177,12 +177,16 @@
 		'end_date': end_date
 	})
 
-	payroll_period_days = get_payroll_period_days(start_date, end_date, employee)
-	if payroll_period_days:
-		depends_on_lwp = frappe.db.get_value("Salary Component", struct_row.salary_component, "depends_on_lwp")
-		if depends_on_lwp != 1:
-			payment_days = working_days
+	payroll_period_days, actual_payroll_days = get_payroll_period_days(start_date, end_date, employee)
 
+	depends_on_lwp = frappe.db.get_value("Salary Component", struct_row.salary_component, "depends_on_lwp")
+	if depends_on_lwp != 1:
+		payment_days = working_days
+		if frequency == "Monthly" and actual_payroll_days in range(360, 370):
+			payment_days = 1
+			payroll_period_days = 12
+
+	if payroll_period_days:
 		# If there is application for benefit then fetch the amount from the application.
 		# else Split the max benefits to the pro-rata components with the ratio of thier max_benefit_amount
 		if benefit_application_name:
diff --git a/erpnext/hr/doctype/payroll_period/payroll_period.py b/erpnext/hr/doctype/payroll_period/payroll_period.py
index e570f71..e1c9e75 100644
--- a/erpnext/hr/doctype/payroll_period/payroll_period.py
+++ b/erpnext/hr/doctype/payroll_period/payroll_period.py
@@ -61,9 +61,10 @@
 	})
 
 	if len(payroll_period_dates) > 0:
-		working_days = date_diff(getdate(payroll_period_dates[0][1]), getdate(payroll_period_dates[0][0])) + 1
+		actual_no_of_days = date_diff(getdate(payroll_period_dates[0][1]), getdate(payroll_period_dates[0][0])) + 1
+		working_days = actual_no_of_days
 		if not cint(frappe.db.get_value("HR Settings", None, "include_holidays_in_total_working_days")):
 			holidays = get_holidays_for_employee(employee, getdate(payroll_period_dates[0][0]), getdate(payroll_period_dates[0][1]))
 			working_days -= len(holidays)
-		return working_days
+		return working_days, actual_no_of_days
 	return False
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index 4c36fe7..8f58fe5 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -89,7 +89,8 @@
 
 	def add_employee_flexi_benefits(self, struct_row):
 		if frappe.db.get_value("Salary Component", struct_row.salary_component, "pay_against_benefit_claim") != 1:
-			benefit_component_amount = get_benefit_component_amount(self.employee, self.start_date, self.end_date, struct_row, self._salary_structure_doc, self.payment_days, self.total_working_days)
+			benefit_component_amount = get_benefit_component_amount(self.employee, self.start_date, self.end_date, \
+			struct_row, self._salary_structure_doc, self.payment_days, self.total_working_days, self.payroll_frequency)
 			if benefit_component_amount:
 				self.update_component_row(struct_row, benefit_component_amount, "earnings")
 		else: