Detect non-numeric entry when locating row for purchase batch
i.e. don't try to convert to GPC if non-numeric
This commit is contained in:
parent
23a94ebfad
commit
9daefed9b3
|
@ -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')
|
||||
|
||||
|
|
Loading…
Reference in a new issue