Detect bad memtype number early, for CORE API -> Rattail import

to avoid false diffs when we give a bad value
This commit is contained in:
Lance Edgar 2023-06-10 13:06:18 -05:00
parent 2cf865d879
commit 86a8e2d241

View file

@ -846,11 +846,20 @@ class MemberImporter(FromCOREPOSAPI, corepos_importing.model.MemberImporter):
'%Y-%m-%d %H:%M:%S') '%Y-%m-%d %H:%M:%S')
withdrew = withdrew.date() withdrew = withdrew.date()
typeno = int(member['customerTypeID']) or None
if typeno:
memtype = self.get_membership_type_by_number(typeno)
if not memtype:
logger = log.warning if self.get_warn_for_unknown_membership_type() else log.debug
logger("unknown customerTypeID (membership_type_number) %s for: %s",
member['customerTypeID'], member)
typeno = None
return { return {
'number': card_number, 'number': card_number,
'customer_uuid': customer.uuid, 'customer_uuid': customer.uuid,
'person_uuid': person.uuid, 'person_uuid': person.uuid,
'membership_type_number': int(member['customerTypeID']), 'membership_type_number': typeno,
'joined': joined, 'joined': joined,
'withdrew': withdrew, 'withdrew': withdrew,
'active': not bool(withdrew), 'active': not bool(withdrew),