* feat: added year filters (cherry picked from commit d0d9b53361c57d362e7e975f16b48ccbfdc021a8) * Fix: if there is no component (cherry picked from commit f9ca29cebd0a0963ec58b8971283d7e0d2868f2b) * fix: test_tax_for_payroll_period (cherry picked from commit ece9508eb5a02962a994fbaad0e989e323d3f56c) Co-authored-by: Anurag Mishra <mishranaman123@gmail.com>
This commit is contained in:
parent
7813cabfd3
commit
dca65de1b6
@ -271,6 +271,7 @@ class TestSalarySlip(unittest.TestCase):
|
|||||||
# as per assigned salary structure 40500 in monthly salary so 236000*5/100/12
|
# as per assigned salary structure 40500 in monthly salary so 236000*5/100/12
|
||||||
frappe.db.sql("""delete from `tabPayroll Period`""")
|
frappe.db.sql("""delete from `tabPayroll Period`""")
|
||||||
frappe.db.sql("""delete from `tabSalary Component`""")
|
frappe.db.sql("""delete from `tabSalary Component`""")
|
||||||
|
frappe.db.sql("""delete from `tabAdditional Salary`""")
|
||||||
|
|
||||||
payroll_period = create_payroll_period()
|
payroll_period = create_payroll_period()
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ import frappe, erpnext
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
columns = get_columns(filters)
|
|
||||||
data = get_data(filters)
|
data = get_data(filters)
|
||||||
|
columns = get_columns(filters) if len(data) else []
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
@ -78,8 +78,11 @@ def get_conditions(filters):
|
|||||||
if filters.get("company"):
|
if filters.get("company"):
|
||||||
conditions.append("sal.company = '%s' " % (filters["company"]) )
|
conditions.append("sal.company = '%s' " % (filters["company"]) )
|
||||||
|
|
||||||
if filters.get("period"):
|
if filters.get("month"):
|
||||||
conditions.append("month(sal.start_date) = '%s' " % (filters["period"]))
|
conditions.append("month(sal.start_date) = '%s' " % (filters["month"]))
|
||||||
|
|
||||||
|
if filters.get("year"):
|
||||||
|
conditions.append("year(start_date) = '%s' " % (filters["year"]))
|
||||||
|
|
||||||
return " and ".join(conditions)
|
return " and ".join(conditions)
|
||||||
|
|
||||||
@ -96,6 +99,9 @@ def get_data(filters):
|
|||||||
|
|
||||||
component_types = [comp_type[0] for comp_type in component_types]
|
component_types = [comp_type[0] for comp_type in component_types]
|
||||||
|
|
||||||
|
if not len(component_types):
|
||||||
|
return []
|
||||||
|
|
||||||
conditions = get_conditions(filters)
|
conditions = get_conditions(filters)
|
||||||
|
|
||||||
entry = frappe.db.sql(""" select sal.employee, sal.employee_name, sal.posting_date, ded.salary_component, ded.amount,sal.gross_pay
|
entry = frappe.db.sql(""" select sal.employee, sal.employee_name, sal.posting_date, ded.salary_component, ded.amount,sal.gross_pay
|
||||||
|
@ -84,9 +84,11 @@ def get_conditions(filters):
|
|||||||
if filters.get("company"):
|
if filters.get("company"):
|
||||||
conditions.append("company = '%s' " % (filters["company"]) )
|
conditions.append("company = '%s' " % (filters["company"]) )
|
||||||
|
|
||||||
if filters.get("period"):
|
if filters.get("month"):
|
||||||
conditions.append("month(start_date) = '%s' " % (filters["period"]))
|
conditions.append("month(start_date) = '%s' " % (filters["month"]))
|
||||||
conditions.append("year(start_date) = '%s' " % (frappe.utils.getdate().year))
|
|
||||||
|
if filters.get("year"):
|
||||||
|
conditions.append("year(start_date) = '%s' " % (filters["year"]))
|
||||||
|
|
||||||
return " and ".join(conditions)
|
return " and ".join(conditions)
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ erpnext.salary_slip_deductions_report_filters = {
|
|||||||
default: frappe.defaults.get_user_default("Company"),
|
default: frappe.defaults.get_user_default("Company"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
fieldname: "period",
|
fieldname: "month",
|
||||||
label: __("Period"),
|
label: __("Month"),
|
||||||
fieldtype: "Select",
|
fieldtype: "Select",
|
||||||
reqd: 1 ,
|
reqd: 1 ,
|
||||||
options: [
|
options: [
|
||||||
@ -31,6 +31,12 @@ erpnext.salary_slip_deductions_report_filters = {
|
|||||||
],
|
],
|
||||||
default: frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth() + 1
|
default: frappe.datetime.str_to_obj(frappe.datetime.get_today()).getMonth() + 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fieldname:"year",
|
||||||
|
label: __("Year"),
|
||||||
|
fieldtype: "Select",
|
||||||
|
reqd: 1
|
||||||
|
},
|
||||||
{
|
{
|
||||||
fieldname: "department",
|
fieldname: "department",
|
||||||
label: __("Department"),
|
label: __("Department"),
|
||||||
@ -43,5 +49,18 @@ erpnext.salary_slip_deductions_report_filters = {
|
|||||||
fieldtype: "Link",
|
fieldtype: "Link",
|
||||||
options: "Branch",
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
@ -7,8 +7,8 @@ from frappe import _
|
|||||||
from erpnext.regional.report.provident_fund_deductions.provident_fund_deductions import get_conditions
|
from erpnext.regional.report.provident_fund_deductions.provident_fund_deductions import get_conditions
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
columns = get_columns(filters)
|
|
||||||
data = get_data(filters)
|
data = get_data(filters)
|
||||||
|
columns = get_columns(filters) if len(data) else []
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
@ -45,6 +45,9 @@ def get_data(filters):
|
|||||||
component_type_dict = frappe._dict(frappe.db.sql(""" select name, component_type from `tabSalary Component`
|
component_type_dict = frappe._dict(frappe.db.sql(""" select name, component_type from `tabSalary Component`
|
||||||
where component_type = 'Professional Tax' """))
|
where component_type = 'Professional Tax' """))
|
||||||
|
|
||||||
|
if not len(component_type_dict):
|
||||||
|
return []
|
||||||
|
|
||||||
conditions = get_conditions(filters)
|
conditions = get_conditions(filters)
|
||||||
|
|
||||||
entry = frappe.db.sql(""" select sal.employee, sal.employee_name, ded.salary_component, ded.amount
|
entry = frappe.db.sql(""" select sal.employee, sal.employee_name, ded.salary_component, ded.amount
|
||||||
|
@ -3,11 +3,12 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
|
from frappe.utils import getdate
|
||||||
from frappe import _
|
from frappe import _
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
columns = get_columns(filters)
|
|
||||||
data = get_data(filters)
|
data = get_data(filters)
|
||||||
|
columns = get_columns(filters) if len(data) else []
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
@ -71,10 +72,13 @@ def get_conditions(filters):
|
|||||||
conditions.append("sal.branch = '%s' " % (filters["branch"]) )
|
conditions.append("sal.branch = '%s' " % (filters["branch"]) )
|
||||||
|
|
||||||
if filters.get("company"):
|
if filters.get("company"):
|
||||||
conditions.append("sal.company = '%s' " % (filters["company"]) )
|
conditions.append("sal.company = '%s' " % (filters["company"]))
|
||||||
|
|
||||||
if filters.get("period"):
|
if filters.get("month"):
|
||||||
conditions.append("month(sal.start_date) = '%s' " % (filters["period"]))
|
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"):
|
if filters.get("mode_of_payment"):
|
||||||
conditions.append("sal.mode_of_payment = '%s' " % (filters["mode_of_payment"]))
|
conditions.append("sal.mode_of_payment = '%s' " % (filters["mode_of_payment"]))
|
||||||
@ -114,6 +118,9 @@ def get_data(filters):
|
|||||||
component_type_dict = frappe._dict(frappe.db.sql(""" select name, component_type from `tabSalary Component`
|
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')"""))
|
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
|
entry = frappe.db.sql(""" select sal.name, sal.employee, sal.employee_name, ded.salary_component, ded.amount
|
||||||
from `tabSalary Slip` sal, `tabSalary Detail` ded
|
from `tabSalary Slip` sal, `tabSalary Detail` ded
|
||||||
where sal.name = ded.parent
|
where sal.name = ded.parent
|
||||||
@ -150,4 +157,12 @@ def get_data(filters):
|
|||||||
|
|
||||||
data.append(employee)
|
data.append(employee)
|
||||||
|
|
||||||
return data
|
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)
|
Loading…
x
Reference in New Issue
Block a user