def filter_price(self, price_from=None, price_to=None): filters = {} try: filters['unit_price__gte'] = round_2(float(price_from)) except (TypeError, ValueError): pass try: filters['unit_price__lte'] = round_2(float(price_to)) except (TypeError, ValueError): pass return self.filter(**filters)
def get_price(self): price = self.get_unit_price() if self.is_discounted: discount = self.get_discount_percent() if discount: price -= (discount * price) / Decimal('100') if self.is_taxed: tax = self.get_tax_percent() price += (tax * price) / Decimal('100') return round_2(price)
def get_unit_price(self): if self.is_price_inherited: return self.parent.get_unit_price() return round_2(self.unit_price)
def calculate_currency(self, price): return round_2(price * self.currency_factor)