This chapter provides an overview of customizing Oracle Communications Billing Care to restrict the validity or end date set by the customer service representatives (CSRs) while purchasing additional products or services.
Typically, CSRs set the validity or end date of a product or service in a bundle (/deal object) during purchase. For additional purchases, you can customize Billing Care to restrict the validity or end date set by the CSR based on the CSR's role by using the OES policies and the Billing Care SDK.
For example, for an additional discount purchased from a bundle, you can allow a CSR with super user role to set an end date up to a maximum of 12 months and a CSR with basic role to set an end date only up to a maximum of 6 months.
You can customize the Purchase Catalogue screen using OES policies to restrict the end date set by CSRs for additional purchases.
To restrict bundle validity:
Define a new ResourceType and Resource in the OES Server for restricting bundle validity. For example, DealResourceType, DealResource.
Define purchase as the corresponding action for the ResourceType in the OES Server.
Associate the new resource that you created to a CSR who has permission to purchase products or services.
Add the new ResourceType to the CustomConfigurations.xml file. For example:
<keyvals> <key>authorizationResourceTypes</key> <value>DealResourceType</value> <desc>Add comma separated OES Resource Types(values) for authorization. Also these resource types should be defined in OES. Please note that the key should not be changed here. </desc> </keyvals>
To set the validity allowed for a CSR, add an obligation with a string (for example, maximum validity end month) for a policy using OES and set a numeric value to the string (for example, 6).
Create a custom REST resource for validating the end date entered in the Purchase Catalogue screen. See "Creating CustomAccountResource.java Class" for more information.
Create a custom view model to override the default additional purchase logic with your customization. See"Creating a Custom Purchase View Model" for more information.
Create a customRegistry.js file to configure Billing Care to use the custom view model that you created. See "Configuring the Custom Purchase View Model in the Registry" for more information.
Deploy your customizations using one of the methods described in "Using an Exploded Archive during Customization" or "Packaging and Deploying Customizations".
Verify your changes in Billing Care by doing the following:
Log into Billing Care as a CSR who has the permission to purchase products or services and obligation to validate end date during purchase.
Purchase an additional charge or discount offer. For more information, see the Billing Care Online Help.
In the Configure screen, enter a end date for the purchased offer.
If the end date exceeds the end date specified in the obligation associated with the CSR, an error is displayed. If it matches or less than the end date in the obligation, CSR is allowed to configure the offer.
Create a custom resource Java class to get the list of all customized charge offers and discount offers in Billing Care and validate their end dates.
To create the customAccountResource.java class:
Create the CustomAccountResource.java file in myproject/projectname/src/java/com/oracle/communications/brm/cc/ws/account, where myproject is your NetBeans IDE Billing Care customizations project and projectname is the name of your custom project.
Add the following code in the CustomAccountResource.java file using a text editor:
//This custom REST validates the deal end month with the obligation and then calls the OOTB REST resource. @Path("customaccounts") public class CustomAccountResource { @Context HttpServletRequest servletRequest; @Path("{id}/custombundle") @POST @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public void purchaseCustomizedBundle(@PathParam("id") String id, CustomizedBundleForPurchase custbundle) throws JSONException, IOException { /* * Get the list of all CustomizedChargeOffers using getCustomizedChargeOffers() method of CustomizedBundleForPurchase class. */ List <CustomizedChargeOffers> custoffer = custbundle.getCustomizedChargeOffers(); List <CustomizedDiscountOffers> custDistOffer = custbundle.getCustomizedDiscountOffers(); /* * Iterate through each charge offer and get the purchaseEnd months and validate the same against OES obligation */ for (CustomizedChargeOffers i : custoffer) { purchaseEnd=i.getPurchaseEnd(); months=purchaseEnd.getUnitSettings().getOffset(); UIRequestValue maxValidityEndMonthLimit = new UIRequestValue("Maximum validity end month", new BigDecimal(months), ConstraintOperator.GREATER_THAN, new EnforcementError(40002,"Maximum validity end month exceeded")); //Checks if user is not super csr and UI value is greater than OES obligation value and throws error "Maximum validity end month exceeded" if (!EnforcementUtil.isResourceGranted(servletRequest, subject, "BillingCare", EnforcementConstants.SUPERUSER_RESOURCE)) { EnforcementUtil.checkAccess(subject, "BillingCare", "Purchase", "DealResourceType","DealResource", error, maxValidityEndMonthLimit); } } Repeat the above validations for all the discount offers as well by iterating through custDistOffer. /* *After validating maximum validity end month criteria invoke out of the box code to perform purchase.In below steps *we have used jersey clients to achieve the same. */ 1. Create a new Jersey Client 2. Create a webresource passing the baseURI ( host:port/bc/webresources/v1.0/accounts/id/bundle ). 3. Convert custbundle java object to json object. String scheme = servletRequest.getScheme(); // http or https String serverName = servletRequest.getServerName(); // hostname.com int serverPort = servletRequest.getServerPort(); // port String BASE_URI = scheme + " + serverName + ":" + serverPort + "/bc/webresources/v1.0/accounts/"; Client client = Client.create(); ObjectMapper mapper = new ObjectMapper(); String jsonInString = mapper.writeValueAsString(custbundle); JSONObject object = new JSONObject(jsonInString); javax.servlet.http.Cookie[] cookies=servletRequest.getCookies(); WebResource webResource2 = client.resource(BASE_URI).path(id).path("bundle"); WebResource.Builder webresourceBuilder = webResource2.accept(MediaType.APPLICATION_JSON); Cookie cookieObject =null; for(javax.servlet.http.Cookie cookie: cookies) { if(cookie.getName().contains("JSESSIONID")) { cookieObject = new Cookie(cookie.getName(),cookie.getValue()); webresourceBuilder.cookie(cookieObject); } } webresourceBuilder.post(ClientResponse.class, object); }}
Save the file in your NetBeans IDE project.
Billing Care uses view model to define the display of the screens in Billing Care. You must create or update the custom view model, CustomPurcahseViewModel, and add the details containing the logic to validate the end date for offers and allow purchase.
See "About View Models" for more information about Billing Care view models.
To create a custom purchase view model:
Create or update the customPurchaseViewModel.js file in myproject/web/custom/viewmodels directory.
Add the following code in the customPurchaseViewModel.js file using a text editor:
define(['knockout', 'jquery', 'underscore', Registry.accountCreation.wizardBase, 'viewmodels/purchase/PurchaseViewModel', Registry.purchase.wizardView, 'viewmodels/purchase/PurchaseCatalogue' ], function (ko, $, _, WizardBaseViewModel, PurchaseViewModel, wizardTempl, PurchaseCatalogue) { CustomPurchaseViewModel.prototype = new WizardBaseViewModel(); function CustomPurchaseViewModel(title, content, messages) { WizardBaseViewModel.apply(this, arguments); PurchaseViewModel.apply(this, arguments); var self = this; self.sharedData = {}; self.purchaseCatalogue = new PurchaseCatalogue(); self.purchaseBundle = function (stepObj) { var id = self.sharedData.selectedServiceId || globalAppContext.currentAccountViewModel().account().id(); var urlToFetch = baseURL + "/customaccounts/" + id + "/custombundle"; var data = ko.toJSON(self.purchaseCatalogue.bundlePurchaseData); util.showBusyCursor(); var ajaxDef = $.ajax({ type: "POST", url: urlToFetch, data: data, contentType: "application/json; charset=utf-8", dataType: "json", processData: false }); ajaxDef.done(function (completeResponse) { self.updateStatus(stepObj, 'confirmation'); EventNotifier.assetsUpdated.dispatch("all"); EventNotifier.billUnitsUpdated.dispatch(); self.isInProgress(false); util.resetCursor(); self.close(); }); ajaxDef.fail(function (errorThrown) { alert(util.getLocalizedValue(purchasePackage, "UNABLE_TO_PURCHASE_BUNDLE")); self.updateStatus(stepObj, 'error'); self.isInProgress(false); util.resetCursor(); }); return ajaxDef; }; } return CustomPurchaseViewModel; });
Save the file in your NetBeans IDE project.
After creating the required custom view model, create a custom purchase view model entry in the customRegistry.js file. Billing Care uses the custom purchase view model instead of the default view model during additional product purchase and renders the Purchase Add on Deal Confirmation screen containing your customization.
To create the custom purchase view model entry in the registry:
Create a customRegistry.js file in myproject/web/custom/ directory.
Define the custom event adjustment view model entry in this file. For example:
purchaseConfiguration: { viewmodel: 'custom/viewModels/purchase/customPurchaseViewModel.js' }
Save the file in your NetBeans IDE project.