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

Incorrect allocation by ratios #55

Closed
itd3v opened this issue Nov 24, 2021 · 6 comments
Closed

Incorrect allocation by ratios #55

itd3v opened this issue Nov 24, 2021 · 6 comments

Comments

@itd3v
Copy link
Contributor

itd3v commented Nov 24, 2021

Hi!
That is a cool library, thanks for your time to develop it and make others life easier:)

While integrating it into my project I've found wrong allocation using ratios:
10m.Usd().Allocate(new RatioCollection(1m, 0m));
Expected result: 10m & 0m
Act result: 10.01m & -0.01m
NMoneys version: 6.1.0

Seems the problem is in Currency.Round method in MidpointRounding value.

internal decimal Round(decimal share)
{
	decimal raw = share - (.5m * MinAmount);
	decimal rounded = Math.Round(raw, SignificantDecimalDigits, MidpointRounding.AwayFromZero);
	return rounded;
}

Thanks in advance.

@itd3v
Copy link
Contributor Author

itd3v commented Nov 24, 2021

I've made a pull request, please check it when it possible.
Thanks.

@dgg
Copy link
Owner

dgg commented Nov 25, 2021

Hi,

Thanks for the compliment.
I will be able to have a look at it this evening.
I'll have to build myself a .NET dev environment and check that the release process still works.

Thanks a lot for the contribution

@dgg
Copy link
Owner

dgg commented Nov 25, 2021

Hi I was able to have a look.
Oh boy this project is old! Besides, I do not have a Windows machine anymore and that makes things twice as difficult.

I could verify the changes look good but the "automated" release process cannot run as it is pretty ancient.
I cannot release manually due to lack of time today, but I will try my luck tomorrow.

Thanks for the contribution.
I promise I will push the changes as soon as possible.

@itd3v
Copy link
Contributor Author

itd3v commented Nov 25, 2021

Hi Daniel!
Thanks a lot, I appreciate your efforts.
Will wait;)

Have a good time!

@itd3v
Copy link
Contributor Author

itd3v commented Dec 1, 2021

Hi Daniel!
Hope are doing good.

Any update?

@dgg
Copy link
Owner

dgg commented Dec 1, 2021

Hi,

Good news.

CI was able to build the project and I could manually push it to the gallery: https://www.nuget.org/packages/NMoneys/6.1.1

I will be creating the rest of the release artifacts later today.

Thanks for the contribution

@dgg dgg closed this as completed Dec 1, 2021
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

No branches or pull requests

2 participants