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',
|
||||
'lastName',
|
||||
'accountHolder',
|
||||
# 'phone',
|
||||
# 'altPhone',
|
||||
# 'email',
|
||||
'phone',
|
||||
'altPhone',
|
||||
'email',
|
||||
]
|
||||
|
||||
def query(self):
|
||||
query = super(MemberImporter, self).query()
|
||||
query = query.options(orm.joinedload(model.Customer.addresses))\
|
||||
.options(orm.joinedload(model.Customer._people)\
|
||||
.joinedload(model.CustomerPerson.person)\
|
||||
.joinedload(model.Person.phones))\
|
||||
.options(orm.joinedload(model.Customer._people)\
|
||||
.joinedload(model.CustomerPerson.person)\
|
||||
.joinedload(model.Person.emails))
|
||||
query = super().query()
|
||||
model = self.model
|
||||
|
||||
# TODO: should joinedload for CustomerShopper.phones etc. too?
|
||||
query = query.options(orm.joinedload(model.Customer.addresses))
|
||||
|
||||
return query
|
||||
|
||||
def normalize_host_object(self, customer):
|
||||
|
@ -120,18 +118,18 @@ class MemberImporter(FromRattail, corepos_importing.model.MemberImporter):
|
|||
shoppers = []
|
||||
for shopper in customer.shoppers:
|
||||
person = shopper.person
|
||||
# phones = person.phones
|
||||
# phone1 = phones[0] if phones else None
|
||||
# phone2 = phones[1] if len(phones) > 1 else None
|
||||
# email = person.emails[0] if person.emails else None
|
||||
phones = person.phones
|
||||
phone1 = phones[0] if phones else None
|
||||
phone2 = phones[1] if len(phones) > 1 else None
|
||||
email = person.emails[0] if person.emails else None
|
||||
shoppers.append({
|
||||
'customerID': str(shopper.corepos_customer_id),
|
||||
'firstName': person.first_name,
|
||||
'lastName': person.last_name,
|
||||
'accountHolder': shopper.shopper_number == 1,
|
||||
# 'phone': phone1.number if phone1 else '',
|
||||
# 'altPhone': phone2.number if phone2 else '',
|
||||
# 'email': email.address if email else '',
|
||||
'phone': phone1.number if phone1 else '',
|
||||
'altPhone': phone2.number if phone2 else '',
|
||||
'email': email.address if email else '',
|
||||
})
|
||||
|
||||
member = self.app.get_member(customer)
|
||||
|
@ -154,7 +152,7 @@ class MemberImporter(FromRattail, corepos_importing.model.MemberImporter):
|
|||
'cardNo': customer.number,
|
||||
'customerAccountID': str(customer.corepos_account_id or ''),
|
||||
'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 '',
|
||||
'state': address.state if address else '',
|
||||
'zip': address.zipcode if address else '',
|
||||
|
|
Loading…
Reference in a new issue