Extend Credit Check
Use an order management extension to modify credit check.
Skip Credit Check for Order Revisions
- If the sales order is a change order, and if Credit Management isn't enabled, then set PreCreditCheckedFlag to true.
Setting PreCreditCheckedFlag to true instructs Order Management to skip credit check.
Here's your extension.
import oracle.apps.scm.doo.common.extensions.ValidationException;
Boolean isCCMgmtEnabled = false;
BigDecimal refHeaderId = header.getAttribute("ReferenceHeaderId");
if(refHeaderId != null)
{
def lookupVO =context.getViewObject("oracle.apps.financials.assets.shared.publicView.LookupPVO");
def vc = lookupVO.createViewCriteria();
def vcrow = vc.createViewCriteriaRow();
vcrow.setAttribute("LookupType", 'AR_FEATURES');//ACCOUNT_TYPE AR_FEATURES
vcrow.setAttribute("EnabledFlag", 'Y');
vcrow.setAttribute("LookupCode", 'AR_CREDIT_MGMT');
def rowset = lookupVO.findByViewCriteria(vc, -1);
rowset.reset();
if(rowset.hasNext()){
isCCMgmtEnabled = true;
}
if(!isCCMgmtEnabled)
header.setAttribute("PreCreditCheckedFlag", "Y");
}
Skip Credit Check When Lines Are On Hold
Skip credit check when an order line in a change order is on credit check hold. For example:
- If the sales order is a change order, and if no order lines in the original order are on credit check hold, and if Credit Management isn't enabled, then set PreCreditCheckedFlag to true.
Here's your extension.
import oracle.apps.scm.doo.common.extensions.ValidationException;
Boolean isCCMgmtEnabled = false;
BigDecimal refHeaderId = header.getAttribute("ReferenceHeaderId");
Boolean ccHoldFoundOnOriginalLines = false;
if(refHeaderId != null)
{
def holdInstanceVO =context.getViewObject("oracle.apps.scm.doo.publicView.analytics.HoldInstancePVO");
def hodlInstanceVc = holdInstanceVO.createViewCriteria();
def holdInstanceVrow = hodlInstanceVc.createViewCriteriaRow();
holdInstanceVrow.setAttribute("HeaderHeaderId", refHeaderId);
holdInstanceVrow.setAttribute("FulfillLineOnHold", 'Y');
def holdInstanceRowset = holdInstanceVO.findByViewCriteria(hodlInstanceVc, -1);
holdInstanceRowset.reset();
while(holdInstanceRowset.hasNext())
{
def holdInstance = holdInstanceRowset.next();
def holdDefs = holdInstance.getAttribute("HoldDefinition");
String holdCode = holdDefs.getAttribute("HoldHoldCode");
if("DOO_CREDIT_CHECK".equalsIgnoreCase(holdCode))
{
ccHoldFoundOnOriginalLines = true;
break;
}
}
if(!ccHoldFoundOnOriginalLines)
{
def lookupVO =context.getViewObject("oracle.apps.financials.assets.shared.publicView.LookupPVO");
def vc = lookupVO.createViewCriteria();
def vcrow = vc.createViewCriteriaRow();
vcrow.setAttribute("LookupType", 'AR_FEATURES');//ACCOUNT_TYPE AR_FEATURES
vcrow.setAttribute("EnabledFlag", 'Y');
vcrow.setAttribute("LookupCode", 'AR_CREDIT_MGMT');
def rowset = lookupVO.findByViewCriteria(vc, -1);
rowset.reset();
if(rowset.hasNext())
{
isCCMgmtEnabled = true;
}
if(!isCCMgmtEnabled)
header.setAttribute("PreCreditCheckedFlag", "Y");
}
}
Manage the Authorization Expiration Date
If you set the PreCreditCheckedFlag to Y in an order management extension to skip
credit check, then you must also set the CreditCheckAuthorizationExpiryDate
attribute on the fulfillment line to null
. A null value means the
authorization never expires. If you don't do this, and if you revise the sales
order, then Order Management might run credit check again because the authorization
expired.
Here's how:
if ("CC".equals(header.getAttribute("CustomerPONumber"))) {
if ("Y".equals(header.getAttribute("PreCreditCheckedFlag"))) {
def lines = header.getAttribute("Lines");
while (lines.hasNext()) {
def line = lines.next();
def creditAuthExpDate = line.getAttribute("CreditCheckAuthorizationExpiryDate");
if (creditAuthExpDate != null) {
java.sql.Date currentDate = new java.sql.Date((new Date()).getTime());
java.sql.Date creditAuthExpSqlDate = new java.sql.Date((creditAuthExpDate).getTime());
if (creditAuthExpSqlDate < currentDate) {
//line.setAttribute("CreditCheckAuthorizationExpiryDate", null);
line.setAttribute("CreditCheckAuthorizationExpiryDate", currentDate);
}
}
}
}
}
As an alternative, you can set the Expiration Offset Days attribute on the customer account to a large value so the authorization doesn't expire while you're revising the sales order. For details, see How You Set Up a Customer Profile for Credit Checks.