Develop > Controller layer > Application developer > Trading subsystem > Extensions to terms and conditions


Create an extended term and condition type for contracts and accounts

You create a new extended term and condition ("term") type for contracts and accounts if supplement the default term types provided by WebSphere Commerce. Suppose you have a preferred customer for whom to waive the application of a surcharge, or perhaps provide a different surcharge. This "waivable flexible surcharge" term is not provided by default, so to provide that term, you create a new extended term type.


Procedure

  1. Define the new term type in the TCConfigurationExt.xml file, which you create.

    Use this new approach, you define contract terms in the TCConfigurationExt.xml file. For details of the attributes mentioned in these steps, see Attributes for a new extended term contract.

    1. If the WC_EAR /xml/trading/xml/TCConfigurationExt.xml file does not already exist, create it by copying and pasting the following XML code:

      <?xml version="1.0" encoding="UTF-8"?>
      <TCConfiguration
      xmlns="http://www.ibm.com/xmlns/prod/commerce/9/contract"
      xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
      xmlns:oa="http://www.openapplications.org/oagis/9"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.ibm.com/xmlns/prod/commerce/9/contract TCConfiguration.xsd"
      resourceBundle="contract. customTCRB">        
      <!-- Add extended term definitions here; see Step 2.  -->
      </TCConfiguration>
      

    2. Add new extended term types to this file by inserting after the line:

      <!-- Add extended term definitions here. -->
      

      something like the following code:

      <TCDefinition 
            type="SurChargeTC" 
            existing="false" 
            usage="Contract" 
            display="true">    
      <Display 
           displayNameKey="SurChargeTC" 
           descriptionKey="SurChargeTCDescription"/>        
      <Property 
                name="waiveSurCharge" 
                column="INTEGERFIELD1" 
                required="true" 
                changeable="true">              
      <Display 
                    displayNameKey="waiveSurCharge" 
                    descriptionKey="waiveSurChargeDescription"/>        
      </Property>        
      <Property 
              name="surChargeAmount" 
              column="FLOATFIELD1" 
              required="false" 
              changeable="true">                
      <Display 
                      displayNameKey="surChargeAmount" 
                      descriptionKey="surChargeAmountDescription"/>        
      </Property>
      </TCDefinition>
      

      • The value of the type attribute for the TCDefinition element must not be "TermCondition" or the same as subtypes of existing terms.

      • The value of the "usage" attribute is "Contract". This means this new term type only applies to contracts. If you also want to apply the new term type to accounts, you can change its value to "All".

    3. Save and close the file.

  2. Set the display properties in the resource bundle, to resolve names into labels and descriptions for displaying on the WebSphere Commerce Accelerator in different languages.

    You will need to provide values for the displayable identifiers in the previous section (such as waiveSurCharge) in all languages that support for the business users. In the resource bundle, provide the displayable values for the term types, in the form name=value. You need to create the own resource bundle, rather than use one supplied with the product, so that the content is not overwritten by applying service updates to the product.

    You must create the resource bundle in the WC_EAR/properties/com/ibm/commerce/tools/contract/properties folder, in order to associate it with the "contract" namespace. The name of the resource bundle is the choice, except that it should not collide with any existing resource bundle names. In the above example of the TCConfigurationExt.xml file, the resource bundle is identified by the attribute resourceBundle="contract. customTCRB". The file name that would be used is customTCRB.properties. Continuing with the previous example, the content of the customTCRB.properties file would be:

    # -- customized contented defined for each extended tc
    SurChargeTC=Surcharge TC
    SurChargeTCDescription=Surcharge Term and Condition is used for
    specifying the settings related to surcharge
    waiveSurCharge=Waive Surcharge
    waiveSurChargeDescription=Whether to waive the charge
    surChargeAmount=Surcharge Amount
    surChargeAmountDescription=The amount of the surcharge
    

    Additional languages can be supported for the business users by translating the property values (not the names) and storing them in resource bundles such as customTCRB_fr_CH.properties. The name is composed of the base name (customTCRB), followed by an underscore (_), the ISO 639-1 language code (fr), another underscore, then the ISO 3166-1 country code (CH). The name customTCRB_fr_CH.properties is the file to be used when the locale is specified for the French language (fr) in Switzerland (CH). Finally, the resource bundle must be registered in the resource.xml file in the WC_EAR/xml/tools/contract folder by adding the following entry, replacing customTCRB with the name you used:

    <resourceBundle name=" customTCRB" bundle="com.ibm.commerce.tools.contract.properties. customTCRB" /> 
    

    Note that these changes in the resource.xml file might be overwritten when applying service to the product. You may need to redo this change to resource.xml after applying service to the product.

  3. Register the new term type.

    Extended terms fit into the existing contract model, and define a new term type by inserting a record into the TCTYPE table. You can define a single term type for all extended terms to use, or define multiple term types. Run the following SQL command to create a single new TCTYPE called 'ExtendedTC':

    Insert into TCTYPE (TCTYPE_ID) values ('ExtendedTC');
    

    The value ExtendedTC can be any unique name that is not already in use in the TCTYPE column.

    For each term and condition found in the TCConfigurationExt.xml file, define a new term condition subtype by inserting a record into the TCSUBTYPE table.

    • To register the new extended term type in the TCSUBTYPE table, run the following SQL command:

      Insert into tcsubtype(TCSUBTYPE_ID,TCTYPE_ID)
      Values ('SurChargeTC', 'ExtendedTC');
      

      You should leave the value for the ACCESSBEANNAME column as null. You can also leave the DEPLOYCOMMAND column as null if you do not have custom deployment logic for the term.

      • If the ACCESSBEANNAME column is null, the default access bean (ExtendedTermConditionAccessBean) will be used when you create and update the extended term conditions. The calling method can use the getProperty and setProperty methods of ExtendedTermConditionAccessBean to get and set properties on the term and condition.

      • If the DEPLOYCOMMAND column is null, the terms with this type will be ignored during deployment.

    • To register with a custom deploy command, run this SQL command:

      Insert into tcsubtype(TCSUBTYPE_ID, TCTYPE_ID, ACCESSBEANNAME, DEPLOYCOMMAND)
      Values ('SurChargeTC', 'ExtendedTC', null, 
      YourDeployCommandName);
      

    Where:

    YourDeployCommandName

    The name of the custom deploy command. The default value is 'com.ibm.commerce.contract.commands.DeployExtendedTCCmd.'

    The default access bean 'com.ibm.commerce.contract.objects.ExtendedTermConditionAccessBean' is used for handling all extended terms. Note that the name 'SurChargeTC' shown here is an example. You should enter the same value used in the type attribute of the TCDefinition element shown previously under Define the new term. In addition, the value for TCTYPE_ID should match the value in the TCTYPE table.

    You do not typically need to define the own deploy command. So you can leave yourDeployCommandName as null. However, to have your own deployment logic, replace yourDeployCommandName with the name of the own deploy command.

  4. Refresh the Terms and Conditions Mapping.

    In order to make use of the new terms in the WebSphere Commerce Accelerator user interface or the WebSphere Commerce runtime environment, the values must be propagated to the Registry. The Terms and Conditions Mapping is new with this release, and is found along with the other WebSphere Commerce registries.

    If you restart the server, the registry is updated automatically. Otherwise, to update the registry:

    1. Start the WebSphere Commerce Server.

    2. Open the Administration Console.

    3. Select Site and click OK.

    4. Select Configuration > Registry.

    5. From the Registry list, select Terms and Conditions Mapping and click the Update button.

    6. After completing the update, log out of the Administration Console.


Results

After you have created the term type, you can add it to contracts or accounts. Before that term type can have any effect, however, provide logic to handle it. Providing this logic is similar to previous releases, except that previously the custom code used the TermConditionAccessBean to access the terms. Now, the custom code uses ExtendedTermConditionAccessBean to access the extended term. A sample follows.

Long contractId = new Long(23504); 
ExtendedTermConditionAccessBean etcAB = new ExtendedTermConditionAccessBean(); 
Enumeration etcABs = etcAB.findByTradingAndTCSubType(contractId, "SurChargeTC"); 
if (etcABs.hasMoreElements()) 
{ 
  etcAB = (ExtendedTermConditionAccessBean)etcABs.nextElement(); 
  Integer waiveSurCharge = (Integer)etcAB.getProperty("waiveSurCharge"); 
  Double surChargeAmount = (Double)etcAB.getProperty("surChargeAmount"); 
}


Related concepts

What's new in terms and conditions

Import and exporting contracts with extended terms defined

Extensions to terms and conditions

Related reference

TCConfiguration.xml file


+

Search Tips   |   Advanced Search