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

Asset account -> Opening balance does not keep the correct amount #972

Closed
pjotrvdh opened this issue Nov 1, 2017 · 19 comments
Closed

Asset account -> Opening balance does not keep the correct amount #972

pjotrvdh opened this issue Nov 1, 2017 · 19 comments
Assignees
Labels
bug Verified and replicated bugs and issues. fixed Bugs that are fixed (in a coming release).

Comments

@pjotrvdh
Copy link

pjotrvdh commented Nov 1, 2017

I am running Firefly III version 4.6.9

Description of my issue:

The opening balance does nog keep the value that I entered. Instead it looks like it places a negative of the number

Steps to reproduce

  • add a asset account
  • only filled in the following fields:
    [name] = Rabo
    [Opening balance] = 1000
    [Account role] = Savings
    [Opening balance date] = 21/09/2017
    Save the info
  • go and edit the just created asset and add IBAN
    NL39RABO0300065264 (this is an valid example)
    Save the info

the value is now negative.

it is not possible to edit the value to a positive number

@pjotrvdh pjotrvdh changed the title Asset account -> Opening balance does nog keep the correct amount Asset account -> Opening balance does not keep the correct amount Nov 1, 2017
@JC5
Copy link
Member

JC5 commented Nov 1, 2017

I'm not able to replicate this on the demo site. Both before and after saving the amount remains 1000,-.

Are you running Firefly III in Dutch? What happens when you enter the amount "123.45"? Does it still reverse the amount?

Could you check the following?

Open your favorite database editor and run this query:

select * from transactions where account_id = *

Where the ID is the ID of your new asset account. Then, run the following query:

select * from transactions where transaction_journal_id = *

Where the transaction_journal_id is retrieved from the previous query.

Could you share the amounts for the transactions?

@pjotrvdh
Copy link
Author

pjotrvdh commented Nov 1, 2017

Yes I'm running in Dutch but the problem exists in english
the result of the first query is

Modify id created_at updated_at deleted_at user_id transaction_type_id bill_id transaction_currency_id description date interest_date book_date process_date order tag_count encrypted completed
edit 1 2017-11-01 12:32:13 2017-11-01 14:21:10 NULL 1 4 NULL 1 eyJpdiI6Im9nbTViQW5tbm1OVXNcL2hJcEx3dWFnPT0iLCJ2YWx1ZSI6InNzRGZ3SVp6dWVxTDlKNDlNMW1BclwvZHd1TzZlaDBn... 2017-09-21 NULL NULL NULL 0 0 1 1

the second query gives the same result so i did it on the transaction_journals with the following result:

Modify id created_at updated_at deleted_at user_id transaction_type_id bill_id transaction_currency_id description date interest_date book_date process_date order tag_count encrypted completed
edit 1 2017-11-01 12:32:13 2017-11-01 14:21:10 NULL 1 4 NULL 1 eyJpdiI6Im9nbTViQW5tbm1OVXNcL2hJcEx3dWFnPT0iLCJ2YWx1ZSI6InNzRGZ3SVp6dWVxTDlKNDlNMW1BclwvZHd1TzZlaDBn... 2017-09-21 NULL NULL NULL 0 0 1 1
edit 2 2017-11-01 12:32:13 2017-11-01 15:45:31 2017-11-01 15:45:31 1 4 NULL 1 eyJpdiI6IlR4OFdMdEtoZmNkclwvaTJOZFE1WXRBPT0iLCJ2YWx1ZSI6ImVoMmdMMXJadWlwcmxQUEhmMmRjd2hja0ZxbStvbHlV... 2017-09-21 NULL NULL NULL 0 0 1 1
edit 3 2017-11-01 15:47:47 2017-11-01 15:47:47 NULL 1 4 NULL 1 eyJpdiI6IitVZ0I3ZTRkOTBxaUNcL3k4R2FZdG1RPT0iLCJ2YWx1ZSI6Impna1NiUHpEb3RWK1FUQkJcL0xoQUl1cEVQZXNLTUoy... 2017-09-21 NULL NULL NULL 0 0 1 1

@JC5
Copy link
Member

JC5 commented Nov 1, 2017

Both of these queries were executed on the transaction_journals table, not on the transactions table. Could you check that one as well?

@pjotrvdh
Copy link
Author

pjotrvdh commented Nov 1, 2017

My bad

select * from transactions where account_id = 1

id created_at updated_at deleted_at account_id transaction_journal_id description transaction_currency_id amount foreign_amount foreign_currency_id identifier
1 2017-11-01 12:32:13 2017-11-01 16:04:22 NULL 1 1 NULL 1 -123.450000000000 NULL NULL 0

select * from transactions where transaction_journal_id = 1

id created_at updated_at deleted_at account_id transaction_journal_id description transaction_currency_id amount foreign_amount foreign_currency_id identifier
1 2017-11-01 12:32:13 2017-11-01 16:04:22 NULL 1 1 NULL 1 -123.450000000000 NULL NULL 0
2 2017-11-01 12:32:13 2017-11-01 16:04:22 NULL 2 1 NULL 1 -123.450000000000 NULL NULL 0

It's good to know that i'm running on a clean install with only the actions from before

@JC5
Copy link
Member

JC5 commented Nov 1, 2017

Mmm, both are negative, that shouldn't happen.

Which OS are you running FF on? Is it running from a Docker image? Are you using Sandstorm.io?

Which browser / operating system?

@pjotrvdh
Copy link
Author

pjotrvdh commented Nov 1, 2017

I'm running it op an mac mini with ampps
php version: 7.1.8
Browser: Chrome

JC5 added a commit that referenced this issue Nov 1, 2017
@JC5
Copy link
Member

JC5 commented Nov 1, 2017

Using Safari, Chrome or FF?

All I can do at this point is add debug info for the next release. I'm having a hard time replicating your issue (it all works just fine here) but I am seeing some conditions in the code that could cause trouble. It's just that I don't have said trouble.

You could help me out by enabling debug mode.

Then, open file firefly-iii/app/Repositories/Account/AccountRepository.php and replacing its entire contents with the content of this file.

That should add a lot more debug logging. If you could try it, I might be able to pinpoint the problem.

@pjotrvdh
Copy link
Author

pjotrvdh commented Nov 2, 2017

I enabled the debug mode and replaced said file.
Then I tried to correct the value and the error stil exists.
I've attached the log
ff3-apache2handler-2017-11-02.log

@JC5
Copy link
Member

JC5 commented Nov 2, 2017

Could you try to recreate the account?

To fix the current account, change one of the two entries in your database (table transactions) to be positive (leave the other one negative). That should fix it for this account.

With the extra logging I hope to find out what happens when you create a new account (and it goes badly).

Thanks for the logs so far!

@pjotrvdh
Copy link
Author

pjotrvdh commented Nov 2, 2017

I've compiled whole new project with composer and created the account and all with the debug logging enabled.
Problem still exists
Here is the logs:
ff3-apache2handler-2017-11-02.log

@JC5
Copy link
Member

JC5 commented Nov 2, 2017

Damn! That's all I can ask you for now. I will push 3.9.10 this weekend. It will contain some changes that I hope will fix this. Is that OK?

In the mean time, to fix your current asset account, change either of the two entries in transactions to a positive amount. Then it should work again.

@pjotrvdh
Copy link
Author

pjotrvdh commented Nov 2, 2017

I also just tried it on another machine (MAMP PRO v4.2). no problem there.
uninstalled AMPPS, installed MAMP (4.2.1) and installed again. It seems to work correctly.
maybe it had something to do with the AMPPS environment?
Other problem that I now have is a conflict with https behind reverse proxy...

@JC5
Copy link
Member

JC5 commented Nov 2, 2017

It could be yes, I will keep it in mind. As for the reverse proxy, try some of the tricks from this issue: #921

@JC5
Copy link
Member

JC5 commented Nov 2, 2017

But I am glad the bug seems to be gone at least. The debug-logging I've added may help somebody else in the future.

@JC5 JC5 self-assigned this Nov 3, 2017
@JC5 JC5 added bug Verified and replicated bugs and issues. fixed Bugs that are fixed (in a coming release). labels Nov 3, 2017
@JC5
Copy link
Member

JC5 commented Nov 3, 2017

Closed, a new release is live.

@JC5 JC5 closed this as completed Nov 3, 2017
@pjotrvdh
Copy link
Author

pjotrvdh commented Jan 4, 2018

Sadly the problem still exists in version 4.6.12

Here's some info

select * from transactions where account_id = 1

id created_at updated_at deleted_at reconciled account_id transaction_journal_id description transaction_currency_id amount foreign_amount foreign_currency_id identifier
1 2018-01-04 20:31:32 2018-01-04 20:32:45 NULL 0 1 1 NULL 1 -123.450000000000 NULL NULL 0

select * from transactions where transaction_journal_id = 1

id created_at updated_at deleted_at reconciled account_id transaction_journal_id description transaction_currency_id amount foreign_amount foreign_currency_id identifier
1 2018-01-04 20:31:32 2018-01-04 20:32:45 NULL 0 1 1 NULL 1 -123.450000000000 NULL NULL 0
2 2018-01-04 20:31:32 2018-01-04 20:32:45 NULL 0 2 1 NULL 1 -123.450000000000 NULL NULL 0

running on a linux webserver with
Php (7.1.12)
MySQL (5.5.5-10.1.24-MariaDB)

using browser Chrome (63.0.3239.84)

Here's the debug log:
ff3-litespeed-2018-01-04.log

@JC5
Copy link
Member

JC5 commented Jan 4, 2018

[2018-01-04 20:31:32] local.NOTICE: First amount is 1000, second amount is -1000  
[2018-01-04 20:31:32] local.NOTICE: Stored two transactions for new account, #1 and #2  

Compare this with the creation of these transactions https://github.com/firefly-iii/firefly-iii/blob/master/app/Repositories/Account/AccountRepository.php#L389.

I still have no idea what's causing this.

Could you sure the firefly.app/debug page here?

@JC5
Copy link
Member

JC5 commented Jan 4, 2018

Wait, looking further, i see the initial creation went through fine, the edit is broken.

JC5 added a commit that referenced this issue Jan 4, 2018
@JC5
Copy link
Member

JC5 commented Jan 4, 2018

OK, that was surprisingly simple once I got to think about it. I've pushed a fix (see above) and I invite you to replace the entire content of the AccountRepository.php file with this.

This will also fix accounts that are already broken.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 24, 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