More tweaks for CORE <-> Rattail member sync

This commit is contained in:
Lance Edgar 2023-06-11 20:55:46 -05:00
parent 788efbd114
commit 3cef682a75
3 changed files with 16 additions and 11 deletions

View file

@ -135,7 +135,7 @@ class MemberImporter(FromRattail, corepos_importing.model.MemberImporter):
'customerID': str(shopper.corepos_customer_id),
'firstName': person.first_name,
'lastName': person.last_name,
'accountHolder': shopper.shopper_number == 1,
'accountHolder': 1 if shopper.shopper_number == 1 else 0,
'phone': phone1.number if phone1 else '',
'altPhone': phone2.number if phone2 else '',
'email': email.address if email else '',
@ -160,11 +160,11 @@ class MemberImporter(FromRattail, corepos_importing.model.MemberImporter):
return {
'cardNo': customer.number,
'customerAccountID': str(customer.corepos_account_id or ''),
'addressFirstLine': address.street if address else '',
'addressFirstLine': (address.street or '') 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 '',
'city': (address.city or '') if address else '',
'state': (address.state or '') if address else '',
'zip': (address.zipcode or '') if address else '',
'startDate': start_date,
'endDate': end_date,
'customers': shoppers,

View file

@ -132,6 +132,9 @@ class CoreCustomerShopper(model.Base):
cascade='all, delete-orphan',
cascade_backrefs=False))
# please note, there is *not* a unique constraint on this field.
# that is intentional, for now, to give some breathing room for
# testing etc.
corepos_customer_id = sa.Column(sa.Integer(), nullable=True, doc="""
``Customers.customerID`` value for this shopper, within CORE-POS.
""")

View file

@ -845,12 +845,14 @@ class MemberImporter(FromCOREPOSAPI, corepos_importing.model.MemberImporter):
card_number, member)
return
if member['memberStatus'] in self.non_member_status_codes:
log.debug("skipping non-member %s with status '%s': %s",
member['memberStatus'], card_number, member)
return
if member['memberStatus'] not in self.member_status_codes:
# note that we will still import this one! we don't skip it
# TODO: at first i was *skipping* non-member status records,
# but since CORE sort of assumes all customers are members,
# probably not worth making the distinction here..? it is
# important to import the full member info from CORE, so that
# we have it to sync back. therefore can't afford to "skip"
# any member records here
if (member['memberStatus'] not in self.member_status_codes
and member['memberStatus'] not in self.non_member_status_codes):
log.warning("unexpected status '%s' for member %s: %s",
member['memberStatus'], card_number, member)