Changing Formula to COR

Questions about and code samples for custom order rules and validation within Select.
Post Reply
tmeisinger
Posts: 75
Joined: Fri Apr 24, 2015 10:33 am

Changing Formula to COR

Post by tmeisinger »

I want to move a Formula to a COR. Is there any way to call the RateTableCalc function from COR? I can handle changing the field references.

From Formula:

Code: Select all

RateTableCalc({{Order.Title.LoanPolicies[1].SplitCalculation.RateTable.RateScheduleName}}, 1, {{order.title.TitleInsuranceCalculations[1].LoanPolicy.PremiumCalculation.CoverageAmount}}, 100.00) - RateTableCalc({{Order.Title.LoanPolicies[1].SplitCalculation.RateTable.RateScheduleName}}, 1, {{order.title.TitleInsuranceCalculations[1].OwnersPolicy.PremiumCalculation.CoverageAmount}}, 100.00)
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Changing Formula to COR

Post by BobRichards »

You can do a similar calculation in the COR manually if you want. However, the RateTableCalc function is not a public method that is available through the API. In the OP and LP you can access the selected rate table and call a method to calculate the premium. It will be up to you to implement the proper behavior based on the method and any other necessary logic.

Code: Select all

def PremiumCalculation_BasePremium_Value(args):	
	# Get the current table selection.
	calc = args.Context
	table = calc.PremiumRateTable
	if table:
		args.Value = table.CalculatePremium(Decimal(calc.CoverageAmount))
	else:
		# No table is selected.  Run the Select rule.
		args.RunDefaultRule()
		return
Bob Richards, Senior Software Developer, SoftPro
tmeisinger
Posts: 75
Joined: Fri Apr 24, 2015 10:33 am

Re: Changing Formula to COR

Post by tmeisinger »

Thanks Bob. Somehow I was able to save my COR yesterday, even though it had errors. Today I fixed it with your advice and now I can't save the Order because of a compilation error. Should have gotten that yesterday, but everything is fine now? I deleted every module for the order and still can't save the order with no COR modules? Any thoughts.
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Changing Formula to COR

Post by BobRichards »

What is the error message(s) in the Error and Warnings window?
Bob Richards, Senior Software Developer, SoftPro
tmeisinger
Posts: 75
Joined: Fri Apr 24, 2015 10:33 am

Re: Changing Formula to COR

Post by tmeisinger »

It was saying module compilation error, with no other details. Each COR (had a few) were working fine with no Errors, but still couldn't save the Order. After repeated, saving by adding a space here or there, deleting and recreating (copy, delete, add, paste, ...) I was finally able to get the Order to save. Can't identify why, but as of an hour or so ago, everything seems to be working now...
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Changing Formula to COR

Post by BobRichards »

I'm not sure what happened. But remember during development when rules are aborted due to runtime errors, other rules may have been prevented from running and the order model might be in a weird state.

When developing CORs, after a couple hours of Python runtime syntax and object type errors, you may notice the Select client stops behaving correctly and you may need to restart the client. (No. I'm not going to explain "stops behaving correctly". It's obvious if it happens. If in doubt, just restart the client.)

This does NOT occur when rules are designed properly (when runtime errors do not occur). For clarity - Value rules calling RaiseError(), RaiseWarning(), and RaiseInformation() are NOT the runtime errors I am talking about - they are always OK to use.
Bob Richards, Senior Software Developer, SoftPro
Post Reply