Update quoted_item_comparison.py
This commit is contained in:
parent
5c031a3512
commit
8e885163a3
@ -3,11 +3,9 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from erpnext.setup.utils import get_exchange_rate
|
from erpnext.setup.utils import get_exchange_rate
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
|
|
||||||
qty_list = get_quantity_list(filters.item)
|
qty_list = get_quantity_list(filters.item)
|
||||||
|
|
||||||
data = get_quote_list(filters.item, qty_list)
|
data = get_quote_list(filters.item, qty_list)
|
||||||
@ -15,12 +13,9 @@ def execute(filters=None):
|
|||||||
columns = get_columns(qty_list)
|
columns = get_columns(qty_list)
|
||||||
|
|
||||||
return columns, data
|
return columns, data
|
||||||
|
|
||||||
|
|
||||||
def get_quote_list(item, qty_list):
|
def get_quote_list(item, qty_list):
|
||||||
|
|
||||||
out = []
|
out = []
|
||||||
|
|
||||||
if item:
|
if item:
|
||||||
price_data = []
|
price_data = []
|
||||||
suppliers = []
|
suppliers = []
|
||||||
@ -38,11 +33,11 @@ def get_quote_list(item, qty_list):
|
|||||||
|
|
||||||
#Add a row for each supplier
|
#Add a row for each supplier
|
||||||
for root in set(suppliers):
|
for root in set(suppliers):
|
||||||
supplier_currency = frappe.db.get_value("Supplier",root,"default_currency")
|
supplier_currency = frappe.db.get_value("Supplier", root, "default_currency")
|
||||||
if supplier_currency:
|
if supplier_currency:
|
||||||
exg = get_exchange_rate(supplier_currency,company_currency)
|
exchange_rate = get_exchange_rate(supplier_currency, company_currency)
|
||||||
else:
|
else:
|
||||||
exg = 1
|
exchange_rate = 1
|
||||||
|
|
||||||
row = frappe._dict({
|
row = frappe._dict({
|
||||||
"supplier_name": root
|
"supplier_name": root
|
||||||
@ -51,7 +46,7 @@ def get_quote_list(item, qty_list):
|
|||||||
# Get the quantity for this row
|
# Get the quantity for this row
|
||||||
for item_price in price_data:
|
for item_price in price_data:
|
||||||
if str(item_price.qty) == col.key and item_price.supplier == root:
|
if str(item_price.qty) == col.key and item_price.supplier == root:
|
||||||
row[col.key] = item_price.rate * exg
|
row[col.key] = item_price.rate * exchange_rate
|
||||||
row[col.key + "QUOTE"] = item_price.parent
|
row[col.key + "QUOTE"] = item_price.parent
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
@ -59,15 +54,11 @@ def get_quote_list(item, qty_list):
|
|||||||
row[col.key + "QUOTE"] = ""
|
row[col.key + "QUOTE"] = ""
|
||||||
out.append(row)
|
out.append(row)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def get_quantity_list(item):
|
def get_quantity_list(item):
|
||||||
|
|
||||||
out = []
|
out = []
|
||||||
|
|
||||||
|
|
||||||
if item:
|
if item:
|
||||||
qty_list = frappe.db.sql("""select distinct qty from `tabSupplier Quotation Item` where ifnull(item_code,'')=%s and docstatus < 2""", item, as_dict=1)
|
qty_list = frappe.db.sql("""select distinct qty from `tabSupplier Quotation Item` where ifnull(item_code,'')=%s and docstatus < 2""", item, as_dict=1)
|
||||||
qty_list.sort(reverse=False)
|
qty_list.sort(reverse=False)
|
||||||
@ -105,5 +96,4 @@ def get_columns(qty_list):
|
|||||||
"width": 90
|
"width": 90
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return columns
|
||||||
return columns
|
|
||||||
|
Loading…
Reference in New Issue
Block a user