mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-26 13:25:20 +00:00
Fix: if there is no component
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user