mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-16 12:05:53 +00:00
Adding internal functions to use internal prices
This commit is contained in:
@ -726,7 +726,7 @@ class PriceBreak(models.Model):
|
||||
return converted.amount
|
||||
|
||||
|
||||
def get_price(instance, quantity, moq=True, multiples=True, currency=None):
|
||||
def get_price(instance, quantity, moq=True, multiples=True, currency=None, break_name:str='price_breaks'):
|
||||
""" Calculate the price based on quantity price breaks.
|
||||
|
||||
- Don't forget to add in flat-fee cost (base_cost field)
|
||||
@ -734,7 +734,10 @@ def get_price(instance, quantity, moq=True, multiples=True, currency=None):
|
||||
- If order multiples are to be observed, then we need to calculate based on that, too
|
||||
"""
|
||||
|
||||
price_breaks = instance.price_breaks.all()
|
||||
if hasattr(instance, break_name):
|
||||
price_breaks = getattr(instance, break_name).all()
|
||||
else:
|
||||
price_breaks = []
|
||||
|
||||
# No price break information available?
|
||||
if len(price_breaks) == 0:
|
||||
@ -756,7 +759,7 @@ def get_price(instance, quantity, moq=True, multiples=True, currency=None):
|
||||
currency = currency_code_default()
|
||||
|
||||
pb_min = None
|
||||
for pb in instance.price_breaks.all():
|
||||
for pb in price_breaks:
|
||||
# Store smallest price break
|
||||
if not pb_min:
|
||||
pb_min = pb
|
||||
|
Reference in New Issue
Block a user