feat(Supplier Scorecard): added method for invoiced quantity in supplier scorecard (#37580)
feat(Supplier Scorecard): added method for invoiced quantity in supplier scorecard
Co-authored-by: vishnu <vishnuviswambara2002@gmail.com>
diff --git a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py
index 6e22acf..683a12a 100644
--- a/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py
+++ b/erpnext/buying/doctype/supplier_scorecard/supplier_scorecard.py
@@ -334,6 +334,11 @@
"variable_label": "Total Ordered",
"path": "get_ordered_qty",
},
+ {
+ "param_name": "total_invoiced",
+ "variable_label": "Total Invoiced",
+ "path": "get_invoiced_qty",
+ },
]
install_standing_docs = [
{
diff --git a/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.py b/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.py
index 4080d1f..6c91a04 100644
--- a/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.py
+++ b/erpnext/buying/doctype/supplier_scorecard_variable/supplier_scorecard_variable.py
@@ -440,6 +440,23 @@
).run(as_list=True)[0][0] or 0
+def get_invoiced_qty(scorecard):
+ """Returns the total number of invoiced quantity (based on Purchase Invoice)"""
+
+ pi = frappe.qb.DocType("Purchase Invoice")
+
+ return (
+ frappe.qb.from_(pi)
+ .select(Sum(pi.total_qty))
+ .where(
+ (pi.supplier == scorecard.supplier)
+ & (pi.docstatus == 1)
+ & (pi.posting_date >= scorecard.get("start_date"))
+ & (pi.posting_date <= scorecard.get("end_date"))
+ )
+ ).run(as_list=True)[0][0] or 0
+
+
def get_rfq_total_number(scorecard):
"""Gets the total number of RFQs sent to supplier"""
supplier = frappe.get_doc("Supplier", scorecard.supplier)