Fix: if there is no component

This commit is contained in:
Anurag Mishra
2020-06-23 11:49:47 +05:30
parent d0d9b53361
commit f9ca29cebd
4 changed files with 37 additions and 12 deletions

View File

@@ -6,8 +6,8 @@ import frappe, erpnext
from frappe import _
def execute(filters=None):
columns = get_columns(filters)
data = get_data(filters)
columns = get_columns(filters) if len(data) else []
return columns, data
@@ -78,8 +78,11 @@ def get_conditions(filters):
if filters.get("company"):
conditions.append("sal.company = '%s' " % (filters["company"]) )
if filters.get("period"):
conditions.append("month(sal.start_date) = '%s' " % (filters["period"]))
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"]))
return " and ".join(conditions)
@@ -96,6 +99,9 @@ def get_data(filters):
component_types = [comp_type[0] for comp_type in component_types]
if not len(component_types):
return []
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

View File

@@ -84,9 +84,11 @@ def get_conditions(filters):
if filters.get("company"):
conditions.append("company = '%s' " % (filters["company"]) )
if filters.get("period"):
conditions.append("month(start_date) = '%s' " % (filters["period"]))
conditions.append("year(start_date) = '%s' " % (frappe.utils.getdate().year))
if filters.get("month"):
conditions.append("month(start_date) = '%s' " % (filters["month"]))
if filters.get("year"):
conditions.append("year(start_date) = '%s' " % (filters["year"]))
return " and ".join(conditions)