Import member first/last name from CORE API
This commit is contained in:
parent
f6c08af32c
commit
64048db92f
|
@ -789,7 +789,8 @@ class MemberImporter(FromCOREPOSAPI, corepos_importing.model.MemberImporter):
|
|||
'number',
|
||||
'corepos_account_id',
|
||||
'customer_uuid',
|
||||
'person_uuid',
|
||||
'person_first_name',
|
||||
'person_last_name',
|
||||
'membership_type_number',
|
||||
'joined',
|
||||
'withdrew',
|
||||
|
@ -832,10 +833,14 @@ class MemberImporter(FromCOREPOSAPI, corepos_importing.model.MemberImporter):
|
|||
except orm.exc.NoResultFound:
|
||||
pass
|
||||
|
||||
def get_corepos_customer(self, corepos_member):
|
||||
for customer in corepos_member['customers']:
|
||||
if customer['accountHolder']:
|
||||
return customer
|
||||
|
||||
def normalize_host_object(self, member):
|
||||
card_number = member['cardNo']
|
||||
customer = self.get_customer_by_number(card_number)
|
||||
person = self.app.get_person(customer) if customer else None
|
||||
|
||||
# TODO: at first i was *skipping* non-member status records,
|
||||
# but since CORE sort of assumes all customers are members,
|
||||
|
@ -871,13 +876,21 @@ class MemberImporter(FromCOREPOSAPI, corepos_importing.model.MemberImporter):
|
|||
member['customerTypeID'], member)
|
||||
typeno = None
|
||||
|
||||
return {
|
||||
data = {
|
||||
'number': card_number,
|
||||
'corepos_account_id': int(member['customerAccountID']),
|
||||
'customer_uuid': customer.uuid if customer else None,
|
||||
'person_uuid': person.uuid if person else None,
|
||||
'person_first_name': None,
|
||||
'person_last_name': None,
|
||||
'membership_type_number': typeno,
|
||||
'joined': joined,
|
||||
'withdrew': withdrew,
|
||||
'active': not bool(withdrew),
|
||||
}
|
||||
|
||||
corepos_customer = self.get_corepos_customer(member)
|
||||
if corepos_customer:
|
||||
data['person_first_name'] = corepos_customer['firstName']
|
||||
data['person_last_name'] = corepos_customer['lastName']
|
||||
|
||||
return data
|
||||
|
|
Loading…
Reference in a new issue