Avoid false match when importing equity payments from CORE
This commit is contained in:
		
							parent
							
								
									a598796618
								
							
						
					
					
						commit
						98da72ea14
					
				
					 1 changed files with 16 additions and 3 deletions
				
			
		|  | @ -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 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Lance Edgar
						Lance Edgar