robvankeilegom / firefly-III-paypal-importer

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

Pushing to firefly stops due to a 404 error #12

Closed Benny12323 closed 1 year ago

Benny12323 commented 1 year ago

First of all: thanks for the great work! I got the importer to work and he pushes entries to firefly. But it stops everytime after a few entries with the error message:

Pushing data to Firefly

In RequestException.php line 113:

  Client error: `PUT http://192.168.178.106/api/v1/transactions/1564` resulte
  d in a `404 Not Found` response:
  {"message":"Resource not found","exception":"NotFoundHttpException"}

The only thing i found out: It is at least correct, there is no transaction with the ID 1564 in firefly. Any ideas how to find out the reason why this is happening?

robvankeilegom commented 1 year ago

Hi!

Did you run the importer before, and emptied the Firefly database or remove the transaction in Firefly? This error indicates that the importer tries to update a transaction that's no longer known in Firefly.

I pushed a change in develop that should fix this. Can you try again with the develop tag?

Thanks!

Benny12323 commented 1 year ago

Hi Rob,

yes the importer was running before and I have a rule in Friefly that deletes old entries automatically (everything tht is befor a specifc date). In this respect, it may well be that your assumption is correct. I tried it with the new develop version (thanks for that), unfortunately the error remains:

Pushing data to Firefly

In RequestException.php line 113:

  Client error: `PUT http://192.168.178.106/api/v1/transactions/1564` resulte
  d in a `404 Not Found` response:
  {"message": "Resource not found", "exception": "NotFoundHttpException"}

For now, I can certainly help myself with lushing the cache and start all over without deleting old transactions. But if you still have an idea for the solution, that would be great of course!

robvankeilegom commented 1 year ago

Hey @Benny12323 , I made a mistake in the docker file which caused the code base to mount as volume. As a result, when updating the docker container the new code base that comes with it would be overwritten with the old volume. Can you try en update the container again? I tagged it as a new version so you can easily see the update succeeded by visiting the ip of the container. Make sure to remove /var/www/html as a volume. Thanks!

robvankeilegom commented 1 year ago

The version should be 0.2.9 btw!

Benny12323 commented 1 year ago

Hi @robvankeilegom, thank you so much for continuing to address the problem. I have removed the /var/www/html volume and updated to version 0.2.9. After that pushing data to firefly stopped with

Pushing data to Firefly

In RequestException.php line 113:

  Client error: `PUT http://192.168.178.106/api/v1/transactions/1583` resulte
  d in a `422 Unprocessable Content` response:
  {"message":"Bei der Suche nach der Kennung \u201e0\u201d oder dem Namen \u2
  01e\u201d konnte kein g\u00fcltiges Quellkont (truncated...)

So I set up a fresh container again. Now I got

Pushing data to Firefly

In Builder.php line 586:

  No query results for model [App\Models\Transaction].

According to the web interface this happened after pushing 3 transactions. At least those are the new transactions, that have not been in firefly yet, so it is quite a success for me...

robvankeilegom commented 1 year ago

For the first error: do you also delete clean up asset/expense accounts in Firefly? Did you remove values from the error message for privacy or did it actually say \u201e0\u201d and \u201e\u201d?

For the second error, this is usually the case when the CURRENCY env variable is set incorrectly. This error will throw when a transaction is in a different currency than the one set in CURRENCY, but no second transaction is found to convert the currency from one to another.

Benny12323 commented 1 year ago

Hi Rob,

for the first error: those are the actual error messages. I did not remove any values. But it looks like a fresh container solved whatever issue that was. Right now I am still stuck with the second error. I have set the Environment CURRENCY to EUR, which is also the default Currency in Firefly. But there are some transactions in my Paypal Acocunt that have been paid in USD and it looks like they have not been converted by/within paypal. So your suspicion could be exactly right. Do you have any suggestion how to solve that one?

Thank you so much for helping me out all the time. Really appreciated!

Benny12323 commented 1 year ago

In addition to that: I saw #9 and started a sync with the currency set to USD with the same result. I ran another sync attempt with the currency ste to USD and Firefly having USD as default currency wiht the same result.

robvankeilegom commented 1 year ago

@Benny12323 I also make payments in USD, but my PayPal account is in euro, so is the bank account that's connected to it. I assumed there would be a conversion transaction for every payment, but i might be wrong there. I pushed a change in the develop version of the docker container where it would just skip the transaction with the error and log an error. Can you try it out?

Benny12323 commented 1 year ago

@robvankeilegom Thank you so much! I created a new container with the current develop version and it works great! At the end there is a message indicating the missing currency conversion, so it works as you planned. The message is: ` In RequestException.php line 113:

Client error: POST http://192.168.178.106/api/v1/transactions resulted in a 422 Unprocessable Content response: {"message":"transactions.0.foreign_currency_code ist ung\u00fcltig.","error s":{"transactions.0.foreign_currency_code":[" (truncated...) `

To explain how there can be the missing conversion, although my paypal and bank account are both in EUR: I can decide if Paypal does the conversion, or if Paypal should debit in USD from my account. In this case the bank does the conversion to EUR. The exchange rates sometimes differ significantly. Then there is no conversion entry in the Paypal account.

Thank you again for your great help!

robvankeilegom commented 1 year ago

@Benny12323 Thanks for the feedback. That does make sense, i didn't know PayPal could do that tho.

The message you got is different than the one i programmed. The importer tries to push a transaction with a currency that's unknown to FireFly. I pushed another change that should suppress the error. The sync should end with a message saying 'done'.

Make sure to check the logs after syncing. You'll probably miss one ore more transactions. The log should clearly specify which transactions, and the reason the why it didn't push correctly.

Let me know if it worked out!