From 7522dd14cbce221c3ab350e9c0be9e20542500f0 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Thu, 4 Nov 2021 17:42:38 -0500 Subject: [PATCH] Add `custdata` importer for CORE Office -> Lane to double-check sync issues --- .../corepos/lane/importing/op/model.py | 5 +++ .../corepos/lane/importing/op/office.py | 41 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/rattail_corepos/corepos/lane/importing/op/model.py b/rattail_corepos/corepos/lane/importing/op/model.py index dbb48f0..dfbe5fa 100644 --- a/rattail_corepos/corepos/lane/importing/op/model.py +++ b/rattail_corepos/corepos/lane/importing/op/model.py @@ -45,3 +45,8 @@ class DepartmentImporter(ToCore): class ProductImporter(ToCore): model_class = corepos.Product key = 'id' + + +class CustDataImporter(ToCore): + model_class = corepos.CustData + key = 'id' diff --git a/rattail_corepos/corepos/lane/importing/op/office.py b/rattail_corepos/corepos/lane/importing/op/office.py index 2071ca4..5d31d03 100644 --- a/rattail_corepos/corepos/lane/importing/op/office.py +++ b/rattail_corepos/corepos/lane/importing/op/office.py @@ -73,6 +73,7 @@ class FromCoreOfficeToCoreLane(FromCoreOfficeHandler, ToCoreLaneHandler): importers = OrderedDict() importers['Department'] = DepartmentImporter importers['Product'] = ProductImporter + importers['CustData'] = CustDataImporter return importers @@ -183,3 +184,43 @@ class ProductImporter(FromCore, corepos_importing.model.ProductImporter): data = dict([(field, getattr(product, field)) for field in self.common_fields]) return data + + +class CustDataImporter(FromCore, corepos_importing.model.CustDataImporter): + host_model_class = coreoffice.CustData + + # these fields are held in common, between Office and Lane tables + common_fields = [ + 'id', + 'card_number', + 'person_number', + 'first_name', + 'last_name', + 'cash_back', + 'balance', + 'discount', + 'member_discount_limit', + 'charge_limit', + 'charge_ok', + 'write_checks', + 'store_coupons', + 'type', + 'member_type_id', + 'staff', + 'ssi', + 'purchases', + 'number_of_checks', + 'member_coupons', + 'blue_line', + 'shown', + 'last_change', + ] + + @property + def supported_fields(self): + return self.common_fields + + def normalize_host_object(self, custdata): + data = dict([(field, getattr(custdata, field)) + for field in self.common_fields]) + return data