Fix how customerAccountID is imported from CORE API
geez. also optimize joinedloads when fetching Rattail member data for CORE export
This commit is contained in:
parent
914fcbe192
commit
2ca9cd8f76
|
@ -106,8 +106,17 @@ class MemberImporter(FromRattail, corepos_importing.model.MemberImporter):
|
||||||
query = super().query()
|
query = super().query()
|
||||||
model = self.model
|
model = self.model
|
||||||
|
|
||||||
# TODO: should joinedload for CustomerShopper.phones etc. too?
|
query = query.options(orm.joinedload(model.Customer.members))\
|
||||||
query = query.options(orm.joinedload(model.Customer.addresses))
|
.options(orm.joinedload(model.Customer._corepos))\
|
||||||
|
.options(orm.joinedload(model.Customer.addresses))\
|
||||||
|
.options(orm.joinedload(model.Customer.shoppers)\
|
||||||
|
.joinedload(model.CustomerShopper._corepos))\
|
||||||
|
.options(orm.joinedload(model.Customer.shoppers)\
|
||||||
|
.joinedload(model.CustomerShopper.person)\
|
||||||
|
.joinedload(model.Person.phones))\
|
||||||
|
.options(orm.joinedload(model.Customer.shoppers)\
|
||||||
|
.joinedload(model.CustomerShopper.person)\
|
||||||
|
.joinedload(model.Person.emails))
|
||||||
|
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
|
|
@ -172,6 +172,7 @@ class CustomerImporter(FromCOREPOSAPI, corepos_importing.model.CustomerImporter)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'corepos_card_number': card_number,
|
'corepos_card_number': card_number,
|
||||||
|
'corepos_account_id': int(member['customerAccountID']),
|
||||||
'number': card_number,
|
'number': card_number,
|
||||||
'name': normalize_full_name(customer['firstName'],
|
'name': normalize_full_name(customer['firstName'],
|
||||||
customer['lastName']),
|
customer['lastName']),
|
||||||
|
@ -183,10 +184,6 @@ class CustomerImporter(FromCOREPOSAPI, corepos_importing.model.CustomerImporter)
|
||||||
'address_zipcode': member['zip'] or None,
|
'address_zipcode': member['zip'] or None,
|
||||||
}
|
}
|
||||||
|
|
||||||
if 'corepos_account_id' in self.fields:
|
|
||||||
account_id = customer.get('customerAccountID')
|
|
||||||
data['corepos_account_id'] = int(account_id) if account_id is not None else None
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue