mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Display build pricing information
This commit is contained in:
parent
2b098942b0
commit
b64a29b897
@ -36,6 +36,19 @@ InvenTree | Build - {{ build }}
|
|||||||
<td>Quantity</td>
|
<td>Quantity</td>
|
||||||
<td>{{ build.quantity }}</td>
|
<td>{{ build.quantity }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>BOM Price</td>
|
||||||
|
<td>
|
||||||
|
{% if bom_price %}
|
||||||
|
{{ bom_price }}
|
||||||
|
{% if build.part.has_complete_bom_pricing == False %}
|
||||||
|
<span class='warning-msg'><i>BOM pricing is incomplete</i></span>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<span class='warning-msg'><i>No pricing information</i></span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -265,6 +265,16 @@ class BuildDetail(DetailView):
|
|||||||
template_name = 'build/detail.html'
|
template_name = 'build/detail.html'
|
||||||
context_object_name = 'build'
|
context_object_name = 'build'
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
|
||||||
|
ctx = super(DetailView, self).get_context_data(**kwargs)
|
||||||
|
|
||||||
|
build = self.get_object()
|
||||||
|
|
||||||
|
ctx['bom_price'] = build.part.get_price_info(build.quantity, buy=False)
|
||||||
|
|
||||||
|
return ctx
|
||||||
|
|
||||||
|
|
||||||
class BuildAllocate(DetailView):
|
class BuildAllocate(DetailView):
|
||||||
""" View for allocating parts to a Build """
|
""" View for allocating parts to a Build """
|
||||||
|
@ -598,11 +598,17 @@ class Part(models.Model):
|
|||||||
|
|
||||||
return self.get_price_info()
|
return self.get_price_info()
|
||||||
|
|
||||||
def get_price_info(self, quantity=1):
|
def get_price_info(self, quantity=1, buy=True, bom=True):
|
||||||
""" Return a simplified pricing string for this part """
|
""" Return a simplified pricing string for this part
|
||||||
|
|
||||||
min_price = self.get_min_price(quantity)
|
Args:
|
||||||
max_price = self.get_max_price(quantity)
|
quantity: Number of units to calculate price for
|
||||||
|
buy: Include supplier pricing (default = True)
|
||||||
|
bom: Include BOM pricing (default = True)
|
||||||
|
"""
|
||||||
|
|
||||||
|
min_price = self.get_min_price(quantity, buy, bom)
|
||||||
|
max_price = self.get_max_price(quantity, buy, bom)
|
||||||
|
|
||||||
if min_price is None:
|
if min_price is None:
|
||||||
return None
|
return None
|
||||||
@ -710,7 +716,7 @@ class Part(models.Model):
|
|||||||
|
|
||||||
return max_price
|
return max_price
|
||||||
|
|
||||||
def get_min_price(self, quantity=1):
|
def get_min_price(self, quantity=1, buy=True, bom=True):
|
||||||
""" Return the minimum price for this part. This price can be either:
|
""" Return the minimum price for this part. This price can be either:
|
||||||
|
|
||||||
- Supplier price (if purchased from suppliers)
|
- Supplier price (if purchased from suppliers)
|
||||||
@ -720,8 +726,8 @@ class Part(models.Model):
|
|||||||
Minimum of the supplier price or BOM price. If no pricing available, returns None
|
Minimum of the supplier price or BOM price. If no pricing available, returns None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
buy_price = self.get_min_supplier_price(quantity)
|
buy_price = self.get_min_supplier_price(quantity) if buy else None
|
||||||
bom_price = self.get_min_bom_price(quantity)
|
bom_price = self.get_min_bom_price(quantity) if bom else None
|
||||||
|
|
||||||
if buy_price is None:
|
if buy_price is None:
|
||||||
return bom_price
|
return bom_price
|
||||||
@ -731,7 +737,7 @@ class Part(models.Model):
|
|||||||
|
|
||||||
return min(buy_price, bom_price)
|
return min(buy_price, bom_price)
|
||||||
|
|
||||||
def get_max_price(self, quantity=1):
|
def get_max_price(self, quantity=1, buy=True, bom=True):
|
||||||
""" Return the maximum price for this part. This price can be either:
|
""" Return the maximum price for this part. This price can be either:
|
||||||
|
|
||||||
- Supplier price (if purchsed from suppliers)
|
- Supplier price (if purchsed from suppliers)
|
||||||
@ -741,8 +747,8 @@ class Part(models.Model):
|
|||||||
Maximum of the supplier price or BOM price. If no pricing available, returns None
|
Maximum of the supplier price or BOM price. If no pricing available, returns None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
buy_price = self.get_max_supplier_price(quantity)
|
buy_price = self.get_max_supplier_price(quantity) if buy else None
|
||||||
bom_price = self.get_max_bom_price(quantity)
|
bom_price = self.get_max_bom_price(quantity) if bom else None
|
||||||
|
|
||||||
if buy_price is None:
|
if buy_price is None:
|
||||||
return bom_price
|
return bom_price
|
||||||
|
Loading…
Reference in New Issue
Block a user