Skip to content

Commit

Permalink
feat: introduce function to compute current and future taxable earnings
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabh6790 committed Feb 17, 2023
1 parent eb776c8 commit 3830662
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion hrms/payroll/doctype/salary_slip/salary_slip.json
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@
{
"fieldname": "deductions_before_tax_calculation",
"fieldtype": "Currency",
"label": "Deductions before tax calculation",
"label": "Deductions before Tax Calculation",
"read_only": 1
},
{
Expand Down
54 changes: 30 additions & 24 deletions hrms/payroll/doctype/salary_slip/salary_slip.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,30 +645,7 @@ def compute_taxable_earnings_for_year(self):
self.payroll_period.start_date, self.start_date, self.tax_slab.allow_tax_exemption
)

# get remaining numbers of sub-period (period for which one salary is processed)
self.remaining_sub_periods = get_period_factor(
self.employee, self.start_date, self.end_date, self.payroll_frequency, self.payroll_period
)[1]

# get taxable_earnings for current period (all days)
self.current_taxable_earnings = self.get_taxable_earnings(self.tax_slab.allow_tax_exemption)
self.future_structured_taxable_earnings = self.current_taxable_earnings.taxable_earnings * (
math.ceil(self.remaining_sub_periods) - 1
)

# get taxable_earnings, addition_earnings for current actual payment days
self.current_taxable_earnings_for_payment_days = self.get_taxable_earnings(
self.tax_slab.allow_tax_exemption, based_on_payment_days=1
)
self.current_structured_taxable_earnings = (
self.current_taxable_earnings_for_payment_days.taxable_earnings
)
self.current_additional_earnings = (
self.current_taxable_earnings_for_payment_days.additional_income
)
self.current_additional_earnings_with_full_tax = (
self.current_taxable_earnings_for_payment_days.additional_income_with_full_tax
)
self.compute_current_and_future_taxable_earnings()

# Deduct taxes forcefully for unsubmitted tax exemption proof and unclaimed benefits in the last period
if self.payroll_period.end_date <= getdate(self.end_date):
Expand Down Expand Up @@ -702,6 +679,35 @@ def compute_taxable_earnings_for_year(self):
self.total_taxable_earnings - self.current_additional_earnings_with_full_tax
)

def compute_current_and_future_taxable_earnings(self):
# get remaining numbers of sub-period (period for which one salary is processed)
self.remaining_sub_periods = get_period_factor(
self.employee, self.start_date, self.end_date, self.payroll_frequency, self.payroll_period
)[1]

# get taxable_earnings for current period (all days)
self.current_taxable_earnings = self.get_taxable_earnings(self.tax_slab.allow_tax_exemption)
self.future_structured_taxable_earnings = self.current_taxable_earnings.taxable_earnings * (
math.ceil(self.remaining_sub_periods) - 1
)

# get taxable_earnings, addition_earnings for current actual payment days
self.current_taxable_earnings_for_payment_days = self.get_taxable_earnings(
self.tax_slab.allow_tax_exemption, based_on_payment_days=1
)

self.current_structured_taxable_earnings = (
self.current_taxable_earnings_for_payment_days.taxable_earnings
)

self.current_additional_earnings = (
self.current_taxable_earnings_for_payment_days.additional_income
)

self.current_additional_earnings_with_full_tax = (
self.current_taxable_earnings_for_payment_days.additional_income_with_full_tax
)

def compute_income_tax_breakup(self):
if not self.payroll_period:
return
Expand Down

0 comments on commit 3830662

Please sign in to comment.