Be smarter about member datasync for Rattail -> CORE
per new CustomerShopper schema etc.
This commit is contained in:
parent
6e50ea58a8
commit
77bd9e34e4
|
@ -169,9 +169,10 @@ class FromRattailToCore(DataSyncImportConsumer):
|
||||||
# also establish the API client for each!
|
# also establish the API client for each!
|
||||||
importer.establish_api()
|
importer.establish_api()
|
||||||
|
|
||||||
# sync all Customer changes
|
# sync all Member changes
|
||||||
types = [
|
types = [
|
||||||
'Customer',
|
'Customer',
|
||||||
|
'CustomerShopper',
|
||||||
'Person',
|
'Person',
|
||||||
'CustomerPerson',
|
'CustomerPerson',
|
||||||
'CustomerMailingAddress',
|
'CustomerMailingAddress',
|
||||||
|
@ -238,38 +239,44 @@ class FromRattailToCore(DataSyncImportConsumer):
|
||||||
return session.get(getattr(model, change.payload_type), change.payload_key)
|
return session.get(getattr(model, change.payload_type), change.payload_key)
|
||||||
|
|
||||||
def get_customers(self, session, change):
|
def get_customers(self, session, change):
|
||||||
|
clientele = self.app.get_clientele_handler()
|
||||||
|
|
||||||
if change.payload_type == 'Customer':
|
if change.payload_type == 'Customer':
|
||||||
customer = session.get(model.Customer, change.payload_key)
|
customer = session.get(model.Customer, change.payload_key)
|
||||||
if customer:
|
if customer:
|
||||||
return [customer]
|
return [customer]
|
||||||
|
|
||||||
if change.payload_type == 'CustomerPerson':
|
elif change.payload_type == 'CustomerShopper':
|
||||||
|
shopper = session.get(model.CustomerShopper, change.payload_key)
|
||||||
|
if shopper:
|
||||||
|
return [shopper.customer]
|
||||||
|
|
||||||
|
elif change.payload_type == 'CustomerPerson':
|
||||||
cp = session.get(model.CustomerPerson, change.payload_key)
|
cp = session.get(model.CustomerPerson, change.payload_key)
|
||||||
if cp:
|
if cp:
|
||||||
return [cp.customer]
|
return [cp.customer]
|
||||||
|
|
||||||
if change.payload_type == 'Person':
|
elif change.payload_type == 'Person':
|
||||||
person = session.get(model.Person, change.payload_key)
|
person = session.get(model.Person, change.payload_key)
|
||||||
if person:
|
if person:
|
||||||
return person.customers
|
return clientele.get_customers_for_account_holder(person)
|
||||||
|
|
||||||
if change.payload_type == 'CustomerMailingAddress':
|
elif change.payload_type == 'CustomerMailingAddress':
|
||||||
address = session.get(model.CustomerMailingAddress, change.payload_key)
|
address = session.get(model.CustomerMailingAddress, change.payload_key)
|
||||||
if address:
|
if address:
|
||||||
return [address.customer]
|
return [address.customer]
|
||||||
|
|
||||||
if change.payload_type == 'PersonPhoneNumber':
|
elif change.payload_type == 'PersonPhoneNumber':
|
||||||
phone = session.get(model.PersonPhoneNumber, change.payload_key)
|
phone = session.get(model.PersonPhoneNumber, change.payload_key)
|
||||||
if phone:
|
if phone:
|
||||||
return phone.person.customers
|
return clientele.get_customers_for_account_holder(phone.person)
|
||||||
|
|
||||||
if change.payload_type == 'PersonEmailAddress':
|
elif change.payload_type == 'PersonEmailAddress':
|
||||||
email = session.get(model.PersonEmailAddress, change.payload_key)
|
email = session.get(model.PersonEmailAddress, change.payload_key)
|
||||||
if email:
|
if email:
|
||||||
return email.person.customers
|
return clientele.get_customers_for_account_holder(email.person)
|
||||||
|
|
||||||
if change.payload_type == 'Member':
|
elif change.payload_type == 'Member':
|
||||||
member = session.get(model.Member, change.payload_key)
|
member = session.get(model.Member, change.payload_key)
|
||||||
if member:
|
if member:
|
||||||
return [member.customer]
|
return [member.customer]
|
||||||
|
|
Loading…
Reference in a new issue