Fix bug in KeHe invoice parser, if row has no UPC.
This commit is contained in:
parent
f420d1fdd9
commit
8d37cff1f1
38
rattail/contrib/vendors/catalogs/kehe.py
vendored
38
rattail/contrib/vendors/catalogs/kehe.py
vendored
|
@ -74,7 +74,8 @@ class KeheCatalogParser(CatalogParser):
|
|||
for r in range(1, sheet.nrows): # Skip first header row.
|
||||
|
||||
row = VendorCatalogRow()
|
||||
row.upc = GPC(int(sheet.cell_value(r, 5)))
|
||||
upc = sheet.cell_value(r, 5) or None
|
||||
row.upc = GPC(int(upc)) if upc else None
|
||||
row.brand_name = sheet.cell_value(r, 1)
|
||||
row.description = sheet.cell_value(r, 2)
|
||||
row.size = sheet.cell_value(r, 3)
|
||||
|
@ -89,25 +90,26 @@ class KeheCatalogParser(CatalogParser):
|
|||
# use the "Case Pack" column in that case.
|
||||
case_pack = int(sheet.cell_value(r, 6))
|
||||
unit_of_sales = int(sheet.cell_value(r, 7))
|
||||
product = products.get(row.upc)
|
||||
if product:
|
||||
if row.upc:
|
||||
product = products.get(row.upc)
|
||||
if product:
|
||||
|
||||
# First we try to find an existing cost record for KeHE. If
|
||||
# one exists, we will honor its case size.
|
||||
cost = product.cost_for_vendor(self.vendor)
|
||||
if cost:
|
||||
if cost.case_size == case_pack:
|
||||
row.case_size = case_pack
|
||||
elif cost.case_size == unit_of_sales:
|
||||
row.case_size = unit_of_sales
|
||||
# First we try to find an existing cost record for KeHE. If
|
||||
# one exists, we will honor its case size.
|
||||
cost = product.cost_for_vendor(self.vendor)
|
||||
if cost:
|
||||
if cost.case_size == case_pack:
|
||||
row.case_size = case_pack
|
||||
elif cost.case_size == unit_of_sales:
|
||||
row.case_size = unit_of_sales
|
||||
|
||||
# If there was no KeHE cost record, then we'll honor the
|
||||
# "preferred" cost record case size, if it has one.
|
||||
if row.case_size is None and product.cost:
|
||||
if product.cost.case_size == case_pack:
|
||||
row.case_size = case_pack
|
||||
elif product.cost.case_size == unit_of_sales:
|
||||
row.case_size = unit_of_sales
|
||||
# If there was no KeHE cost record, then we'll honor the
|
||||
# "preferred" cost record case size, if it has one.
|
||||
if row.case_size is None and product.cost:
|
||||
if product.cost.case_size == case_pack:
|
||||
row.case_size = case_pack
|
||||
elif product.cost.case_size == unit_of_sales:
|
||||
row.case_size = unit_of_sales
|
||||
|
||||
# If all else fails, use the "Case Pack" column.
|
||||
if row.case_size is None:
|
||||
|
|
Loading…
Reference in a new issue