Round Up Full Premium

Questions about and code samples for custom order rules and validation within Select.
Post Reply
bdutil
Posts: 83
Joined: Tue Jul 19, 2016 1:48 pm

Round Up Full Premium

Post by bdutil » Fri May 18, 2018 3:31 pm

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

BobRichards
Posts: 1007
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Round Up Full Premium

Post by BobRichards » Fri May 18, 2018 4:39 pm

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"
Bob Richards, Software Developer, SoftPro

Post Reply