Exemplo n.º 1
0
    def getDefaultCurrency(self, instance):
        """
        Retrieves default currency if 'default_currency_method'
        specified.

        XXX: Get the default currency from the locale if no default
        method provided.
        """
        if self.default_currency_method and \
            hasattr(instance, self.default_currency_method):
            method = getattr(instance, self.default_currency_method)
            return method()
        else:
            props_tool = getToolByName(self, 'portal_properties')
            sheet = props_tool.get('financial_properties', {})
            symbol = sheet.getProperty('default_currency', None)
            return CURRENCIES.get(symbol, '')
    def getDefaultCurrency(self, instance):
        """
        Retrieves default currency if 'default_currency_method'
        specified.

        XXX: Get the default currency from the locale if no default
        method provided.
        """
        if self.default_currency_method and \
            hasattr(instance, self.default_currency_method):
            method = getattr(instance, self.default_currency_method)
            return method()
        else:
            props_tool = getToolByName(self, 'portal_properties')
            sheet = props_tool.get('financial_properties', {})
            symbol = sheet.getProperty('default_currency', None)
            return CURRENCIES.get(symbol, '')
Exemplo n.º 3
0
def parseString(s):
    # remove commas
    s = s.replace(',', '')
    if not (money_re.match(s) or float_re.match(s)):
        raise InvalidMoneyString(s)
    if money_neg_re.match(s):
        # strip the brackets
        s = s[1:-1]
        cur, value = s.split()
        # add minus symbol to fixedpoint value
        s = '%s -%s' % (cur, value)
    if money_re.match(s):
        cur, value = s.split()
        if CURRENCIES.has_key(cur):
            cur = CURRENCIES[cur]
        elif SYMBOLS_MAP.has_key(cur):
            cur = SYMBOLS_MAP[cur]
    else:
        cur = None
        value = s
    return cur, FixedPoint(value)
Exemplo n.º 4
0
from Products.Archetypes.utils import DisplayList

ADD_CONTENT_PERMISSION = 'Add FinanceFields content'
PROJECTNAME = "FinanceFields"
GLOBALS = globals()
I18N_DOMAIN = 'plone_accounting'
SKINS_DIR = 'skins'

from AccessControl import allow_module
allow_module('Products.FinanceFields.config')
allow_module('Products.FinanceFields.Money')

from Currency import CURRENCIES

l = DisplayList()
for cur in CURRENCIES.values():
    symbol = cur.int_currency_symbol
    l.add(symbol, symbol, symbol)
l._itor.sort()
CURRENCY_DISPLAY_LIST = l