diff --git a/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py b/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py index 3d898ba..8113e05 100644 --- a/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py +++ b/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py @@ -26,6 +26,7 @@ CORE-POS -> Catapult Inventory Workbook import re import datetime +import decimal import logging from sqlalchemy.exc import ProgrammingError @@ -407,13 +408,25 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo if self.exclude_missing_department: return - size = "{} {}".format((product.size or '').strip(), - (product.unit_of_measure or '').strip()) - size = size.strip() + # size may come from one of two fields, or combination thereof + pack_size = (product.size or '').strip() + uom = (product.unit_of_measure or '').strip() + numeric_pack = False + if pack_size: + try: + decimal.Decimal(pack_size) + except decimal.InvalidOperation: + pass + else: + numeric_pack = True + if numeric_pack: + size = "{} {}".format(pack_size, uom).strip() + else: + size = pack_size or uom or None # TODO: this logic may actually be client-specific? i just happened to - # find some of these chars in a client DB and needed to avoid them, b/c - # the openpyxl lib said IllegalCharacterError - if '\x00' in size: + # find some null chars in a client DB and needed to avoid them, b/c the + # openpyxl lib said IllegalCharacterError + if size is not None and '\x00' in size: logger = log.warning if self.warn_size_null_byte else log.debug logger("product %s has null byte in size field: %s", product.upc, product)