enhancement: Item-wise sales history report (#19500)

* refactor(item-wise-sales-history): convert query report to script report

* refactor: add columns, fetch data

* refactor: shift company set func to utils

* fix: add filters

* fix: minor changes

* fix: fetch all the descendants
This commit is contained in:
Mangesh-Khairnar
2019-11-11 10:54:12 +05:30
committed by Nabin Hait
parent 090f9a3dc9
commit 2f44480d69
4 changed files with 272 additions and 33 deletions

View File

@@ -7,6 +7,7 @@ import frappe
from frappe.model.document import Document
from frappe import _
from frappe.utils import getdate, nowdate, cint, flt
from frappe.utils.nestedset import get_descendants_of
class SubsidiaryCompanyError(frappe.ValidationError): pass
class ParentCompanyError(frappe.ValidationError): pass
@@ -131,7 +132,8 @@ def get_designation_counts(designation, company):
return False
employee_counts = {}
company_set = get_company_set(company)
company_set = get_descendants_of('Company', company)
company_set.append(company)
employee_counts["employee_count"] = frappe.db.get_value("Employee",
filters={
@@ -167,14 +169,4 @@ def get_active_staffing_plan_details(company, designation, from_date=getdate(now
designation, from_date, to_date)
# Only a single staffing plan can be active for a designation on given date
return staffing_plan if staffing_plan else None
def get_company_set(company):
return frappe.db.sql_list("""
SELECT
name
FROM `tabCompany`
WHERE
parent_company=%(company)s
OR name=%(company)s
""", (dict(company=company)))
return staffing_plan if staffing_plan else None