From e8dfe92be33cb85761963ccb70d60a12322d8a1d Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 25 Jan 2018 15:07:16 -0600 Subject: [PATCH] Improve case/unit quantity validation for order worksheet --- tailbone/views/purchasing/ordering.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tailbone/views/purchasing/ordering.py b/tailbone/views/purchasing/ordering.py index 32db947a..fb1a6a4f 100644 --- a/tailbone/views/purchasing/ordering.py +++ b/tailbone/views/purchasing/ordering.py @@ -202,11 +202,15 @@ class OrderingBatchView(PurchasingBatchView): if not cases_ordered or not cases_ordered.isdigit(): return {'error': "Invalid value for cases ordered: {}".format(cases_ordered)} cases_ordered = int(cases_ordered) + if cases_ordered >= 100000: # TODO: really this depends on underlying column + return {'error': "Invalid value for cases ordered: {}".format(cases_ordered)} units_ordered = self.request.POST.get('units_ordered', '0') if not units_ordered or not units_ordered.isdigit(): return {'error': "Invalid value for units ordered: {}".format(units_ordered)} units_ordered = int(units_ordered) + if units_ordered >= 100000: # TODO: really this depends on underlying column + return {'error': "Invalid value for units ordered: {}".format(units_ordered)} uuid = self.request.POST.get('product_uuid') product = self.Session.query(model.Product).get(uuid) if uuid else None