robvankeilegom / firefly-III-paypal-importer

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

Not creating new expense accounts or relating to existing ones #20

Open shrippen opened 7 months ago

shrippen commented 7 months ago

Hi, using the new 0.3.3 I am able to pull and push my paypal data. Unfortunately the firefly_expense_id is either 0 or NULL in the sqlite. Where and when does the importer try to match "name" and firefly_expense_id?

This also applies to income accounts when there is a refund.

robvankeilegom commented 7 months ago

@shrippen Can you send me the event_codes for a transaction linked to the payer where you expect the firefly_expense_id to be filled in? This can be multiple transaction records for a single transaction if there's a currency conversion.

Here is an example: image

As you can see there's one main record with the payer_id entered, and 3 sub records where the reference_id is equal to the pp_id on the main record. These 4 records in the transactions table are a single transaction in PayPal.

If there's anything unclear, lmk!

shrippen commented 7 months ago

image

image

I hope this is helpful

shrippen commented 6 months ago

Any news on this?

robvankeilegom commented 6 months ago

@shrippen I'm not sure what's going on. There might be an issue where Firefly returns an error that wasn't caught. I made some changes in 0.3.4, can you try again? You'll have to set the 0 values to null manually first or delete the database and start from scratch.

shrippen commented 6 months ago

Now we have some new information. When running sync:firefly I get the following error:

Client error: POST http://firefly_app:8080/api/v1/accounts resulted in a 422 Unprocessable Content response:
{"message":"Dieser Kontoname wird bereits verwendet.","errors":{"name":["Dieser Kontoname wird bereit
s verwendet."]}}

(The name of this account is already in use)

As not even one transaction was pushed to firefly I assumed it was related to id 1 in the sql. So I checked that and found it related to Patreon Ireland Limited. And yes an expense account of that name already exists within my firefly installation.

It wasn't used so I tried deleting it and running the sync again. Now the importer successfully created Patreon Ireland Limited but crashed on the second transaction, this time relating to Patreon, Inc (also already existing).

So yes there seems to be a problem with attaching transactions to existing expense accounts or accounts in general.

robvankeilegom commented 6 months ago

Thanks, that clears out a lot. Since Firefly doesn't really return an error code, i have to check on the error message.

The application tries to create an account. If we get an error saying the account already exists it searches for the account based on name and tries to find an exact match.

This check is only on the english error message, so i'll have to figure something out for firefly instances in other languages.

If anyone wants to look at it before i get around to it, the code i'm talking about is at https://github.com/robvankeilegom/firefly-III-paypal-importer/blob/d554cc85d05d143a2547899646ee97bf3202de06/app/Firefly.php#L104C33-L104C34