Add behavior options for CORE member importer
This commit is contained in:
parent
1cb7d45e23
commit
e74a47b99a
|
@ -158,6 +158,30 @@ class MemberInfoImporter(ToCore):
|
||||||
model_class = corepos.MemberInfo
|
model_class = corepos.MemberInfo
|
||||||
key = 'card_number'
|
key = 'card_number'
|
||||||
|
|
||||||
|
# default is to read first/last name directly from `meminfo`
|
||||||
|
# table, but if this flag is set then names will be read from
|
||||||
|
# `custdata` instead (where `personNum = 1`) although `meminfo`
|
||||||
|
# will still be used as fallback in that case.
|
||||||
|
prefer_local_names_from_custdata = False
|
||||||
|
|
||||||
|
# default is to compare street address "as-is" between systems.
|
||||||
|
# but CORE can be inconsistent with presence or lack of newline
|
||||||
|
# suffix, when address is just one line (which is the typical
|
||||||
|
# scenario). so if this flag is set then importer will strip
|
||||||
|
# whitespace automatically when reading this field value.
|
||||||
|
strip_address_street = False
|
||||||
|
|
||||||
|
# similar to previous flag, this one makes the importer strip
|
||||||
|
# whitespace from *all* address fields when reading.
|
||||||
|
strip_address_all = False
|
||||||
|
|
||||||
|
# somewhat akin to the address flags, this one if set will cause
|
||||||
|
# the importer to "normalize" phone numbers read from CORE. the
|
||||||
|
# assumption would be that the host/source side of the import
|
||||||
|
# would also be presenting normalized phone data for comparison to
|
||||||
|
# work correctly. cf. AppHandler.normalize_phone_number()
|
||||||
|
normalize_phone_numbers = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_fields(self):
|
def supported_fields(self):
|
||||||
fields = list(super(MemberInfoImporter, self).supported_fields)
|
fields = list(super(MemberInfoImporter, self).supported_fields)
|
||||||
|
@ -169,6 +193,21 @@ class MemberInfoImporter(ToCore):
|
||||||
def normalize_local_object(self, member):
|
def normalize_local_object(self, member):
|
||||||
data = super(MemberInfoImporter, self).normalize_local_object(member)
|
data = super(MemberInfoImporter, self).normalize_local_object(member)
|
||||||
|
|
||||||
|
if self.prefer_local_names_from_custdata and member.customers:
|
||||||
|
customer = member.customers[0]
|
||||||
|
data['first_name'] = customer.first_name
|
||||||
|
data['last_name'] = customer.last_name
|
||||||
|
|
||||||
|
if self.normalize_phone_numbers:
|
||||||
|
data['phone'] = self.app.normalize_phone_number(data['phone'])
|
||||||
|
|
||||||
|
if self.strip_address_street or self.strip_address_all:
|
||||||
|
data['street'] = (data['street'] or '').strip()
|
||||||
|
if self.strip_address_all:
|
||||||
|
data['city'] = (data['city'] or '').strip()
|
||||||
|
data['state'] = (data['state'] or '').strip()
|
||||||
|
data['zip'] = (data['zip'] or '').strip()
|
||||||
|
|
||||||
if 'member_type_id' in self.fields:
|
if 'member_type_id' in self.fields:
|
||||||
data['member_type_id'] = None
|
data['member_type_id'] = None
|
||||||
customer = member.customers[0] if member.customers else None
|
customer = member.customers[0] if member.customers else None
|
||||||
|
|
Loading…
Reference in a new issue