fix: component pay calculation
diff --git a/erpnext/payroll/doctype/salary_structure/salary_structure.py b/erpnext/payroll/doctype/salary_structure/salary_structure.py
index fa36b7a..edf17db 100644
--- a/erpnext/payroll/doctype/salary_structure/salary_structure.py
+++ b/erpnext/payroll/doctype/salary_structure/salary_structure.py
@@ -253,6 +253,7 @@
source_name,
target_doc=None,
employee=None,
+ posting_date=None,
as_print=False,
print_format=None,
for_preview=0,
@@ -269,6 +270,9 @@
target.designation = employee_details.designation
target.department = employee_details.department
+ if posting_date:
+ target.posting_date = posting_date
+
target.run_method("process_salary_structure", for_preview=for_preview)
doc = get_mapped_doc(
diff --git a/erpnext/regional/india/utils.py b/erpnext/regional/india/utils.py
index 6aa1f1f..2fc1565 100644
--- a/erpnext/regional/india/utils.py
+++ b/erpnext/regional/india/utils.py
@@ -422,8 +422,8 @@
return frappe._dict(
{
"hra_amount": hra_amount,
- "annual_exemption": annual_exemption,
- "monthly_exemption": monthly_exemption,
+ "annual_exemption": flt(annual_exemption, doc.precision("annual_hra_exemption")),
+ "monthly_exemption": flt(monthly_exemption, doc.precision("monthly_hra_exemption")),
}
)
@@ -459,12 +459,12 @@
employee, salary_structure, basic_component, hra_component, from_date
):
salary_slip = make_salary_slip(
- salary_structure, employee=employee, for_preview=1, ignore_permissions=True
+ salary_structure,
+ employee=employee,
+ for_preview=1,
+ ignore_permissions=True,
+ posting_date=from_date,
)
- # generate salary slip as per assignment on "from_date"
- salary_slip.posting_date = from_date
- salary_slip.start_date = salary_slip.end_date = None
- salary_slip.run_method("process_salary_structure", for_preview=True)
basic_amt, hra_amt = 0, 0
for earning in salary_slip.earnings:
@@ -502,13 +502,13 @@
if frequency == "Daily":
return amount * days
elif frequency == "Weekly":
- return amount * math.ceil(days / 7)
+ return amount * math.floor(days / 7)
elif frequency == "Fortnightly":
- return amount * math.ceil(days / 15)
+ return amount * math.floor(days / 14)
elif frequency == "Monthly":
return amount * month_diff(to_date, from_date)
elif frequency == "Bimonthly":
- return amount * math.ceil(days / 60)
+ return amount * (month_diff(to_date, from_date) / 2)
def validate_house_rent_dates(doc):