26 Limiting Event Adjustment Percentage Entered by CSRs

This chapter describes how to limit the event adjustment percentage entered by customer service representatives (CSRs) using the Oracle Communications Billing Care SDK.

About Adjustments

Typically, CSRs perform the adjustments to satisfy an unhappy customer or correct a problem. For example, a CSR might give an adjustment when the entire monthly fee is charged for a service that was unavailable for a few days. You customize Billing Care to limit the percentage of event adjustment allowed for a CSR by using the SDK and Oracle Entitlements Server (OES) policies.

Limiting Event Adjustments Entered by CSRs

To limit the event adjustment percentage entered by a CSR:

  1. Add an obligation for the OES authorization policy; for example, Maximum Adjustment Amount Percentage. For more information on adding obligations, see Oracle Fusion Middleware Administrator's Guide for Oracle Entitlements Server.

  2. Update the CustomExtendAdjustmentModule.java class file to override the default event adjustment flow. See "Updating CustomExtendAdjustmentModule.java Class" for more information.

  3. Create a custom adjustment worker class to add custom logic. See "Creating CustomAdjustmentWorker.java Class" for more information.

  4. Create or update the customized_en.xlf file to add an error code and message for limiting adjustments. See "Creating a customized_en.xlf File Entry for the Error Message" for more information.

Updating CustomExtendAdjustmentModule.java Class

Update the CustomExtendAdjustmentModule.java class to override the adjustEvent ( ) method.

To update the CustomExtendAdjustmentModule.java Class:

  1. Open the CustomExtendAdjustmentModule.java file in myproject/projectname/src/java/com/rest/sdk.

  2. Override the adjustEvent ( ) method as shown in this example:

    @Override 
    public void adjustEvent(AdjustmentEvent adjustEvent) { 
    CustomAdjustmentWorker worker = new CustomAdjustmentWorker(); 
    boolean isAllowed; 
    
    isAllowed = worker.isAllowedForAdjustment(adjustEvent); 
    if (isAllowed) { 
    super.adjustEvent(adjustEvent); 
    } else { 
    ExceptionHelper.buildErrorInfo(70001, 
    "More than allowed Percentage", Response.Status.BAD_REQUEST); 
    }
    }
    
  3. Save the file in your NetBeans IDE project.

Creating CustomAdjustmentWorker.java Class

Create a custom template worker class containing logic to calculate the percentage of adjustment allowed and limit the adjustment amount entered by a CSR in Billing Care if it is more than the percentage allowed.

To create the CustomAdjustmentWorker.java Class:

  1. Create the CustomAdjustmentWorker.java file in myproject/projectname/src/java/com/rest/sdk.

  2. Extend AdjustmentWorker as shown in this example:

    public class CustomAdjustmentWorker extends AdjustmentWorker {
     
    /* 
     *Check if the amount is more than allowed percentage 
     */ 
    
    public boolean isAllowedForAdjustment(AdjustmentEvent adjustEvent){ 
    boolean isAllowed = true; 
    
    //Get total amount available for adjustment from BRM 
    BigDecimal availableAmountForAdjustment = 
    getAvailableAmountForEventAdjustment(adjustEvent); 
    
    //String configured as obligation in OES Admin 
    String obligationString = "Maximum Adjustment Amount Percentage"; 
    Subject subject = Security.getCurrentSubject(); 
    String action = "Make"; 
    Map<String, String> env = new HashMap<>(0); 
    Map<String, String> obligationNameValueMap = new HashMap<>(); 
    Integer obligationPer = 0; 
    
    //Getting obligation allowed percentage value from OES 
    String resourceString = "BillingCare" + "/" + 
    "AdjustmentCurrencyResourceType" + "/" + "AdjustmentResource"; 
    try { 
    PepResponse response = 
    PepRequestFactoryImpl.getPepRequestFactory().newPepRequest(subject, action, resourceString, env).decide(); 
    Map<String, Obligation> obligations = response.getObligations(); 
    for (String name : obligations.keySet()) { 
    obligationNameValueMap = obligations.get(name).getStringValues(); 
    obligationPer = 
    Integer.parseInt(obligationNameValueMap.get(obligationString)); break; 
    } 
    
    } catch (PepException ex) { 
    Logger.getLogger(AdjustmentWorker.class.getName()).log(Level.SEVERE, null, ex); 
    } 
    
    //Calculate the allowed amount using obligationPer retrieved from OES and 
    availableAmountForAdjustment retrieved from BRM 
    double allowedAmountInDouble = (obligationPer * 
    availableAmountForAdjustment.doubleValue()) / 100; 
    BigDecimal allowedAmount = new BigDecimal(allowedAmountInDouble); 
             
    //If amount is greater than allowed amount return false 
    //Note: Please handle the decimal case as per the requirement if only first 2 decimal needed etc.. 
    
    if(adjustBill.getAmount().compareTo(allowedAmount)==1) 
    { 
    isAllowed=false; 
    } 
    
    return isAllowed; 
    
    } 
    

    Note:

    The JAR files required for this customization are available in the SDK_home/BillingCare_SDK/libs directory, where SDK_home is the directory where you installed the SDK.
  3. Save the file in your NetBeans IDE project.

Creating a customized_en.xlf File Entry for the Error Message

You must provide a localized English entry for the new adjustment error code and message in the customized_en.xlf file to provide a translatable text string in Billing Care. For more information on the customized_en.xlf file and how to add a new entry, see "Customizing Billing Care Labels".

This example shows a sample entry for the error code and message to add in the customized_en.xlf file:

<?xml version="1.0" encoding="utf-8" ?> 
<xliff version="1.0"> 
    <file original="test_en.js" source-language="EN-US"   
          target-language="EN-US" datatype="JavaScript"> 
        <header/> 
        <body> 
            <group id="errors" restype="errors"> 
                <trans-unit id="70001" translate="yes"> 
                    <source>More than allowed Percentage.</source> 
                    <target>More than allowed Percentage.</target> 
                </trans-unit> 
            </group> 
        </body> 
    </file> 
</xliff>

Note:

For custom error codes, the series must start from 70000; for example, 70001,70002, and so on.