Page 1 of 1

Changing Formula to COR

Posted: Thu Aug 31, 2017 10:52 am
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)

Re: Changing Formula to COR

Posted: Thu Aug 31, 2017 4:19 pm
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

Re: Changing Formula to COR

Posted: Fri Sep 01, 2017 9:05 am
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.

Re: Changing Formula to COR

Posted: Tue Sep 05, 2017 10:22 am
by BobRichards
What is the error message(s) in the Error and Warnings window?

Re: Changing Formula to COR

Posted: Tue Sep 05, 2017 12:23 pm
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...

Re: Changing Formula to COR

Posted: Tue Sep 05, 2017 4:17 pm
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.