Avoid false match when importing equity payments from CORE
This commit is contained in:
parent
a598796618
commit
98da72ea14
|
@ -667,13 +667,13 @@ class MemberEquityPaymentImporter(FromCOREPOS, corepos_importing.model.MemberEqu
|
||||||
return
|
return
|
||||||
|
|
||||||
# first look for exact match
|
# first look for exact match
|
||||||
datetime = self.app.localtime(stock_purchase.datetime)
|
dt = self.app.localtime(stock_purchase.datetime)
|
||||||
match = [payment for payment in payments
|
match = [payment for payment in payments
|
||||||
if payment.corepos_transaction_number == stock_purchase.transaction_number
|
if payment.corepos_transaction_number == stock_purchase.transaction_number
|
||||||
and payment.corepos_transaction_id == stock_purchase.transaction_id
|
and payment.corepos_transaction_id == stock_purchase.transaction_id
|
||||||
and payment.amount == stock_purchase.amount
|
and payment.amount == stock_purchase.amount
|
||||||
and payment.corepos_department_number == stock_purchase.department_number
|
and payment.corepos_department_number == stock_purchase.department_number
|
||||||
and self.app.localtime(payment.corepos_datetime, from_utc=True) == datetime]
|
and self.app.localtime(payment.corepos_datetime, from_utc=True) == dt]
|
||||||
if len(match) == 1:
|
if len(match) == 1:
|
||||||
return match[0]
|
return match[0]
|
||||||
|
|
||||||
|
@ -684,7 +684,20 @@ class MemberEquityPaymentImporter(FromCOREPOS, corepos_importing.model.MemberEqu
|
||||||
and payment.amount == stock_purchase.amount
|
and payment.amount == stock_purchase.amount
|
||||||
and payment.corepos_department_number == stock_purchase.department_number]
|
and payment.corepos_department_number == stock_purchase.department_number]
|
||||||
if len(matches) == 1:
|
if len(matches) == 1:
|
||||||
return matches[0]
|
log.warning("found 'loose' match for card #%s, txn %s, for $%0.2f: %s",
|
||||||
|
stock_purchase.card_number,
|
||||||
|
stock_purchase.transaction_number,
|
||||||
|
stock_purchase.amount,
|
||||||
|
stock_purchase.datetime)
|
||||||
|
|
||||||
|
# so there is one match, but its timestamp may be way off,
|
||||||
|
# so let's also make sure at least date matches
|
||||||
|
payment = matches[0]
|
||||||
|
if self.app.localtime(payment.corepos_datetime, from_utc=True).date() == dt.date():
|
||||||
|
return payment
|
||||||
|
|
||||||
|
# do not assume any match, if dates were off
|
||||||
|
return
|
||||||
|
|
||||||
# TODO: not sure how to handle yet, if last check found more
|
# TODO: not sure how to handle yet, if last check found more
|
||||||
# than one match. presumably if none were found then it is
|
# than one match. presumably if none were found then it is
|
||||||
|
|
Loading…
Reference in a new issue