Is there a way to retrieve the Policy Type for those Invoice Lines that are generated by the Title Insurance Premium Screen?
I am trying to create a COR that overrides the Owner's Policy Description, on the Invoice, when the Order's Product Type is "TSG" or "LITGNT" and the Invoice Line was created specifically by the Owner's Policy.
The following code is currently looking at the Invoice Line Description to make this determination and does change the code the 1st time it sees the Description contains "Owner's Policy", but it fails if the Product Type is switched between TSG and LITGNT because the Description no longer contains "Owner's Policy" and I do not have a field that will always identify the line that is tied to the Owner's Policy. If I could access the actual Policy Type associated with the Line Items, then I would be able to make an accurate determination regardless of what the description may currently contain.
def InvoiceLine_Description_Value(args):
# Exit if processing template.
if args.Context.Root.IsTemplate:
args.RunDefaultRule()
return
# Exit if not fully initialized
if (args.Context.Parent is None):
args.RunDefaultRule()
return
# Exit if the Product Type Code is Not TSG or LITGNT
listOfProductCds = ['TSG', 'LITGNT']
if (args.Context.Root.ProductType.Code.upper() not in listOfProductCds):
args.RunDefaultRule()
return
# If Assigned, get the Description
if (hasattr(args.Context,'Description')):
invLineDescription = args.Context.Description
else: invLineDescription = ''
# Exit if the Description does not contain Owner's Policy (*** This should be checking the Policy Type = OwnersPolicy)
if (invLineDescription is None or invLineDescription[0:14].upper() != "OWNER'S POLICY"):
#args.RunDefaultRule() #Only run this if I am able to check the actual Policy Type associated with the Line Item
return
if args.Context.Root.ProductType.Code.upper() == 'TSG': # Override the description for TSG
args.Value = str(invLineDescription.Replace("Owner's Policy","Trustee's Sale Guaranty"))
return
elif args.Context.Root.ProductType.Code.upper() == 'LITGNT': # Override the description for LITGNT
args.Value = str('Litigation Guarantee Conversion Fee')
return
else: # No Change
return
After reaching out to other sources, at SoftPro, I was finally able to put together something that works even if it is not as clean as it could be. A big thanks to Brandy Dutil for providing the details I needed to determine the source of the invoice.
from System import *
from SoftPro.ClientModel import *
from SoftPro.OrderTracking.Client import *
from SoftPro.OrderTracking.Client.Orders import *
##############################################################################
#
# COR Order: zCOR-0-Production
# Rule file name: Rest Invoice Description
#
# Override the Invoice Line Description when Produt Type is TSG or LITGNT and the Invoice Line Source is OwnersPolicy.
# Replace "Owner's Policy" with "Trustee's Sale Guarantee", "Littigation Guarantee" or "Binder Policy" based on the Product Type and Lookup Code.
# Version
# 1: Original 11/18/2019 Brian Hinote with assistance from Brandy Dutil(SP)
#
##############################################################################
def InvoiceLine_Description_Value(args):
# Exit if processing template.
if args.Context.Root.IsTemplate:
args.RunDefaultRule()
return
line = args.Context
invoice = args.Context.Parent
order = args.Context.Root
# Exit if not fully initialized
if not order or not invoice or not line:
args.RunDefaultRule()
return
# Exit if Product Code is None
if order.ProductType.Code is None:
args.RunDefaultRule()
return
# Exit if the Product Type Code is Not TSG or LITGNT
listOfProductCds = ['TSG', 'LITGNT']
productType = order.ProductType.Code.upper()
if (productType not in listOfProductCds):
args.RunDefaultRule()
return
# Get the Source of the line item
lineSrc = line.GetSource()
# Exist if No Source as I am only interested in lines that are created from the OwnersPolicy
if (lineSrc is None):
args.RunDefaultRule()
return
# Get the Source Name
lineSrcName = lineSrc.GetType().Name
ChargeSources = ['OwnersPolicy'] #['LoanPolicy', 'OwnersPolicy','Endorsement', 'AdditionalTitleCharge']
# Exit if sourse is not in list
if lineSrcName not in ChargeSources:
args.RunDefaultRule()
return
# If Assigned, get the Description
#if (hasattr(args.Context,'Description')):
# invLineDescription = args.Context.Description
#else: invLineDescription = ''
# Because there is nothing preventing a user from switching between TSG and LITGNT
# I am running the Default Rules to set the Description to its Default before proceeding.
# I would prefer to only reset it if it needs to be changed, but do not currently know how to do this.
args.RunDefaultRule()
invLineDescription = line.Description
if (invLineDescription is None):
return
# Exit if the Description does not contain Owner's Policy
if (invLineDescription is None or invLineDescription[0:14].upper() != "OWNER'S POLICY"):
#Do not Run Default Rule as the Owner's Policy Description has alredy been changed.
return
# Get the Version Lookup Code from the Source
lineSrcVersionLookupCode = 'NotSet'
if (hasattr(lineSrc,'VersionLookupCode')):
lineSrcVersionLookupCodeTest = lineSrc.VersionLookupCode
if lineSrcVersionLookupCodeTest is None:
lineSrcVersionLookupCode = 'NotSet' # lineSrcVersionLookupCode = lineSrc.VersionLookupCode.upper()
else: lineSrcVersionLookupCode = lineSrc.VersionLookupCode.upper()
else: lineSrcVersionLookupCode = 'NotSet'
# Replace “Owner’s Policy” with “Trustee’s Sale Guarantee” for the TSG Products
# and “Litigation Guarantee Conversion Fee” for the LITGNT Products
if (lineSrcVersionLookupCode == 'BINDER'): # Override the description for a Binder
args.Value = str(invLineDescription.Replace("Owner's Policy","Binder Policy"))
return
elif (productType == 'TSG'): # Override the description for TSG
args.Value = str(invLineDescription.Replace("Owner's Policy","Trustee's Sale Guaranty"))
return
elif (productType == 'LITGNT'): # Override the description for LITGNT
args.Value = str(invLineDescription.Replace("Owner's Policy","Litigation Guarantee")) #args.Value = str('Litigation Guarantee Conversion Fee')
return
else: # No Change
return