Use shared logic for rendering percentage values
This commit is contained in:
parent
22c33b58c7
commit
c2b2d11141
|
@ -1006,10 +1006,9 @@ class Form(object):
|
|||
return pretty_quantity(value)
|
||||
|
||||
def render_percent(self, obj, field):
|
||||
app = self.request.rattail_config.get_app()
|
||||
value = self.obtain_value(obj, field)
|
||||
if value is None:
|
||||
return ""
|
||||
return "{:0.3f} %".format(value * 100)
|
||||
return app.render_percent(value, places=3)
|
||||
|
||||
def render_gpc(self, obj, field):
|
||||
value = self.obtain_value(obj, field)
|
||||
|
|
|
@ -369,10 +369,9 @@ class Grid(object):
|
|||
return value.pretty()
|
||||
|
||||
def render_percent(self, obj, column_name):
|
||||
app = self.request.rattail_config.get_app()
|
||||
value = self.obtain_value(obj, column_name)
|
||||
if value is None:
|
||||
return ""
|
||||
return "{:0.3f} %".format(value * 100)
|
||||
return app.render_percent(value, places=3)
|
||||
|
||||
def render_quantity(self, obj, column_name):
|
||||
value = self.obtain_value(obj, column_name)
|
||||
|
|
|
@ -670,7 +670,9 @@ class ProductView(MasterView):
|
|||
return ""
|
||||
if product.volatile.true_margin is None:
|
||||
return ""
|
||||
return "{:0.3f} %".format(product.volatile.true_margin * 100)
|
||||
app = self.get_rattail_app()
|
||||
return app.render_percent(product.volatile.true_margin,
|
||||
places=3)
|
||||
|
||||
def render_on_hand(self, product, column):
|
||||
inventory = product.inventory
|
||||
|
|
Loading…
Reference in a new issue