Merge pull request #31850 from HarryPaulo/add-two-new-filters-gross-profit
feat: two new filters for gross profit
This commit is contained in:
commit
acb88e5c57
@ -38,6 +38,18 @@ frappe.query_reports["Gross Profit"] = {
|
|||||||
"options": "Invoice\nItem Code\nItem Group\nBrand\nWarehouse\nCustomer\nCustomer Group\nTerritory\nSales Person\nProject\nMonthly\nPayment Term",
|
"options": "Invoice\nItem Code\nItem Group\nBrand\nWarehouse\nCustomer\nCustomer Group\nTerritory\nSales Person\nProject\nMonthly\nPayment Term",
|
||||||
"default": "Invoice"
|
"default": "Invoice"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "item_group",
|
||||||
|
"label": __("Item Group"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Item Group"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "sales_person",
|
||||||
|
"label": __("Sales Person"),
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"options": "Sales Person"
|
||||||
|
},
|
||||||
],
|
],
|
||||||
"tree": true,
|
"tree": true,
|
||||||
"name_field": "parent",
|
"name_field": "parent",
|
||||||
|
@ -7,6 +7,7 @@ from frappe import _, scrub
|
|||||||
from frappe.utils import cint, flt, formatdate
|
from frappe.utils import cint, flt, formatdate
|
||||||
|
|
||||||
from erpnext.controllers.queries import get_match_cond
|
from erpnext.controllers.queries import get_match_cond
|
||||||
|
from erpnext.stock.report.stock_ledger.stock_ledger import get_item_group_condition
|
||||||
from erpnext.stock.utils import get_incoming_rate
|
from erpnext.stock.utils import get_incoming_rate
|
||||||
|
|
||||||
|
|
||||||
@ -676,6 +677,17 @@ class GrossProfitGenerator(object):
|
|||||||
if self.filters.to_date:
|
if self.filters.to_date:
|
||||||
conditions += " and posting_date <= %(to_date)s"
|
conditions += " and posting_date <= %(to_date)s"
|
||||||
|
|
||||||
|
if self.filters.item_group:
|
||||||
|
conditions += " and {0}".format(get_item_group_condition(self.filters.item_group))
|
||||||
|
|
||||||
|
if self.filters.sales_person:
|
||||||
|
conditions += """
|
||||||
|
and exists(select 1
|
||||||
|
from `tabSales Team` st
|
||||||
|
where st.parent = `tabSales Invoice`.name
|
||||||
|
and st.sales_person = %(sales_person)s)
|
||||||
|
"""
|
||||||
|
|
||||||
if self.filters.group_by == "Sales Person":
|
if self.filters.group_by == "Sales Person":
|
||||||
sales_person_cols = ", sales.sales_person, sales.allocated_amount, sales.incentives"
|
sales_person_cols = ", sales.sales_person, sales.allocated_amount, sales.incentives"
|
||||||
sales_team_table = "left join `tabSales Team` sales on sales.parent = `tabSales Invoice`.name"
|
sales_team_table = "left join `tabSales Team` sales on sales.parent = `tabSales Invoice`.name"
|
||||||
@ -723,6 +735,7 @@ class GrossProfitGenerator(object):
|
|||||||
from
|
from
|
||||||
`tabSales Invoice` inner join `tabSales Invoice Item`
|
`tabSales Invoice` inner join `tabSales Invoice Item`
|
||||||
on `tabSales Invoice Item`.parent = `tabSales Invoice`.name
|
on `tabSales Invoice Item`.parent = `tabSales Invoice`.name
|
||||||
|
join `tabItem` item on item.name = `tabSales Invoice Item`.item_code
|
||||||
{sales_team_table}
|
{sales_team_table}
|
||||||
{payment_term_table}
|
{payment_term_table}
|
||||||
where
|
where
|
||||||
|
Loading…
Reference in New Issue
Block a user