feat: add method for ordered quantity in supplier scorecard (#35930)
fix: add method for getting ordered quantity in the supplier scorecard variable. Co-authored-by: vishnu <vishnuviswambara2002@gmail.com>
This commit is contained in:
parent
ab58c01a0f
commit
e05b33a6c2
@ -329,6 +329,11 @@ def make_default_records():
|
|||||||
"variable_label": "Total Shipments",
|
"variable_label": "Total Shipments",
|
||||||
"path": "get_total_shipments",
|
"path": "get_total_shipments",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"param_name": "total_ordered",
|
||||||
|
"variable_label": "Total Ordered",
|
||||||
|
"path": "get_ordered_qty",
|
||||||
|
},
|
||||||
]
|
]
|
||||||
install_standing_docs = [
|
install_standing_docs = [
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ import sys
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from frappe.query_builder.functions import Sum
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate
|
||||||
|
|
||||||
|
|
||||||
@ -422,6 +423,23 @@ def get_total_shipments(scorecard):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def get_ordered_qty(scorecard):
|
||||||
|
"""Returns the total number of ordered quantity (based on Purchase Orders)"""
|
||||||
|
|
||||||
|
po = frappe.qb.DocType("Purchase Order")
|
||||||
|
|
||||||
|
return (
|
||||||
|
frappe.qb.from_(po)
|
||||||
|
.select(Sum(po.total_qty))
|
||||||
|
.where(
|
||||||
|
(po.supplier == scorecard.supplier)
|
||||||
|
& (po.docstatus == 1)
|
||||||
|
& (po.transaction_date >= scorecard.get("start_date"))
|
||||||
|
& (po.transaction_date <= scorecard.get("end_date"))
|
||||||
|
)
|
||||||
|
).run(as_list=True)[0][0] or 0
|
||||||
|
|
||||||
|
|
||||||
def get_rfq_total_number(scorecard):
|
def get_rfq_total_number(scorecard):
|
||||||
"""Gets the total number of RFQs sent to supplier"""
|
"""Gets the total number of RFQs sent to supplier"""
|
||||||
supplier = frappe.get_doc("Supplier", scorecard.supplier)
|
supplier = frappe.get_doc("Supplier", scorecard.supplier)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user