From 9daefed9b35c966e19cc168030671afe62eac591 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 7 Nov 2018 13:08:59 -0600 Subject: [PATCH] Detect non-numeric entry when locating row for purchase batch i.e. don't try to convert to GPC if non-numeric --- tailbone/views/purchasing/receiving.py | 31 +++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/tailbone/views/purchasing/receiving.py b/tailbone/views/purchasing/receiving.py index b5332f2d..8c935587 100644 --- a/tailbone/views/purchasing/receiving.py +++ b/tailbone/views/purchasing/receiving.py @@ -1077,20 +1077,22 @@ class ReceivingBatchView(PurchasingBatchView): key = self.rattail_config.product_key() if key == 'upc': - # we prefer "exact" UPC matches, i.e. those which assumed the entry - # already contained the check digit. - provided = GPC(entry, calc_check_digit=False) - rows = [row for row in batch.active_rows() - if row.upc == provided] - if rows: - return rows + if entry.isdigit(): - # if no "exact" UPC matches, we'll settle for those (UPC matches) - # which assume the entry lacked a check digit. - checked = GPC(entry, calc_check_digit='upc') - rows = [row for row in batch.active_rows() - if row.upc == checked] - return rows + # we prefer "exact" UPC matches, i.e. those which assumed the entry + # already contained the check digit. + provided = GPC(entry, calc_check_digit=False) + rows = [row for row in batch.active_rows() + if row.upc == provided] + if rows: + return rows + + # if no "exact" UPC matches, we'll settle for those (UPC matches) + # which assume the entry lacked a check digit. + checked = GPC(entry, calc_check_digit='upc') + rows = [row for row in batch.active_rows() + if row.upc == checked] + return rows elif key == 'item_id': rows = [row for row in batch.active_rows() @@ -1162,6 +1164,9 @@ class ReceivingBatchView(PurchasingBatchView): if len(entry) > 14: return + if not entry.isdigit(): + return + provided = GPC(entry, calc_check_digit=False) checked = GPC(entry, calc_check_digit='upc')