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)
|
return pretty_quantity(value)
|
||||||
|
|
||||||
def render_percent(self, obj, field):
|
def render_percent(self, obj, field):
|
||||||
|
app = self.request.rattail_config.get_app()
|
||||||
value = self.obtain_value(obj, field)
|
value = self.obtain_value(obj, field)
|
||||||
if value is None:
|
return app.render_percent(value, places=3)
|
||||||
return ""
|
|
||||||
return "{:0.3f} %".format(value * 100)
|
|
||||||
|
|
||||||
def render_gpc(self, obj, field):
|
def render_gpc(self, obj, field):
|
||||||
value = self.obtain_value(obj, field)
|
value = self.obtain_value(obj, field)
|
||||||
|
|
|
@ -369,10 +369,9 @@ class Grid(object):
|
||||||
return value.pretty()
|
return value.pretty()
|
||||||
|
|
||||||
def render_percent(self, obj, column_name):
|
def render_percent(self, obj, column_name):
|
||||||
|
app = self.request.rattail_config.get_app()
|
||||||
value = self.obtain_value(obj, column_name)
|
value = self.obtain_value(obj, column_name)
|
||||||
if value is None:
|
return app.render_percent(value, places=3)
|
||||||
return ""
|
|
||||||
return "{:0.3f} %".format(value * 100)
|
|
||||||
|
|
||||||
def render_quantity(self, obj, column_name):
|
def render_quantity(self, obj, column_name):
|
||||||
value = self.obtain_value(obj, column_name)
|
value = self.obtain_value(obj, column_name)
|
||||||
|
|
|
@ -670,7 +670,9 @@ class ProductView(MasterView):
|
||||||
return ""
|
return ""
|
||||||
if product.volatile.true_margin is None:
|
if product.volatile.true_margin is None:
|
||||||
return ""
|
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):
|
def render_on_hand(self, product, column):
|
||||||
inventory = product.inventory
|
inventory = product.inventory
|
||||||
|
|
Loading…
Reference in a new issue