diff --git a/rattail_corepos/importing/corepos/api.py b/rattail_corepos/importing/corepos/api.py index 1735ddd..1c0612e 100644 --- a/rattail_corepos/importing/corepos/api.py +++ b/rattail_corepos/importing/corepos/api.py @@ -58,6 +58,7 @@ class FromCOREPOSToRattail(importing.ToRattailHandler): importers['Customer'] = CustomerImporter importers['Person'] = PersonImporter importers['CustomerPerson'] = CustomerPersonImporter + importers['MembershipType'] = MembershipTypeImporter importers['Member'] = MemberImporter importers['Store'] = StoreImporter importers['Department'] = DepartmentImporter @@ -840,6 +841,26 @@ class ProductCostImporter(FromCOREPOSAPI, corepos_importing.model.ProductCostImp } +class MembershipTypeImporter(FromCOREPOSAPI, importing.model.MembershipTypeImporter): + """ + Imports membership type data from CORE-POS API + """ + key = 'number' + supported_fields = [ + 'number', + 'name', + ] + + def get_host_objects(self): + return self.api.get_member_types() + + def normalize_host_object(self, memtype): + return { + 'number': int(memtype['memtype']), + 'name': memtype['memDesc'], + } + + class MemberImporter(FromCOREPOSAPI, corepos_importing.model.MemberImporter): """ Importer for member data from CORE POS API. @@ -849,6 +870,7 @@ class MemberImporter(FromCOREPOSAPI, corepos_importing.model.MemberImporter): 'number', 'customer_uuid', 'person_uuid', + 'membership_type_number', 'joined', 'withdrew', 'active', @@ -931,6 +953,7 @@ class MemberImporter(FromCOREPOSAPI, corepos_importing.model.MemberImporter): 'number': card_number, 'customer_uuid': customer.uuid, 'person_uuid': person.uuid, + 'membership_type_number': int(member['customerTypeID']), 'joined': joined, 'withdrew': withdrew, 'active': not bool(withdrew),