Add 'price_divider' for Catapult export

This commit is contained in:
Lance Edgar 2020-03-30 09:44:12 -05:00
parent 4cb42d06ea
commit c2c10de64b

View file

@ -170,6 +170,15 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
logger("item_id %s has no department: %s", item_id, product)
return
price_divider = None
if (product.quantity and product.group_price and
product.price_method == corepos_enum.PRODUCT_PRICE_METHOD_ALWAYS):
diff = (product.quantity * product.normal_price) - product.group_price
if abs(round(diff, 2)) > .01:
log.warning("product %s has multi-price with $%0.2f diff: %s",
item_id, diff, product)
price_divider = product.quantity
sold_by_ea_or_lb = None
if is_plu:
sold_by_ea_or_lb = 'LB' if product.scale else 'EA'
@ -241,7 +250,7 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
# 'sugg_retail': None,
'last_cost': product.cost,
'price_divider': product.quantity or 1, # TODO: is this right?
'price_divider': price_divider,
'base_price': product.normal_price,
'ideal_margin': department.margin * 100 if department.margin else None,