Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

18 lines (16 sloc) 0.546 kb
# 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
Jump to Line
Something went wrong with that request. Please try again.