mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
added in internal prices in price calculations
This commit is contained in:
parent
0e8a97acb0
commit
4f3bfe569a
@ -1544,7 +1544,7 @@ class Part(MPTTModel):
|
||||
|
||||
return (min_price, max_price)
|
||||
|
||||
def get_bom_price_range(self, quantity=1):
|
||||
def get_bom_price_range(self, quantity=1, internal=False):
|
||||
""" Return the price range of the BOM for this part.
|
||||
Adds the minimum price for all components in the BOM.
|
||||
|
||||
@ -1561,7 +1561,7 @@ class Part(MPTTModel):
|
||||
print("Warning: Item contains itself in BOM")
|
||||
continue
|
||||
|
||||
prices = item.sub_part.get_price_range(quantity * item.quantity)
|
||||
prices = item.sub_part.get_price_range(quantity * item.quantity, internal=internal)
|
||||
|
||||
if prices is None:
|
||||
continue
|
||||
@ -1585,7 +1585,7 @@ class Part(MPTTModel):
|
||||
|
||||
return (min_price, max_price)
|
||||
|
||||
def get_price_range(self, quantity=1, buy=True, bom=True):
|
||||
def get_price_range(self, quantity=1, buy=True, bom=True, internal=False):
|
||||
|
||||
""" Return the price range for this part. This price can be either:
|
||||
|
||||
@ -1596,8 +1596,13 @@ class Part(MPTTModel):
|
||||
Minimum of the supplier price or BOM price. If no pricing available, returns None
|
||||
"""
|
||||
|
||||
# only get internal price if set and should be used
|
||||
if internal and self.has_internal_price_breaks:
|
||||
internal_price = self.get_internal_price(quantity)
|
||||
return internal_price, internal_price
|
||||
|
||||
buy_price_range = self.get_supplier_price_range(quantity) if buy else None
|
||||
bom_price_range = self.get_bom_price_range(quantity) if bom else None
|
||||
bom_price_range = self.get_bom_price_range(quantity, internal=internal) if bom else None
|
||||
|
||||
if buy_price_range is None:
|
||||
return bom_price_range
|
||||
|
@ -2105,7 +2105,8 @@ class PartPricing(AjaxView):
|
||||
# BOM pricing information
|
||||
if part.bom_count > 0:
|
||||
|
||||
bom_price = part.get_bom_price_range(quantity)
|
||||
use_internal = InvenTreeSetting.get_setting('PART_BOM_USE_INTERNAL_PRICE', False)
|
||||
bom_price = part.get_bom_price_range(quantity, internal=use_internal)
|
||||
|
||||
if bom_price is not None:
|
||||
min_bom_price, max_bom_price = bom_price
|
||||
|
Loading…
Reference in New Issue
Block a user