@ -630,7 +630,8 @@ class SalarySlip(TransactionBase):
get_salary_component_data ( additional_salary . component ) ,
additional_salary . amount ,
component_type ,
additional_salary
additional_salary ,
is_recurring = additional_salary . is_recurring
)
def add_tax_components ( self , payroll_period ) :
@ -651,7 +652,7 @@ class SalarySlip(TransactionBase):
tax_row = get_salary_component_data ( d )
self . update_component_row ( tax_row , tax_amount , " deductions " )
def update_component_row ( self , component_data , amount , component_type , additional_salary = None ) :
def update_component_row ( self , component_data , amount , component_type , additional_salary = None , is_recurring = 0 ) :
component_row = None
for d in self . get ( component_type ) :
if d . salary_component != component_data . salary_component :
@ -698,6 +699,8 @@ class SalarySlip(TransactionBase):
else :
component_row . default_amount = 0
component_row . additional_amount = amount
component_row . is_recurring_additional_salary = is_recurring
component_row . additional_salary = additional_salary . name
component_row . deduct_full_tax_on_selected_payroll_date = \
additional_salary . deduct_full_tax_on_selected_payroll_date
@ -894,25 +897,33 @@ class SalarySlip(TransactionBase):
amount , additional_amount = earning . default_amount , earning . additional_amount
if earning . is_tax_applicable :
if additional_amount :
if earning . is_flexible_benefit :
flexi_benefits + = amount
else :
taxable_earnings + = ( amount - additional_amount )
additional_income + = additional_amount
# Get additional amount based on future recurring additional salary
if additional_amount and earning . is_recurring_additional_salary :
additional_income + = self . get_future_recurring_additional_amount ( earning . additional_salary ,
earning . additional_amount ) # Used earning.additional_amount to consider the amount for the full month
if earning . deduct_full_tax_on_selected_payroll_date :
additional_income_with_full_tax + = additional_amount
continue
if earning . is_flexible_benefit :
flexi_benefits + = amount
else :
taxable_earnings + = amount
if allow_tax_exemption :
for ded in self . deductions :
if ded . exempted_from_income_tax :
amount = ded . amount
amount , additional_amount = ded . amount , ded . additional_amount
if based_on_payment_days :
amount = self . get_amount_based_on_payment_days ( ded , joining_date , relieving_date ) [ 0 ]
taxable_earnings - = flt ( amount )
amount , additional_amount = self . get_amount_based_on_payment_days ( ded , joining_date , relieving_date )
taxable_earnings - = flt ( amount - additional_amount )
additional_income - = additional_amount
if additional_amount and ded . is_recurring_additional_salary :
additional_income - = self . get_future_recurring_additional_amount ( ded . additional_salary ,
ded . additional_amount ) # Used ded.additional_amount to consider the amount for the full month
return frappe . _dict ( {
" taxable_earnings " : taxable_earnings ,
@ -921,11 +932,21 @@ class SalarySlip(TransactionBase):
" flexi_benefits " : flexi_benefits
} )
def get_future_recurring_additional_amount ( self , additional_salary , monthly_additional_amount ) :
future_recurring_additional_amount = 0
to_date = frappe . db . get_value ( " Additional Salary " , additional_salary , ' to_date ' )
# future month count excluding current
future_recurring_period = ( getdate ( to_date ) . month - getdate ( self . start_date ) . month )
if future_recurring_period > 0 :
future_recurring_additional_amount = monthly_additional_amount * future_recurring_period # Used earning.additional_amount to consider the amount for the full month
return future_recurring_additional_amount
def get_amount_based_on_payment_days ( self , row , joining_date , relieving_date ) :
amount , additional_amount = row . amount , row . additional_amount
if ( self . salary_structure and
cint ( row . depends_on_payment_days ) and cint ( self . total_working_days ) and
( not self . salary_slip_based_on_timesheet or
cint ( row . depends_on_payment_days ) and cint ( self . total_working_days )
and not ( row . additional_salary and row . default_amount ) # to identify overwritten additional salary
and ( not self . salary_slip_based_on_timesheet or
getdate ( self . start_date ) < joining_date or
( relieving_date and getdate ( self . end_date ) > relieving_date )
) ) :