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()
|
key = self.rattail_config.product_key()
|
||||||
if key == 'upc':
|
if key == 'upc':
|
||||||
|
|
||||||
# we prefer "exact" UPC matches, i.e. those which assumed the entry
|
if entry.isdigit():
|
||||||
# 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)
|
# we prefer "exact" UPC matches, i.e. those which assumed the entry
|
||||||
# which assume the entry lacked a check digit.
|
# already contained the check digit.
|
||||||
checked = GPC(entry, calc_check_digit='upc')
|
provided = GPC(entry, calc_check_digit=False)
|
||||||
rows = [row for row in batch.active_rows()
|
rows = [row for row in batch.active_rows()
|
||||||
if row.upc == checked]
|
if row.upc == provided]
|
||||||
return rows
|
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':
|
elif key == 'item_id':
|
||||||
rows = [row for row in batch.active_rows()
|
rows = [row for row in batch.active_rows()
|
||||||
|
@ -1162,6 +1164,9 @@ class ReceivingBatchView(PurchasingBatchView):
|
||||||
if len(entry) > 14:
|
if len(entry) > 14:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not entry.isdigit():
|
||||||
|
return
|
||||||
|
|
||||||
provided = GPC(entry, calc_check_digit=False)
|
provided = GPC(entry, calc_check_digit=False)
|
||||||
checked = GPC(entry, calc_check_digit='upc')
|
checked = GPC(entry, calc_check_digit='upc')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue