Changeset - 5a75a992639c
[Not reviewed]
0 1 0
Lance Edgar - 5 years ago 2020-03-29 23:13:52
lance@edbob.org
Add 'pos_menu_group' and 'weight_profile' to Catapult export
1 file changed with 27 insertions and 10 deletions:
0 comments (0 inline, 0 general) First comment
rattail_corepos/corepos/importing/db/exporters/catapult_inventory.py
Show inline comments
 
@@ -46,6 +46,7 @@ class FromCoreToCatapult(FromCoreHandler, ToFileHandler):
 
    """
 
    host_title = "CORE-POS"
 
    local_title = "Catapult (Inventory Workbook)"
 
    direction = 'export'
 

	
 
    def get_importers(self):
 
        importers = OrderedDict()
 
@@ -73,11 +74,11 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
 
        # 'disc_mult',
 
        # 'ideal_margin',
 
        'bottle_deposit',
 
        # 'pos_menu_group',
 
        'pos_menu_group',
 
        # 'scale_label',
 
        'sold_by_ea_or_lb',
 
        'quantity_required',
 
        # 'weight_profile',
 
        'weight_profile',
 
        'tax_1',
 
        'tax_2',
 
        'spec_tend_1',
 
@@ -110,10 +111,21 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
 
        # '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):
 
        query = self.host_session.query(corepos.Product)\
 
                                 .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
 

	
 
    def normalize_host_object(self, product):
 
@@ -129,6 +141,10 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
 
                      item_id, product)
 
            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
 
        if len(str(int(item_id))) < 6:
 
            is_plu = True
 
@@ -145,14 +161,18 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
 

	
 
        department = product.department
 
        if not department:
 
            log.warning("item_id %s has no department: %s",
 
                        item_id, product)
 
            logger = log.warning if self.warn_missing_department else log.debug
 
            logger("item_id %s has no department: %s", item_id, product)
 
            return
 

	
 
        sold_by_ea_or_lb = None
 
        if is_plu:
 
            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
 
        tax_1 = 0
 
        tax_2 = 0
 
@@ -200,17 +220,14 @@ class InventoryItemImporter(FromCore, catapult_importing.model.InventoryItemImpo
 
            # 'ideal_margin': None,
 

	
 
            'bottle_deposit': product.deposit or None,
 
            'pos_menu_group': product.subdepartment.name if product.subdepartment else None,
 

	
 
            # TODO: does CORE have these?
 
            # 'pos_menu_group': None,
 
            # 'scale_label': None,
 

	
 
            'sold_by_ea_or_lb': sold_by_ea_or_lb,
 
            'quantity_required': 'Y' if product.quantity_enforced else None,
 

	
 
            # TODO: does CORE have this?
 
            # 'weight_profile': None,
 

	
 
            'weight_profile': weight_profile,
 
            'tax_1': tax_1 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,
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now