From c5e618d5177408e9107b303e29a773090e366d1c Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Mon, 30 Mar 2020 12:00:30 -0500 Subject: [PATCH] Add scale info fields to Catapult export --- .../db/exporters/catapult_inventory.py | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py b/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py index 8372e4e..0e0d280 100644 --- a/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py +++ b/rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py @@ -76,7 +76,7 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo 'ideal_margin', 'bottle_deposit', 'pos_menu_group', - # 'scale_label', + 'scale_label', 'sold_by_ea_or_lb', 'quantity_required', 'weight_profile', @@ -107,9 +107,9 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo # 'pf7', # 'pf8', # 'memo', - # 'scale_shelf_life', - # 'scale_shelf_life_type', - # 'scale_ingredient_text', + 'scale_shelf_life', + 'scale_shelf_life_type', + 'scale_ingredient_text', ] def setup(self): @@ -141,7 +141,8 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo .options(orm.joinedload(corepos.Product.subdepartment))\ .options(orm.joinedload(corepos.Product.vendor_items)\ .joinedload(corepos.VendorItem.vendor))\ - .options(orm.joinedload(corepos.Product.default_vendor)) + .options(orm.joinedload(corepos.Product.default_vendor))\ + .options(orm.joinedload(corepos.Product.scale_item)) return query def normalize_host_object(self, product): @@ -273,6 +274,15 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo logger("product %s has %s vendorItems but each is missing (valid) vendor: %s", product.upc, len(product.vendor_items), product) + scale_item = product.scale_item + scale_ingredient_text = None + if scale_item: + scale_ingredient_text = scale_item.text + if "\n" in scale_ingredient_text: + log.warning("must remove carriage returns for scale ingredients: %s", + scale_ingredient_text) + scale_ingredient_text = scale_ingredient_text.replace("\n", " ") + if vendor_items: if len(vendor_items) > 1: @@ -324,10 +334,7 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo 'bottle_deposit': product.deposit or None, 'pos_menu_group': product.subdepartment.name if product.subdepartment else None, - - # TODO: does CORE have these? - # 'scale_label': None, - + 'scale_label': 'Y' if scale_item else None, 'sold_by_ea_or_lb': sold_by_ea_or_lb, 'quantity_required': 'Y' if product.quantity_enforced else None, 'weight_profile': weight_profile, @@ -369,9 +376,10 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo # 'pf7', # 'pf8', - # TODO: does CORE have these? + # TODO: does CORE have this? # 'memo': None, - # 'scale_shelf_life', - # 'scale_shelf_life_type', - # 'scale_ingredient_text', + + 'scale_shelf_life': scale_item.shelf_life if scale_item else None, + 'scale_shelf_life_type': 0 if scale_item else None, + 'scale_ingredient_text': scale_ingredient_text, }