From 2d754097574806371b349c3ec66f1948d06b21c8 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 12 Apr 2021 11:36:24 -0500 Subject: [PATCH] Accept any decimal numbers for API inventory batch counts i.e. don't assume integer values --- tailbone/api/batch/inventory.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tailbone/api/batch/inventory.py b/tailbone/api/batch/inventory.py index 40ab8ef6..a798c58e 100644 --- a/tailbone/api/batch/inventory.py +++ b/tailbone/api/batch/inventory.py @@ -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)