Users can also specify certain cost centers to be billed internally for items in their orders. Cost centers are defined at the business unit level and are inherited by users.

After the payment portion of the checkout process, the user may be asked to associate cost centers with the order. This determination is made at checkout/IsEmptyCostCenters.jsp. If the user does not have cost centers, he or she is redirected to checkout/confirmation.jsp. If the user has cost centers, then the Redirect droplet proceeds to checkout/cost_centers.jsp.

If the user does have cost centers, then she will be able to assign them either to the entire order, or to portions of the order. The list of cost centers that the user may choose from includes a default cost center and an alternate list of authorized cost centers. In the simple case, the user can assign all items in the order to the default cost center, which is selected by default in checkout/cost_centers.jsp, or can choose another cost center from the select box.

checkout/cost_centers.jsp uses CostCenterDroplet to create appropriate cost centers and CommerceIdentifierCostCenters for the given user. It is used as follows in checkout/cost_centers.jsp to display all the authorized cost centers in a select box and assign a cost center to the order:

<%--
    CostCenterDroplet initializes cost centers available to user, and also
    CostCenters objects corresponding to the order to associate cost centers to
    the order
--%>

<dsp:droplet name="CostCenterDroplet">
<dsp:param name="clear" value="true"/>
<dsp:param name="initCostCenters" value="true"/>
<dsp:param name="initItemCostCenters" value="false"/>
<dsp:param name="initShippingCostCenters" value="false"/>
<dsp:param name="initTaxCostCenters" value="false"/>
<dsp:param name="initOrderCostCenters" value="true"/>
<dsp:param name="useAmount" value="false"/>
<dsp:oparam name="output">

  <tr valign=top>
    <td></td>
        <td align=right><span class=smallb>Cost center</span></td>
    <td>
      <dsp:setvalue bean="CostCenterFormHandler.listId" paramvalue="order.id"/>
      <dsp:input bean="CostCenterFormHandler.listId" paramvalue="order.id"
        priority="<%=(int) 9%>" type="hidden"/>
        <%-- we only expect this to have 1 element at [0], but we put this in a
          ForEach to be safe --%>
      <dsp:droplet name="ForEach">
        <dsp:param bean="CostCenterFormHandler.currentList" name="array"/>
        <dsp:oparam name="output">
          <dsp:select bean=
            "CostCenterFormHandler.currentList[param:index].CostCenterName"><br>

            <%--
                 List all the cost centers available to the user in select
                 box, so he can choose one among them.
            --%>
          <dsp:droplet name="ForEach">
            <dsp:param bean="Profile.costCenters" name="array"/>
            <dsp:param name="elementName" value="CostCenter"/>
            <dsp:oparam name="output">
              <dsp:droplet name="Switch">
                <dsp:param name="value" param="CostCenter.repositoryId"/>
                <dsp:getvalueof id="costCenterId" idtype="String"
                  param="CostCenter.identifier">
       <dsp:getvalueof id="defaultCostCenter" idtype="String"
         bean="Profile.defaultCostCenter.repositoryId">
                  <dsp:oparam name="<%=defaultCostCenter%>">
                    <dsp:option selected="<%=true%>" value="<%=costCenterId%>"/>
                      <dsp:valueof param="CostCenter.identifier"/> -
                      <dsp:valueof param="CostCenter.description"/>
                  </dsp:oparam>
                  <dsp:oparam name="default">
                    <dsp:option selected="<%=false%>" value="<%=costCenterId%>"/>
                      <dsp:valueof param="CostCenter.identifier"/>
                      <dsp:valueof param="CostCenter.description"/>
                  </dsp:oparam>
                </dsp:getvalueof>
       </dsp:getvalueof>

          </dsp:droplet> <%-- Switch --%>
    </dsp:oparam><%-- End: ForEach.oparam --%>
    </dsp:droplet> <%-- End: ForEach --%>
          </dsp:select>
        </dsp:oparam>
      </dsp:droplet>
  </td></tr>
    </dsp:oparam>
    </dsp:droplet> <%-- End: CostCenterDroplet --%>

The user may assign any cost center to the order and can decide to proceed to the next step in the purchase process, confirmation, by submitting the form.

Using Multiple Cost Centers

Splitting cost centers among items in an order is implemented with cost_centers_line_item.jsp, which is a link from cost_centers.jsp.

This page utilizes a request parameter init to enable or disable initialization of the CostCenterDroplet. The CostCenterDroplet is used on costCentersLineItemDetails.jsp to create cost centers for all the items, shipping groups, and tax in the order. Like PaymentGroupDroplet, CostCenterDroplet is context dependent. This droplet takes an init parameter, which specifies whether the old CostCenterMapContainer and CommerceIdentiferCostCenterMap should be reinitialized. The CostCenterDroplet is introduced on costCentersLineItemDetails.jsp as follows:

<%--
     CostCenterDroplet initializes the CommerceIdentifierCostCenter objects based
     on the requested init parameter and also creates costcenter objects.
--%>

<dsp:droplet name="CostCenterDroplet">
  <dsp:param name="clear" param="init"/>
  <dsp:param name="initCostCenters" value="true"/>
  <dsp:param name="initItemCostCenters" param="init"/>
  <dsp:param name="initShippingCostCenters" param="init"/>
  <dsp:param name="initTaxCostCenters" param="init"/>
  <dsp:param name="useAmount" value="false"/>
  <dsp:oparam name="output">

Once the initialization is complete, we present the user with a form to edit the cost centers, which modifies the CommerceIdentifierCostCenter objects. We first gather the CommerceItems, ShippingGroups, and the tax groups from the order. For each of these we obtain the corresponding list of CommerceIdentiferCostCenter objects and iterate over each list.

We provide dropdown lists so that the user can edit the splitCostCenterName and splitQuantity properties of CommerceIdentiferCostCenter objects that correspond to commerce items in the order and the items’ splitCostCenterName for shipping groups and tax.

The following code illustrates the form to modify CommerceIdentifierCostCenter objects for the CommerceItems in the order:

<%--
    Iterate through the commerceitems of the order and assign that particular
    commerceIdentifierCostCenter to the CostCenterFormHandler to edit the
    costcenter information. Since we provide <dsp:form></dsp:form> elements across
    each item we will be editing only one item at any given time.
    If user splits any item across cost centers, we create extra
    CommerceIdentifierCostCenter to accomodate the split qty.
--%>

<dsp:droplet name="ForEach">
  <dsp:param name="array" param="order.commerceItems"/>
  <dsp:oparam name="output">
    <%--
      Set the current item id to CostCenterFormHandler
      --%>
    <dsp:setvalue paramvalue="element" param="commerceItem"/>
    <dsp:setvalue bean="CostCenterFormHandler.listId"
      paramvalue="commerceItem.id"/>
        <dsp:droplet name="ForEach">
          <dsp:param bean="CostCenterFormHandler.currentList" name="array"/>
          <dsp:oparam name="output">
            <%-- begin line item --%>

            <tr valign=top>
              <dsp:form action="cost_centers_line_item.jsp" method="post">
              <td><dsp:valueof param="commerceItem.catalogRefId"/></td>
              <td></td>
              <td><dsp:a href="../catalog/product.jsp?navAction=jump">
                     <dsp:param name="id" param=
                       "commerceItem.auxiliaryData.productId"/>
                     <dsp:valueof param=
                       "commerceItem.auxiliaryData.productRef.displayName"/>
                       </dsp:a></td>
              <td></td>


              <td align=middle><dsp:valueof param="element.quantity"/></td>
              <td>&nbsp;</td>


              <td>
              <dsp:input bean=
                "CostCenterFormHandler.currentList[param:index].splitQuantity"
                paramvalue="element.quantity" size="4" type="text"/></td>
              <td>&nbsp;</td>


              <td align=center>
                  <%--
                    Set the cost center to be used for the current item
                    --%>
                <dsp:getvalueof id="itemCenterName" idtype="String" param=
                  "element.costCenterName">
                <dsp:select bean="CostCenterFormHandler.
                  currentList[param:index].splitCostCenterName">
                  <%--
                    Iterate through the available cost centers so that user can
                    choose one among them to assign for the current item
                    --%>
                <dsp:droplet name="ForEach">
                  <dsp:param name="array" param="costCenters"/>
                  <dsp:oparam name="output">
                    <dsp:droplet name="Switch">
                      <dsp:param name="value" param="key"/>
                      <dsp:getvalueof id="keyname" idtype="String" param="key">
                     <%-- <dsp:oparam name="param:...element.costCenterName"> --%>
                        <dsp:oparam name="<%=itemCenterName%>">
                        <dsp:option selected="<%=true%>" value="<%=keyname%>"/>
                          <dsp:valueof param="key"/>
                        <dsp:droplet name="ForEach">
                         <dsp:param bean="Profile.costCenters" name="array"/>
                         <dsp:param name="elementName" value="costCenter"/>
                         <dsp:oparam name="output">
                          <dsp:droplet name="Switch">
                           <dsp:param name="value" param="costCenter.identifier"/>
                           <dsp:oparam name="<%=keyname%>">
                            <dsp:valueof param="costCenter.description"/>
                           </dsp:oparam>
                          </dsp:droplet>
                         </dsp:oparam>
                        </dsp:droplet>
                      </dsp:oparam>
                      <dsp:oparam name="default">
                        <dsp:option selected="<%=false%>" value="<%=keyname%>"/>
                          <dsp:valueof param="key"/>
                        <dsp:droplet name="ForEach">
                         <dsp:param bean="Profile.costCenters" name="array"/>
                         <dsp:param name="elementName" value="costCenter"/>
                         <dsp:oparam name="output">
                          <dsp:droplet name="Switch">
                           <dsp:param name="value" param="costCenter.identifier"/>
                           <dsp:oparam name="<%=keyname%>">
                            <dsp:valueof param="costCenter.description"/>
                           </dsp:oparam>
                          </dsp:droplet>
                         </dsp:oparam>
                        </dsp:droplet>
                      </dsp:oparam>
                      </dsp:getvalueof>
                    </dsp:droplet>
                  </dsp:oparam>
                </dsp:droplet>
                </dsp:select>

                </dsp:getvalueof>
              </td>
              <td align=center>
                <dsp:input bean="CostCenterFormHandler.listId" paramvalue=
                  "commerceItem.id" priority="<%=(int) 9%>" type="hidden"/>
                <dsp:input bean="CostCenterFormHandler.splitCostCentersSuccessURL"
                  type="hidden" value="cost_centers_line_item.jsp?init=false"/>
                <dsp:input bean="CostCenterFormHandler.splitCostCentersErrorURL"
                  type="hidden" value="cost_centers_line_item.jsp?init=false"/>
                <dsp:input bean="CostCenterFormHandler.splitCostCenters"
                  type="submit" value="Save"/>
              </td>
            </tr>
            </dsp:form>
            <%-- end line item --%>
          </dsp:oparam>
        </dsp:droplet>
  </dsp:oparam>
</dsp:droplet>

Upon submission, the form’s action redirects the user to the next portion of purchase process, which begins at checkout/confirmation.jsp.


Copyright © 1997, 2019 Oracle and/or its affiliates. All rights reserved. Legal Notices