# Path: cmsplugin_shop/settings.py
# PRICE_TYPE          = S('PRICE_TYPE', 'gross')
# 
# Path: cmsplugin_shop/utils.py
# def quantize(price):
#     return price.quantize(QUANTIZE)
# 
# def currency(val, localeconv=None, international=False):
#     """Formats val according to the currency settings for current language."""
#     val = Decimal(val)
#     conv = localeconv_cache.getconv()
#     conv.update(localeconv or settings.LOCALECONV)
# 
#     # split integer part and fraction
#     parts = str(abs(val)).split('.')
# 
#     # grouping
#     groups = []
#     s = parts[0]
#     for interval in locale._grouping_intervals(conv['mon_grouping']):
#         if not s:
#             break
#         groups.append(s[-interval:])
#         s = s[:-interval]
#     if s:
#         groups.append(s)
#     groups.reverse()
#     s = smart_text(conv['mon_thousands_sep']).join(groups)
# 
#     # display fraction for non integer values
#     if len(parts) > 1:
#         s += smart_text(conv['mon_decimal_point']) + parts[1]
# 
#     # '<' and '>' are markers if the sign must be inserted between symbol and value
#     s = '<' + s + '>'
# 
#     smb = smart_text(conv[international and 'int_curr_symbol' or 'currency_symbol'])
#     precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
#     separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
# 
#     if precedes:
#         s = smb + (separated and ' ' or '') + s
#     else:
#         s = s + (separated and ' ' or '') + smb
# 
#     sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
#     sign = conv[val<0 and 'negative_sign' or 'positive_sign']
# 
#     if sign_pos == 0:
#         s = '(' + s + ')'
#     elif sign_pos == 1:
#         s = sign + s
#     elif sign_pos == 2:
#         s = s + sign
#     elif sign_pos == 3:
#         s = s.replace('<', sign)
#     elif sign_pos == 4:
#         s = s.replace('>', sign)
#     else:
#         # the default if nothing specified;
#         # this should be the most fitting sign position
#         s = sign + s
# 
#     return s.replace('<', '').replace('>', '')


from collections import namedtuple
from decimal import Decimal
from django.utils.encoding import python_2_unicode_compatible
from itertools import groupby
from .settings import PRICE_TYPE
from .utils import quantize, currency
        except:
            return NotImplemented

    def __le__(self, other):
        return self < other or self == other

    def __eq__(self, other):
        try:
            if PRICE_TYPE == 'gross':
                return self.gross == other.gross
            else:
                return self.net   == other.net
        except:
            return False

    def __ne__(self, other):
        return not self == other

    def __radd__(self, other):
        return self + other

    def __rmul__(self, other):
        return self * other

    @property
    def tax(self):
        return self.gross - self.net

    def __str__(self):
        if PRICE_TYPE == 'gross':

# Path: cmsplugin_shop/settings.py
# PRICE_TYPE          = S('PRICE_TYPE', 'gross')
# 
# Path: cmsplugin_shop/utils.py
# def quantize(price):
#     return price.quantize(QUANTIZE)
# 
# def currency(val, localeconv=None, international=False):
#     """Formats val according to the currency settings for current language."""
#     val = Decimal(val)
#     conv = localeconv_cache.getconv()
#     conv.update(localeconv or settings.LOCALECONV)
# 
#     # split integer part and fraction
#     parts = str(abs(val)).split('.')
# 
#     # grouping
#     groups = []
#     s = parts[0]
#     for interval in locale._grouping_intervals(conv['mon_grouping']):
#         if not s:
#             break
#         groups.append(s[-interval:])
#         s = s[:-interval]
#     if s:
#         groups.append(s)
#     groups.reverse()
#     s = smart_text(conv['mon_thousands_sep']).join(groups)
# 
#     # display fraction for non integer values
#     if len(parts) > 1:
#         s += smart_text(conv['mon_decimal_point']) + parts[1]
# 
#     # '<' and '>' are markers if the sign must be inserted between symbol and value
#     s = '<' + s + '>'
# 
#     smb = smart_text(conv[international and 'int_curr_symbol' or 'currency_symbol'])
#     precedes = conv[val<0 and 'n_cs_precedes' or 'p_cs_precedes']
#     separated = conv[val<0 and 'n_sep_by_space' or 'p_sep_by_space']
# 
#     if precedes:
#         s = smb + (separated and ' ' or '') + s
#     else:
#         s = s + (separated and ' ' or '') + smb
# 
#     sign_pos = conv[val<0 and 'n_sign_posn' or 'p_sign_posn']
#     sign = conv[val<0 and 'negative_sign' or 'positive_sign']
# 
#     if sign_pos == 0:
#         s = '(' + s + ')'
#     elif sign_pos == 1:
#         s = sign + s
#     elif sign_pos == 2:
#         s = s + sign
#     elif sign_pos == 3:
#         s = s.replace('<', sign)
#     elif sign_pos == 4:
#         s = s.replace('>', sign)
#     else:
#         # the default if nothing specified;
#         # this should be the most fitting sign position
#         s = sign + s
# 
#     return s.replace('<', '').replace('>', '')


# Path: cmsplugin_shop/price.py
from collections import namedtuple
from decimal import Decimal
from django.utils.encoding import python_2_unicode_compatible
from itertools import groupby
from .settings import PRICE_TYPE
from .utils import quantize, currency

        except:
            return NotImplemented

    def __le__(self, other):
        return self < other or self == other

    def __eq__(self, other):
        try:
            if PRICE_TYPE == 'gross':
                return self.gross == other.gross
            else:
                return self.net   == other.net
        except:
            return False

    def __ne__(self, other):
        return not self == other

    def __radd__(self, other):
        return self + other

    def __rmul__(self, other):
        return self * other

    @property
    def tax(self):
        return self.gross - self.net

    def __str__(self):
        if PRICE_TYPE == 'gross':

            return currency(self.gross)