Accept any decimal numbers for API inventory batch counts
i.e. don't assume integer values
This commit is contained in:
		
							parent
							
								
									c48371ca2a
								
							
						
					
					
						commit
						2d75409757
					
				
					 1 changed files with 7 additions and 3 deletions
				
			
		|  | @ -2,7 +2,7 @@ | |||
| ################################################################################ | ||||
| # | ||||
| #  Rattail -- Retail Software Framework | ||||
| #  Copyright © 2010-2020 Lance Edgar | ||||
| #  Copyright © 2010-2021 Lance Edgar | ||||
| # | ||||
| #  This file is part of Rattail. | ||||
| # | ||||
|  | @ -26,6 +26,8 @@ Tailbone Web API - Inventory Batches | |||
| 
 | ||||
| from __future__ import unicode_literals, absolute_import | ||||
| 
 | ||||
| import decimal | ||||
| 
 | ||||
| import six | ||||
| 
 | ||||
| from rattail import pod | ||||
|  | @ -157,17 +159,19 @@ class InventoryBatchRowViews(APIBatchRowView): | |||
| 
 | ||||
|         Converts certain fields within the data, to proper "native" types. | ||||
|         """ | ||||
|         data = dict(data) | ||||
| 
 | ||||
|         # convert some data types as needed | ||||
|         if 'cases' in data: | ||||
|             if data['cases'] == '': | ||||
|                 data['cases'] = None | ||||
|             elif data['cases']: | ||||
|                 data['cases'] = int(data['cases']) | ||||
|                 data['cases'] = decimal.Decimal(data['cases']) | ||||
|         if 'units' in data: | ||||
|             if data['units'] == '': | ||||
|                 data['units'] = None | ||||
|             elif data['units']: | ||||
|                 data['units'] = int(data['units']) | ||||
|                 data['units'] = decimal.Decimal(data['units']) | ||||
| 
 | ||||
|         # update row per usual | ||||
|         row = super(InventoryBatchRowViews, self).update_object(row, data) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar