Make currency field renderer display negative amounts in parentheses

Also remove space between amount and dollar sign.
This commit is contained in:
Lance Edgar 2016-04-21 13:43:08 -05:00
parent c7c2fecec0
commit eb64e709c4

View file

@ -214,14 +214,13 @@ class CurrencyFieldRenderer(formalchemy.FieldRenderer):
Sort of generic field renderer for currency values.
"""
def __init__(self, field):
super(CurrencyFieldRenderer, self).__init__(field)
def render_readonly(self, **kwargs):
value = self.raw_value
if value is None:
return ''
return '$ {:0,.2f}'.format(value)
if value < 0:
return "(${:0,.2f})".format(0 - value)
return "${:0,.2f}".format(value)
class YesNoFieldRenderer(CheckBoxFieldRenderer):