The CostCenterFormHandler framework enables customers to gather complex CostCenter information from a user during the purchase process. The primary objective of this framework permits the user to associate their authorized cost centers with the order’s various CommerceIdentifiers.
In order to facilitate the processing of this information, the CostCenterFormHandler framework utilizes the following helper classes:
CommerceIdentifierCostCenter
The CommerceIdentifierCostCenter object stores the information needed to associate cost centers, referenced by name, and CommerceIdentifiers. It contains the following properties:
Property name | Type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CommerceIdentifierCostCenterContainer
The CommerceIdentifierCostCenterContainer interface keeps track of all the CommerceIdentifierCostCenters associated with the various Order CommerceIdentifiers.
CostCenterMapContainer
The CostCenterMapContainer interface keeps track of all the user’s cost centers by name, as well as a default cost center.
CostCenterContainerService
The CostCenterContainerService is a GenericService that implements both container interfaces and comprises a convenient session-scoped component.
CostCenterDroplet
The CostCenterDroplet servlet bean includes a request-scoped component whose service method is responsible for the following tasks:
CostCenterinitialization – The user’s authorized cost centers are created and added to theCostCenterMapContainer.CommerceIdentifierCostCenterinitialization - NewCommerceIdentifierCostCenterinstances are created specific to the current Order and added to theCommerceIdentifierCostCenterContainer.
During initialization, the CostCenterDroplet optionally creates one CommerceIdentifierCostCenter object for each CommerceIdentifier type (for example, each CommerceItem, each ShippingGroup, the Order, and the Tax) and with the following default properties:
Property | Description |
|---|---|
| Set to reference the |
| Set to the appropriate |
| Set to the |
| Set to the Amount property of the |
| Set to the |
For example, a simpler cost center page might permit the customer to assign a cost center to the entire Order, or split the entire Order cost into multiple cost centers. This simple page will not permit the user to assign cost centers to CommerceItems, ShippingGroups, or the Tax.
A more advanced CostCenter page could permit the customer to assign and split CostCenter associations among the CommerceItem, ShippingGroup, and the Tax. This is implemented by the same CostCenterDroplet servlet bean with different initialization parameters. See Appendix A, Oracle ATG Web Commerce Servlet Beans for additional information on CostCenterDroplet.
CostCenterFormHandler
The CostCenterFormHandler extends the PurchaseProcessFormHandler. It is a request-scoped component with two handler methods:
handleSplitCostCentersThis handler relies on the
splitCostCenter,splitAmountandsplitQuantityproperties of theCommerceIdentifierCostCenterto split extraCommerceIdentifierCostCenterobjects by quantity or by amount.In a form, the user might decide to split $50 of an original
CommerceIdentifieramount of $100 onto a separate cost center. This will create a newCommerceIdentifierCostCenterobject, and adjust the amount of both the original and the newCommerceIdentifierCostCenterobjects to add up to the originalCommerceIdentifiertotal amount.handleApplyCostCentersThis handler, whose invocation is the objective of this entire framework, takes the information found in the containers and applies it to the current order. The
CommerceIdentifierCostCenterassociations created by the user are first scrutinized and the appropriate business methods are called in theOrderManagerfamily based on theRelationshipTypeof theCommerceIdentifierCostCenter. Second, anyDefaultCostCenterNameof theCostCenterMapContaineris used to determine if any remaining Order amount is added to a cost center. This readily facilitates applications that apply a default cost center to any remaining Order amount not explicitly covered by other cost centers.
The following code sample is an example of how to use CostCenterFormHandler. The resulting JSP lists the items in a customer’s order and has a text box and a drop-down list of available cost centers next to each item. Customers can use this page to specify the quantity of an item and associate a cost center with the items.
<dsp:form action="cost_centers_line_item.jsp" method="post">
<tr>
<td><br>
<table border=0 cellpadding=6 cellspacing=0>
<tr>
<td></td>
<td colspan=2><span class="big">Cost Centers</span>
<dsp:include page="../common/FormError.jsp"></dsp:include></td>
</tr>
<tr valign=top>
<td width=40><dsp:img hspace="20" src="../images/d.gif"/></td>
<td>
<table border=0 cellpadding=4 cellspacing=1 width=85%>
<tr>
<td colspan=13><span class=help>Assign each line item to a cost center. You
can also divide a line item between cost centers by entering the number of
items to assign to the new cost center.
</span></td>
</tr>
<tr valign=bottom bgcolor="#666666">
<td colspan=2><span class=smallbw>Part #</span></td>
<td colspan=2><span class=smallbw>Name</span></td>
<td colspan=3><span class=smallbw>Qty</span></td>
<td colspan=2><span class=smallbw>Qty. to move</span></td>
<td colspan=2><span class=smallbw>Price</span></td>
<td colspan=2><span class=smallbw>Cost Center</span></td>
<!--<td colspan=2><span class=smallbw>Current Cost Center</span></td>-->
</tr>
<dsp:droplet name="ForEach">
<dsp:param param="order.commerceItems" name="array"/>
<dsp:oparam name="output">
<dsp:setvalue paramvalue="element" param="commerceItem"/>
<dsp:droplet name="BeanProperty">
<dsp:param param="ciccMap" name="bean"/>
<dsp:param param="commerceItem.id" name="propertyName"/>
<dsp:oparam name="output">
<dsp:setvalue paramvalue="propertyValue" param="ciccList"/>
<dsp:droplet name="ForEach">
<dsp:param param="ciccList" name="array"/>
<dsp:oparam name="output">
<!-- begin line item -->
<tr valign=top>
<td><dsp:valueof param="commerceItem.catalogRefId"/></td>
<td></td>
<td><dsp:a href="../catalog/product.jsp?navAction=jump">
<dsp:param param="commerceItem.auxiliaryData.productId"
name="id"/>
<dsp:valueof
param="commerceItem.auxiliaryData.productRef.displayName"/>
</dsp:a></td>
<td></td>
<td> </td>
<td align=right><dsp:valueof param="element.quantity"/></td>
<td> </td>
<td>
<dsp:input
bean='<%="CostCenterDroplet.CostCenterMapContainer.
CommerceIdentifierCostCenterMap." +
request.getParameter("commerceItem.id")+
"[param:index].splitQuantity"%>' size="4" value="0"
type="text"/></td>
<td> </td>
<td align=right><dsp:valueof param="element.amount"
converter="currency"/></td>
<td> </td>
<td>
<dsp:select bean='<%="CostCenterDroplet.CostCenterMapContainer.
CommerceIdentifierCostCenterMap." +
request.getParameter("commerceItem.id")+
"[param:index].splitCostCenterName"%>'>
<dsp:droplet name="ForEach">
<dsp:param param="costCenters" name="array"/>
<dsp:oparam name="output">
<dsp:getvalueof id="option178" param="element"
idtype="java.lang.String">
<dsp:option value="<%=option178%>"/>
</dsp:getvalueof><dsp:valueof param="element"/>
</dsp:oparam>
</dsp:droplet>
</dsp:select>
</td>
<td> </td>
<td>
</td>
<td>
<dsp:valueof param="element.costCenterName">
<dsp:valueof bean="CostCenterDroplet.
CostCenterMapContainer.defaultCostCenterName"/>
</dsp:valueof>
</td>
</tr>
<!-- end line item -->
</dsp:oparam>
</dsp:droplet>
</dsp:oparam>
</dsp:droplet>
</dsp:oparam>
</dsp:droplet>
<dsp:droplet name="ForEach">
<dsp:param param="order.shippingGroups" name="array"/>
<dsp:oparam name="output">
<dsp:setvalue paramvalue="element" param="shippingGroup"/>
<dsp:droplet name="BeanProperty">
<dsp:param param="ciccMap" name="bean"/>
<dsp:param param="shippingGroup.id" name="propertyName"/>
<dsp:oparam name="output">
<dsp:setvalue paramvalue="propertyValue" param="ciccList"/>
<dsp:droplet name="ForEach">
<dsp:param param="ciccList" name="array"/>
<dsp:oparam name="output">
<!-- begin shipping line item -->
<tr valign=top>
<td colspan=7>
<dsp:valueof param="shippingGroup.description"/></td>
<td></td>
<td></td>
<td align=right><dsp:valueof param="element.amount"
converter="currency"/></td>
<td></td>
<td>
<dsp:select bean='<%="CostCenterDroplet.CostCenterMapContainer.
CommerceIdentifierCostCenterMap." +
request.getParameter("shippingGroup.id")+
"[param:index].splitCostCenterName"%>'>
<dsp:droplet name="ForEach">
<dsp:param param="costCenters" name="array"/>
<dsp:oparam name="output">
<dsp:getvalueof id="option279" param="element"
idtype="java.lang.String">
<dsp:option value="<%=option279%>"/>
</dsp:getvalueof><dsp:valueof param="element"/>
</dsp:oparam>
</dsp:droplet>
</dsp:select>
</td>
<td> </td>
<td>
</td>
<td>
<dsp:valueof param="element.costCenterName">
<dsp:valueof bean="CostCenterDroplet.CostCenterMapContainer.
defaultCostCenterName"/>
</dsp:valueof>
</td>
</tr>
<!-- end shipping line item -->
</dsp:oparam>
</dsp:droplet>
</dsp:oparam>
</dsp:droplet>
</dsp:oparam>
</dsp:droplet>
<dsp:droplet name="BeanProperty">
<dsp:param param="ciccMap" name="bean"/>
<dsp:param param="order.id" name="propertyName"/>
<dsp:oparam name="output">
<dsp:setvalue paramvalue="propertyValue" param="ciccList"/>
<dsp:droplet name="ForEach">
<dsp:param param="ciccList" name="array"/>
<dsp:oparam name="output">
<!-- begin tax line item -->
<dsp:droplet name="Switch">
<dsp:param param="element.RelationshipType" name="value"/>
<dsp:oparam name="CCTAXAMOUNT">
<tr valign=top>
<td colspan=7>Tax</td>
<td></td>
<td></td>
<td align=right><dsp:valueof param="element.amount"
converter="currency"/></td>
<td></td>
<td>
<dsp:select bean='<%="CostCenterDroplet.CostCenterMapContainer.
CommerceIdentifierCostCenterMap." +
request.getParameter("order.id")+
"[param:index].splitCostCenterName"%>'>
<dsp:droplet name="ForEach">
<dsp:param param="costCenters" name="array"/>
<dsp:oparam name="output">
<dsp:getvalueof id="option376" param="element"
idtype="java.lang.String">
<dsp:option value="<%=option376%>"/>
</dsp:getvalueof><dsp:valueof param="element"/>
</dsp:oparam>
</dsp:droplet>
</dsp:select>
</td>
<td> </td>
<td>
</td>
<td>
<dsp:valueof param="element.costCenterName">
<dsp:valueof bean="CostCenterDroplet.
CostCenterMapContainer.defaultCostCenterName"/>
</dsp:valueof>
</td>
<td> </td>
</tr>
<!-- end tax line item -->
</dsp:oparam>
</dsp:droplet>
</dsp:oparam>
</dsp:droplet>
</dsp:oparam>
</dsp:droplet>
<tr>
<td colspan=13>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr bgcolor="#666666">
<td><dsp:img src="../images/d.gif"/></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td></td>
<dsp:input bean="CostCenterFormHandler.applyCostCentersSuccessURL"
value="confirmation.jsp" type="hidden"/>
<dsp:input bean="CostCenterFormHandler.splitCostCentersSuccessURL"
value="cost_centers_line_item.jsp?init=false" type="hidden"/>
<td><span class=help>You must save changes before continuing.</span><p>
<!-- <dsp:input bean="CostCenterFormHandler.order" type="hidden"
beanvalue="ShoppingCart.current"/> -->
<dsp:input bean="CostCenterFormHandler.splitCostCenters" value="Save changes"
type="submit"/>
<dsp:input bean="CostCenterFormHandler.applyCostCenters" value="Continue"
type="submit"/>
</td>
</tr>
</table>
</td>
</tr>
</table>
</dsp:form>
