Tweak CORE DB -> Rattail for Product, to match CORE API -> Rattail

This commit is contained in:
Lance Edgar 2020-03-16 15:44:41 -05:00
parent 36b8afb03b
commit 85c45ef57e

View file

@ -42,7 +42,7 @@ class FromCOREPOSToRattail(importing.FromSQLAlchemyHandler, importing.ToRattailH
@property @property
def host_title(self): def host_title(self):
return "CORE POS ({})".format(self.corepos_dbkey) return "CORE POS (DB/{})".format(self.corepos_dbkey)
def make_host_session(self): def make_host_session(self):
return CoreSession(bind=self.config.corepos_engines[self.corepos_dbkey]) return CoreSession(bind=self.config.corepos_engines[self.corepos_dbkey])
@ -158,7 +158,7 @@ class ProductImporter(FromCOREPOS, importing.model.ProductImporter):
Importer for product data from CORE POS. Importer for product data from CORE POS.
""" """
host_model_class = corepos.Product host_model_class = corepos.Product
key = 'upc' key = 'item_id'
supported_fields = [ supported_fields = [
'item_id', 'item_id',
'upc', 'upc',
@ -172,7 +172,7 @@ class ProductImporter(FromCOREPOS, importing.model.ProductImporter):
'regular_price_multiple', 'regular_price_multiple',
'regular_price_type', 'regular_price_type',
'food_stampable', 'food_stampable',
'tax1', # 'tax1',
] ]
def normalize_host_object(self, product): def normalize_host_object(self, product):
@ -189,23 +189,19 @@ class ProductImporter(FromCOREPOS, importing.model.ProductImporter):
if product.normal_price is not None: if product.normal_price is not None:
price = decimal.Decimal('{:03f}'.format(product.normal_price)) price = decimal.Decimal('{:03f}'.format(product.normal_price))
size = (product.size or '').strip() or None
if size == '0': # TODO: this is only for sake of CORE sample data...
size = None
return { return {
'item_id': product.upc, 'item_id': product.upc,
'upc': upc, 'upc': upc,
'brand_name': (product.brand or '').strip() or None, 'brand_name': (product.brand or '').strip() or None,
'description': (product.description or '').strip(), 'description': (product.description or '').strip(),
'size': size, 'size': (product.size or '').strip() or None,
'department_number': product.department_number or None, 'department_number': product.department_number or None,
'subdepartment_number': product.subdepartment_number or None, 'subdepartment_number': product.subdepartment_number or None,
'weighed': bool(product.scale), 'weighed': bool(product.scale),
'food_stampable': product.foodstamp, 'food_stampable': product.foodstamp,
'tax1': bool(product.tax), # TODO: is this right? # 'tax1': bool(product.tax), # TODO: is this right?
'regular_price_price': price, 'regular_price_price': price,
'regular_price_multiple': 1 if price is not None else None, 'regular_price_multiple': 1 if price is not None else None,