This commit is contained in:
Matthias 2021-05-24 22:45:00 +02:00
parent b4c9edcd27
commit b15c20611d

View File

@ -847,15 +847,15 @@ class PartPricingView(PartDetail):
# BOM Information for Pie-Chart # BOM Information for Pie-Chart
bom_items = [{'name': str(a.sub_part), 'price': a.sub_part.get_price_range(quantity), 'q': a.quantity} for a in part.bom_items.all()] bom_items = [{'name': str(a.sub_part), 'price': a.sub_part.get_price_range(quantity), 'q': a.quantity} for a in part.bom_items.all()]
if [True for a in bom_items if len(set(a['price']))==2]: if [True for a in bom_items if len(set(a['price'])) == 2]:
ctx['bom_parts'] = [{ ctx['bom_parts'] = [{
'name': a['name'], 'name': a['name'],
'min_price': str((a['price'][0] * a['q'])/ quantity), 'min_price': str((a['price'][0] * a['q']) / quantity),
'max_price': str((a['price'][1] * a['q']) / quantity)} for a in bom_items] 'max_price': str((a['price'][1] * a['q']) / quantity)} for a in bom_items]
ctx['bom_pie_min'] = True ctx['bom_pie_min'] = True
else: else:
ctx['bom_parts'] = [{ ctx['bom_parts'] = [{
'name':a['name'], 'name': a['name'],
'price': str((a['price'][0] * a['q']) / quantity)} for a in bom_items] 'price': str((a['price'][0] * a['q']) / quantity)} for a in bom_items]
return ctx return ctx