Page 1 of 1

Round Up Full Premium

Posted: Fri May 18, 2018 3:31 pm
by bdutil
Trying to Get the System calculated Full Premium amount on CDF orders to Round Up automatically. Is this possible? I found Math.Round and some other options in the SDK but can't get any of them to work.

Field is PremiumCalulation_SimultaneousPremium

Re: Round Up Full Premium

Posted: Fri May 18, 2018 4:39 pm
by BobRichards
You can do this with any decimal. Select does rounding to the nearest penny for display to the user but the field value internally has all the fractional pennies from the original calculation. To make sure the field has no fractional pennies, do the rounding before you set the field. As an example, the COR below rounds to the nearest penny.

Code: Select all

def SalesContract_SalesPrice_Value(args):
    d = Decimal(100.505)
    args.Value = Math.Round(d, 2, MidpointRounding.AwayFromZero)    # 2 means round to 2 digits right of the decimal
	
    # Output is "$100.51"
If you wanted, you could even round to the nearest dollar.

Code: Select all

def SalesContract_SalesPrice_Value(args):
    d = Decimal(100.505)
    args.Value = Math.Round(d, 0, MidpointRounding.AwayFromZero)    # 0 means round to 0 digits right of the decimal
	
    # Output is "$101.00"