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> -->
|
||||||
</b-field>
|
</b-field>
|
||||||
|
|
||||||
|
% if product_price_may_be_questionable:
|
||||||
<b-checkbox v-model="productPriceNeedsConfirmation"
|
<b-checkbox v-model="productPriceNeedsConfirmation"
|
||||||
type="is-warning"
|
type="is-warning"
|
||||||
size="is-small">
|
size="is-small">
|
||||||
This price is questionable and should be confirmed
|
This price is questionable and should be confirmed
|
||||||
by someone before order proceeds.
|
by someone before order proceeds.
|
||||||
</b-checkbox>
|
</b-checkbox>
|
||||||
|
% endif
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -629,7 +631,11 @@
|
||||||
</b-table-column>
|
</b-table-column>
|
||||||
|
|
||||||
<b-table-column field="total_price_display" label="Total">
|
<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 }}
|
{{ props.row.total_price_display }}
|
||||||
</span>
|
</span>
|
||||||
</b-table-column>
|
</b-table-column>
|
||||||
|
@ -758,7 +764,10 @@
|
||||||
defaultUOM: defaultUOM,
|
defaultUOM: defaultUOM,
|
||||||
productUOM: defaultUOM,
|
productUOM: defaultUOM,
|
||||||
productCaseSize: null,
|
productCaseSize: null,
|
||||||
|
|
||||||
|
% if product_price_may_be_questionable:
|
||||||
productPriceNeedsConfirmation: false,
|
productPriceNeedsConfirmation: false,
|
||||||
|
% endif
|
||||||
|
|
||||||
## TODO: should find a better way to handle CSRF token
|
## 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},
|
csrftoken: ${json.dumps(request.session.get_csrf_token() or request.session.new_csrf_token())|n},
|
||||||
|
@ -1290,7 +1299,11 @@
|
||||||
this.productQuantity = 1
|
this.productQuantity = 1
|
||||||
this.productUnitChoices = this.defaultUnitChoices
|
this.productUnitChoices = this.defaultUnitChoices
|
||||||
this.productUOM = this.defaultUOM
|
this.productUOM = this.defaultUOM
|
||||||
|
|
||||||
|
% if product_price_may_be_questionable:
|
||||||
this.productPriceNeedsConfirmation = false
|
this.productPriceNeedsConfirmation = false
|
||||||
|
% endif
|
||||||
|
|
||||||
this.showingItemDialog = true
|
this.showingItemDialog = true
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.productAutocomplete.focus()
|
this.$refs.productAutocomplete.focus()
|
||||||
|
@ -1311,7 +1324,10 @@
|
||||||
this.productQuantity = row.order_quantity
|
this.productQuantity = row.order_quantity
|
||||||
this.productUnitChoices = row.order_uom_choices
|
this.productUnitChoices = row.order_uom_choices
|
||||||
this.productUOM = row.order_uom
|
this.productUOM = row.order_uom
|
||||||
|
|
||||||
|
% if product_price_may_be_questionable:
|
||||||
this.productPriceNeedsConfirmation = row.price_needs_confirmation
|
this.productPriceNeedsConfirmation = row.price_needs_confirmation
|
||||||
|
% endif
|
||||||
|
|
||||||
this.showingItemDialog = true
|
this.showingItemDialog = true
|
||||||
},
|
},
|
||||||
|
@ -1348,7 +1364,10 @@
|
||||||
this.productURL = null
|
this.productURL = null
|
||||||
this.productImageURL = null
|
this.productImageURL = null
|
||||||
this.productUnitChoices = this.defaultUnitChoices
|
this.productUnitChoices = this.defaultUnitChoices
|
||||||
|
|
||||||
|
% if product_price_may_be_questionable:
|
||||||
this.productPriceNeedsConfirmation = false
|
this.productPriceNeedsConfirmation = false
|
||||||
|
% endif
|
||||||
},
|
},
|
||||||
|
|
||||||
setProductUnitChoices(choices) {
|
setProductUnitChoices(choices) {
|
||||||
|
@ -1387,7 +1406,10 @@
|
||||||
this.productURL = response.data.url
|
this.productURL = response.data.url
|
||||||
this.productImageURL = response.data.image_url
|
this.productImageURL = response.data.image_url
|
||||||
this.setProductUnitChoices(response.data.uom_choices)
|
this.setProductUnitChoices(response.data.uom_choices)
|
||||||
|
|
||||||
|
% if product_price_may_be_questionable:
|
||||||
this.productPriceNeedsConfirmation = false
|
this.productPriceNeedsConfirmation = false
|
||||||
|
% endif
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.clearProduct()
|
this.clearProduct()
|
||||||
|
@ -1401,7 +1423,10 @@
|
||||||
product_uuid: this.productUUID,
|
product_uuid: this.productUUID,
|
||||||
order_quantity: this.productQuantity,
|
order_quantity: this.productQuantity,
|
||||||
order_uom: this.productUOM,
|
order_uom: this.productUOM,
|
||||||
|
|
||||||
|
% if product_price_may_be_questionable:
|
||||||
price_needs_confirmation: this.productPriceNeedsConfirmation,
|
price_needs_confirmation: this.productPriceNeedsConfirmation,
|
||||||
|
% endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.editingItem) {
|
if (this.editingItem) {
|
||||||
|
|
|
@ -188,7 +188,11 @@ class CustomerOrderView(MasterView):
|
||||||
g.set_type('order_quantity', 'quantity')
|
g.set_type('order_quantity', 'quantity')
|
||||||
g.set_type('cases_ordered', 'quantity')
|
g.set_type('cases_ordered', 'quantity')
|
||||||
g.set_type('units_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_enum('order_uom', self.enum.UNIT_OF_MEASURE)
|
||||||
g.set_renderer('status_code', self.render_row_status_code)
|
g.set_renderer('status_code', self.render_row_status_code)
|
||||||
|
@ -277,6 +281,7 @@ class CustomerOrderView(MasterView):
|
||||||
'batch': batch,
|
'batch': batch,
|
||||||
'normalized_batch': self.normalize_batch(batch),
|
'normalized_batch': self.normalize_batch(batch),
|
||||||
'new_order_requires_customer': self.handler.new_order_requires_customer(),
|
'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(),
|
'allow_contact_info_choice': self.handler.allow_contact_info_choice(),
|
||||||
'restrict_contact_info': self.handler.should_restrict_contact_info(),
|
'restrict_contact_info': self.handler.should_restrict_contact_info(),
|
||||||
'order_items': items,
|
'order_items': items,
|
||||||
|
@ -615,12 +620,14 @@ class CustomerOrderView(MasterView):
|
||||||
'unit_price_display': self.get_unit_price_display(row),
|
'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': 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,
|
'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_code': row.status_code,
|
||||||
'status_text': row.status_text,
|
'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()
|
key = self.rattail_config.product_key()
|
||||||
if key == 'upc':
|
if key == 'upc':
|
||||||
data['product_key'] = data['product_upc_pretty']
|
data['product_key'] = data['product_upc_pretty']
|
||||||
|
@ -669,10 +676,14 @@ class CustomerOrderView(MasterView):
|
||||||
if not product:
|
if not product:
|
||||||
return {'error': "Product not found"}
|
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,
|
row = self.handler.add_product(batch, product,
|
||||||
decimal.Decimal(data.get('order_quantity') or '0'),
|
decimal.Decimal(data.get('order_quantity') or '0'),
|
||||||
data.get('order_uom'),
|
data.get('order_uom'),
|
||||||
price_needs_confirmation=data.get('price_needs_confirmation'))
|
**kwargs)
|
||||||
self.Session.flush()
|
self.Session.flush()
|
||||||
|
|
||||||
else: # product is not known
|
else: # product is not known
|
||||||
|
@ -707,7 +718,10 @@ class CustomerOrderView(MasterView):
|
||||||
row.product = product
|
row.product = product
|
||||||
row.order_quantity = decimal.Decimal(data.get('order_quantity') or '0')
|
row.order_quantity = decimal.Decimal(data.get('order_quantity') or '0')
|
||||||
row.order_uom = data.get('order_uom')
|
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.handler.refresh_row(row)
|
||||||
self.Session.flush()
|
self.Session.flush()
|
||||||
self.Session.refresh(row)
|
self.Session.refresh(row)
|
||||||
|
|
Loading…
Reference in a new issue