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>
This commit is contained in:
Vishnu VS 2023-10-21 18:04:54 +05:30 committed by GitHub
parent 35020a9423
commit 98cc7434d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -334,6 +334,11 @@ def make_default_records():
"variable_label": "Total Ordered",
"path": "get_ordered_qty",
},
{
"param_name": "total_invoiced",
"variable_label": "Total Invoiced",
"path": "get_invoiced_qty",
},
]
install_standing_docs = [
{

View File

@ -440,6 +440,23 @@ def get_ordered_qty(scorecard):
).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)