From 43cd63c1f5fc04f8e4c357ccf1da357c5334ffe5 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sat, 10 Jun 2023 21:18:14 -0500 Subject: [PATCH] Add phone/email support for Rattail -> CORE export for Member --- .../corepos/office/importing/rattail.py | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/rattail_corepos/corepos/office/importing/rattail.py b/rattail_corepos/corepos/office/importing/rattail.py index 0a5f7ce..62640a6 100644 --- a/rattail_corepos/corepos/office/importing/rattail.py +++ b/rattail_corepos/corepos/office/importing/rattail.py @@ -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 '',