mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-22 03:35:43 +00:00
fix: Billed Qty and Qty to Bill Calculation in Purchase Order Analysis (#42100)
(cherry picked from commit 0c76a8cc9e)
Co-authored-by: Nihantra C. Patel <141945075+Nihantra-Patel@users.noreply.github.com>
This commit is contained in:
@@ -39,6 +39,7 @@ def validate_filters(filters):
|
|||||||
def get_data(filters):
|
def get_data(filters):
|
||||||
po = frappe.qb.DocType("Purchase Order")
|
po = frappe.qb.DocType("Purchase Order")
|
||||||
po_item = frappe.qb.DocType("Purchase Order Item")
|
po_item = frappe.qb.DocType("Purchase Order Item")
|
||||||
|
pi = frappe.qb.DocType("Purchase Invoice")
|
||||||
pi_item = frappe.qb.DocType("Purchase Invoice Item")
|
pi_item = frappe.qb.DocType("Purchase Invoice Item")
|
||||||
|
|
||||||
query = (
|
query = (
|
||||||
@@ -46,6 +47,8 @@ def get_data(filters):
|
|||||||
.from_(po_item)
|
.from_(po_item)
|
||||||
.left_join(pi_item)
|
.left_join(pi_item)
|
||||||
.on(pi_item.po_detail == po_item.name)
|
.on(pi_item.po_detail == po_item.name)
|
||||||
|
.left_join(pi)
|
||||||
|
.on(pi.name == pi_item.parent)
|
||||||
.select(
|
.select(
|
||||||
po.transaction_date.as_("date"),
|
po.transaction_date.as_("date"),
|
||||||
po_item.schedule_date.as_("required_date"),
|
po_item.schedule_date.as_("required_date"),
|
||||||
@@ -69,6 +72,7 @@ def get_data(filters):
|
|||||||
po_item.name,
|
po_item.name,
|
||||||
)
|
)
|
||||||
.where((po_item.parent == po.name) & (po.status.notin(("Stopped", "Closed"))) & (po.docstatus == 1))
|
.where((po_item.parent == po.name) & (po.status.notin(("Stopped", "Closed"))) & (po.docstatus == 1))
|
||||||
|
.where(pi.docstatus == 1)
|
||||||
.groupby(po_item.name)
|
.groupby(po_item.name)
|
||||||
.orderby(po.transaction_date)
|
.orderby(po.transaction_date)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user