Пример #1
0
 def test_product_adjustments(self):
     p1 = self.product.unit_price
     self.assertEqual(p1, Decimal('20.00'))
     signals.satchmo_price_query.connect(five_off)
     p2 = self.product.unit_price
     self.assertEqual(p2, Decimal('15.00'))
     adj = get_product_quantity_adjustments(self.product, qty=1)
     self.assertEqual(len(adj.adjustments), 1)
     a = adj.adjustments[0]
     self.assertEqual(a.key, 'half')
     self.assertEqual(a.amount, Decimal(5))
     signals.satchmo_price_query.disconnect(five_off)
Пример #2
0
 def test_product_adjustments(self):
     p1 = self.product.unit_price
     self.assertEqual(p1, Decimal('20.00'))
     signals.satchmo_price_query.connect(five_off)
     p2 = self.product.unit_price
     self.assertEqual(p2, Decimal('15.00'))
     adj = get_product_quantity_adjustments(self.product, qty=1)
     self.assertEqual(len(adj.adjustments), 1)
     a = adj.adjustments[0]
     self.assertEqual(a.key, 'half')
     self.assertEqual(a.amount, Decimal(5))
     signals.satchmo_price_query.disconnect(five_off)
Пример #3
0
    def get_qty_price(self, qty, include_discount=True):
        if include_discount:
            price = get_product_quantity_price(
                self.product, qty,
                delta=self.price_delta(False),
                parent=self.parent.product)
        else:
            adjustment = get_product_quantity_adjustments(self, qty, parent=self.parent.product)
            if adjustment.price is not None:
                price = adjustment.price.price + self.price_delta(True)
            else:
                price = None

        return price
Пример #4
0
    def get_qty_price(self, qty, include_discount=True):
        # if no prices have been set specifically for this variation, we derive a price from the parent
        # if a price *has* been set (for the appropriate quantity), the delta is ignored, and the price is used as-is
        should_use_delta = len(self._get_self_qty_price_list(qty)) == 0
        if include_discount:
            price = get_product_quantity_price(
                self.product, qty,
                delta=(0, self.price_delta(False))[should_use_delta],
                parent=self.parent.product)
        else:
            adjustment = get_product_quantity_adjustments(self.product, qty, parent=self.parent.product)
            if adjustment.price is not None:
                price = adjustment.price.price + self.price_delta(True)
            else:
                price = None

        return price
Пример #5
0
    def get_qty_price(self, qty, include_discount=True):
        # if no prices have been set specifically for this variation, we derive a price from the parent
        # if a price *has* been set (for the appropriate quantity), the delta is ignored, and the price is used as-is
        should_use_delta = len(self._get_self_qty_price_list(qty)) == 0
        if include_discount:
            price = get_product_quantity_price(
                self.product, qty,
                delta=(0, self.price_delta(False))[should_use_delta],
                parent=self.parent.product)
        else:
            adjustment = get_product_quantity_adjustments(self, qty, parent=self.parent.product)
            if adjustment.price is not None:
                price = adjustment.price.price + self.price_delta(True)
            else:
                price = None

        return price