Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating deposit/withdrawal with foreign currency not working #1236

Closed
razorbenke92 opened this issue Mar 8, 2018 · 7 comments
Closed

Updating deposit/withdrawal with foreign currency not working #1236

razorbenke92 opened this issue Mar 8, 2018 · 7 comments
Labels
bug Verified and replicated bugs and issues. fixed Bugs that are fixed (in a coming release).
Milestone

Comments

@razorbenke92
Copy link

I am running Firefly III version 4.7.1.4

Description of my issue:

Updating a deposit/withdrawal which was created with foreign currency is not working properly. After update, the foreign currency and amount disappears.

Steps to reproduce

Reproducing on demo site:

Adding a withdrawal with a EUR account, but changing currency to HUF. It shows the HUF as main, and EUR under it. Set amounts and submit.
You will see a transfer with ammount xxx EUR ( yyy HUF)

Go to the edit page of this transaction:
You will see HUF still at main, and EUR under it. Edit something for eg. add a tag. Update.

Now you will only see the transaction with only yyy HUF ammount (and no EUR)

Go to the edit page again:

Now you only see the main HUF value and no EUR.

After this, there is no scenario to set the EUR master value back.

I think with the update, you are overwriting the native currency with the foreign one.

(please include if this problem also exists on the demo site)

Other important details (log files, system info):

Please click the version number in the right corner of any Firefly III page to get debug information.

@razorbenke92
Copy link
Author

I am just starting to learn Laravel, but I sense something in TransactionUpdateService.php

$data['amount'] and $data['foreign_amount'] is used but (if these are the form values) the update form is using 'native_amount' and 'amount' where 'amount' stands for the foreign value.

@razorbenke92
Copy link
Author

Even the database has this.
kep

var_dump for the $data array says this:
array(17) { ["currency_id"]=> int(2) ["currency_code"]=> NULL ["description"]=> NULL ["amount"]=> string(5) "10000" ["budget_id"]=> int(0) ["budget_name"]=> NULL ["category_id"]=> NULL ["category_name"]=> string(0) "" ["source_id"]=> int(5) ["source_name"]=> string(0) "" ["destination_id"]=> NULL ["destination_name"]=> string(0) "" ["foreign_currency_id"]=> NULL ["foreign_currency_code"]=> NULL ["foreign_amount"]=> NULL ["reconciled"]=> bool(false) ["identifier"]=> int(0) }

JC5 added a commit that referenced this issue Mar 9, 2018
@JC5
Copy link
Member

JC5 commented Mar 9, 2018

Thanks for reporting this, and thanks for the extended bug report!

It seems the problem was in Javascript, and not in PHP. You can see in the commit that the currency for the asset account was set to HUF instead of EUR (in your example). That makes Firefly III think that HUF is the normal amount.

This fix is live on the demo site where you should be able to edit a transaction with foreign amount data without any problems.

Let me know if this has fixed it!

@JC5 JC5 added bug Verified and replicated bugs and issues. fixed Bugs that are fixed (in a coming release). labels Mar 9, 2018
@JC5 JC5 added this to the 4.7.2 milestone Mar 9, 2018
@razorbenke92
Copy link
Author

Yes, fixed.

Another notice:
I don't know if it is a feature or a bug, but relates to this topic, so I will describe.

As you know, bills only work with the default currency. In my case it is HUF. I have a EUR account for my payments and company related expenses.
What happens is, that I want to pay my phonebill (issued in HUF) with my EUR account. When storeing the withdrawal using HUF as foreign currency, and EUR as native (of course) :

  • Spent money in HUF not appearing in my monthly balance
  • Bill not changing to payed
  • I can only see the balance change on the EUR part of my Net Worth

BUT
If I manually swap the native-foreign currencies and values in the database for the transaction:

  • Spent money appears in HUF on the monthly balance
  • Bills can match automaticaly
  • The net worth still calculates properly for every account

I think it is rather a bug, but I could use it as a feature, converting all my EUR expenses to HUF and solving a lot of problem with that.
Any hints where to change the code at my local server, to save foreign and native data swapped (even on creation or on edit). Sorry, as I said I am new to Laravel, and I can hardly find the proper functions.

Thanks!

@JC5
Copy link
Member

JC5 commented Mar 9, 2018

If you swap out transactions I cannot guarantee things will work. I can see what you're doing but I can only do one thing, not both:

  1. Use the EUR account in EUR, measuring your balance in EUR and your net worth in EUR, using HUF amounts as a reference only.
  2. Do the same but in reverse.

You can use HUF transactions on a EUR account as main currency. It is not difficult to do this. But the charts will deviate (main balance of the account will be incorrect) and other sums could break as well.

I'm not sure what the bug is, but several features relate to this: #1207 #1071 #991 #869

@razorbenke92
Copy link
Author

razorbenke92 commented Mar 9, 2018

Okay, I don't want to waste your time, since it would be just a hack-fix, not a proper solution.

But if you are interested, I show what I mean:

At the beginning, this is my dashboards header:
kep

I add a 1000 EUR worth of deposit, by 300 000 HUF as a foreign currency:
kep

So my header looks like:
kep
You can see, that the balance has not changed, and for me it is misleading.

Thats why I swap the foreign and native values in the database and hit rescan transactions at bills:
kep

Now the balance shows that I had 300 000 HUF worth of income, but at the Net Worth It still calculates the EUR value of the deposit.
kep

Try it again with withdrawal, using a tag for my last unpayed bill:
kep

This is my heather (notice the only change in the EUR Net worth)
kep

Now swapping currencies and values and rescan transactions:
kep

Gives a heather:
kep

So in my case (I know there can be more difficult cases) I see only benefitsd from swapping the currencies, since I see my net balance referenced in HUF even for the transactions I do in EUR.

I will find a way to use it like this until the next release. Thanks!

@JC5
Copy link
Member

JC5 commented Mar 10, 2018

Aha, now I get what you mean. Thanks! The box for balance is not multi-currency, and that is confusing indeed. I can see that it updates as it should, but it adds 1000 EUR to your HUF balance.

I have updated the development version to fix this. There is only room for two currencies, but that should be enough.

screen shot 2018-03-10 at 06 40 02

For your withdrawal, I also see a change in balance that is wrong. This will also be fixed.

JC5 added a commit that referenced this issue Mar 10, 2018
@JC5 JC5 closed this as completed Mar 19, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jan 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Verified and replicated bugs and issues. fixed Bugs that are fixed (in a coming release).
Projects
None yet
Development

No branches or pull requests

2 participants