From 69909c0f51a7d8759de85d00247ea804329481f0 Mon Sep 17 00:00:00 2001 From: Mangesh-Khairnar Date: Fri, 29 Mar 2019 20:44:23 +0530 Subject: [PATCH] feat: create procurement tracker report --- .../report/procurement_tracker/__init__.py | 0 .../procurement_tracker.js | 9 + .../procurement_tracker.json | 20 +++ .../procurement_tracker.py | 167 ++++++++++++++++++ 4 files changed, 196 insertions(+) create mode 100644 erpnext/buying/report/procurement_tracker/__init__.py create mode 100644 erpnext/buying/report/procurement_tracker/procurement_tracker.js create mode 100644 erpnext/buying/report/procurement_tracker/procurement_tracker.json create mode 100644 erpnext/buying/report/procurement_tracker/procurement_tracker.py diff --git a/erpnext/buying/report/procurement_tracker/__init__.py b/erpnext/buying/report/procurement_tracker/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/erpnext/buying/report/procurement_tracker/procurement_tracker.js b/erpnext/buying/report/procurement_tracker/procurement_tracker.js new file mode 100644 index 0000000000..7096b9f9f8 --- /dev/null +++ b/erpnext/buying/report/procurement_tracker/procurement_tracker.js @@ -0,0 +1,9 @@ +// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt +/* eslint-disable */ + +frappe.query_reports["Procurement Tracker"] = { + "filters": [ + + ] +} diff --git a/erpnext/buying/report/procurement_tracker/procurement_tracker.json b/erpnext/buying/report/procurement_tracker/procurement_tracker.json new file mode 100644 index 0000000000..028736c7c4 --- /dev/null +++ b/erpnext/buying/report/procurement_tracker/procurement_tracker.json @@ -0,0 +1,20 @@ +{ + "add_total_row": 1, + "creation": "2019-03-29 17:05:45.196949", + "disable_prepared_report": 0, + "disabled": 0, + "docstatus": 0, + "doctype": "Report", + "idx": 0, + "is_standard": "Yes", + "modified": "2019-03-29 17:18:06.678728", + "modified_by": "Administrator", + "module": "Buying", + "name": "Procurement Tracker", + "owner": "Administrator", + "prepared_report": 0, + "ref_doctype": "Purchase Order", + "report_name": "Procurement Tracker", + "report_type": "Script Report", + "roles": [] +} \ No newline at end of file diff --git a/erpnext/buying/report/procurement_tracker/procurement_tracker.py b/erpnext/buying/report/procurement_tracker/procurement_tracker.py new file mode 100644 index 0000000000..ee6fd2d0fb --- /dev/null +++ b/erpnext/buying/report/procurement_tracker/procurement_tracker.py @@ -0,0 +1,167 @@ +# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe import _ +from frappe.utils import cint,cstr + +def execute(filters=None): + columns = get_columns() + data = get_data() + return columns, data + +def get_columns(): + columns = [ + { + "label": _("Date Requisition Received in Procurement "), + "fieldname": "date_requisition_received_in_procurement", + "fieldtype": "Date", + "width": 140 + }, + { + "label": _("Date Requisition was Raised"), + "fieldname": "date_requisition_was_raised", + "fieldtype": "Date", + "width": 140 + }, + { + "label": _("Sector/Project"), + "options": "Cost Center", + "fieldname": "sector/project", + "fieldtype": "Link", + "width": 140 + }, + { + "label": _("Requesting Site"), + "options": "Warehouse", + "fieldname": "requesting_site", + "fieldtype": "Link", + "width": 140 + }, + { + "label": _("Requestor"), + "options": "Employee", + "fieldname": "requestor", + "fieldtype": "Link", + "width": 140 + }, + { + "label": _("Budget Code"), + "options": "Budget", + "fieldname": "budget_code", + "fieldtype": "Link", + "width": 140 + }, + { + "label": _("Requisition Line"), + "options": "Item", + "fieldname": "requisition_line", + "fieldtype": "Link", + "width": 140 + }, + { + "label": _("Description"), + "fieldname": "description", + "fieldtype": "Data", + "width": 200 + }, + { + "label": _("Quantity"), + "fieldname": "quantity", + "fieldtype": "Int", + "width": 140 + }, + { + "label": _("Unit of Measure"), + "options": "UOM", + "fieldname": "unit_of_measurement", + "fieldtype": "Link", + "width": 140 + }, + { + "label": _("Status"), + "fieldname": "status", + "fieldtype": "data", + "width": 140 + }, + { + "label": _("Purchase Order Date"), + "fieldname": "purchase_order_date", + "fieldtype": "Date", + "width": 140 + }, + { + "label": _("Purchase Order"), + "options": "Purchase Order", + "fieldname": "purchase_order", + "fieldtype": "Link", + "width": 140 + }, + { + "label": _("Supplier"), + "options": "Supplier", + "fieldname": "supplier", + "fieldtype": "Link", + "width": 140 + }, + { + "label": _("Estimated Cost"), + "fieldname": "estimated_cost", + "fieldtype": "Float", + "width": 140 + }, + { + "label": _("Actual Cost"), + "fieldname": "actual_cost", + "fieldtype": "Float", + "width": 140 + }, + { + "label": _("Purchase Order Amount"), + "fieldname": "purchase_order_amount", + "fieldtype": "Float", + "width": 140 + }, + { + "label": _("Purchase Order Amount(USD)"), + "fieldname": "purchase_order_amount_usd", + "fieldtype": "Float", + "width": 140 + }, + { + "label": _("Expected Delivery Date"), + "fieldname": "expected_delivery_date", + "fieldtype": "Date", + "width": 140 + }, + { + "label": _("Actual Delivery Date"), + "fieldname": "actual_delivery_date", + "fieldtype": "Date", + "width": 140 + }, + ] + return columns + +def get_data(): + purchase_order_entry = frappe.db.sql(""" + SELECT + po_item.item_code, + po_item.item_name, + po_item.description, + po.name, + po.transaction_date, + po.customer, + po.territory, + sum(po_item.qty) as net_qty, + po.company + FROM `tabPurchase Order` po, `tabPurchase Order Item` po_item + WHERE + po.docstatus = 1 + and po.name = po_item.parent + and po.status not in ("Closed","Completed","Cancelled") + GROUP BY + po.name,po_item.item_code + """, as_dict = 1) + return data \ No newline at end of file