Fixes counting of in stock parent assemblies and formatting of csv

This commit is contained in:
Ben Cornwell-Mott 2017-01-10 14:29:10 -08:00 committed by Nabin Hait
parent 1c91dc4589
commit 5597f6a830

View File

@ -364,8 +364,16 @@ class ProductionPlanningTool(Document):
if include_sublevel:
if (d.default_material_request_type == "Purchase" and d.is_sub_contracted \
and supply_subs) or (d.default_material_request_type == "Manufacture"):
my_qty = 0
if self.create_material_requests_for_all_required_qty:
my_qty = d.qty
elif (bom_wise_item_details[d.item_code].qty - d.qty) < self.get_item_projected_qty(d.item_code):
my_qty = bom_wise_item_details[d.item_code].qty - self.get_item_projected_qty(d.item_code)
else:
my_qty = d.qty
if my_qty > 0:
self.get_subitems(bom_wise_item_details,d.default_bom, \
d.qty, include_sublevel, only_raw, supply_subs)
my_qty, include_sublevel, only_raw, supply_subs)
return bom_wise_item_details
def make_items_dict(self, item_list):
@ -387,6 +395,8 @@ class ProductionPlanningTool(Document):
flt(w.ordered_qty), flt(w.actual_qty)])
if item_qty:
item_list.append(['', '', '', '', 'Total', i_qty, o_qty, a_qty])
else:
item_list.append(['', '', '', '', 'Total', 0, 0, 0])
return item_list
@ -449,6 +459,13 @@ class ProductionPlanningTool(Document):
return items_to_be_requested
def get_item_projected_qty(self,item):
item_projected_qty = frappe.db.sql("""select ifnull(sum(projected_qty),0) as qty from `tabBin`
where item_code = %(item_code)s and warehouse=%(warehouse)s""", \
{"item_code":item, "warehouse": self.purchase_request_for_warehouse},as_dict=1)
#frappe.msgprint(item_projected_qty)
return item_projected_qty[0].qty
def get_projected_qty(self):
items = self.item_dict.keys()
item_projected_qty = frappe.db.sql("""select item_code, sum(projected_qty)