diff --git a/rattail_corepos/importing/corepos/db.py b/rattail_corepos/importing/corepos/db.py index 9eeb537..2a1bc8e 100644 --- a/rattail_corepos/importing/corepos/db.py +++ b/rattail_corepos/importing/corepos/db.py @@ -667,13 +667,13 @@ class MemberEquityPaymentImporter(FromCOREPOS, corepos_importing.model.MemberEqu return # 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 if payment.corepos_transaction_number == stock_purchase.transaction_number and payment.corepos_transaction_id == stock_purchase.transaction_id and payment.amount == stock_purchase.amount 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: return match[0] @@ -684,7 +684,20 @@ class MemberEquityPaymentImporter(FromCOREPOS, corepos_importing.model.MemberEqu and payment.amount == stock_purchase.amount and payment.corepos_department_number == stock_purchase.department_number] 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 # than one match. presumably if none were found then it is