fix: a few fixes in payroll
This commit is contained in:
parent
39f58ae92b
commit
a08bf7ef86
@ -177,9 +177,12 @@ def get_benefit_component_amount(employee, start_date, end_date, struct_row, sal
|
|||||||
|
|
||||||
# Considering there is only one application for a year
|
# Considering there is only one application for a year
|
||||||
benefit_application_name = frappe.db.sql("""
|
benefit_application_name = frappe.db.sql("""
|
||||||
select name from `tabEmployee Benefit Application`
|
select name
|
||||||
where payroll_period=%(payroll_period)s and employee=%(employee)s
|
from `tabEmployee Benefit Application`
|
||||||
and docstatus = 1
|
where
|
||||||
|
payroll_period=%(payroll_period)s
|
||||||
|
and employee=%(employee)s
|
||||||
|
and docstatus = 1
|
||||||
""", {
|
""", {
|
||||||
'employee': employee,
|
'employee': employee,
|
||||||
'payroll_period': payroll_period
|
'payroll_period': payroll_period
|
||||||
@ -209,7 +212,8 @@ def get_benefit_pro_rata_ratio_amount(sal_struct, component_max):
|
|||||||
total_pro_rata_max = 0
|
total_pro_rata_max = 0
|
||||||
benefit_amount = 0
|
benefit_amount = 0
|
||||||
for sal_struct_row in sal_struct.get("earnings"):
|
for sal_struct_row in sal_struct.get("earnings"):
|
||||||
pay_against_benefit_claim, max_benefit_amount = frappe.db.get_value("Salary Component", sal_struct_row.salary_component, ["pay_against_benefit_claim", "max_benefit_amount"])
|
pay_against_benefit_claim, max_benefit_amount = frappe.db.get_value("Salary Component",
|
||||||
|
sal_struct_row.salary_component, ["pay_against_benefit_claim", "max_benefit_amount"])
|
||||||
if sal_struct_row.is_flexible_benefit == 1 and pay_against_benefit_claim != 1:
|
if sal_struct_row.is_flexible_benefit == 1 and pay_against_benefit_claim != 1:
|
||||||
total_pro_rata_max += max_benefit_amount
|
total_pro_rata_max += max_benefit_amount
|
||||||
if total_pro_rata_max > 0:
|
if total_pro_rata_max > 0:
|
||||||
|
@ -100,7 +100,7 @@
|
|||||||
"in_global_search": 0,
|
"in_global_search": 0,
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
"in_standard_filter": 0,
|
||||||
"label": "Maximum Exemption Amount",
|
"label": "Maximum Exempted Amount",
|
||||||
"length": 0,
|
"length": 0,
|
||||||
"no_copy": 0,
|
"no_copy": 0,
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
@ -125,7 +125,7 @@
|
|||||||
"columns": 0,
|
"columns": 0,
|
||||||
"fetch_if_empty": 0,
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "amount",
|
"fieldname": "amount",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Currency",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"ignore_user_permissions": 0,
|
"ignore_user_permissions": 0,
|
||||||
"ignore_xss_filter": 0,
|
"ignore_xss_filter": 0,
|
||||||
@ -160,7 +160,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2019-04-25 15:45:11.279158",
|
"modified": "2019-04-26 11:28:14.023086",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Employee Tax Exemption Declaration Category",
|
"name": "Employee Tax Exemption Declaration Category",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
"allow_copy": 0,
|
||||||
|
"allow_events_in_timeline": 0,
|
||||||
"allow_guest_to_view": 0,
|
"allow_guest_to_view": 0,
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"allow_rename": 0,
|
"allow_rename": 0,
|
||||||
@ -20,6 +21,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "company",
|
"fieldname": "company",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -53,6 +55,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "column_break_2",
|
"fieldname": "column_break_2",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -84,6 +87,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "start_date",
|
"fieldname": "start_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -116,6 +120,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "end_date",
|
"fieldname": "end_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -148,6 +153,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "section_break_5",
|
"fieldname": "section_break_5",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
@ -180,6 +186,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "periods",
|
"fieldname": "periods",
|
||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -213,6 +220,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "section_break_7",
|
"fieldname": "section_break_7",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -245,6 +253,7 @@
|
|||||||
"bold": 0,
|
"bold": 0,
|
||||||
"collapsible": 0,
|
"collapsible": 0,
|
||||||
"columns": 0,
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
"fieldname": "taxable_salary_slabs",
|
"fieldname": "taxable_salary_slabs",
|
||||||
"fieldtype": "Table",
|
"fieldtype": "Table",
|
||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
@ -270,6 +279,39 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"translatable": 0,
|
"translatable": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"allow_bulk_edit": 0,
|
||||||
|
"allow_in_quick_entry": 0,
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"bold": 0,
|
||||||
|
"collapsible": 0,
|
||||||
|
"columns": 0,
|
||||||
|
"fetch_if_empty": 0,
|
||||||
|
"fieldname": "standard_tax_exemption_amount",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"ignore_xss_filter": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_global_search": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"in_standard_filter": 0,
|
||||||
|
"label": "Standard Tax Exemption Amount",
|
||||||
|
"length": 0,
|
||||||
|
"no_copy": 0,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 0,
|
||||||
|
"print_hide_if_no_value": 0,
|
||||||
|
"read_only": 0,
|
||||||
|
"remember_last_selected_value": 0,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"translatable": 0,
|
||||||
|
"unique": 0
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
"has_web_view": 0,
|
||||||
@ -282,7 +324,7 @@
|
|||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"max_attachments": 0,
|
"max_attachments": 0,
|
||||||
"modified": "2018-05-25 12:29:07.207927",
|
"modified": "2019-04-26 01:45:03.160929",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Payroll Period",
|
"name": "Payroll Period",
|
||||||
@ -354,5 +396,6 @@
|
|||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"track_changes": 1,
|
"track_changes": 1,
|
||||||
"track_seen": 0
|
"track_seen": 0,
|
||||||
|
"track_views": 0
|
||||||
}
|
}
|
@ -5,10 +5,8 @@ frappe.ui.form.on('Salary Component', {
|
|||||||
setup: function(frm) {
|
setup: function(frm) {
|
||||||
frm.set_query("default_account", "accounts", function(doc, cdt, cdn) {
|
frm.set_query("default_account", "accounts", function(doc, cdt, cdn) {
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
var root_types = ["Expense", "Liability"];
|
|
||||||
return {
|
return {
|
||||||
filters: {
|
filters: {
|
||||||
"root_type": ["in", root_types],
|
|
||||||
"is_group": 0,
|
"is_group": 0,
|
||||||
"company": d.company
|
"company": d.company
|
||||||
}
|
}
|
||||||
|
@ -107,8 +107,8 @@ class SalarySlip(TransactionBase):
|
|||||||
for d in self.get("earnings"):
|
for d in self.get("earnings"):
|
||||||
if d.is_flexible_benefit == 1:
|
if d.is_flexible_benefit == 1:
|
||||||
current_flexi_amount += d.amount
|
current_flexi_amount += d.amount
|
||||||
last_benefits = get_last_payroll_period_benefits(self.employee, self.start_date, self.end_date,\
|
last_benefits = get_last_payroll_period_benefits(self.employee, self.start_date, self.end_date,
|
||||||
current_flexi_amount, payroll_period, self._salary_structure_doc)
|
current_flexi_amount, payroll_period, self._salary_structure_doc)
|
||||||
if last_benefits:
|
if last_benefits:
|
||||||
for last_benefit in last_benefits:
|
for last_benefit in last_benefits:
|
||||||
last_benefit = frappe._dict(last_benefit)
|
last_benefit = frappe._dict(last_benefit)
|
||||||
@ -118,7 +118,7 @@ class SalarySlip(TransactionBase):
|
|||||||
def add_employee_flexi_benefits(self, struct_row):
|
def add_employee_flexi_benefits(self, struct_row):
|
||||||
if frappe.db.get_value("Salary Component", struct_row.salary_component, "pay_against_benefit_claim") != 1:
|
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, \
|
benefit_component_amount = get_benefit_component_amount(self.employee, self.start_date, self.end_date, \
|
||||||
struct_row, self._salary_structure_doc, self.total_working_days, self.payroll_frequency)
|
struct_row, self._salary_structure_doc, self.total_working_days, self.payroll_frequency)
|
||||||
if benefit_component_amount:
|
if benefit_component_amount:
|
||||||
self.update_component_row(struct_row, benefit_component_amount, "earnings")
|
self.update_component_row(struct_row, benefit_component_amount, "earnings")
|
||||||
else:
|
else:
|
||||||
@ -418,7 +418,7 @@ class SalarySlip(TransactionBase):
|
|||||||
|
|
||||||
for d in self.get(component_type):
|
for d in self.get(component_type):
|
||||||
if (self.salary_structure and
|
if (self.salary_structure and
|
||||||
cint(d.depends_on_payment_days) and
|
cint(d.depends_on_payment_days) and cint(self.total_working_days) and
|
||||||
(not
|
(not
|
||||||
self.salary_slip_based_on_timesheet or
|
self.salary_slip_based_on_timesheet or
|
||||||
getdate(self.start_date) < joining_date or
|
getdate(self.start_date) < joining_date or
|
||||||
@ -593,7 +593,7 @@ class SalarySlip(TransactionBase):
|
|||||||
unclaimed_earning = self.calculate_unclaimed_taxable_earning(payroll_period, tax_component)
|
unclaimed_earning = self.calculate_unclaimed_taxable_earning(payroll_period, tax_component)
|
||||||
earning_in_period = taxable_earning["taxable_earning"] + unclaimed_earning
|
earning_in_period = taxable_earning["taxable_earning"] + unclaimed_earning
|
||||||
period_factor = self.get_period_factor(payroll_period.start_date, payroll_period.end_date,
|
period_factor = self.get_period_factor(payroll_period.start_date, payroll_period.end_date,
|
||||||
payroll_period.start_date, self.end_date)
|
payroll_period.start_date, self.end_date)
|
||||||
annual_taxable_earning = earning_in_period * period_factor
|
annual_taxable_earning = earning_in_period * period_factor
|
||||||
additional_income += self.get_total_additional_income(payroll_period.start_date)
|
additional_income += self.get_total_additional_income(payroll_period.start_date)
|
||||||
else:
|
else:
|
||||||
@ -607,6 +607,7 @@ class SalarySlip(TransactionBase):
|
|||||||
{"employee": self.employee, "payroll_period": payroll_period.name, "docstatus": 1},
|
{"employee": self.employee, "payroll_period": payroll_period.name, "docstatus": 1},
|
||||||
"total_exemption_amount")
|
"total_exemption_amount")
|
||||||
annual_taxable_earning = annual_earning - exemption_amount
|
annual_taxable_earning = annual_earning - exemption_amount
|
||||||
|
|
||||||
if self.deduct_tax_for_unclaimed_employee_benefits or self.deduct_tax_for_unsubmitted_tax_exemption_proof:
|
if self.deduct_tax_for_unclaimed_employee_benefits or self.deduct_tax_for_unsubmitted_tax_exemption_proof:
|
||||||
tax_detail = self.get_tax_paid_in_period(payroll_period, tax_component)
|
tax_detail = self.get_tax_paid_in_period(payroll_period, tax_component)
|
||||||
if tax_detail:
|
if tax_detail:
|
||||||
@ -616,11 +617,17 @@ class SalarySlip(TransactionBase):
|
|||||||
|
|
||||||
# add any additional income in this slip
|
# add any additional income in this slip
|
||||||
additional_income += taxable_earning["additional_income"]
|
additional_income += taxable_earning["additional_income"]
|
||||||
args = {"payroll_period": payroll_period.name, "tax_component": tax_component,
|
args = {
|
||||||
"annual_taxable_earning": annual_taxable_earning, "period_factor": period_factor,
|
"payroll_period": payroll_period.name,
|
||||||
"unclaimed_benefit": unclaimed_benefit, "additional_income": additional_income,
|
"tax_component": tax_component,
|
||||||
"pro_rata_tax_paid": pro_rata_tax_paid, "benefit_tax_paid": benefit_tax_paid,
|
"period_factor": period_factor,
|
||||||
"additional_tax_paid": additional_tax_paid}
|
"annual_taxable_earning": annual_taxable_earning,
|
||||||
|
"additional_income": additional_income,
|
||||||
|
"unclaimed_benefit": unclaimed_benefit,
|
||||||
|
"pro_rata_tax_paid": pro_rata_tax_paid,
|
||||||
|
"benefit_tax_paid": benefit_tax_paid,
|
||||||
|
"additional_tax_paid": additional_tax_paid
|
||||||
|
}
|
||||||
return self.calculate_tax(args)
|
return self.calculate_tax(args)
|
||||||
|
|
||||||
def calculate_unclaimed_taxable_benefit(self, payroll_period):
|
def calculate_unclaimed_taxable_benefit(self, payroll_period):
|
||||||
@ -667,27 +674,49 @@ class SalarySlip(TransactionBase):
|
|||||||
return total_taxable_earning
|
return total_taxable_earning
|
||||||
|
|
||||||
def get_total_additional_income(self, from_date):
|
def get_total_additional_income(self, from_date):
|
||||||
total_additional_pay = 0
|
sum_additional_earning = frappe.db.sql("""
|
||||||
sum_additional_earning = frappe.db.sql("""select sum(sd.amount) from `tabSalary Detail` sd join
|
select sum(sd.amount)
|
||||||
`tabSalary Slip` ss on sd.parent=ss.name where sd.parentfield='earnings'
|
from
|
||||||
and sd.is_tax_applicable=1 and is_additional_component=1 and is_flexible_benefit=0
|
`tabSalary Detail` sd join `tabSalary Slip` ss on sd.parent=ss.name
|
||||||
and ss.docstatus=1 and ss.employee='{0}' and ss.start_date between '{1}' and '{2}'
|
where
|
||||||
and ss.end_date between '{1}' and '{2}'""".format(self.employee,
|
sd.parentfield='earnings'
|
||||||
from_date, self.start_date))
|
and sd.is_tax_applicable=1 and is_additional_component=1
|
||||||
if sum_additional_earning and sum_additional_earning[0][0]:
|
and is_flexible_benefit=0 and ss.docstatus=1
|
||||||
total_additional_pay = sum_additional_earning[0][0]
|
and ss.employee=%(employee)s
|
||||||
return total_additional_pay
|
and ss.start_date between %(from_date)s and %(to_date)s
|
||||||
|
and ss.end_date between %(from_date)s and %(to_date)s
|
||||||
|
""", {
|
||||||
|
"employee": self.employee,
|
||||||
|
"from_date": from_date,
|
||||||
|
"to_date": self.start_date
|
||||||
|
})
|
||||||
|
return sum_additional_earning[0][0] if sum_additional_earning else 0
|
||||||
|
|
||||||
def get_tax_paid_in_period(self, payroll_period, tax_component, only_total=False):
|
def get_tax_paid_in_period(self, payroll_period, tax_component, only_total=False):
|
||||||
# find total_tax_paid, tax paid for benefit, additional_salary
|
# find total_tax_paid, tax paid for benefit, additional_salary
|
||||||
sum_tax_paid = frappe.db.sql("""select sum(sd.amount), sum(tax_on_flexible_benefit),
|
sum_tax_paid = frappe.db.sql("""
|
||||||
sum(tax_on_additional_salary) from `tabSalary Detail` sd join `tabSalary Slip`
|
select
|
||||||
ss on sd.parent=ss.name where sd.parentfield='deductions' and sd.salary_component='{3}'
|
sum(sd.amount), sum(tax_on_flexible_benefit), sum(tax_on_additional_salary)
|
||||||
and sd.variable_based_on_taxable_salary=1 and ss.docstatus=1 and ss.employee='{0}'
|
from
|
||||||
and ss.start_date between '{1}' and '{2}' and ss.end_date between '{1}' and
|
`tabSalary Detail` sd join `tabSalary Slip` ss on sd.parent=ss.name
|
||||||
'{2}'""".format(self.employee, payroll_period.start_date, self.start_date, tax_component))
|
where
|
||||||
|
sd.parentfield='deductions' and sd.salary_component=%(salary_component)s
|
||||||
|
and sd.variable_based_on_taxable_salary=1
|
||||||
|
and ss.docstatus=1 and ss.employee=%(employee)s
|
||||||
|
and ss.start_date between %(from_date)s and %(to_date)s
|
||||||
|
and ss.end_date between %(from_date)s and %(to_date)s
|
||||||
|
""", {
|
||||||
|
"salary_component": tax_component,
|
||||||
|
"employee": self.employee,
|
||||||
|
"from_date": payroll_period.start_date,
|
||||||
|
"to_date": self.start_date
|
||||||
|
})
|
||||||
if sum_tax_paid and sum_tax_paid[0][0]:
|
if sum_tax_paid and sum_tax_paid[0][0]:
|
||||||
return {'total_tax_paid': sum_tax_paid[0][0], 'benefit_tax':sum_tax_paid[0][1], 'additional_tax': sum_tax_paid[0][2]}
|
return {
|
||||||
|
'total_tax_paid': sum_tax_paid[0][0],
|
||||||
|
'benefit_tax':sum_tax_paid[0][1],
|
||||||
|
'additional_tax': sum_tax_paid[0][2]
|
||||||
|
}
|
||||||
|
|
||||||
def get_taxable_earnings(self, include_flexi=0, only_flexi=0):
|
def get_taxable_earnings(self, include_flexi=0, only_flexi=0):
|
||||||
taxable_earning = 0
|
taxable_earning = 0
|
||||||
@ -698,22 +727,22 @@ class SalarySlip(TransactionBase):
|
|||||||
additional_income += earning.amount
|
additional_income += earning.amount
|
||||||
continue
|
continue
|
||||||
if only_flexi:
|
if only_flexi:
|
||||||
if earning.is_tax_applicable and earning.is_flexible_benefit:
|
if earning.is_flexible_benefit:
|
||||||
taxable_earning += earning.amount
|
taxable_earning += earning.amount
|
||||||
continue
|
continue
|
||||||
if include_flexi:
|
if include_flexi or not earning.is_flexible_benefit:
|
||||||
if earning.is_tax_applicable or (earning.is_tax_applicable and earning.is_flexible_benefit):
|
taxable_earning += earning.amount
|
||||||
taxable_earning += earning.amount
|
return {
|
||||||
else:
|
"taxable_earning": taxable_earning,
|
||||||
if earning.is_tax_applicable and not earning.is_flexible_benefit:
|
"additional_income": additional_income
|
||||||
taxable_earning += earning.amount
|
}
|
||||||
return {"taxable_earning": taxable_earning, "additional_income": additional_income}
|
|
||||||
|
|
||||||
def calculate_tax(self, args):
|
def calculate_tax(self, args):
|
||||||
tax_amount, benefit_tax, additional_tax = 0, 0, 0
|
tax_amount, benefit_tax, additional_tax = 0, 0, 0
|
||||||
annual_taxable_earning = args.get("annual_taxable_earning")
|
annual_taxable_earning = args.get("annual_taxable_earning")
|
||||||
benefit_to_tax = args.get("unclaimed_benefit")
|
benefit_to_tax = args.get("unclaimed_benefit")
|
||||||
additional_income = args.get("additional_income")
|
additional_income = args.get("additional_income")
|
||||||
|
|
||||||
# Get tax calc by period
|
# Get tax calc by period
|
||||||
annual_tax = self.calculate_tax_by_tax_slab(args.get("payroll_period"), annual_taxable_earning)
|
annual_tax = self.calculate_tax_by_tax_slab(args.get("payroll_period"), annual_taxable_earning)
|
||||||
|
|
||||||
@ -744,8 +773,10 @@ class SalarySlip(TransactionBase):
|
|||||||
|
|
||||||
def calculate_tax_by_tax_slab(self, payroll_period, annual_taxable_earning):
|
def calculate_tax_by_tax_slab(self, payroll_period, annual_taxable_earning):
|
||||||
payroll_period_obj = frappe.get_doc("Payroll Period", payroll_period)
|
payroll_period_obj = frappe.get_doc("Payroll Period", payroll_period)
|
||||||
|
annual_taxable_earning -= flt(payroll_period_obj.standard_tax_exemption_amount)
|
||||||
data = self.get_data_for_eval()
|
data = self.get_data_for_eval()
|
||||||
data.update({"annual_taxable_earning": annual_taxable_earning})
|
data.update({"annual_taxable_earning": annual_taxable_earning})
|
||||||
|
|
||||||
taxable_amount = 0
|
taxable_amount = 0
|
||||||
for slab in payroll_period_obj.taxable_salary_slabs:
|
for slab in payroll_period_obj.taxable_salary_slabs:
|
||||||
if slab.condition and not self.eval_tax_slab_condition(slab.condition, data):
|
if slab.condition and not self.eval_tax_slab_condition(slab.condition, data):
|
||||||
|
@ -159,21 +159,21 @@ class TestSalarySlip(unittest.TestCase):
|
|||||||
month = "%02d" % getdate(nowdate()).month
|
month = "%02d" % getdate(nowdate()).month
|
||||||
m = get_month_details(fiscal_year, month)
|
m = get_month_details(fiscal_year, month)
|
||||||
|
|
||||||
for payroll_frequncy in ["Monthly", "Bimonthly", "Fortnightly", "Weekly", "Daily"]:
|
for payroll_frequency in ["Monthly", "Bimonthly", "Fortnightly", "Weekly", "Daily"]:
|
||||||
make_employee(payroll_frequncy + "_test_employee@salary.com")
|
make_employee(payroll_frequency + "_test_employee@salary.com")
|
||||||
ss = make_employee_salary_slip(payroll_frequncy + "_test_employee@salary.com", payroll_frequncy)
|
ss = make_employee_salary_slip(payroll_frequency + "_test_employee@salary.com", payroll_frequency)
|
||||||
if payroll_frequncy == "Monthly":
|
if payroll_frequency == "Monthly":
|
||||||
self.assertEqual(ss.end_date, m['month_end_date'])
|
self.assertEqual(ss.end_date, m['month_end_date'])
|
||||||
elif payroll_frequncy == "Bimonthly":
|
elif payroll_frequency == "Bimonthly":
|
||||||
if getdate(ss.start_date).day <= 15:
|
if getdate(ss.start_date).day <= 15:
|
||||||
self.assertEqual(ss.end_date, m['month_mid_end_date'])
|
self.assertEqual(ss.end_date, m['month_mid_end_date'])
|
||||||
else:
|
else:
|
||||||
self.assertEqual(ss.end_date, m['month_end_date'])
|
self.assertEqual(ss.end_date, m['month_end_date'])
|
||||||
elif payroll_frequncy == "Fortnightly":
|
elif payroll_frequency == "Fortnightly":
|
||||||
self.assertEqual(ss.end_date, add_days(nowdate(),13))
|
self.assertEqual(ss.end_date, add_days(nowdate(),13))
|
||||||
elif payroll_frequncy == "Weekly":
|
elif payroll_frequency == "Weekly":
|
||||||
self.assertEqual(ss.end_date, add_days(nowdate(),6))
|
self.assertEqual(ss.end_date, add_days(nowdate(),6))
|
||||||
elif payroll_frequncy == "Daily":
|
elif payroll_frequency == "Daily":
|
||||||
self.assertEqual(ss.end_date, nowdate())
|
self.assertEqual(ss.end_date, nowdate())
|
||||||
|
|
||||||
def test_tax_for_payroll_period(self):
|
def test_tax_for_payroll_period(self):
|
||||||
|
@ -57,11 +57,12 @@ class SalaryStructure(Document):
|
|||||||
have_a_flexi = True
|
have_a_flexi = True
|
||||||
max_of_component = frappe.db.get_value("Salary Component", earning_component.salary_component, "max_benefit_amount")
|
max_of_component = frappe.db.get_value("Salary Component", earning_component.salary_component, "max_benefit_amount")
|
||||||
flexi_amount += max_of_component
|
flexi_amount += max_of_component
|
||||||
|
|
||||||
if have_a_flexi and flt(self.max_benefits) == 0:
|
if have_a_flexi and flt(self.max_benefits) == 0:
|
||||||
frappe.throw(_("Max benefits should be greater than zero to dispense benefits"))
|
frappe.throw(_("Max benefits should be greater than zero to dispense benefits"))
|
||||||
if have_a_flexi and flt(self.max_benefits) > flexi_amount:
|
if have_a_flexi and flexi_amount and flt(self.max_benefits) > flexi_amount:
|
||||||
frappe.throw(_("Total flexible benefit component amount {0} should not be less \
|
frappe.throw(_("Total flexible benefit component amount {0} should not be less than max benefits {1}")
|
||||||
than max benefits {1}").format(flexi_amount, self.max_benefits))
|
.format(flexi_amount, self.max_benefits))
|
||||||
if not have_a_flexi and flt(self.max_benefits) > 0:
|
if not have_a_flexi and flt(self.max_benefits) > 0:
|
||||||
frappe.throw(_("Salary Structure should have flexible benefit component(s) to dispense benefit amount"))
|
frappe.throw(_("Salary Structure should have flexible benefit component(s) to dispense benefit amount"))
|
||||||
|
|
||||||
|
@ -568,7 +568,7 @@ execute:frappe.delete_doc_if_exists("Page", "sales-analytics")
|
|||||||
execute:frappe.delete_doc_if_exists("Page", "purchase-analytics")
|
execute:frappe.delete_doc_if_exists("Page", "purchase-analytics")
|
||||||
execute:frappe.delete_doc_if_exists("Page", "stock-analytics")
|
execute:frappe.delete_doc_if_exists("Page", "stock-analytics")
|
||||||
execute:frappe.delete_doc_if_exists("Page", "production-analytics")
|
execute:frappe.delete_doc_if_exists("Page", "production-analytics")
|
||||||
erpnext.patches.v11_0.ewaybill_fields_gst_india #2018-11-13 #2019-01-09 #2019-04-01
|
erpnext.patches.v11_0.ewaybill_fields_gst_india #2018-11-13 #2019-01-09 #2019-04-01 #2019-04-26
|
||||||
erpnext.patches.v11_0.drop_column_max_days_allowed
|
erpnext.patches.v11_0.drop_column_max_days_allowed
|
||||||
erpnext.patches.v10_0.update_user_image_in_employee
|
erpnext.patches.v10_0.update_user_image_in_employee
|
||||||
erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items
|
erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items
|
||||||
|
Loading…
x
Reference in New Issue
Block a user