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

Fix bug 1187: Allow balance assertions with multiple posts to the same account #472

Merged
merged 1 commit into from Oct 17, 2016

Conversation

mk12
Copy link
Contributor

@mk12 mk12 commented Oct 5, 2016

Fixes Bug 1187

@thdox also discussed this in #451

Before, balance assertions/assignments just subtracted the amount in the current post. With these changes, they also subtract all amounts posted to the same account so far in the xact. I think anyone who wrote such a transaction would expect this behaviour.

I added two regression tests as well.

@thdox
Copy link
Contributor

thdox commented Oct 5, 2016

Hi @mk12

Thank you very much for this first patch. It corrects the use case I described in PR #451 :-)

However, my ledger file is still not passing. Here is another use case, when there are several commodities on the same account.

2001/01/01 * Balance
    Actif:Courant:Cc                  10000,00 F = 10000,00 F
    Equity

2002/01/11 * Passage à l'euro
    Actif:Courant:Cc                 -10000,00 F = 0,00 F
    Actif:Courant:Cc                   1524,49 € = -1524,49 €
    Revenu:Devise                    -10000,00 F
    Revenu:Devise                      1524,49 €

Is there something you can do? Maybe checking the commodity while computing the balance ?
Thank you so much for your help.

@mk12
Copy link
Contributor Author

mk12 commented Oct 6, 2016

@thdox, is there a mistake in your example? Shouldn't the second assertion be positive 1524,49 €, not negative?

I see what you mean though. Currently I am subtracting the amounts from previous postings to the same account in the same transaction without regard to commodities. I should change it to only subtract amounts of the same commodity as the current posting. I'll try to do this tonight or on the weekend.

@thdox
Copy link
Contributor

thdox commented Oct 6, 2016

@mk12, yes, that should looks to something like:

2001/01/01 * Balance
    Actif:Courant:Cc                  10000,00 F = 10000,00 F
    Equity

2002/01/11 * Passage à l'euro
    Actif:Courant:Cc                 -10000,00 F = 0,00 F
    Actif:Courant:Cc                   1524,49 € = 1524,49 €
    Revenu:Devise                     10000,00 F
    Revenu:Devise                     -1524,49 €

I tried myself, based on your pull request, but this is much harder than I thought, I realized that I am not a c++ guy, and that I lack knowledge of the ledger's internals...
Thank you to look at it
Cheers

@mk12
Copy link
Contributor Author

mk12 commented Oct 8, 2016

@thdox, I have updated the PR with your two examples as 1187_1.test and 1187_2.test, respectively. Both are passing with my new changes.

@jwiegley, What's up with the clang build? It seems to be failing for your next branch as well. In any case, let me know if this looks good to merge :)

@thdox
Copy link
Contributor

thdox commented Oct 8, 2016

THANK YOU 👍

@mk12, thank you so much, it does work on my ledger file now. FWIW, I did not tell that I tried to fix myself, and spend something like 6 hours with a lot more lines of codes, and time to compile, but without success. Sometimes Internet is beautiful. You made my day.

@tbm
Copy link
Contributor

tbm commented Oct 8, 2016

@mk12, I want to echo Thierry's comments. Your work is very welcome!

@mk12
Copy link
Contributor Author

mk12 commented Oct 9, 2016

Glad to be of help :)

@tbm, are you able to merge this? CI tests passed for gcc, and the clang failure seems be happening on the next branch already.

@jwiegley jwiegley merged commit a285b2a into ledger:next Oct 17, 2016
@mk12 mk12 deleted the bug-1187-assertions branch October 18, 2016 02:42
@thdox
Copy link
Contributor

thdox commented Oct 18, 2016

Thanks for merging 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants