22 Separating Event Adjustment Amount and Percentage Fields

This chapter describes how to customize Oracle Communications Billing Care Event Adjustment dialog box to separate the event adjustment amount and percentage fields.

About Event Adjustments using Amount and Percentage

In Billing Care, you can use either the amount or percentage field in the Event Adjustment dialog box to adjust the amount and tax.

You can separate the amount and percentage fields in the Event Adjustment dialog box, and make them independent of each other by using the Billing Care SDK. When you enter a value in one field, for example amount, the other field percentage gets disabled, and vice versa.

For more information, see "Separating Amount and Percentage Fields".

Separating Amount and Percentage Fields

This section provides a high-level overview of the process on how to customize Billing Care to separate the amount and percentage fields in the Event Adjustment dialog box.

To separate amount and percentage fields:

  1. Create custom view model to define the display of the Event Adjustment dialog box. See "Creating Custom View Model to Separate Amount and Percentage Fields" for more information.

  2. Create a customRegistry.js file configuring Billing Care to use the custom view model created in step 1. See "Configuring the Custom View Model in the Registry" for more information.

  3. Package and deploy your customization to your Billing Care domain using one of the methods described in "Using an Exploded Archive during Customization" or "Packaging and Deploying Customizations".

Creating Custom View Model to Separate Amount and Percentage Fields

Billing Care uses the view model to define the display of the Event Adjustment dialog box. You must create the custom view model, CustomEventAdjustmentViewModel, containing overrides for the default Event Adjustment dialog box. See "About View Models" for more information about Billing Care view models.

To create custom view model to separate amount and percentage fields:

  1. Create the CustomEventAdjustmentViewModel.js file in the myproject/web/custom/viewmodels/ARActions/adjustments directory, where myproject is the folder containing your NetBeans IDE project.

  2. Open the CustomEventAdjustmentViewModel.js file using a text editor and add the code as shown in Example 22-1.

    Example 22-1 Sample code to separate amount and percentage fields in the Event Adjustment dialog box

    define(['jquery', 'knockout',
        'viewmodels/ARActions/adjustments/EventAdjustmentViewModel'],
            function ($, ko, EventAdjustmentViewModel) {
     
                function CustomEventAdjustmentViewModel() {
                    EventAdjustmentViewModel.apply(this, arguments);
                    self = this;
                    self.percentValue = 0;
                    self.amountValue = 0;
    self.adjustmentPercentage = ko.observable(0).extend({notify:
    "always"}).extend({numeric: 2});
                    self.amountStateController = ko.computed(function () {
                        if ((Number(self.adjustmentAmount()) === 0) &&
                                (Number(self.adjustmentPercentage()) === 0)) {
                            self.enablePercentage(true);
                            self.enableAmount(true);
                        } else if (Number(self.adjustmentPercentage()) === 0) {
                            self.enablePercentage(false);
                            self.enableAmount(true);
                        } else {
                            self.enablePercentage(true);
                            self.enableAmount(false);
                        }
                    });
                }
                CustomEventAdjustmentViewModel.prototype = new
    EventAdjustmentViewModel();
                return  CustomEventAdjustmentViewModel;
            });
    
  3. Save the file in your NetBeans IDE project.

Configuring the Custom View Model in the Registry

Create a custom entry in your customRegistry.js file. Billing Care uses the custom model instead of the default entry and renders the Event Adjustment dialog box containing your custom fields. See "About the Registry File" for more information.

To configure the custom view model in the registry:

  1. Create a customRegistry.js file in myproject/web/custom/ directory.

  2. Define the custom view model in this file. See Example 22-2.

    Example 22-2 Sample Event Adjustment Dialog Box registry entry

    eventAdjustment: {
             viewmodel:
    'custom/viewmodels/ARActions/adjustments/CustomEventAdjustmentViewModel'
       }
    
  3. Save the file in your NetBeans IDE project.