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:
parent
4d33e3dcbe
commit
1bdb845032
|
@ -545,12 +545,14 @@
|
|||
<!-- </b-field> -->
|
||||
</b-field>
|
||||
|
||||
% if product_price_may_be_questionable:
|
||||
<b-checkbox v-model="productPriceNeedsConfirmation"
|
||||
type="is-warning"
|
||||
size="is-small">
|
||||
This price is questionable and should be confirmed
|
||||
by someone before order proceeds.
|
||||
</b-checkbox>
|
||||
% endif
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -629,7 +631,11 @@
|
|||
</b-table-column>
|
||||
|
||||
<b-table-column field="total_price_display" label="Total">
|
||||
<span :class="props.row.price_needs_confirmation ? 'has-background-warning' : ''">
|
||||
<span
|
||||
% if product_price_may_be_questionable:
|
||||
:class="props.row.price_needs_confirmation ? 'has-background-warning' : ''"
|
||||
% endif
|
||||
>
|
||||
{{ props.row.total_price_display }}
|
||||
</span>
|
||||
</b-table-column>
|
||||
|
@ -758,7 +764,10 @@
|
|||
defaultUOM: defaultUOM,
|
||||
productUOM: defaultUOM,
|
||||
productCaseSize: null,
|
||||
|
||||
% if product_price_may_be_questionable:
|
||||
productPriceNeedsConfirmation: false,
|
||||
% endif
|
||||
|
||||
## TODO: should find a better way to handle CSRF token
|
||||
csrftoken: ${json.dumps(request.session.get_csrf_token() or request.session.new_csrf_token())|n},
|
||||
|
@ -1290,7 +1299,11 @@
|
|||
this.productQuantity = 1
|
||||
this.productUnitChoices = this.defaultUnitChoices
|
||||
this.productUOM = this.defaultUOM
|
||||
|
||||
% if product_price_may_be_questionable:
|
||||
this.productPriceNeedsConfirmation = false
|
||||
% endif
|
||||
|
||||
this.showingItemDialog = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.productAutocomplete.focus()
|
||||
|
@ -1311,7 +1324,10 @@
|
|||
this.productQuantity = row.order_quantity
|
||||
this.productUnitChoices = row.order_uom_choices
|
||||
this.productUOM = row.order_uom
|
||||
|
||||
% if product_price_may_be_questionable:
|
||||
this.productPriceNeedsConfirmation = row.price_needs_confirmation
|
||||
% endif
|
||||
|
||||
this.showingItemDialog = true
|
||||
},
|
||||
|
@ -1348,7 +1364,10 @@
|
|||
this.productURL = null
|
||||
this.productImageURL = null
|
||||
this.productUnitChoices = this.defaultUnitChoices
|
||||
|
||||
% if product_price_may_be_questionable:
|
||||
this.productPriceNeedsConfirmation = false
|
||||
% endif
|
||||
},
|
||||
|
||||
setProductUnitChoices(choices) {
|
||||
|
@ -1387,7 +1406,10 @@
|
|||
this.productURL = response.data.url
|
||||
this.productImageURL = response.data.image_url
|
||||
this.setProductUnitChoices(response.data.uom_choices)
|
||||
|
||||
% if product_price_may_be_questionable:
|
||||
this.productPriceNeedsConfirmation = false
|
||||
% endif
|
||||
})
|
||||
} else {
|
||||
this.clearProduct()
|
||||
|
@ -1401,7 +1423,10 @@
|
|||
product_uuid: this.productUUID,
|
||||
order_quantity: this.productQuantity,
|
||||
order_uom: this.productUOM,
|
||||
|
||||
% if product_price_may_be_questionable:
|
||||
price_needs_confirmation: this.productPriceNeedsConfirmation,
|
||||
% endif
|
||||
}
|
||||
|
||||
if (this.editingItem) {
|
||||
|
|
|
@ -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')
|
||||
|
||||
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')
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue