Skip to content
This repository
tree: 35908c6f53
Fetching contributors…

Cannot retrieve contributors at this time

file 18 lines (16 sloc) 0.546 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# encoding: utf-8
# Copyright 2011 Tree.io Limited
# This file is part of Treeio.
# License www.tree.io/license

from decimal import *

def convert(obj, name, currency=None):
    display = getattr(obj, name+'_display', None)
    if not currency:
        currency = getattr(obj, name+'_currency', None)
    if display and currency:
        if currency.is_default:
            setattr(obj, name, display)
        else:
            setattr(obj, name, (display * currency.factor).quantize(Decimal('.01'), rounding=ROUND_UP))
    obj.save()
    return
Something went wrong with that request. Please try again.