diff --git a/tailbone/views/batch/product.py b/tailbone/views/batch/product.py index e649d7bf..50b18953 100644 --- a/tailbone/views/batch/product.py +++ b/tailbone/views/batch/product.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2019 Lance Edgar +# Copyright © 2010-2020 Lance Edgar # # This file is part of Rattail. # @@ -30,6 +30,7 @@ from rattail.db import model from rattail.util import OrderedDict import colander +from webhelpers2.html import HTML from tailbone import forms from tailbone.views.batch import BatchMasterView @@ -156,6 +157,9 @@ class ProductBatchView(BatchMasterView): g.set_type('current_price', 'currency') g.set_type('suggested_price', 'currency') + # highlight red for SRP breaches + g.set_renderer('suggested_price', self.render_suggested_price) + def row_grid_extra_class(self, row, i): if row.status_code in (row.STATUS_MISSING_KEY, row.STATUS_PRODUCT_NOT_FOUND): @@ -174,6 +178,28 @@ class ProductBatchView(BatchMasterView): f.set_renderer('family', self.render_family) f.set_renderer('reportcode', self.render_report) + f.set_type('regular_cost', 'currency') + f.set_type('current_cost', 'currency') + f.set_type('regular_price', 'currency') + f.set_type('current_price', 'currency') + f.set_type('suggested_price', 'currency') + + # highlight red for SRP breaches + f.set_renderer('suggested_price', self.render_suggested_price) + + def render_suggested_price(self, row, field): + price = getattr(row, field) + if not price: + return "" + + text = "${:0,.2f}".format(price) + + if row.regular_price and row.suggested_price and ( + row.regular_price > row.suggested_price): + text = HTML.tag('span', style='color: red;', c=text) + + return text + def get_execute_success_url(self, batch, result, **kwargs): if kwargs['action'] == 'make_label_batch': return self.request.route_url('labels.batch.view', uuid=result.uuid)