Closed axelivarsson closed 3 years ago
The platform always returns fraction digits with a value of 2 for CentPrecisionMoney and doesn't differentiate between the currencies and their fractions so the factor would always be 100. If there is a need for different fractions you would have to use HighPrecisionMoney or create an own extension method to convert the amount to a decimal.
The JSON we get from the API for a KRW price looks like this:
"value": {
"type": "centPrecision",
"currencyCode": "KRW",
"centAmount": 60500,
"fractionDigits": 0
},
The platform always returns fraction digits with a value of 2 for CentPrecisionMoney
I'm not sure what you mean, we get 0
for fractionDigits
in the JSON?
Oops. This information slipped through back then when the fractionDigits had been introduced. We will change to AmountToDecimal to use the calculation
@axelivarsson We solved it and created a new release with version 1.1.4
Thank you!
The
Money
class in the dotnet core SDK uses(decimal)CentAmount / 100M;
forAmountToDecimal()
without considering the number ofFractionDigits
for the current currency.Although most currencies has 2 fraction digits, this will give us the wrong amount for currencies like KRW which has 0 fraction digits or OMR that has 3.
I would expect this to do something like
CentAmount / (decimal) Math.Pow(10, FractionDigits.GetValueOrDefault())
, similar to how it is done inHighPrecisionMoney
.