Add phone/email support for Rattail -> CORE export for Member
This commit is contained in:
parent
7489d4a4a9
commit
43cd63c1f5
|
@ -97,20 +97,18 @@ class MemberImporter(FromRattail, corepos_importing.model.MemberImporter):
|
||||||
'firstName',
|
'firstName',
|
||||||
'lastName',
|
'lastName',
|
||||||
'accountHolder',
|
'accountHolder',
|
||||||
# 'phone',
|
'phone',
|
||||||
# 'altPhone',
|
'altPhone',
|
||||||
# 'email',
|
'email',
|
||||||
]
|
]
|
||||||
|
|
||||||
def query(self):
|
def query(self):
|
||||||
query = super(MemberImporter, self).query()
|
query = super().query()
|
||||||
query = query.options(orm.joinedload(model.Customer.addresses))\
|
model = self.model
|
||||||
.options(orm.joinedload(model.Customer._people)\
|
|
||||||
.joinedload(model.CustomerPerson.person)\
|
# TODO: should joinedload for CustomerShopper.phones etc. too?
|
||||||
.joinedload(model.Person.phones))\
|
query = query.options(orm.joinedload(model.Customer.addresses))
|
||||||
.options(orm.joinedload(model.Customer._people)\
|
|
||||||
.joinedload(model.CustomerPerson.person)\
|
|
||||||
.joinedload(model.Person.emails))
|
|
||||||
return query
|
return query
|
||||||
|
|
||||||
def normalize_host_object(self, customer):
|
def normalize_host_object(self, customer):
|
||||||
|
@ -120,18 +118,18 @@ class MemberImporter(FromRattail, corepos_importing.model.MemberImporter):
|
||||||
shoppers = []
|
shoppers = []
|
||||||
for shopper in customer.shoppers:
|
for shopper in customer.shoppers:
|
||||||
person = shopper.person
|
person = shopper.person
|
||||||
# phones = person.phones
|
phones = person.phones
|
||||||
# phone1 = phones[0] if phones else None
|
phone1 = phones[0] if phones else None
|
||||||
# phone2 = phones[1] if len(phones) > 1 else None
|
phone2 = phones[1] if len(phones) > 1 else None
|
||||||
# email = person.emails[0] if person.emails else None
|
email = person.emails[0] if person.emails else None
|
||||||
shoppers.append({
|
shoppers.append({
|
||||||
'customerID': str(shopper.corepos_customer_id),
|
'customerID': str(shopper.corepos_customer_id),
|
||||||
'firstName': person.first_name,
|
'firstName': person.first_name,
|
||||||
'lastName': person.last_name,
|
'lastName': person.last_name,
|
||||||
'accountHolder': shopper.shopper_number == 1,
|
'accountHolder': shopper.shopper_number == 1,
|
||||||
# 'phone': phone1.number if phone1 else '',
|
'phone': phone1.number if phone1 else '',
|
||||||
# 'altPhone': phone2.number if phone2 else '',
|
'altPhone': phone2.number if phone2 else '',
|
||||||
# 'email': email.address if email else '',
|
'email': email.address if email else '',
|
||||||
})
|
})
|
||||||
|
|
||||||
member = self.app.get_member(customer)
|
member = self.app.get_member(customer)
|
||||||
|
@ -154,7 +152,7 @@ class MemberImporter(FromRattail, corepos_importing.model.MemberImporter):
|
||||||
'cardNo': customer.number,
|
'cardNo': customer.number,
|
||||||
'customerAccountID': str(customer.corepos_account_id or ''),
|
'customerAccountID': str(customer.corepos_account_id or ''),
|
||||||
'addressFirstLine': address.street if address else '',
|
'addressFirstLine': address.street if address else '',
|
||||||
'addressSecondLine': address.street2 if address else '',
|
'addressSecondLine': (address.street2 or '') if address else '',
|
||||||
'city': address.city if address else '',
|
'city': address.city if address else '',
|
||||||
'state': address.state if address else '',
|
'state': address.state if address else '',
|
||||||
'zip': address.zipcode if address else '',
|
'zip': address.zipcode if address else '',
|
||||||
|
|
Loading…
Reference in a new issue