Add basic per-item discount support for custorders
This commit is contained in:
parent
b37f63a231
commit
2950827c63
3 changed files with 82 additions and 2 deletions
|
@ -348,6 +348,7 @@ class CustomerOrderView(MasterView):
|
|||
'department_options': self.get_department_options(),
|
||||
'default_uom_choices': self.batch_handler.uom_choices_for_product(None),
|
||||
'default_uom': None,
|
||||
'allow_item_discounts': self.batch_handler.allow_item_discounts(),
|
||||
})
|
||||
|
||||
if self.batch_handler.allow_case_orders():
|
||||
|
@ -695,6 +696,7 @@ class CustomerOrderView(MasterView):
|
|||
'order_quantity': pretty_quantity(row.order_quantity),
|
||||
'order_uom': row.order_uom,
|
||||
'order_uom_choices': self.uom_choices_for_row(row),
|
||||
'discount_percent': pretty_quantity(row.discount_percent),
|
||||
|
||||
'department_display': row.department_name,
|
||||
|
||||
|
@ -807,6 +809,7 @@ class CustomerOrderView(MasterView):
|
|||
|
||||
order_quantity = decimal.Decimal(data.get('order_quantity') or '0')
|
||||
order_uom = data.get('order_uom')
|
||||
discount_percent = decimal.Decimal(data.get('discount_percent') or '0')
|
||||
|
||||
if data.get('product_is_known'):
|
||||
|
||||
|
@ -822,6 +825,9 @@ class CustomerOrderView(MasterView):
|
|||
if self.batch_handler.product_price_may_be_questionable():
|
||||
kwargs['price_needs_confirmation'] = data.get('price_needs_confirmation')
|
||||
|
||||
if self.batch_handler.allow_item_discounts():
|
||||
kwargs['discount_percent'] = discount_percent
|
||||
|
||||
row = self.batch_handler.add_product(batch, product,
|
||||
order_quantity, order_uom,
|
||||
**kwargs)
|
||||
|
@ -838,9 +844,14 @@ class CustomerOrderView(MasterView):
|
|||
|
||||
pending_info['user'] = self.request.user
|
||||
|
||||
kwargs = {}
|
||||
if self.batch_handler.allow_item_discounts():
|
||||
kwargs['discount_percent'] = discount_percent
|
||||
|
||||
row = self.batch_handler.add_pending_product(batch,
|
||||
pending_info,
|
||||
order_quantity, order_uom)
|
||||
order_quantity, order_uom,
|
||||
**kwargs)
|
||||
|
||||
self.Session.flush()
|
||||
return {'batch': self.normalize_batch(batch),
|
||||
|
@ -860,6 +871,7 @@ class CustomerOrderView(MasterView):
|
|||
|
||||
order_quantity = decimal.Decimal(data.get('order_quantity') or '0')
|
||||
order_uom = data.get('order_uom')
|
||||
discount_percent = decimal.Decimal(data.get('discount_percent') or '0')
|
||||
|
||||
if data.get('product_is_known'):
|
||||
|
||||
|
@ -879,6 +891,9 @@ class CustomerOrderView(MasterView):
|
|||
if self.batch_handler.product_price_may_be_questionable():
|
||||
row.price_needs_confirmation = data.get('price_needs_confirmation')
|
||||
|
||||
if self.batch_handler.allow_item_discounts():
|
||||
row.discount_percent = discount_percent
|
||||
|
||||
self.batch_handler.refresh_row(row)
|
||||
|
||||
else: # product is not known
|
||||
|
@ -887,6 +902,9 @@ class CustomerOrderView(MasterView):
|
|||
row.order_quantity = order_quantity
|
||||
row.order_uom = order_uom
|
||||
|
||||
if self.batch_handler.allow_item_discounts():
|
||||
row.discount_percent = discount_percent
|
||||
|
||||
# nb. this will refresh the row
|
||||
pending_info = dict(data['pending_product'])
|
||||
self.batch_handler.update_pending_product(row, pending_info)
|
||||
|
@ -965,6 +983,9 @@ class CustomerOrderView(MasterView):
|
|||
{'section': 'rattail.custorders',
|
||||
'option': 'allow_unknown_product',
|
||||
'type': bool},
|
||||
{'section': 'rattail.custorders',
|
||||
'option': 'allow_item_discounts',
|
||||
'type': bool},
|
||||
]
|
||||
|
||||
@classmethod
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue