Honor the "product price may be questionable" flag for new custorder

i.e. don't expose the per-item flag unless *that* flag is set
This commit is contained in:
Lance Edgar 2021-11-03 20:20:22 -05:00
parent 4d33e3dcbe
commit 1bdb845032
2 changed files with 44 additions and 5 deletions

View file

@ -188,7 +188,11 @@ class CustomerOrderView(MasterView):
g.set_type('order_quantity', 'quantity')
g.set_type('cases_ordered', 'quantity')
g.set_type('units_ordered', 'quantity')
g.set_renderer('total_price', self.render_price_with_confirmation)
if self.handler.product_price_may_be_questionable():
g.set_renderer('total_price', self.render_price_with_confirmation)
else:
g.set_type('total_price', 'currency')
g.set_enum('order_uom', self.enum.UNIT_OF_MEASURE)
g.set_renderer('status_code', self.render_row_status_code)
@ -277,6 +281,7 @@ class CustomerOrderView(MasterView):
'batch': batch,
'normalized_batch': self.normalize_batch(batch),
'new_order_requires_customer': self.handler.new_order_requires_customer(),
'product_price_may_be_questionable': self.handler.product_price_may_be_questionable(),
'allow_contact_info_choice': self.handler.allow_contact_info_choice(),
'restrict_contact_info': self.handler.should_restrict_contact_info(),
'order_items': items,
@ -615,12 +620,14 @@ class CustomerOrderView(MasterView):
'unit_price_display': self.get_unit_price_display(row),
'total_price': six.text_type(row.total_price) if row.total_price is not None else None,
'total_price_display': "${:0.2f}".format(row.total_price) if row.total_price is not None else None,
'price_needs_confirmation': row.price_needs_confirmation,
'status_code': row.status_code,
'status_text': row.status_text,
}
if self.handler.product_price_may_be_questionable():
data['price_needs_confirmation'] = row.price_needs_confirmation
key = self.rattail_config.product_key()
if key == 'upc':
data['product_key'] = data['product_upc_pretty']
@ -669,10 +676,14 @@ class CustomerOrderView(MasterView):
if not product:
return {'error': "Product not found"}
kwargs = {}
if self.handler.product_price_may_be_questionable():
kwargs['price_needs_confirmation'] = data.get('price_needs_confirmation')
row = self.handler.add_product(batch, product,
decimal.Decimal(data.get('order_quantity') or '0'),
data.get('order_uom'),
price_needs_confirmation=data.get('price_needs_confirmation'))
**kwargs)
self.Session.flush()
else: # product is not known
@ -707,7 +718,10 @@ class CustomerOrderView(MasterView):
row.product = product
row.order_quantity = decimal.Decimal(data.get('order_quantity') or '0')
row.order_uom = data.get('order_uom')
row.price_needs_confirmation = data.get('price_needs_confirmation')
if self.handler.product_price_may_be_questionable():
row.price_needs_confirmation = data.get('price_needs_confirmation')
self.handler.refresh_row(row)
self.Session.flush()
self.Session.refresh(row)