robvankeilegom / firefly-III-paypal-importer

PayPal Data Importer for Firefly III
48 stars 3 forks source link

Not importing payment refunds in foreign currency #14

Closed mgundelfinger closed 1 year ago

mgundelfinger commented 1 year ago

Hi, thanks for your work on this project, this seems to solve all of my issues I've had with importing my PayPal data, especially since it automatically gets new transactions!

This first question is mostly unrelated but is it the intended behavior that transactions made to and from my bank account are not imported? At least for me they aren't, and that works in my favor, since I'm importing my bank transactions separately and would have to delete one copy of each transfers manually if they were also imported from this app.

Now onto the issue: I noticed that after importing all of my transactions from PayPal through this app (and all transfers made between my bank account and PayPal separately, since they are not part of the import) that I did not end up with a balance of 0, which would be the logical end result (unless i have balance on my PayPal account of course). Instead my Balance (on FF3) is displayed as hundreds below 0.

So I went on to investigate and compare some of my bank statements with the paypal statements and I found two transactions that didn't show up in FF3. They are refunds made in a foreign currency (USD).

Looking into it a little further it seems to me foreign currency refunds aren't imported at all. Would it be possible to include those in the import?

Thanks in advance!

mgundelfinger commented 1 year ago

Sorry for closing and opening the issue, just a little misclick on my part.

I should have done this way earlier but the log files say [2023-06-03 10:58:41] production.ERROR: Can't find conversion for transaction xxx for four different transactions, which is the same amount as i have foreign currency refunds. I did some digging and compared the data of those transactions and realized that the forgeign currency refunds still have the transaction ID of the original payment as their referenced transaction ID, not the ID of the refund:

Date Description Currency Net Transaction ID Reference Txn ID
01.09.2022 Payment USD -269,23 xxxxxxxxx  
01.09.2022 PAYMENT Conversion FROM EUR -281,29 aaaaaaaaa xxxxxxxxx
01.09.2022 PAYMENT Conversion TO USD 269,23 bbbbbbbbb xxxxxxxxx
01.09.2022 Transfer Bank -> PayPal EUR 278,74 ccccccccc xxxxxxxxx
           
13.09.2022 Refund USD 269,23 ddddddddd xxxxxxxxx
13.09.2022 REFUND Conversion FROM USD -269,23 eeeeeeeee xxxxxxxxx
13.09.2022 REFUND Conversion TO EUR 264,01 fffffffff xxxxxxxxx
13.09.2022 Transfer PayPal -> Bank EUR -264,01 ggggggggg xxxxxxxxx

I changed the descriptions to save the hassle of figuring out what each of the lines mean, swapped out the transaction IDs and reduced the data to what I think is relevant. The "Transfer Bank -> PayPal" is less than the amount being converted in "PAYMENT Conversion FROM", which I assume just means I had a little bit of PayPal balance at the time.

So the way I understand it is that if there is a conversion and a refund happening for the same transaction, it seems that the conversion transactions of the refund get a "Reference Txn ID" matching the original transaction, not the refund transaction.

I hope my explanation didn't make it harder to understand, but the data shows it quite nicely I think.

Instead of searching for the matching "Transaction ID", simply matching the conversion by looking for the "Reference Txn ID" and the converted amount should work.

Would love if this could be adjusted!

robvankeilegom commented 1 year ago

@mikemilligram Hey,

Sorry for the delay, i took some time off. Thanks for the very detailed comment. You have a correct understanding of the issue.

I pushed my changes in the develop tag of the docker container. https://hub.docker.com/layers/robvankeilegom/firefly-iii-paypal-importer/develop/images/sha256-705fb3e74e188d75a228ce302c18c91332597176652af0174c1980a69306305d?context=repo

Could you be so kind to validate the changes and let me know? Thanks!

mgundelfinger commented 1 year ago

No need to apologize at all!

I just tried running the develop image and it works perfectly, now all of my foreign currency refunds show up as intended! Thank you very much for your help with this issue and for your work in general!

Enjoy your weekend!