diff options
author | Magnus Hagander | 2025-06-16 12:46:38 +0000 |
---|---|---|
committer | Magnus Hagander | 2025-06-16 12:46:38 +0000 |
commit | 738f80fc75113ef6522c4a15eb969d0f16f21697 (patch) | |
tree | ddad65191c465d0945c34f77816cbce23aa1011b /postgresqleu/transferwise/api.py | |
parent | 97056a46108815c9c1c2b84f848d34ab6b6c9598 (diff) |
Negate *all* wise transactions based on "Sent by ..." in text
Turns out we need to do this both for primary ands secondary amounts
(which makes sense). Clarify the comment a bit further after more
research that still shows Wise API returns that incoming payments are
actually outgoing. Sigh.
Diffstat (limited to 'postgresqleu/transferwise/api.py')
-rw-r--r-- | postgresqleu/transferwise/api.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/postgresqleu/transferwise/api.py b/postgresqleu/transferwise/api.py index a61278e6..ed8c40a9 100644 --- a/postgresqleu/transferwise/api.py +++ b/postgresqleu/transferwise/api.py @@ -143,9 +143,13 @@ class TransferwiseApi(object): # Yes, the transfer will actually have a positive amount even if it's a withdrawal. # No, this is not indicated anywhere, since the "target account id" that would # indicate it, points to the wrong account for incoming payments. + # Oh, and the status is *always* set to `outgoing_payment_sent`, even for incoming + # payments. I guess all payments are outgoing from *something*. # Let's do a wild gamble and assume the description is always this... if activity.get('description', '').startswith('Sent by '): - amount = -amount + negatizer = -1 + else: + negatizer = 1 # We also need to look at the amount in the activity, as it might be different # if there are fees. @@ -167,7 +171,7 @@ class TransferwiseApi(object): yield { 'id': 'TRANSFER-{}'.format(activity['resource']['id']), 'datetime': details['created'], - 'amount': amount, + 'amount': amount * negatizer, 'feeamount': 0, # XXX! 'transtype': 'TRANSFER', 'paymentref': details['reference'], |