More FUN with Splits

Discussions related to writing and managing custom business rules.

Moderator: Phil Barton

Post Reply
DanChapin
Posts: 16
Joined: Thu Sep 24, 2015 10:40 am

More FUN with Splits

Post by DanChapin »

Any ideas how I can return the total of OwnersPolicy split 1 to split 5. I don’t want the dollar amount I want the total percent. So if split 1 is 10% and 2 is 20% and 3 is 18% and 4 and 5 are empty, I want it to return 48%........
I have the following code which gets the percentage entered into each owners policy split field, BUT how do I get the TOTAL?

Code: Select all

def Split_Percent_Validate(args):
	split = args.Context
	policy = split.Parent.Parent
	Order = args.Context.Root
	SplitPercent = 0
	
	if Order.IsTemplate:
		return
		
	if str(policy).StartsWith('Own'):
			if policy.Type == TitleProductType.OwnersPolicy:
				SplitPercent = split.Percent		

				args.RaiseInformation (str(SplitPercent))
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: More FUN with Splits

Post by BobRichards »

First, a question. Are you going to validate that in each split field that the value after "% of" (the split basis) is set to "Final Premium to Split"? Otherwise the summation of percentages won't tell you the whole story. In the default order, the last four values are set to "% of Balance after 1st Split" so you just can't add the value and derive much meaningful information. You need to take into consideration this split basis field.

In your proposed example, the percent summation is 48%, but the amount of premium paid is approximately 45%.

If this is what you actually want to do, you'll have to manually get each split and sum them (.SplitCalculation.Split1.Percent + .SplitCalculation.Split2.Percent + .SplitCalculation.Split3.Percent + .SplitCalculation.Split4.Percent + .SplitCalculation.Split5.Percent).
Bob Richards, Senior Software Developer, SoftPro
DanChapin
Posts: 16
Joined: Thu Sep 24, 2015 10:40 am

Re: More FUN with Splits

Post by DanChapin »

For anyone who is following along, here is what I came up with.... Thanks to Dan Van Fleet for the help.

Code: Select all

def Split_Percent_Validate(args):
      split = args.Context
      split1 = split.Parent.Split1
      policy = split.Parent.Parent
      Order = args.Context.Root
      SplitPercent = 0
      t = split1.Parent
      if Order.IsTemplate:
            return
            
      if str(policy).StartsWith('Own'):
            if split.Guid == split1.Guid:
                  #if policy.Type == TitleProductType.OwnersPolicy:
                        
                        SplitPercent += t.Split1.Percent
                        SplitPercent += t.Split2.Percent
                        SplitPercent += t.Split3.Percent
                        SplitPercent += t.Split4.Percent
                        SplitPercent += t.Split5.Percent  
                        if (SplitPercent > 1):
                        
                              args.RaiseInformation ('Total Owners Policy split exceeds 100%')
Post Reply