Skip to content

Commit

Permalink
feat: add method for ordered quantity in supplier scorecard (#35930)
Browse files Browse the repository at this point in the history
fix: add method for getting ordered quantity in the supplier scorecard variable.

Co-authored-by: vishnu <vishnuviswambara2002@gmail.com>
  • Loading branch information
Vishnu7025 and vishnu authored Jul 3, 2023
1 parent ab58c01 commit e05b33a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ def make_default_records():
"variable_label": "Total Shipments",
"path": "get_total_shipments",
},
{
"param_name": "total_ordered",
"variable_label": "Total Ordered",
"path": "get_ordered_qty",
},
]
install_standing_docs = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.query_builder.functions import Sum
from frappe.utils import getdate


Expand Down Expand Up @@ -422,6 +423,23 @@ def get_total_shipments(scorecard):
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):
"""Gets the total number of RFQs sent to supplier"""
supplier = frappe.get_doc("Supplier", scorecard.supplier)
Expand Down

0 comments on commit e05b33a

Please sign in to comment.