Back to top
 
 
 

Customizing Discount Adjusters

Customers can change the way discounts are applied to a CPBM invoice.
  1. Change the engine to customized implementation:
    1. Customizing the way percent discount engine works:
      1. Implement a new DiscountEngine by extending the abstract class DiscountEngine (com.vmops.component.discount.policy.DiscountEngine) and put it inside the citrix.cpbm.custom bundle.
      2. Edit the cloud.properties at /usr/share/vts3/repository/prop to point to the new entry by editing the property discount.percent.engine.implementation. Point it to the new implementation.
    2. Customizing the way amount discount engine works:
      1. Implement a new DiscountEngine by extending the abstract class DiscountEngine (com.vmops.component.discount.policy.DiscountEngine) and put it inside the citrix.cpbm.custom bundle.
      2. Edit the cloud.properties at /usr/share/vts3/repository/prop to point to the new entry by editing the property discount.amount.engine.implementation. Point it to the new implementation.
    3. Customizing the way non promotional discount engine works:
      1. Implement a new DiscountEngine by extending the abstract class DiscountEngine (com.vmops.component.discount.policy.DiscountEngine) and put it inside the citrix.cpbm.custom bundle.
      2. Edit the cloud.properties at /usr/share/vts3/repository/prop to point to the new entry by editing the property discount.adhoc.engine.implementation. Point it to the new implementation.

      Restart the CPBM service.

  2. Adding new engines over and above the existing engine:
    1. Implement a new DiscountEngine by extending the abstract class DiscountEngine (com.vmops.component.discount.policy.DiscountEngine) and put it inside the citrix.cpbm.custom bundle.
    2. Add one or more such implementations.

    3. Open the application context file applicationContext-admin-customizations.xml inside the citrix.cpbm.custom bundle.

      Define a bean for each implementation:
      <bean name="discountEngineCustom" class="<Newly added class>" />
      Add the above created bean to the list 'taxEngineList':
      <bean id="discountEngineList" class="java.util.ArrayList">  		<constructor-arg>  			<list>  				<ref bean="adhocDiscountEngine" />  				<ref bean="percentDiscountEngine" />  				<ref bean="amountDiscountEngine" />  				<ref bean="discountEngineCustom" />  			</list>  		</constructor-arg>  	</bean>

      or

      <bean id="taxEngineList" class="java.util.ArrayList">  		<constructor-arg>  			<list>  				<ref bean="discountEngineCustom" />  			</list>  		</constructor-arg>  	</bean>
      Note: You can remove the default implementation and/or add multiple such beans in the list. Beans will be called in the same order as defined in the list.
    4. Restart the CPBM service.

  3. Example:
    public interface RateAdjuster {      /**     * @param invoice A read only (not enforced) invoice for the rate adjuster to get info related to this invoice such as     *          tenant, billing period etc.     * @param newInvoiceItems Every RateAdjuster should process the newInvoiceItems and replace them with adjusted items     *          for the next adjusters for further processing. The first adjuster sees the invoiceItems of     *          ChargeType.CHARGE     * @param serviceStart is the billing period start for the moment, it can be any day in the billing period if we     *          decided to support number of days for a promotion (as oppose to number of billing period)     * @param serviceEnd is the billing period end for the moment, it can be any day in the billing period if we decided     *          to support number of days for a promotion (as oppose to number of billing period)     * @param previewMode if true, nothing will be written to db or the billing activity file. Plan to remove this soon.     * @return     */      public abstract BigDecimal compute(Invoice invoice, List<InvoiceItem> invoiceItemsToBeProcessed, Date serviceStart,        Date serviceEnd, boolean previewMode);    }  
    public class ExampleDiscountEngine extends DiscountEngine {      @Override    public BigDecimal compute(Invoice invoice, List<InvoiceItem> invoiceItemsToBeProcessed, Date serviceStart,        Date serviceEnd, boolean previewMode) {      …… [Put your implementation here ]  }  }  
 

Comments