diff --git a/erpnext/payroll/doctype/salary_structure/salary_structure.py b/erpnext/payroll/doctype/salary_structure/salary_structure.py index c72ada630b0..ed2a863b3dc 100644 --- a/erpnext/payroll/doctype/salary_structure/salary_structure.py +++ b/erpnext/payroll/doctype/salary_structure/salary_structure.py @@ -253,6 +253,7 @@ def make_salary_slip( source_name, target_doc=None, employee=None, + posting_date=None, as_print=False, print_format=None, for_preview=0, @@ -277,6 +278,9 @@ def make_salary_slip( "Department", target.department, "payroll_cost_center" ) + 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 a027a75e98e..b79544cf16f 100644 --- a/erpnext/regional/india/utils.py +++ b/erpnext/regional/india/utils.py @@ -427,8 +427,8 @@ def calculate_annual_eligible_hra_exemption(doc): 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")), } ) @@ -464,12 +464,12 @@ def get_component_amt_from_salary_slip( 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: @@ -507,13 +507,13 @@ def get_component_pay(frequency, amount, from_date, to_date): 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):