mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-23 15:09:20 +00:00
chore: Remove conflicts from Sales Order Analysis report (#30761)
* fix: Remove conflicts from Sales Order Analysis report * fix: change field to duration and fetch elapsed seconds * chore: Ignore linting check for sql query
This commit is contained in:
@@ -54,6 +54,7 @@ def get_conditions(filters):
|
|||||||
|
|
||||||
|
|
||||||
def get_data(conditions, filters):
|
def get_data(conditions, filters):
|
||||||
|
# nosemgrep
|
||||||
data = frappe.db.sql(
|
data = frappe.db.sql(
|
||||||
"""
|
"""
|
||||||
SELECT
|
SELECT
|
||||||
@@ -65,6 +66,7 @@ def get_data(conditions, filters):
|
|||||||
IF(so.status in ('Completed','To Bill'), 0, (SELECT delay_days)) as delay,
|
IF(so.status in ('Completed','To Bill'), 0, (SELECT delay_days)) as delay,
|
||||||
soi.qty, soi.delivered_qty,
|
soi.qty, soi.delivered_qty,
|
||||||
(soi.qty - soi.delivered_qty) AS pending_qty,
|
(soi.qty - soi.delivered_qty) AS pending_qty,
|
||||||
|
IF((SELECT pending_qty) = 0, (TO_SECONDS(Max(dn.posting_date))-TO_SECONDS(so.transaction_date)), 0) as time_taken_to_deliver,
|
||||||
IFNULL(SUM(sii.qty), 0) as billed_qty,
|
IFNULL(SUM(sii.qty), 0) as billed_qty,
|
||||||
soi.base_amount as amount,
|
soi.base_amount as amount,
|
||||||
(soi.delivered_qty * soi.base_rate) as delivered_qty_amount,
|
(soi.delivered_qty * soi.base_rate) as delivered_qty_amount,
|
||||||
@@ -75,17 +77,13 @@ def get_data(conditions, filters):
|
|||||||
soi.description as description
|
soi.description as description
|
||||||
FROM
|
FROM
|
||||||
`tabSales Order` so,
|
`tabSales Order` so,
|
||||||
`tabSales Order Item` soi
|
(`tabSales Order Item` soi
|
||||||
LEFT JOIN `tabSales Invoice Item` sii
|
LEFT JOIN `tabSales Invoice Item` sii
|
||||||
<<<<<<< HEAD
|
|
||||||
ON sii.so_detail = soi.name and sii.docstatus = 1
|
|
||||||
=======
|
|
||||||
ON sii.so_detail = soi.name and sii.docstatus = 1)
|
ON sii.so_detail = soi.name and sii.docstatus = 1)
|
||||||
LEFT JOIN `tabDelivery Note Item` dni
|
LEFT JOIN `tabDelivery Note Item` dni
|
||||||
on dni.so_detail = soi.name
|
on dni.so_detail = soi.name
|
||||||
LEFT JOIN `tabDelivery Note` dn
|
LEFT JOIN `tabDelivery Note` dn
|
||||||
on dni.parent = dn.name and dn.docstatus = 1
|
on dni.parent = dn.name and dn.docstatus = 1
|
||||||
>>>>>>> e28e6726f1 (fix: SO analysis rpt will fetch SO's without Delivery note as well)
|
|
||||||
WHERE
|
WHERE
|
||||||
soi.parent = so.name
|
soi.parent = so.name
|
||||||
and so.status not in ('Stopped', 'Closed', 'On Hold')
|
and so.status not in ('Stopped', 'Closed', 'On Hold')
|
||||||
@@ -272,6 +270,12 @@ def get_columns(filters):
|
|||||||
},
|
},
|
||||||
{"label": _("Delivery Date"), "fieldname": "delivery_date", "fieldtype": "Date", "width": 120},
|
{"label": _("Delivery Date"), "fieldname": "delivery_date", "fieldtype": "Date", "width": 120},
|
||||||
{"label": _("Delay (in Days)"), "fieldname": "delay", "fieldtype": "Data", "width": 100},
|
{"label": _("Delay (in Days)"), "fieldname": "delay", "fieldtype": "Data", "width": 100},
|
||||||
|
{
|
||||||
|
"label": _("Time Taken to Deliver"),
|
||||||
|
"fieldname": "time_taken_to_deliver",
|
||||||
|
"fieldtype": "Duration",
|
||||||
|
"width": 100,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
if not filters.get("group_by_so"):
|
if not filters.get("group_by_so"):
|
||||||
|
|||||||
Reference in New Issue
Block a user