Kai Diefenbach avatar Kai Diefenbach committed 078ac65

Cleaned up PriceCalculators

Comments (0)

Files changed (3)

lfs/gross_price/__init__.py

-# python imports
-import re
-
 # lfs imports
-from lfs.catalog.settings import VARIANT
-from lfs.catalog.models import ProductPropertyValue
 from lfs.plugins import PriceCalculator
 
-# Load logger
-import logging
-logger = logging.getLogger("default")
-
 
 class GrossPriceCalculator(PriceCalculator):
-    """The value of product.price stored in the database includes tax.
+    """
+    The value of product.price stored in the database includes tax, in other
+    words, the stored price is the gross price of the product.
+
+    See lfs.plugins.PriceCalculator for more information.
     """
     def get_price_net(self, with_properties=True):
-        """See lfs.plugins.PriceCalculator
-        """
-        # price - **product** tax
         return self.get_price(with_properties) / self._calc_product_tax_rate()
 
     def get_price_gross(self, with_properties=True):
-        """See lfs.plugins.PriceCalculator
-        """
-        # net price + **customer** tax
-        return self.get_price_net(with_properties) * self._calc_customer_tax_rate()
+        return self.get_price(with_properties)
 
     def get_standard_price_net(self, with_properties=True):
-        """See lfs.plugins
-        """
-        # price - **product** tax
         return self.get_standard_price(with_properties) / self._calc_product_tax_rate()
 
     def get_standard_price_gross(self, with_properties=True):
-        """See lfs.plugins
-        """
-        # price - **product** tax
-        return self.get_standard_price_net(with_properties) * self._calc_customer_tax_rate()
+        return self.get_standard_price(with_properties)
 
     def get_for_sale_price_net(self, with_properties=True):
-        """See lfs.plugins
-        """
-        # price - **product** tax
         return self.get_for_sale_price(with_properties) / self._calc_product_tax_rate()
 
     def get_for_sale_price_gross(self, with_properties=True):
-        """See lfs.plugins
-        """
-        # price - **product** tax
-        return self.get_for_sale_price_net(with_properties) * self._calc_customer_tax_rate()
+        return self.get_for_sale_price(with_properties)
 
     def price_includes_tax(self):
-        """See lfs.plugins.PriceCalculator
-        """
         return True

lfs/net_price/__init__.py

-# python imports
-import re
-
 # lfs imports
-from lfs.catalog.models import ProductPropertyValue
-from lfs.catalog.settings import VARIANT
 from lfs.plugins import PriceCalculator
 
 
 class NetPriceCalculator(PriceCalculator):
-    """The value of product.price stored in the database excludes tax.
+    """
+    The value of product.price stored in the database excludes tax, in other
+    words, the stored price is the net price of the product.
+
+    See lfs.plugins.PriceCalculator for more information.
     """
     def get_price_net(self, with_properties=True):
-        """See lfs.plugins.PriceCalculator
-        """
-        # stored product price
         return self.get_price(with_properties)
 
     def get_price_gross(self, with_properties=True):
-        """See lfs.plugins.PriceCalculator
-        """
-        # net price + customer tax
         return self.get_price_net(with_properties) * self._calc_customer_tax_rate()
 
     def get_standard_price_net(self, with_properties=True):
-        """See lfs.plugins.PriceCalculator
-        """
-        # stored product standard price
         return self.get_standard_price(with_properties)
 
     def get_standard_price_gross(self, with_properties=True):
-        """See lfs.plugins.PriceCalculator
-        """
-        # net standard price + customer tax
         return self.get_standard_price_net(with_properties) * self._calc_customer_tax_rate()
 
     def get_for_sale_price_net(self, with_properties=True):
-        """See lfs.plugins.PriceCalculator
-        """
-        # stored for sale product price
         return self.get_for_sale_price(with_properties)
 
     def get_for_sale_price_gross(self, with_properties=True):
-        """See lfs.plugins.PriceCalculator
-        """
-        # for sale net price + customer tax
         return self.get_for_sale_price_net(with_properties) * self._calc_customer_tax_rate()
 
     def price_includes_tax(self):
-        """See lfs.plugins.PriceCalculator
-        """
         return False
 
     def get_standard_price(self, with_properties=True):
         """
-        Returns always the standard price for the product. Independent
+        Returns always the stored standard price for the product. Independent
         whether the product is for sale or not. If you want the real price of
-        the product use get_price instead.
+        the product use ``get_price`` instead.
 
         **Parameters:**
 
 
         return price
 
-    def get_standard_price_net(self, with_properties):
+    def get_standard_price_net(self, with_properties=True):
         """
         Returns always the standard net price for the product. Independent
         whether the product is for sale or not. If you want the real net price
-        of the product use get_price_net instead.
+        of the product use ``get_price_net`` instead.
 
         **Parameters:**
 
         """
         raise NotImplementedError
 
-    def get_standard_price_gross(self, with_properties):
+    def get_standard_price_gross(self, with_properties=True):
         """
-        Returns always the gros standard price for the product. Independent
+        Returns always the gross standard price for the product. Independent
         whether the product is for sale or not. If you want the real gross
-        price of the product use get_price_gross instead.
+        price of the product use ``get_price_gross`` instead.
 
         **Parameters:**
 
         """
         raise NotImplementedError
 
-    def get_for_sale_price(self, with_properties):
+    def get_for_sale_price(self, with_properties=True):
         """
         Returns the sale price for the product.
 
 
         return price
 
-    def get_for_sale_price_net(self, with_properties):
+    def get_for_sale_price_net(self, with_properties=True):
         """
         Returns the sale net price for the product.
 
         """
         raise NotImplementedError
 
-    def get_for_sale_price_gross(self, with_properties):
+    def get_for_sale_price_gross(self, with_properties=True):
         """
         Returns the sale net price for the product.
 
         """
         raise NotImplementedError
 
-    def get_base_price(self, with_properties):
+    def get_base_price(self, with_properties=True):
         """
         Returns the base price of the product.
         """
         except (TypeError, ZeroDivisionError):
             return 0.0
 
-    def get_base_price_net(self, with_properties):
+    def get_base_price_net(self, with_properties=True):
         """
         Returns the net base price of the product.
         """
         except (TypeError, ZeroDivisionError):
             return 0.0
 
-    def get_base_price_gross(self, with_properties):
+    def get_base_price_gross(self, with_properties=True):
         """
         Returns the gross base price of the product.
         """
         except (TypeError, ZeroDivisionError):
             return 0.0
 
-    def get_base_packing_price(self, request):
+    def get_base_packing_price(self):
         """
         Returns the base packing price of the product.
         """
-        return self.get_price(request) * self._calc_packing_amount()
+        return self.get_price(self.request) * self._calc_packing_amount()
 
-    def get_base_packing_price_net(self, request):
+    def get_base_packing_price_net(self):
         """
         Returns the base packing net price of the product.
         """
-        return self.get_price_net(request) * self._calc_packing_amount()
+        return self.get_price_net(self.request) * self._calc_packing_amount()
 
-    def get_base_packing_price_gross(self, request):
+    def get_base_packing_price_gross(self):
         """
         Returns the base packing gross price of the product.
         """
-        return self.get_price_gross(request) * self._calc_packing_amount()
+        return self.get_price_gross(self.request) * self._calc_packing_amount()
 
     def get_customer_tax_rate(self):
         """
 
     def get_product_tax_rate(self):
         """
-        Returns the stored tax rate of the product. If the product is a
-        variant it returns the parent's tax rate.
+        Returns the stored tax rate of the product. If the product is a variant
+        it returns the parent's tax rate.
         """
         if self.product.is_variant():
             obj = self.product.parent
         except AttributeError:
             return 0.0
 
-    def get_product_tax(self):
+    def get_product_tax(self, with_properties=True):
         """
         Returns the calculated tax for the current product independent of the
         customer.
         """
         return self.get_price(with_properties) - self.get_price(with_properties)
 
-    def price_includes_tax(self, request):
+    def price_includes_tax(self):
         """
         Returns True if stored price includes tax. False if not.
         """
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.