Add phone/email support in CORE -> Rattail importer for CustomerShopper

This commit is contained in:
Lance Edgar 2023-06-10 21:10:09 -05:00
parent 76b0791831
commit 7489d4a4a9

View file

@ -198,16 +198,16 @@ class CustomerShopperImporter(FromCOREPOSAPI, corepos_importing.model.CustomerSh
'last_name',
'display_name',
'active',
# 'phone_number',
# 'phone_number_2',
# 'email_address',
'phone_number',
'phone_number_2',
'email_address',
]
def setup(self):
super().setup()
model = self.model
# self.maxlen_phone_number = self.app.maxlen(model.PhoneNumber.number)
self.maxlen_phone_number = self.app.maxlen(model.PhoneNumber.number)
self.customers_by_card_number = self.app.cache_model(
self.session,
@ -294,30 +294,30 @@ class CustomerShopperImporter(FromCOREPOSAPI, corepos_importing.model.CustomerSh
# TODO: can a CORE shopper be *not* active?
'active': True,
# 'phone_number': shopper['phone'] or None,
# 'phone_number_2': shopper['altPhone'] or None,
'phone_number': shopper['phone'] or None,
'phone_number_2': shopper['altPhone'] or None,
# 'email_address': shopper['email'] or None,
'email_address': shopper['email'] or None,
}
# # truncate phone number data if needed
# if data['phone_number'] and len(data['phone_number']) > self.maxlen_phone_number:
# log.warning("phone_number is too long (%s chars), "
# "will truncate to %s chars: %s",
# len(data['phone_number']),
# self.maxlen_phone_number,
# data['phone_number'])
# data['phone_number'] = data['phone_number'][:self.maxlen_phone_number]
# if data['phone_number_2'] and len(data['phone_number_2']) > self.maxlen_phone_number:
# log.warning("phone_number_2 is too long (%s chars), "
# "will truncate to %s chars: %s",
# len(data['phone_number_2']),
# self.maxlen_phone_number,
# data['phone_number_2'])
# data['phone_number_2'] = data['phone_number_2'][:self.maxlen_phone_number]
# truncate phone number data if needed
if data['phone_number'] and len(data['phone_number']) > self.maxlen_phone_number:
log.warning("phone_number is too long (%s chars), "
"will truncate to %s chars: %s",
len(data['phone_number']),
self.maxlen_phone_number,
data['phone_number'])
data['phone_number'] = data['phone_number'][:self.maxlen_phone_number]
if data['phone_number_2'] and len(data['phone_number_2']) > self.maxlen_phone_number:
log.warning("phone_number_2 is too long (%s chars), "
"will truncate to %s chars: %s",
len(data['phone_number_2']),
self.maxlen_phone_number,
data['phone_number_2'])
data['phone_number_2'] = data['phone_number_2'][:self.maxlen_phone_number]
# # swap 1st and 2nd phone numbers if only latter has value
# self.prioritize_2(data, 'phone_number')
# swap 1st and 2nd phone numbers if only latter has value
self.prioritize_2(data, 'phone_number')
return data