-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added regional reports Provident Fund Deductions and Professional Tax Deductions - Added helper js file `salary_slip_deductions_report_filters.js` - Added custom field setups and gratuity rules setups for UAE and India - Hook for setting up company fixtures and regional setups on company update if country has changed
- Loading branch information
1 parent
6f9ef74
commit 7f6a194
Showing
18 changed files
with
854 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright (c) 2022, Frappe Technologies Pvt. Ltd. and Contributors | ||
# License: GNU General Public License v3. See license.txt | ||
|
||
import json | ||
|
||
import frappe | ||
from frappe import _ | ||
|
||
|
||
def make_company_fixtures(doc, method=None): | ||
if not frappe.flags.country_change: | ||
return | ||
|
||
run_regional_setup(doc.company, doc.country) | ||
make_salary_components(doc.country) | ||
|
||
|
||
def run_regional_setup(company, country): | ||
company = company or frappe.db.get_value("Global Defaults", None, "default_company") | ||
|
||
try: | ||
module_name = f"hrms.regional.{frappe.scrub(country)}.setup.setup" | ||
frappe.get_attr(module_name)(company, False) | ||
except ImportError: | ||
pass | ||
except Exception: | ||
frappe.log_error("Unable to setup country fixtures for HRMS") | ||
frappe.throw( | ||
_("Failed to setup defaults for country {0}. Please contact support.").format( | ||
frappe.bold(country) | ||
) | ||
) | ||
|
||
|
||
def make_salary_components(country): | ||
docs = [] | ||
|
||
file_name = "salary_components.json" | ||
file_path = frappe.get_app_path("hrms", "payroll", "data", file_name) | ||
docs.extend(json.loads(read_data_file(file_path))) | ||
|
||
file_path = frappe.get_app_path("hrms", "regional", frappe.scrub(country), "data", file_name) | ||
docs.extend(json.loads(read_data_file(file_path))) | ||
|
||
for d in docs: | ||
try: | ||
doc = frappe.get_doc(d) | ||
doc.flags.ignore_permissions = True | ||
doc.insert(ignore_if_duplicate=True) | ||
except frappe.NameError: | ||
frappe.clear_messages() | ||
except frappe.DuplicateEntryError: | ||
frappe.clear_messages() | ||
|
||
|
||
def read_data_file(file_path): | ||
try: | ||
with open(file_path, "r") as f: | ||
return f.read() | ||
except IOError: | ||
return "{}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[ | ||
{ | ||
"doctype": "Salary Component", | ||
"salary_component": "Income Tax", | ||
"description": "Income Tax", | ||
"type": "Deduction", | ||
"is_income_tax_component": 1 | ||
}, | ||
{ | ||
"doctype": "Salary Component", | ||
"salary_component": "Basic", | ||
"description": "Basic", | ||
"type": "Earning" | ||
}, | ||
{ | ||
"doctype": "Salary Component", | ||
"salary_component": "Arrear", | ||
"description": "Arrear", | ||
"type": "Earning" | ||
}, | ||
{ | ||
"doctype": "Salary Component", | ||
"salary_component": "Leave Encashment", | ||
"description": "Leave Encashment", | ||
"type": "Earning" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
7 changes: 7 additions & 0 deletions
7
hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors | ||
// For license information, please see license.txt | ||
/* eslint-disable */ | ||
|
||
frappe.require("assets/hrms/js/salary_slip_deductions_report_filters.js", function() { | ||
frappe.query_reports["Professional Tax Deductions"] = hrms.salary_slip_deductions_report_filters; | ||
}); |
20 changes: 20 additions & 0 deletions
20
hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"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": "2022-06-26 19:02:26.306348", | ||
"modified_by": "Administrator", | ||
"module": "Payroll", | ||
"name": "Professional Tax Deductions", | ||
"owner": "Administrator", | ||
"prepared_report": 0, | ||
"ref_doctype": "Salary Slip", | ||
"report_name": "Professional Tax Deductions", | ||
"report_type": "Script Report", | ||
"roles": [] | ||
} |
76 changes: 76 additions & 0 deletions
76
hrms/payroll/report/professional_tax_deductions/professional_tax_deductions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors | ||
# For license information, please see license.txt | ||
|
||
|
||
import frappe | ||
from frappe import _ | ||
|
||
from hrms.payroll.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 |
Empty file.
7 changes: 7 additions & 0 deletions
7
hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors | ||
// For license information, please see license.txt | ||
/* eslint-disable */ | ||
|
||
frappe.require("assets/hrms/js/salary_slip_deductions_report_filters.js", function() { | ||
frappe.query_reports["Provident Fund Deductions"] = hrms.salary_slip_deductions_report_filters; | ||
}); |
20 changes: 20 additions & 0 deletions
20
hrms/payroll/report/provident_fund_deductions/provident_fund_deductions.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"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": "2022-06-26 18:54:19.305763", | ||
"modified_by": "Administrator", | ||
"module": "Payroll", | ||
"name": "Provident Fund Deductions", | ||
"owner": "Administrator", | ||
"prepared_report": 0, | ||
"ref_doctype": "Salary Slip", | ||
"report_name": "Provident Fund Deductions", | ||
"report_type": "Script Report", | ||
"roles": [] | ||
} |
Oops, something went wrong.