com.ibm.commerce.returns.commands
Class CalculateReturnItemAdjustmentPolicyCmdImpl

java.lang.Object
  |
  +--com.ibm.commerce.command.AbstractECCommand
        |
        +--com.ibm.commerce.command.TaskCommandImpl
              |
              +--com.ibm.commerce.command.BusinessPolicyCommandImpl
                    |
                    +--com.ibm.commerce.returns.commands.CalculateReturnItemAdjustmentPolicyCmdImpl
All Implemented Interfaces:
BusinessPolicyCommand, CalculateReturnItemAdjustmentPolicyCmd, ECCommand, TaskCommand
Direct Known Subclasses:
CalculateReturnItemAdjustmentFlatPolicyCmdImpl, CalculateReturnItemAdjustmentPercentagePolicyCmdImpl

public abstract class CalculateReturnItemAdjustmentPolicyCmdImpl
extends BusinessPolicyCommandImpl
implements CalculateReturnItemAdjustmentPolicyCmd

Calculate the adjustment for a return mechandise authorization (RMA) item. This is an abstract implementation which supplies some common infrastructure for concrete implementations.

Behaviour


Fields inherited from class com.ibm.commerce.command.BusinessPolicyCommandImpl
policyId, requestProperties
 
Fields inherited from class com.ibm.commerce.command.AbstractECCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.returns.commands.CalculateReturnItemAdjustmentPolicyCmd
COPYRIGHT, defaultCommandClassName, NAME
 
Constructor Summary
CalculateReturnItemAdjustmentPolicyCmdImpl()
          ReturnItemCreditCalculateCmdImpl constructor comment.
 
Method Summary
protected abstract  java.math.BigDecimal calcAdjustment()
          Calculate the RMA item adjustment (charge).
protected  java.sql.Timestamp calcTimestampShipped()
          Calculate the timestamp when the item was shipped.
protected  void createCharge(java.lang.String aChargeType, java.math.BigDecimal anAmount)
          Create a charge against the rma item.
protected  int findBestDays(int aDaysSinceShipped, int[] theDays)
          Find the smallest days value that is >= number of days since the item was shipped.
 java.math.BigDecimal getAdjustment()
          Get the automatically calculated adjustment for the returned/refunded item.
protected  int getDaysSince(java.sql.Timestamp aTimestamp)
          Get the number of days since a particluar timestamp value.
protected  OrderItemAccessBean getOrderItemAB()
          Get the order item access bean.
protected  RMAItemAccessBean getRMAItemAB()
          Get the RMA item access bean.
protected  java.math.BigDecimal getTotalToAdjust()
          Get the amount to be used to calculate the adjustment.
 void performExecute()
          Execute the command.
protected  void removeExistingCharges()
          Remove existing charges.
 void reset()
          reset the command.
 void setOrderItemAB(OrderItemAccessBean anOrderItemAB)
          (Optional) Set the orderItem being returned/refunded.
 void setRequestProperties(TypedProperty requestProperties)
          Set the request properties for the policy.
 void setRMAItemAB(RMAItemAccessBean anRMAItemAB)
          Set the RMA Item access bean which will have its adjustment updated.
 void validateParameters()
          Check mandatory parameters.
 
Methods inherited from class com.ibm.commerce.command.BusinessPolicyCommandImpl
getPolicyId, getRequestProperties, setPolicyId
 
Methods inherited from class com.ibm.commerce.command.AbstractECCommand
accessControlCheck, checkIsAllowed, checkResourcePermission, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getDefaultProperties, getResources, getStoreId, getUser, getUserId, isReadyToCallExecute, setAccCheck, setCommandContext, setCommandIfName, setDefaultProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.commerce.command.BusinessPolicyCommand
getPolicyId, getRequestProperties, setPolicyId
 
Methods inherited from interface com.ibm.commerce.command.ECCommand
checkIsAllowed, checkResourcePermission, execute, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getDefaultProperties, getResources, getStoreId, getUser, getUserId, setAccCheck, setCommandContext, setCommandIfName, setDefaultProperties
 

Constructor Detail

CalculateReturnItemAdjustmentPolicyCmdImpl

public CalculateReturnItemAdjustmentPolicyCmdImpl()
ReturnItemCreditCalculateCmdImpl constructor comment.
Method Detail

calcAdjustment

protected abstract java.math.BigDecimal calcAdjustment()
                                                throws ECException
Calculate the RMA item adjustment (charge).
Returns:
the adjustment (charge) amount.

calcTimestampShipped

protected java.sql.Timestamp calcTimestampShipped()
                                           throws javax.ejb.FinderException,
                                                  java.rmi.RemoteException,
                                                  javax.naming.NamingException,
                                                  javax.ejb.CreateException,
                                                  ECException
Calculate the timestamp when the item was shipped.
Returns:
the shipped timestamp.

createCharge

protected void createCharge(java.lang.String aChargeType,
                            java.math.BigDecimal anAmount)
                     throws ECSystemException
Create a charge against the rma item.
Parameters:
aChargeType - charge type code
anAmount - charge amount

findBestDays

protected int findBestDays(int aDaysSinceShipped,
                           int[] theDays)
Find the smallest days value that is >= number of days since the item was shipped.
Parameters:
aDaysSinceShipped - days since the item was shipped.
theDays - the days array.
Returns:
the index into the days array. If no value in the days array satisfies the search criteria then -1 is returned.

getAdjustment

public java.math.BigDecimal getAdjustment()
Get the automatically calculated adjustment for the returned/refunded item.
Specified by:
getAdjustment in interface CalculateReturnItemAdjustmentPolicyCmd
Returns:
the amount of the adjustment (in the same currency of the orderItem).

getDaysSince

protected int getDaysSince(java.sql.Timestamp aTimestamp)
Get the number of days since a particluar timestamp value.
Parameters:
aTimestamp - the timestamp to calculate the number of days since.
Returns:
the number of days.

getOrderItemAB

protected OrderItemAccessBean getOrderItemAB()
Get the order item access bean.
Returns:
com.ibm.commerce.order.objects.OrderItemAccessBean

getRMAItemAB

protected RMAItemAccessBean getRMAItemAB()
Get the RMA item access bean.
Returns:
com.ibm.commerce.ordermanagement.objects.RMAItemAccessBean

getTotalToAdjust

protected java.math.BigDecimal getTotalToAdjust()
                                         throws ECSystemException
Get the amount to be used to calculate the adjustment. This is set to the credit amount + the adjustment credit.
Returns:
the amount.

performExecute

public void performExecute()
                    throws ECException
Execute the command.
Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECCommand
Following copied from interface: com.ibm.commerce.command.ECCommand
Throws:
com.ibm.commerce.command.CommandException - The superclass for all ECExceptions.

removeExistingCharges

protected void removeExistingCharges()
                              throws ECSystemException
Remove existing charges.

reset

public void reset()
reset the command.
Overrides:
reset in class AbstractECCommand

setOrderItemAB

public void setOrderItemAB(OrderItemAccessBean anOrderItemAB)
(Optional) Set the orderItem being returned/refunded.
Specified by:
setOrderItemAB in interface CalculateReturnItemAdjustmentPolicyCmd
Parameters:
anOrderItemAB - the orderItem access bean.

setRequestProperties

public void setRequestProperties(TypedProperty requestProperties)
Set the request properties for the policy.
Specified by:
setRequestProperties in interface BusinessPolicyCommand
Overrides:
setRequestProperties in class BusinessPolicyCommandImpl
Parameters:
requestProperties - The request properties

setRMAItemAB

public void setRMAItemAB(RMAItemAccessBean anRMAItemAB)
Set the RMA Item access bean which will have its adjustment updated.
Specified by:
setRMAItemAB in interface CalculateReturnItemAdjustmentPolicyCmd
Parameters:
anRMAItemAB - RMA item access bean.

validateParameters

public void validateParameters()
                        throws ECException
Check mandatory parameters.
Specified by:
validateParameters in interface ECCommand
Overrides:
validateParameters in class AbstractECCommand
Following copied from interface: com.ibm.commerce.command.ECCommand
Throws:
ECException. -