|
|
@ -61,6 +61,7 @@ def get_data(conditions, filters): |
|
|
|
IF(so.status in ('Completed','To Bill'), 0, (SELECT delay_days)) as delay, |
|
|
|
soi.qty, soi.delivered_qty, |
|
|
|
(soi.qty - soi.delivered_qty) AS pending_qty, |
|
|
|
IF((SELECT pending_qty) = 0, DATEDIFF(Max(dn.posting_date), so.transaction_date), 0) as time_taken_to_deliver, |
|
|
|
IFNULL(SUM(sii.qty), 0) as billed_qty, |
|
|
|
soi.base_amount as amount, |
|
|
|
(soi.delivered_qty * soi.base_rate) as delivered_qty_amount, |
|
|
@ -70,9 +71,13 @@ def get_data(conditions, filters): |
|
|
|
so.company, soi.name |
|
|
|
FROM |
|
|
|
`tabSales Order` so, |
|
|
|
`tabSales Order Item` soi |
|
|
|
(`tabSales Order Item` soi |
|
|
|
LEFT JOIN `tabSales Invoice Item` sii |
|
|
|
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 |
|
|
|
on dni.so_detail = soi.name |
|
|
|
RIGHT JOIN `tabDelivery Note` dn |
|
|
|
on dni.parent = dn.name and dn.docstatus = 1 |
|
|
|
WHERE |
|
|
|
soi.parent = so.name |
|
|
|
and so.status not in ('Stopped', 'Closed', 'On Hold') |
|
|
@ -259,6 +264,12 @@ def get_columns(filters): |
|
|
|
"fieldname": "delay", |
|
|
|
"fieldtype": "Data", |
|
|
|
"width": 100 |
|
|
|
}, |
|
|
|
{ |
|
|
|
"label": _("Time Taken to Deliver"), |
|
|
|
"fieldname": "time_taken_to_deliver", |
|
|
|
"fieldtype": "Data", |
|
|
|
"width": 100 |
|
|
|
} |
|
|
|
]) |
|
|
|
if not filters.get("group_by_so"): |
|
|
|