Splits Revisited - Endorsements

Questions about and code samples for custom order rules and validation within Select.
Post Reply
DanChapin
Posts: 16
Joined: Thu Sep 24, 2015 10:40 am

Splits Revisited - Endorsements

Post by DanChapin »

A while back , we put together a COR to set the some split values on the Title insurance premium screen. I want to do the same for the split fields on the endorsement screen. I am having a problem getting at those fields. Below is the code I have so far. This is working code which sets the split values on the TIP screen, I am adding the sections to set the endorsement split fields. When this is run, I get an error saying that "Error encountered during rule execution. 'type' object has no attribute 'OwnersPolicyEndorsement'"

When I comment out the OwnersPolicyEndorsement lines, I do not get the same error for LoanPolicyEndorsements (Which seems weird) but it does not work either (or generate and error for that matter).

Code: Select all

from System import *
from SoftPro.ClientModel import *
from SoftPro.OrderTracking.Client import *
from SoftPro.OrderTracking.Client.Orders import *

def Split_Dollars_Value(args):
    split = args.Context
    split1 = split.Parent.Split1
    split2 = split.Parent.Split2
    policy = split.Parent.Parent
    Order = args.Context.Root
    if (((str(policy).StartsWith('Loan')) or (str(policy).StartsWith('Own'))) and (Order.TitleCompanies)):
        if split.Guid == split1.Guid:
            if policy.Type == TitleProductType.LoanPolicy:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'Split1Loan_Dollars_901045##')
            elif policy.Type == TitleProductType.OwnersPolicy:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'Split1Owners_Dollars_901045##')
            # BELOW FOR ENDORSEMENTS    
            elif policy.Type == TitleProductType.OwnersPolicy.Endorsement:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'END_Split1Owners_Dollars_901045##')
            elif policy.Type == TitleProductType.LoanPolicy.Endorsement:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'END_Split1Loan_Dollars_901045##')
               
            
        if split.Guid == split2.Guid:
            if policy.Type == TitleProductType.LoanPolicy:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'Split2Loan_Dollars_901045##')
            elif policy.Type == TitleProductType.OwnersPolicy:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'Split2Owners_Dollars_901045##')
            # BELOW FOR ENDORSEMENTS    
            elif policy.Type == TitleProductType.OwnersPolicy.Endorsement:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'END_Split2Owners_Dollars_901045##')
            elif policy.Type == TitleProductType.LoanPolicy.Endorsement:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'END_Split2Loan_Dollars_901045##')


            
def DefaultSplit_Percent_Value(args):
    defaultsplit = args.Context
    defaultsplit1 = defaultsplit.Parent.Split1
    defaultsplit2 = defaultsplit.Parent.Split2
    policy = defaultsplit.Parent.Parent
    Order = args.Context.Root
    if (((str(policy).StartsWith('Loan')) or (str(policy).StartsWith('Own'))) and (Order.TitleCompanies)):
        if defaultsplit.Guid == defaultsplit1.Guid:
            if policy.Type == TitleProductType.LoanPolicy:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'Split1Loan_Percent_901045##')
            elif policy.Type == TitleProductType.OwnersPolicy:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'Split1Owners_Percent_901045##')
            # BELOW FOR ENDORSEMENTS    
            elif policy.Type == TitleProductType.LoanPolicy.Endorsement:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'END_Split1Loan_Percent_901045##')
            elif policy.Type == TitleProductType.OwnersPolicy.Endorsement:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'END_Split1Owners_Percent_901045##')
            
        if defaultsplit.Guid == defaultsplit2.Guid:
            if policy.Type == TitleProductType.LoanPolicy:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'Split2Loan_Percent_901045##')
            elif policy.Type == TitleProductType.OwnersPolicy:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'Split2Owners_Percent_901045##')      
            # BELOW FOR ENDORSEMENTS    
            elif policy.Type == TitleProductType.LoanPolicy.Endorsement:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'END_Split2Loan_Percent_901045##')
            elif policy.Type == TitleProductType.OwnersPolicyEndorsement:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'END_Split2Owners_Percent_901045##')          
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Splits Revisited - Endorsements

Post by BobRichards »

The TitleProductType will not tell you the type of policy an Endorsement is attached to - just that it is an Endorsement. Get its parent to get the actual policy type.

Code: Select all

    elif policy.Type == TitleProductType.Endorsement and policy.Parent.Type == TitleProductType.LoanPolicy:
	# This is an LP endorsement
FYI, Additional Title Charges are like endorsements. In that case you have to query the ATC's Policy for the actual policy (if any).
Bob Richards, Senior Software Developer, SoftPro
DanChapin
Posts: 16
Joined: Thu Sep 24, 2015 10:40 am

Re: Splits Revisited - Endorsements

Post by DanChapin »

Thanks Bob,

That makes sense, but still doesn't work, see below. I am guessing that this is not working because, in the line:

elif policy.Type == TitleProductType.Endorsement and policy.Parent.Type == TitleProductType.OwnersPolicy:

policy.Type should be policy.Type == TitleProductType.OwnersPolicy:
and
policy.Type == TitleProductType.Endorsement should be something like policy.Child.Type

but this all confuses me pretty good.

Ideas, Help??

Thanks
Dan

Code: Select all

def Split_Dollars_Value(args):
    split = args.Context
    split1 = split.Parent.Split1
    split2 = split.Parent.Split2
    policy = split.Parent.Parent
    Order = args.Context.Root
    if (((str(policy).StartsWith('Loan')) or (str(policy).StartsWith('Own'))) and (Order.TitleCompanies)):
        if split.Guid == split1.Guid:
            if policy.Type == TitleProductType.LoanPolicy:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'Split1Loan_Dollars_901045##')
            elif policy.Type == TitleProductType.OwnersPolicy:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'Split1Owners_Dollars_901045##')
            # BELOW FOR ENDORSEMENTS    
            elif policy.Type == TitleProductType.Endorsement and policy.Parent.Type == TitleProductType.OwnersPolicy:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'END_Split1Owners_Dollars_901045##')
            elif policy.Type == TitleProductType.Endorsement and policy.Parent.Type == TitleProductType.LoanPolicy:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'END_Split1Loan_Dollars_901045##')
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Splits Revisited - Endorsements

Post by BobRichards »

My response was only half a response. I didn't get a chance to test the script I release because I was between system installs. Here is the corrected (tested) version. The core part of this code is how it determines the type of object is passed to the function. I've started doing "what type of object am I" tests like the following because comparing strings is costly and I think it's more readable.

Code: Select all

# Is object a LoanPolicy object? Compare its type to any LP in our order.
if order.Title.LoanPolicies.Count and type(order.Title.LoanPolicies[0]) == type(object):
    ...
Below is the code for the Split Dollars section to get you started. You will have to add the Split Percent on your own. I broke it up into two functions because I thought it was easier to read (debug) - but there is nothing wrong with your original technique.

Code: Select all

from System import *
from SoftPro.ClientModel import *
from SoftPro.OrderTracking.Client import *
from SoftPro.OrderTracking.Client.Orders import *

def Split_Dollars_Value(args):

    # Exit if not attached to order there are no Title Companies.
    order = args.Context.Root
    if not args.Context.Parent or not order.TitleCompanies.Count:
        return
        
    # Determine who we belong to (LP, OP, or Endorsement) then set value.
    splitObject = args.Context.Parent.Parent
    
    if order.Title.LoanPolicies.Count and type(order.Title.LoanPolicies[0]) == type(splitObject):
        # Loan Policy
        Set_SplitDollarsValue(args, TitleProductType.LoanPolicy)
        return
        
    elif order.Title.OwnersPolicies.Count and type(order.Title.OwnersPolicies[0]) == type(splitObject):
        # Owners Policy
        Set_SplitDollarsValue(args, TitleProductType.OwnersPolicy)
        return
            
    elif order.Title.Endorsements.Count and type(order.Title.Endorsements[0]) == type(splitObject):
        # Endorsement - Determine if LP or OP (therefore filtering out commitments, etc.).
        if order.Title.LoanPolicies.Count and type(order.Title.LoanPolicies[0]) == type(splitObject.Parent):
            Set_SplitDollarsValue(args, TitleProductType.Endorsement, TitleProductType.LoanPolicy)
        elif order.Title.OwnersPolicies.Count and type(order.Title.OwnersPolicies[0]) == type(splitObject.Parent):
        	Set_SplitDollarsValue(args, TitleProductType.Endorsement, TitleProductType.OwnersPolicy)
    	return

    # We don't care about object object.
    return


# Set value on splits.
#	If splitType is LP/OP, ignore parentType
#	parentType: if splitType is endorsement, this gives the parent type.
def Set_SplitDollarsValue(args, splitType, parentType = None):
    splitIndex = None
    if args.Context.Parent.Split1.Guid == args.Context.Guid:
        splitIndex = 0
    elif args.Context.Parent.Split2.Guid == args.Context.Guid:
        splitIndex = 1
    else:
        # Must be a split we don't care about (split3, ...).  Exit.
        return

    propertyName = None
    if splitType == TitleProductType.LoanPolicy:
        propertyName = ['Split1Loan_Dollars_901045##', 'Split2Loan_Dollars_901045##'][splitIndex]
    elif splitType == TitleProductType.OwnersPolicy:
        propertyName = ['Split1Owners_Dollars_901045##', 'Split2Owners_Dollars_901045##'][splitIndex]
    elif splitType == TitleProductType.Endorsement and parentType == TitleProductType.OwnersPolicy:
        propertyName = ['END_Split1Owners_Dollars_901045##', 'END_Split2Owners_Dollars_901045##'][splitIndex]
    elif splitType == TitleProductType.Endorsement and parentType == TitleProductType.LoanPolicy:
        propertyName = ['END_Split1Loan_Dollars_901045##', 'END_Split2Loan_Dollars_901045##'][splitIndex]
    
    # If we found a property, set the split to it's value.
    if propertyName :
        args.Value = IOrderItem.GetProperty(args.Context.Root.TitleCompanies[0], propertyName)
Good luck and as always - don't ship it until you fully test it in the user's environment.
Bob Richards, Senior Software Developer, SoftPro
DanChapin
Posts: 16
Joined: Thu Sep 24, 2015 10:40 am

Re: Splits Revisited - Additional Title Charges

Post by DanChapin »

Hi Bob,

I knew this was going to come up very soon after you helped with the splits for Endorsements. I now need to set the splits for additional title charges. You had said in this chain previously "FYI, Additional Title Charges are like endorsements. In that case you have to query the ATC's Policy for the actual policy (if any)."

Of Course I am lost. I am assuming that the section below is where this will need to happen, I don't, however, know the syntax.

Code: Select all

            # BELOW FOR ENDORSEMENTS    
            elif policy.Type == TitleProductType.LoanPolicy.Endorsement:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'END_Split1Loan_Percent_901045##')
            elif policy.Type == TitleProductType.OwnersPolicy.Endorsement:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'END_Split1Owners_Percent_901045##')
Would it be something like:

Code: Select all

  		# BELOW FOR ADDITIONAL TITLE CHARGES 
            elif policy.Type == TitleProductType.LoanPolicy.AdditionalTitleCharge:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'ATC_Split1Loan_Percent_901045##')
            elif policy.Type == TitleProductType.OwnersPolicy.AdditionalTitleCharge:
                args.Value = IOrderItem.GetProperty(Order.TitleCompanies[0], 'ATC_Split1Owners_Percent_901045##')
 
So Aside from not knowing if the syntax above is correct, I have the additional problem of ONLY wanting it to set the split for Charges with a description of "Commitment Update Fee".......

Can you direct please?
Dan
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: Splits Revisited - Endorsements

Post by BobRichards »

I believe this should do the trick. It is different from endorsements in that I am asking the ATC what policy it is attached to directly (it has this property and endorsements don't). I will just show the two new sections and not the entire COR (exercise left to reader :-)).

Code: Select all

elif order.Title.Endorsements.Count and type(order.Title.Endorsements[0]) == type(splitObject):
    # Endorsement - Determine if LP or OP (therefore filtering out commitments, etc.).
    ...

elif order.Title.AdditionalCharges.Count and type(order.Title.AdditionalCharges[0]) == type(splitObject):
    # ATC - Determine if LP or OP (therefore filtering out commitments and non-specified policy).
    if splitObject.Policy is not None and splitObject.Policy.Type == TitleProductType.LoanPolicy:
        Set_SplitDollarsValue(args, TitleProductType.AdditionalTitleCharge, TitleProductType.LoanPolicy)
    elif splitObject.Policy is not None and splitObject.Policy.Type == TitleProductType.OwnersPolicy:
        Set_SplitDollarsValue(args, TitleProductType.AdditionalTitleCharge, TitleProductType.OwnersPolicy)
    return
And the new code in function "Set_SplitDollarsValue()":

Code: Select all

propertyName = None
if splitType == TitleProductType.LoanPolicy:
    ....
elif splitType == TitleProductType.AdditionalTitleCharge and parentType == TitleProductType.OwnersPolicy:
    propertyName = ['ATC_Split1Owners_Dollars_901045##', 'ATC_Split2Owners_Dollars_901045##'][splitIndex]
elif splitType == TitleProductType.AdditionalTitleCharge and parentType == TitleProductType.LoanPolicy:
    propertyName = ['ATC_Split1Loan_Dollars_901045##', 'ATC_Split2Loan_Dollars_901045##'][splitIndex]
Bob Richards, Senior Software Developer, SoftPro
Post Reply