Add 'pos_menu_group' and 'weight_profile' to Catapult export
This commit is contained in:
parent
5e2fa46650
commit
5a75a99263
|
@ -46,6 +46,7 @@ class FromCoreToCatapult(FromCoreHandler, ToFileHandler):
|
||||||
"""
|
"""
|
||||||
host_title = "CORE-POS"
|
host_title = "CORE-POS"
|
||||||
local_title = "Catapult (Inventory Workbook)"
|
local_title = "Catapult (Inventory Workbook)"
|
||||||
|
direction = 'export'
|
||||||
|
|
||||||
def get_importers(self):
|
def get_importers(self):
|
||||||
importers = OrderedDict()
|
importers = OrderedDict()
|
||||||
|
@ -73,11 +74,11 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
# 'disc_mult',
|
# 'disc_mult',
|
||||||
# 'ideal_margin',
|
# 'ideal_margin',
|
||||||
'bottle_deposit',
|
'bottle_deposit',
|
||||||
# 'pos_menu_group',
|
'pos_menu_group',
|
||||||
# 'scale_label',
|
# 'scale_label',
|
||||||
'sold_by_ea_or_lb',
|
'sold_by_ea_or_lb',
|
||||||
'quantity_required',
|
'quantity_required',
|
||||||
# 'weight_profile',
|
'weight_profile',
|
||||||
'tax_1',
|
'tax_1',
|
||||||
'tax_2',
|
'tax_2',
|
||||||
'spec_tend_1',
|
'spec_tend_1',
|
||||||
|
@ -110,10 +111,21 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
# 'scale_ingredient_text',
|
# 'scale_ingredient_text',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def setup(self):
|
||||||
|
super(InventoryItemImporter, self).setup()
|
||||||
|
|
||||||
|
self.ignored_upcs = self.config.getlist(
|
||||||
|
'corepos', 'exporting.catapult_inventory.ignored_upcs')
|
||||||
|
|
||||||
|
self.warn_missing_department = self.config.getbool(
|
||||||
|
'corepos', 'exporting.catapult_inventory.warn_missing_department',
|
||||||
|
default=True)
|
||||||
|
|
||||||
def query(self):
|
def query(self):
|
||||||
query = self.host_session.query(corepos.Product)\
|
query = self.host_session.query(corepos.Product)\
|
||||||
.order_by(corepos.Product.upc)\
|
.order_by(corepos.Product.upc)\
|
||||||
.options(orm.joinedload(corepos.Product.department))
|
.options(orm.joinedload(corepos.Product.department))\
|
||||||
|
.options(orm.joinedload(corepos.Product.subdepartment))
|
||||||
return query
|
return query
|
||||||
|
|
||||||
def normalize_host_object(self, product):
|
def normalize_host_object(self, product):
|
||||||
|
@ -129,6 +141,10 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
item_id, product)
|
item_id, product)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.ignored_upcs and item_id in self.ignored_upcs:
|
||||||
|
log.debug("ignoring UPC %s for product: %s", item_id, product)
|
||||||
|
return
|
||||||
|
|
||||||
is_plu = False
|
is_plu = False
|
||||||
if len(str(int(item_id))) < 6:
|
if len(str(int(item_id))) < 6:
|
||||||
is_plu = True
|
is_plu = True
|
||||||
|
@ -145,14 +161,18 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
|
|
||||||
department = product.department
|
department = product.department
|
||||||
if not department:
|
if not department:
|
||||||
log.warning("item_id %s has no department: %s",
|
logger = log.warning if self.warn_missing_department else log.debug
|
||||||
item_id, product)
|
logger("item_id %s has no department: %s", item_id, product)
|
||||||
return
|
return
|
||||||
|
|
||||||
sold_by_ea_or_lb = None
|
sold_by_ea_or_lb = None
|
||||||
if is_plu:
|
if is_plu:
|
||||||
sold_by_ea_or_lb = 'LB' if product.scale else 'EA'
|
sold_by_ea_or_lb = 'LB' if product.scale else 'EA'
|
||||||
|
|
||||||
|
weight_profile = None
|
||||||
|
if product.scale and len(item_id) == 12 and item_id[0] == '2':
|
||||||
|
weight_profile = 'LBNT'
|
||||||
|
|
||||||
# TODO: need to finish the logic to map/calculate tax rates
|
# TODO: need to finish the logic to map/calculate tax rates
|
||||||
tax_1 = 0
|
tax_1 = 0
|
||||||
tax_2 = 0
|
tax_2 = 0
|
||||||
|
@ -200,17 +220,14 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
|
||||||
# 'ideal_margin': None,
|
# 'ideal_margin': None,
|
||||||
|
|
||||||
'bottle_deposit': product.deposit or None,
|
'bottle_deposit': product.deposit or None,
|
||||||
|
'pos_menu_group': product.subdepartment.name if product.subdepartment else None,
|
||||||
|
|
||||||
# TODO: does CORE have these?
|
# TODO: does CORE have these?
|
||||||
# 'pos_menu_group': None,
|
|
||||||
# 'scale_label': None,
|
# 'scale_label': None,
|
||||||
|
|
||||||
'sold_by_ea_or_lb': sold_by_ea_or_lb,
|
'sold_by_ea_or_lb': sold_by_ea_or_lb,
|
||||||
'quantity_required': 'Y' if product.quantity_enforced else None,
|
'quantity_required': 'Y' if product.quantity_enforced else None,
|
||||||
|
'weight_profile': weight_profile,
|
||||||
# TODO: does CORE have this?
|
|
||||||
# 'weight_profile': None,
|
|
||||||
|
|
||||||
'tax_1': tax_1 or None, # TODO: logic above is unfinished
|
'tax_1': tax_1 or None, # TODO: logic above is unfinished
|
||||||
'tax_2': tax_2 or None, # TODO: logic above is unfinished
|
'tax_2': tax_2 or None, # TODO: logic above is unfinished
|
||||||
'spec_tend_1': 'EBT' if product.foodstamp else None,
|
'spec_tend_1': 'EBT' if product.foodstamp else None,
|
||||||
|
|
Loading…
Reference in a new issue