chore: Remove regional HR reports, custom field setups

- Removed reports Provident Fund Deductions, Professional Tax Deductions, helper js file `salary_slip_deductions_report_filters.js`

- Removed Gratuity rules setup for India and UAE

- Removed custom field setup for India

- Moved all setups to the HRMS app
This commit is contained in:
Rucha Mahabal 2022-06-27 15:12:05 +05:30
parent c619b58ba9
commit 1d5c8660bb
11 changed files with 0 additions and 706 deletions

View File

@ -1,66 +0,0 @@
frappe.provide("erpnext.salary_slip_deductions_report_filters");
erpnext.salary_slip_deductions_report_filters = {
"filters": [
{
fieldname: "company",
label: __("Company"),
fieldtype: "Link",
options: "Company",
reqd:1,
default: frappe.defaults.get_user_default("Company"),
},
{
fieldname: "month",
label: __("Month"),
fieldtype: "Select",
reqd: 1 ,
options: [
{ "value": 1, "label": __("Jan") },
{ "value": 2, "label": __("Feb") },
{ "value": 3, "label": __("Mar") },
{ "value": 4, "label": __("Apr") },
{ "value": 5, "label": __("May") },
{ "value": 6, "label": __("June") },
{ "value": 7, "label": __("July") },
{ "value": 8, "label": __("Aug") },
{ "value": 9, "label": __("Sep") },
{ "value": 10, "label": __("Oct") },
{ "value": 11, "label": __("Nov") },
{ "value": 12, "label": __("Dec") },
],
default: frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth() + 1
},
{
fieldname:"year",
label: __("Year"),
fieldtype: "Select",
reqd: 1
},
{
fieldname: "department",
label: __("Department"),
fieldtype: "Link",
options: "Department",
},
{
fieldname: "branch",
label: __("Branch"),
fieldtype: "Link",
options: "Branch",
}
],
"onload": function() {
return frappe.call({
method: "erpnext.regional.report.provident_fund_deductions.provident_fund_deductions.get_years",
callback: function(r) {
var year_filter = frappe.query_report.get_filter('year');
year_filter.df.options = r.message;
year_filter.df.default = r.message.split("\n")[0];
year_filter.refresh();
year_filter.set_input(year_filter.df.default);
}
});
}
}

View File

@ -27,7 +27,6 @@ def setup_company_independent_fixtures(patch=False):
add_permissions()
add_custom_roles_for_reports()
frappe.enqueue("erpnext.regional.india.setup.add_hsn_sac_codes", now=frappe.flags.in_test)
create_gratuity_rule()
add_print_formats()
update_accounts_settings_for_taxes()
@ -79,17 +78,6 @@ def add_custom_roles_for_reports():
)
).insert()
for report_name in ("Professional Tax Deductions", "Provident Fund Deductions"):
if not frappe.db.get_value("Custom Role", dict(report=report_name)):
frappe.get_doc(
dict(
doctype="Custom Role",
report=report_name,
roles=[dict(role="HR User"), dict(role="HR Manager"), dict(role="Employee")],
)
).insert()
for report_name in ("HSN-wise-summary of outward supplies", "GSTR-1", "GSTR-2"):
if not frappe.db.get_value("Custom Role", dict(report=report_name)):
@ -959,194 +947,6 @@ def get_custom_fields():
"Purchase Receipt Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
"Purchase Invoice Item": [hsn_sac_field, nil_rated_exempt, is_non_gst, taxable_value],
"Material Request Item": [hsn_sac_field, nil_rated_exempt, is_non_gst],
"Salary Component": [
dict(
fieldname="component_type",
label="Component Type",
fieldtype="Select",
insert_after="description",
options="\nProvident Fund\nAdditional Provident Fund\nProvident Fund Loan\nProfessional Tax",
depends_on='eval:doc.type == "Deduction"',
)
],
"Employee": [
dict(
fieldname="ifsc_code",
label="IFSC Code",
fieldtype="Data",
insert_after="bank_ac_no",
print_hide=1,
depends_on='eval:doc.salary_mode == "Bank"',
),
dict(
fieldname="pan_number",
label="PAN Number",
fieldtype="Data",
insert_after="payroll_cost_center",
print_hide=1,
),
dict(
fieldname="micr_code",
label="MICR Code",
fieldtype="Data",
insert_after="ifsc_code",
print_hide=1,
depends_on='eval:doc.salary_mode == "Bank"',
),
dict(
fieldname="provident_fund_account",
label="Provident Fund Account",
fieldtype="Data",
insert_after="pan_number",
),
],
"Company": [
dict(
fieldname="hra_section",
label="HRA Settings",
fieldtype="Section Break",
insert_after="asset_received_but_not_billed",
collapsible=1,
),
dict(
fieldname="basic_component",
label="Basic Component",
fieldtype="Link",
options="Salary Component",
insert_after="hra_section",
),
dict(
fieldname="hra_component",
label="HRA Component",
fieldtype="Link",
options="Salary Component",
insert_after="basic_component",
),
dict(fieldname="hra_column_break", fieldtype="Column Break", insert_after="hra_component"),
dict(
fieldname="arrear_component",
label="Arrear Component",
fieldtype="Link",
options="Salary Component",
insert_after="hra_column_break",
),
],
"Employee Tax Exemption Declaration": [
dict(
fieldname="hra_section",
label="HRA Exemption",
fieldtype="Section Break",
insert_after="declarations",
),
dict(
fieldname="monthly_house_rent",
label="Monthly House Rent",
fieldtype="Currency",
insert_after="hra_section",
),
dict(
fieldname="rented_in_metro_city",
label="Rented in Metro City",
fieldtype="Check",
insert_after="monthly_house_rent",
depends_on="monthly_house_rent",
),
dict(
fieldname="salary_structure_hra",
label="HRA as per Salary Structure",
fieldtype="Currency",
insert_after="rented_in_metro_city",
read_only=1,
depends_on="monthly_house_rent",
),
dict(
fieldname="hra_column_break",
fieldtype="Column Break",
insert_after="salary_structure_hra",
depends_on="monthly_house_rent",
),
dict(
fieldname="annual_hra_exemption",
label="Annual HRA Exemption",
fieldtype="Currency",
insert_after="hra_column_break",
read_only=1,
depends_on="monthly_house_rent",
),
dict(
fieldname="monthly_hra_exemption",
label="Monthly HRA Exemption",
fieldtype="Currency",
insert_after="annual_hra_exemption",
read_only=1,
depends_on="monthly_house_rent",
),
],
"Employee Tax Exemption Proof Submission": [
dict(
fieldname="hra_section",
label="HRA Exemption",
fieldtype="Section Break",
insert_after="tax_exemption_proofs",
),
dict(
fieldname="house_rent_payment_amount",
label="House Rent Payment Amount",
fieldtype="Currency",
insert_after="hra_section",
),
dict(
fieldname="rented_in_metro_city",
label="Rented in Metro City",
fieldtype="Check",
insert_after="house_rent_payment_amount",
depends_on="house_rent_payment_amount",
),
dict(
fieldname="rented_from_date",
label="Rented From Date",
fieldtype="Date",
insert_after="rented_in_metro_city",
depends_on="house_rent_payment_amount",
),
dict(
fieldname="rented_to_date",
label="Rented To Date",
fieldtype="Date",
insert_after="rented_from_date",
depends_on="house_rent_payment_amount",
),
dict(
fieldname="hra_column_break",
fieldtype="Column Break",
insert_after="rented_to_date",
depends_on="house_rent_payment_amount",
),
dict(
fieldname="monthly_house_rent",
label="Monthly House Rent",
fieldtype="Currency",
insert_after="hra_column_break",
read_only=1,
depends_on="house_rent_payment_amount",
),
dict(
fieldname="monthly_hra_exemption",
label="Monthly Eligible Amount",
fieldtype="Currency",
insert_after="monthly_house_rent",
read_only=1,
depends_on="house_rent_payment_amount",
),
dict(
fieldname="total_eligible_hra_exemption",
label="Total Eligible HRA Exemption",
fieldtype="Currency",
insert_after="monthly_hra_exemption",
read_only=1,
depends_on="house_rent_payment_amount",
),
],
"Supplier": [
{"fieldname": "pan", "label": "PAN", "fieldtype": "Data", "insert_after": "supplier_type"},
{
@ -1212,7 +1012,6 @@ def make_fixtures(company=None):
docs = []
company = company or frappe.db.get_value("Global Defaults", None, "default_company")
set_salary_components(docs)
set_tds_account(docs, company)
for d in docs:
@ -1293,55 +1092,6 @@ def add_accounts_in_gst_settings(
)
def set_salary_components(docs):
docs.extend(
[
{
"doctype": "Salary Component",
"salary_component": "Professional Tax",
"description": "Professional Tax",
"type": "Deduction",
"exempted_from_income_tax": 1,
},
{
"doctype": "Salary Component",
"salary_component": "Provident Fund",
"description": "Provident fund",
"type": "Deduction",
"is_tax_applicable": 1,
},
{
"doctype": "Salary Component",
"salary_component": "House Rent Allowance",
"description": "House Rent Allowance",
"type": "Earning",
"is_tax_applicable": 1,
},
{
"doctype": "Salary Component",
"salary_component": "Basic",
"description": "Basic",
"type": "Earning",
"is_tax_applicable": 1,
},
{
"doctype": "Salary Component",
"salary_component": "Arrear",
"description": "Arrear",
"type": "Earning",
"is_tax_applicable": 1,
},
{
"doctype": "Salary Component",
"salary_component": "Leave Encashment",
"description": "Leave Encashment",
"type": "Earning",
"is_tax_applicable": 1,
},
]
)
def set_tax_withholding_category(company):
accounts = []
fiscal_year_details = None
@ -1832,25 +1582,6 @@ def get_tds_details(accounts, fiscal_year_details):
]
def create_gratuity_rule():
# Standard Indain Gratuity Rule
if not frappe.db.exists("Gratuity Rule", "Indian Standard Gratuity Rule"):
rule = frappe.new_doc("Gratuity Rule")
rule.name = "Indian Standard Gratuity Rule"
rule.calculate_gratuity_amount_based_on = "Current Slab"
rule.work_experience_calculation_method = "Round Off Work Experience"
rule.minimum_year_for_gratuity = 5
fraction = 15 / 26
rule.append(
"gratuity_rule_slabs",
{"from_year": 0, "to_year": 0, "fraction_of_applicable_earnings": fraction},
)
rule.flags.ignore_mandatory = True
rule.save()
def update_accounts_settings_for_taxes():
if frappe.db.count("Company") == 1:
frappe.db.set_value("Accounts Settings", None, "add_taxes_from_item_tax_template", 0)

View File

@ -1,7 +0,0 @@
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
/* eslint-disable */
frappe.require("assets/erpnext/js/salary_slip_deductions_report_filters.js", function() {
frappe.query_reports["Professional Tax Deductions"] = erpnext.salary_slip_deductions_report_filters;
});

View File

@ -1,20 +0,0 @@
{
"add_total_row": 0,
"creation": "2020-06-02 00:37:44.537355",
"disable_prepared_report": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 0,
"is_standard": "Yes",
"modified": "2020-06-16 19:02:26.306348",
"modified_by": "Administrator",
"module": "Regional",
"name": "Professional Tax Deductions",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "Salary Slip",
"report_name": "Professional Tax Deductions",
"report_type": "Script Report",
"roles": []
}

View File

@ -1,78 +0,0 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
import frappe
from frappe import _
from erpnext.regional.report.provident_fund_deductions.provident_fund_deductions import (
get_conditions,
)
def execute(filters=None):
data = get_data(filters)
columns = get_columns(filters) if len(data) else []
return columns, data
def get_columns(filters):
columns = [
{
"label": _("Employee"),
"options": "Employee",
"fieldname": "employee",
"fieldtype": "Link",
"width": 200,
},
{
"label": _("Employee Name"),
"options": "Employee",
"fieldname": "employee_name",
"fieldtype": "Link",
"width": 160,
},
{"label": _("Amount"), "fieldname": "amount", "fieldtype": "Currency", "width": 140},
]
return columns
def get_data(filters):
data = []
component_type_dict = frappe._dict(
frappe.db.sql(
""" select name, component_type from `tabSalary Component`
where component_type = 'Professional Tax' """
)
)
if not len(component_type_dict):
return []
conditions = get_conditions(filters)
entry = frappe.db.sql(
""" select sal.employee, sal.employee_name, ded.salary_component, ded.amount
from `tabSalary Slip` sal, `tabSalary Detail` ded
where sal.name = ded.parent
and ded.parentfield = 'deductions'
and ded.parenttype = 'Salary Slip'
and sal.docstatus = 1 %s
and ded.salary_component in (%s)
"""
% (conditions, ", ".join(["%s"] * len(component_type_dict))),
tuple(component_type_dict.keys()),
as_dict=1,
)
for d in entry:
employee = {"employee": d.employee, "employee_name": d.employee_name, "amount": d.amount}
data.append(employee)
return data

View File

@ -1,7 +0,0 @@
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
/* eslint-disable */
frappe.require("assets/erpnext/js/salary_slip_deductions_report_filters.js", function() {
frappe.query_reports["Provident Fund Deductions"] = erpnext.salary_slip_deductions_report_filters;
});

View File

@ -1,20 +0,0 @@
{
"add_total_row": 0,
"creation": "2020-06-01 23:44:07.919117",
"disable_prepared_report": 0,
"disabled": 0,
"docstatus": 0,
"doctype": "Report",
"idx": 0,
"is_standard": "Yes",
"modified": "2020-06-16 18:54:19.305763",
"modified_by": "Administrator",
"module": "Regional",
"name": "Provident Fund Deductions",
"owner": "Administrator",
"prepared_report": 0,
"ref_doctype": "Salary Slip",
"report_name": "Provident Fund Deductions",
"report_type": "Script Report",
"roles": []
}

View File

@ -1,174 +0,0 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
import frappe
from frappe import _
from frappe.utils import getdate
def execute(filters=None):
data = get_data(filters)
columns = get_columns(filters) if len(data) else []
return columns, data
def get_columns(filters):
columns = [
{
"label": _("Employee"),
"options": "Employee",
"fieldname": "employee",
"fieldtype": "Link",
"width": 200,
},
{
"label": _("Employee Name"),
"options": "Employee",
"fieldname": "employee_name",
"fieldtype": "Link",
"width": 160,
},
{"label": _("PF Account"), "fieldname": "pf_account", "fieldtype": "Data", "width": 140},
{"label": _("PF Amount"), "fieldname": "pf_amount", "fieldtype": "Currency", "width": 140},
{
"label": _("Additional PF"),
"fieldname": "additional_pf",
"fieldtype": "Currency",
"width": 140,
},
{"label": _("PF Loan"), "fieldname": "pf_loan", "fieldtype": "Currency", "width": 140},
{"label": _("Total"), "fieldname": "total", "fieldtype": "Currency", "width": 140},
]
return columns
def get_conditions(filters):
conditions = [""]
if filters.get("department"):
conditions.append("sal.department = '%s' " % (filters["department"]))
if filters.get("branch"):
conditions.append("sal.branch = '%s' " % (filters["branch"]))
if filters.get("company"):
conditions.append("sal.company = '%s' " % (filters["company"]))
if filters.get("month"):
conditions.append("month(sal.start_date) = '%s' " % (filters["month"]))
if filters.get("year"):
conditions.append("year(start_date) = '%s' " % (filters["year"]))
if filters.get("mode_of_payment"):
conditions.append("sal.mode_of_payment = '%s' " % (filters["mode_of_payment"]))
return " and ".join(conditions)
def prepare_data(entry, component_type_dict):
data_list = {}
employee_account_dict = frappe._dict(
frappe.db.sql(""" select name, provident_fund_account from `tabEmployee`""")
)
for d in entry:
component_type = component_type_dict.get(d.salary_component)
if data_list.get(d.name):
data_list[d.name][component_type] = d.amount
else:
data_list.setdefault(
d.name,
{
"employee": d.employee,
"employee_name": d.employee_name,
"pf_account": employee_account_dict.get(d.employee),
component_type: d.amount,
},
)
return data_list
def get_data(filters):
data = []
conditions = get_conditions(filters)
salary_slips = frappe.db.sql(
""" select sal.name from `tabSalary Slip` sal
where docstatus = 1 %s
"""
% (conditions),
as_dict=1,
)
component_type_dict = frappe._dict(
frappe.db.sql(
""" select name, component_type from `tabSalary Component`
where component_type in ('Provident Fund', 'Additional Provident Fund', 'Provident Fund Loan')"""
)
)
if not len(component_type_dict):
return []
entry = frappe.db.sql(
""" select sal.name, sal.employee, sal.employee_name, ded.salary_component, ded.amount
from `tabSalary Slip` sal, `tabSalary Detail` ded
where sal.name = ded.parent
and ded.parentfield = 'deductions'
and ded.parenttype = 'Salary Slip'
and sal.docstatus = 1 %s
and ded.salary_component in (%s)
"""
% (conditions, ", ".join(["%s"] * len(component_type_dict))),
tuple(component_type_dict.keys()),
as_dict=1,
)
data_list = prepare_data(entry, component_type_dict)
for d in salary_slips:
total = 0
if data_list.get(d.name):
employee = {
"employee": data_list.get(d.name).get("employee"),
"employee_name": data_list.get(d.name).get("employee_name"),
"pf_account": data_list.get(d.name).get("pf_account"),
}
if data_list.get(d.name).get("Provident Fund"):
employee["pf_amount"] = data_list.get(d.name).get("Provident Fund")
total += data_list.get(d.name).get("Provident Fund")
if data_list.get(d.name).get("Additional Provident Fund"):
employee["additional_pf"] = data_list.get(d.name).get("Additional Provident Fund")
total += data_list.get(d.name).get("Additional Provident Fund")
if data_list.get(d.name).get("Provident Fund Loan"):
employee["pf_loan"] = data_list.get(d.name).get("Provident Fund Loan")
total += data_list.get(d.name).get("Provident Fund Loan")
employee["total"] = total
data.append(employee)
return data
@frappe.whitelist()
def get_years():
year_list = frappe.db.sql_list(
"""select distinct YEAR(end_date) from `tabSalary Slip` ORDER BY YEAR(end_date) DESC"""
)
if not year_list:
year_list = [getdate().year]
return "\n".join(str(year) for year in year_list)

View File

@ -5,7 +5,6 @@
import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
from frappe.permissions import add_permission, update_permission_property
from erpnext.payroll.doctype.gratuity_rule.gratuity_rule import get_gratuity_rule
def setup(company=None, patch=True):
@ -13,7 +12,6 @@ def setup(company=None, patch=True):
add_print_formats()
add_custom_roles_for_reports()
add_permissions()
create_gratuity_rule()
def make_custom_fields():
@ -278,66 +276,3 @@ def add_permissions():
add_permission(doctype, role, 0)
update_permission_property(doctype, role, 0, "write", 1)
update_permission_property(doctype, role, 0, "create", 1)
def create_gratuity_rule():
rule_1 = rule_2 = rule_3 = None
# Rule Under Limited Contract
slabs = get_slab_for_limited_contract()
if not frappe.db.exists("Gratuity Rule", "Rule Under Limited Contract (UAE)"):
rule_1 = get_gratuity_rule(
"Rule Under Limited Contract (UAE)",
slabs,
calculate_gratuity_amount_based_on="Sum of all previous slabs",
)
# Rule Under Unlimited Contract on termination
slabs = get_slab_for_unlimited_contract_on_termination()
if not frappe.db.exists("Gratuity Rule", "Rule Under Unlimited Contract on termination (UAE)"):
rule_2 = get_gratuity_rule("Rule Under Unlimited Contract on termination (UAE)", slabs)
# Rule Under Unlimited Contract on resignation
slabs = get_slab_for_unlimited_contract_on_resignation()
if not frappe.db.exists("Gratuity Rule", "Rule Under Unlimited Contract on resignation (UAE)"):
rule_3 = get_gratuity_rule("Rule Under Unlimited Contract on resignation (UAE)", slabs)
# for applicable salary component user need to set this by its own
if rule_1:
rule_1.flags.ignore_mandatory = True
rule_1.save()
if rule_2:
rule_2.flags.ignore_mandatory = True
rule_2.save()
if rule_3:
rule_3.flags.ignore_mandatory = True
rule_3.save()
def get_slab_for_limited_contract():
return [
{"from_year": 0, "to_year": 1, "fraction_of_applicable_earnings": 0},
{"from_year": 1, "to_year": 5, "fraction_of_applicable_earnings": 21 / 30},
{"from_year": 5, "to_year": 0, "fraction_of_applicable_earnings": 1},
]
def get_slab_for_unlimited_contract_on_termination():
return [
{"from_year": 0, "to_year": 1, "fraction_of_applicable_earnings": 0},
{"from_year": 1, "to_year": 5, "fraction_of_applicable_earnings": 21 / 30},
{"from_year": 5, "to_year": 0, "fraction_of_applicable_earnings": 1},
]
def get_slab_for_unlimited_contract_on_resignation():
fraction_1 = 1 / 3 * 21 / 30
fraction_2 = 2 / 3 * 21 / 30
fraction_3 = 21 / 30
return [
{"from_year": 0, "to_year": 1, "fraction_of_applicable_earnings": 0},
{"from_year": 1, "to_year": 3, "fraction_of_applicable_earnings": fraction_1},
{"from_year": 3, "to_year": 5, "fraction_of_applicable_earnings": fraction_2},
{"from_year": 5, "to_year": 0, "fraction_of_applicable_earnings": fraction_3},
]