Skip to content

Commit

Permalink
fix: Use CurrencyDecimalDigits instead of NumberDecimalDigits when ro…
Browse files Browse the repository at this point in the history
…unding money
  • Loading branch information
artem-dudarev committed Nov 15, 2024
1 parent 52de3ad commit b0dd10c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public decimal RoundMoney(decimal amount, Currency currency)
{
var roundingType = EnumUtility.SafeParse(currency.RoundingType, RoundingType.Rounding001);
var midpointRounding = EnumUtility.SafeParse(currency.MidpointRounding, MidpointRounding.AwayFromZero);
return Round(amount, currency.NumberFormat.NumberDecimalDigits, roundingType, midpointRounding);
return Round(amount, currency.NumberFormat.CurrencyDecimalDigits, roundingType, midpointRounding);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using VirtoCommerce.CoreModule.Core.Common;
using VirtoCommerce.CoreModule.Core.Currency;
using VirtoCommerce.CoreModule.Core.Enums;
using Xunit;
Expand All @@ -14,7 +15,7 @@ public void CanRound(decimal amount, decimal expected, RoundingType roundingType
{
// Arrange
var roundPolicy = new DefaultMoneyRoundingPolicy();
var currency = new Currency();
var currency = new Currency(new Language("en-US"), code: null);
currency.RoundingType = roundingType.ToString();
currency.MidpointRounding = midpointRounding.ToString();

Expand Down

0 comments on commit b0dd10c

Please sign in to comment.