com.ibm.commerce.price.commands
Class CalculateContractPricesCmdImpl

java.lang.Object
  |
  +--com.ibm.commerce.command.AbstractECCommand
        |
        +--com.ibm.commerce.command.TaskCommandImpl
              |
              +--com.ibm.commerce.price.commands.CalculateContractPricesCmdImpl
All Implemented Interfaces:
CalculateContractPricesCmd, ECCommand, TaskCommand

public class CalculateContractPricesCmdImpl
extends TaskCommandImpl
implements CalculateContractPricesCmd

This CalculateContractPricesCmd Task Command Implementation retrieves all the qualified contract prices and calculates the price adjustment specified by the contract for one or more catalog entries.

If the command is successful in retreiving offers, it will return a list of qualified offers that provide the offer prices which have been adjusted according the corresponding Ts&Cs defined in the trading agreements.

If unsuccessful, it wil return an empty list.

Behaviour

Obtain all the qualified offers for each catalog entries, each offer to be retrieved to find the price of a catalog entry must satisfy certain criteria.

If no valid offer can be found, the parent product offers will be searched providing the catalog entry and the parent product is not excluded from the trading agreements.

Select the best adjustments for each of the offers. The price adjustments are retrieved from those Ts&Cs which references the price list containing the offer.

Calculate the price adjustments for each of the offers.


Field Summary
static java.lang.String COPYRIGHT
           
 
Fields inherited from class com.ibm.commerce.command.AbstractECCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.price.commands.CalculateContractPricesCmd
defaultCommandClassName, NAME
 
Constructor Summary
CalculateContractPricesCmdImpl()
           
 
Method Summary
protected  QualifyingOfferInfo calculatePriceAdjustment(QualifyingOfferInfo aOfferInfo, PriceTC aBestPriceTC)
          Calculates the result price by applying the best T&C price adjustment to the offer price.
protected  java.lang.String getCurrency()
          Returns the currency to be used for the price.
 ItemPriceInfo[] getItemPriceInfo()
          Returns the internal item info structure.
 void performExecute()
          Executes main business logic of the command.
protected  PriceTC selectPriceAdjustment(java.lang.Long aItem, java.util.Vector aTcInfoVec)
          Selects the best adjustments for a catalog entry.
 void setCurrency(java.lang.String astrCurrency)
          Sets the currency to be used for finding the price (Optional).
 void setErrorMode(boolean aErrorMode)
          Sets the flag to indicate if exception will be thrown when the price cannot be found for the input catentry (Optional).
 void setItemPriceInfo(ItemPriceInfo[] aItemPriceInfo)
          Sets the item info structure for internal use on calculating the prices.
 void setMasterCatalogPriceListIds(java.lang.Long[] aMasterpriceListIds)
          Sets the ids the price list associated with the Master Catalog (Optional).
 void setPriceListIds(java.lang.Long[] aPriceListIds)
          Sets the ids of the input price lists to be used for retrieving the offers.
 void setStoreId(java.lang.Integer aStoreId)
          Sets the id of the input store to be used for calculating the price (Optional).
 void setTradingABs(TradingAgreementAccessBean[] aTradingABs)
          Sets the input trading agreement access beans for determining the contract prices.
 void setUseGlobalPriceList(boolean aUseGlobalPriceList)
          Sets the flag to indicate if the list of input price lists can be used globally for retrieving the offers for all of the input catentries (Optional).
 void validateParameters()
          Checks mandatory parameters.
 
Methods inherited from class com.ibm.commerce.command.AbstractECCommand
accessControlCheck, checkIsAllowed, checkResourcePermission, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getDefaultProperties, getResources, getStoreId, getUser, getUserId, isReadyToCallExecute, reset, 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.ECCommand
checkIsAllowed, checkResourcePermission, execute, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getDefaultProperties, getResources, getStoreId, getUser, getUserId, setAccCheck, setCommandContext, setCommandIfName, setDefaultProperties
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
Constructor Detail

CalculateContractPricesCmdImpl

public CalculateContractPricesCmdImpl()
Method Detail

calculatePriceAdjustment

protected QualifyingOfferInfo calculatePriceAdjustment(QualifyingOfferInfo aOfferInfo,
                                                       PriceTC aBestPriceTC)
                                                throws ECException
Calculates the result price by applying the best T&C price adjustment to the offer price. If a single price cannot be retrieved for the requested currency, all prices associated with the offer will be converted to the target currency and the lowest will be chosen to apply the adjustment.

Parameters:
aOfferInfo - the offer info structure providing the offer id and saving the result price.
aBestPriceTC - the T&C providing the best price adjustment.

getCurrency

protected java.lang.String getCurrency()
Returns the currency to be used for the price.

getItemPriceInfo

public ItemPriceInfo[] getItemPriceInfo()
Returns the internal item info structure.
Specified by:
getItemPriceInfo in interface CalculateContractPricesCmd
Following copied from interface: com.ibm.commerce.price.commands.CalculateContractPricesCmd
Returns:
The item info structure for storing information such as the trading agreements, price lists that will be used for calculating the prices of the items.

performExecute

public void performExecute()
                    throws ECException
Executes main business logic of 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.

selectPriceAdjustment

protected PriceTC selectPriceAdjustment(java.lang.Long aItem,
                                        java.util.Vector aTcInfoVec)
                                 throws ECException
Selects the best adjustments for a catalog entry. If the adjustment product set is specified, the adjustment will be selected only if the product set includes the catalog entry.

Parameters:
aItem - the catalog entry for searching the adjustment product set.
aTcInfoVec - Ts&Cs containing the adjustment and adjustment product set.

Returns:
The T&C providing the best adjustment.

setCurrency

public void setCurrency(java.lang.String astrCurrency)
Sets the currency to be used for finding the price (Optional).
Specified by:
setCurrency in interface CalculateContractPricesCmd
Following copied from interface: com.ibm.commerce.price.commands.CalculateContractPricesCmd
Parameters:
astrCurrency - The currency to look up the price. If the currency is not specified then the "negotiated" currency is used for the store Id and shopper's preferred currency. (The negotiated currency is the currency returned from the getCurrency() method of the currency manager).

setErrorMode

public void setErrorMode(boolean aErrorMode)
Sets the flag to indicate if exception will be thrown when the price cannot be found for the input catentry (Optional).
Specified by:
setErrorMode in interface CalculateContractPricesCmd
Following copied from interface: com.ibm.commerce.price.commands.CalculateContractPricesCmd
Parameters:
aErrorMode - The indicator to decide if an exception will be thrown when the price cannot be found. A true value (default) means throw exception. A false value means do not throw exception and returns a null value price

setItemPriceInfo

public void setItemPriceInfo(ItemPriceInfo[] aItemPriceInfo)
Sets the item info structure for internal use on calculating the prices.
Specified by:
setItemPriceInfo in interface CalculateContractPricesCmd
Following copied from interface: com.ibm.commerce.price.commands.CalculateContractPricesCmd
Parameters:
aItemPriceInfo - the item info structure for storing information such as the trading agreements, price lists that will be used for calculating the prices of the items.

setMasterCatalogPriceListIds

public void setMasterCatalogPriceListIds(java.lang.Long[] aMasterpriceListIds)
Sets the ids the price list associated with the Master Catalog (Optional).
Specified by:
setMasterCatalogPriceListIds in interface CalculateContractPricesCmd
Following copied from interface: com.ibm.commerce.price.commands.CalculateContractPricesCmd
Parameters:
aPriceListIds - the price list ids for the Master Catalog.

setPriceListIds

public void setPriceListIds(java.lang.Long[] aPriceListIds)
Sets the ids of the input price lists to be used for retrieving the offers.
Specified by:
setPriceListIds in interface CalculateContractPricesCmd
Following copied from interface: com.ibm.commerce.price.commands.CalculateContractPricesCmd
Parameters:
aPriceListIds - The reference number of one or more price lists that are to be used for retrieving the offers.

setStoreId

public void setStoreId(java.lang.Integer aStoreId)
Sets the id of the input store to be used for calculating the price (Optional).
Specified by:
setStoreId in interface CalculateContractPricesCmd
Following copied from interface: com.ibm.commerce.price.commands.CalculateContractPricesCmd
Parameters:
aStoreId - The reference number of a store to be used for calculating the price. If the store id is not specified then the store id of the command context will be used.

setTradingABs

public void setTradingABs(TradingAgreementAccessBean[] aTradingABs)
Sets the input trading agreement access beans for determining the contract prices.
Specified by:
setTradingABs in interface CalculateContractPricesCmd
Following copied from interface: com.ibm.commerce.price.commands.CalculateContractPricesCmd
Parameters:
aTradingABs - The access beans of a list of trading agreements to be used to determine the price lists and to obtain the Ts&Cs information such as the price adjustment that is to be applied to the offers retrieved from the price lists.

setUseGlobalPriceList

public void setUseGlobalPriceList(boolean aUseGlobalPriceList)
Sets the flag to indicate if the list of input price lists can be used globally for retrieving the offers for all of the input catentries (Optional).
Specified by:
setUseGlobalPriceList in interface CalculateContractPricesCmd
Following copied from interface: com.ibm.commerce.price.commands.CalculateContractPricesCmd
Parameters:
aUseGlobalPriceList - The indicator to decide if the price lists can be used globally. A true value (default) means apply the price lists globally. A false value means individual set of price lists should be obtained for each catentry (Future Support).

validateParameters

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