I'm trying to create a rule that will throw up an error message, if the payoff request good through date is before the settlement date. What am I doing wrong? Thanks!
def WarnIfPayoffExpiresBeforeSettlementDate(args):
order = args.Context.Root
lenders = order.PayoffLenders
for l in lenders:
#args.Value = order.SettlementDate.Date()
expDate = IOrderItem.GetProperty(l, 'PayoffRequestPayoffGoodThroughDate_SP#')
if str(expDate) != '(None)':
if order.SettlementDate > expDate:
args.RaiseError("Payoff will expire prior to closing!")
#rename rule
WarnIfPayoffExpiresBeforeSettlementDate.__name__ = 'PayoffLender_PayoffRequestPayoffGoodThroughDate_SP#_Validate'
1.) When nothing is entered into the Payoff-Good-Through field, my custom error message is displayed. This is not the behavior I want. I don't want to see the error message unless a date is entered into the field AND that date falls before the settlement date.
2.) When a date is entered into the field, I see "Error encountered during rule execution. expected Date, got DateTime." I guess the settlement date field is a DateTime, and the Payoff Good Through field is just a date field, and it doesn't like comparing the two as-is.
I fixed the Date/DateTime type issue by explicitly converting them to the same type in the inequality comparison. You can ask a Date for a DateTime object by using the Convert.ToDateTime().
The second item I changed is a performance enhancement showing the Pythonic way to do things. The preferred way to test against None is to say "if x is None" or "if x is not None". It is much faster since you don't have to convert "x" to a string then do a string comparison and reads like English when degbugging your code.
from System import *
from SoftPro.ClientModel import *
from SoftPro.OrderTracking.Client import *
from SoftPro.OrderTracking.Client.Orders import *
def WarnIfPayoffExpiresBeforeSettlementDate(args):
order = args.Context.Root
lenders = order.PayoffLenders
for l in lenders:
expDate = IOrderItem.GetProperty(l, 'PayoffRequestPayoffGoodThroughDate_SP#')
if expDate is not None:
if order.SettlementDate > Convert.ToDateTime(expDate):
args.RaiseError("Payoff will expire prior to closing!")
#rename rule
WarnIfPayoffExpiresBeforeSettlementDate.__name__ = 'PayoffLender_PayoffRequestPayoffGoodThroughDate_SP#_Validate'
When we built this originally, I used a custom field for the payoff expiration date. I'd like to modify it, so that it references any of the canned payoff expiration dates used in the settlement statement.
My issue is: I'm having a tough time referencing those fields. In the HUD, the field is {{Order.HUDs.Section500.Charges.Calculation.ExpireOnDate}}. In the CD, I don't know the name of the field. The Field Code Browser doesn't tell me. What context and field should I use for my validation rule?
We do have a neat trick to help you get more information about any field. I created a CDF order, went to a section N charge and put my cursor in the "Payoff expires on" field box. The magic occurs when you press Alt+F6.
2020-10-22_15-33-44.png (22.74 KiB) Viewed 8773 times
This triggers a popup where you see all the information that would be in the bottom panel of the Field Code Browser. Your custom order rule would be:
def Payoff_ExpireOnDate_Validate(args):
order = args.Context.Root
disbDate = order.DisbursementDate
if (disbDate is not None) and (args.Value is not None):
if disbDate >= args.Value:
args.RaiseWarning('The payoff is set to expire on or before disbursement.')
So there were two problems with the COR. One was mine and the other was yours.
The original name of the function shows up as underlined in blue in SoftPro Developer Studio - this means that the name meets the simple criteria to be a COR but Select can't match it up to available contexts and properties. The method I gave you (Alt+F6) typically works but here it doesn't - and frankly there is no easy way for you to determine what it is in this case. But believe me - this is one of the rare exceptions!
The other mistake was that the current value for the context expiration date is not "args.Value" but "args.Context.ExpireOnDate".
from System import *
from SoftPro.ClientModel import *
from SoftPro.OrderTracking.Client import *
from SoftPro.OrderTracking.Client.Orders import *
def CDFPayoffChargeCalculation_ExpireOnDate_Validate(args):
order = args.Context.Root
disbDate = order.DisbursementDate
expireOnDate = args.Context.ExpireOnDate
if (disbDate is not None) and (expireOnDate is not None):
if disbDate >= expireOnDate:
args.RaiseWarning('The payoff is set to expire on or before disbursement.')