Add support for Department, Subdepartment, Product in Rattail -> CORE API
This commit is contained in:
parent
ab8894ef0d
commit
cd93d3e36b
4 changed files with 301 additions and 18 deletions
|
@ -102,10 +102,14 @@ class SubdepartmentImporter(FromCOREPOSAPI, importing.model.SubdepartmentImporte
|
|||
return self.api.get_subdepartments()
|
||||
|
||||
def normalize_host_object(self, subdepartment):
|
||||
department_number = None
|
||||
if 'dept_ID' in subdepartment:
|
||||
department_number = int(subdepartment['dept_ID'])
|
||||
|
||||
return {
|
||||
'number': int(subdepartment['subdept_no']),
|
||||
'name': subdepartment['subdept_name'],
|
||||
'department_number': int(subdepartment['dept_ID']),
|
||||
'department_number': department_number,
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,8 +161,8 @@ class ProductImporter(FromCOREPOSAPI, importing.model.ProductImporter):
|
|||
'regular_price_multiple',
|
||||
'regular_price_type',
|
||||
'food_stampable',
|
||||
'tax1',
|
||||
'tax2',
|
||||
# 'tax1',
|
||||
# 'tax2',
|
||||
]
|
||||
|
||||
def get_host_objects(self):
|
||||
|
@ -173,28 +177,32 @@ class ProductImporter(FromCOREPOSAPI, importing.model.ProductImporter):
|
|||
return
|
||||
upc = None
|
||||
|
||||
department_number = None
|
||||
if 'department' in product:
|
||||
department_number = int(product['department'])
|
||||
|
||||
subdepartment_number = None
|
||||
if 'subdept' in product:
|
||||
subdepartment_number = int(product['subdept']) or None
|
||||
|
||||
price = None
|
||||
if product['normal_price'] is not None:
|
||||
price = decimal.Decimal(product['normal_price'])
|
||||
|
||||
size = product.get('size', '').strip() or None
|
||||
if size == '0': # TODO: this is maybe just for sake of CORE sample data?
|
||||
size = None
|
||||
|
||||
return {
|
||||
'item_id': product['upc'],
|
||||
'upc': upc,
|
||||
'brand_name': product.get('brand') or None,
|
||||
'description': product.get('description') or '',
|
||||
'size': size,
|
||||
'size': product.get('size', '').strip() or None,
|
||||
|
||||
'department_number': int(product['department']) or None,
|
||||
'subdepartment_number': int(product['subdept']) or None,
|
||||
'department_number': department_number,
|
||||
'subdepartment_number': subdepartment_number,
|
||||
|
||||
'weighed': product['scale'] == '1',
|
||||
'food_stampable': product['foodstamp'] == '1',
|
||||
'tax1': product['tax'] == '1', # TODO: is this right?
|
||||
'tax2': product['tax'] == '2', # TODO: is this right?
|
||||
# 'tax1': product['tax'] == '1', # TODO: is this right?
|
||||
# 'tax2': product['tax'] == '2', # TODO: is this right?
|
||||
|
||||
'regular_price_price': price,
|
||||
'regular_price_multiple': 1 if price is not None else None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue