Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

What about currency precision in a plugin?

$
0
0

If I sell something @4.85 w/50% discount I get extended amount 2.43 and manual discount of 2.43 -- both of them round up from 2.425.  $ precision is set to 2 and all these fields are set to currency precision (also tested them hard coded to 2 with no difference in execution.)  So, I changed my code to this betting on the rounding to take place upon conversion from decimal to Money

        //2021-12-30 make sure rounding to 2 places doesn't cause base amount <> extended amouunt + manual discount amount
                decimal manualdiscountamount = line.GetAttributeValue<Money>("baseamount").Value - line.GetAttributeValue<Money>("extendedamount").Value;
                addOrSet("manualdiscountamount", new Money(manualdiscountamount), line);

It doesn't.  Why?  What should I do, actually pull the currency precision and do all the rounding manually?  Rounding to currency precision doesn't really happen -- it's presentation level only?  Or it only happens on Update?

TIA


Viewing all articles
Browse latest Browse all 79901

Trending Articles