Add "quick receive all" support for mobile receiving
i.e. quick receive button can now receive all/remainder of the ordered qty
This commit is contained in:
		
							parent
							
								
									d4b2cf9943
								
							
						
					
					
						commit
						56392ccdd0
					
				
					 3 changed files with 39 additions and 6 deletions
				
			
		|  | @ -1113,6 +1113,8 @@ class ReceivingBatchView(PurchasingBatchView): | |||
|             'form': form, | ||||
|             'allow_expired': self.handler.allow_expired_credits(), | ||||
|             'allow_cases': self.handler.allow_cases(), | ||||
|             'quick_receive': self.rattail_config.getbool('rattail.batch', 'purchase.mobile_quick_receive', default=True), | ||||
|             'quick_receive_all': self.rattail_config.getbool('rattail.batch', 'purchase.mobile_quick_receive_all', default=False) | ||||
|         } | ||||
| 
 | ||||
|         if self.request.has_perm('{}.create_row'.format(permission_prefix)): | ||||
|  | @ -1165,6 +1167,32 @@ class ReceivingBatchView(PurchasingBatchView): | |||
|         # unit_uom can vary by product | ||||
|         context['unit_uom'] = 'LB' if row.product and row.product.weighed else 'EA' | ||||
| 
 | ||||
|         if context['quick_receive'] and context['quick_receive_all']: | ||||
|             if context['allow_cases']: | ||||
|                 context['quick_receive_uom'] = 'CS' | ||||
|                 raise NotImplementedError("TODO: add CS support for quick_receive_all") | ||||
|             else: | ||||
|                 context['quick_receive_uom'] = context['unit_uom'] | ||||
|                 accounted_for = self.handler.get_units_accounted_for(row) | ||||
|                 remainder = self.handler.get_units_ordered(row) - accounted_for | ||||
| 
 | ||||
|                 if accounted_for: | ||||
|                     # some product accounted for; button should receive "remainder" only | ||||
|                     if remainder: | ||||
|                         remainder = pretty_quantity(remainder) | ||||
|                         context['quick_receive_quantity'] = remainder | ||||
|                         context['quick_receive_text'] = "Receive Remainder ({} {})".format(remainder, context['unit_uom']) | ||||
|                     else: | ||||
|                         # unless there is no remainder, in which case disable it | ||||
|                         context['quick_receive'] = False | ||||
| 
 | ||||
|                 else: # nothing yet accounted for, button should receive "all" | ||||
|                     if not remainder: | ||||
|                         raise ValueError("why is remainder empty?") | ||||
|                     remainder = pretty_quantity(remainder) | ||||
|                     context['quick_receive_quantity'] = remainder | ||||
|                     context['quick_receive_text'] = "Receive ALL ({} {})".format(remainder, context['unit_uom']) | ||||
| 
 | ||||
|         # effective uom can vary in a few ways...the basic default is 'CS' if | ||||
|         # self.default_uom_is_case is true, otherwise whatever unit_uom is. | ||||
|         sticky_case = self.request.session.get('tailbone.mobile.receiving.sticky_uom_is_case') | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar