atg.commerce.csr.returns
Class ReturnManager

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.csr.returns.ReturnManager
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class ReturnManager
extends GenericService

This component provides the main API for managing returns & exchanges.

A ReturnRequest provides access to the object graph that represents a return. It contains all the meta-data needed to calculate the proper refunds and price replacement orders. A return is initialized using a fulfilled order, which is used to construct the ReturnShippingGroup and ReturnItem objects in the ReturnRequest.

A ReturnShippingGroup is created for each shipping group and a ReturnItem for each CommerceItemRelationship in the group. Items are selected for return by specifying a return quantity in the ReturnItem and applying those selections. After which, the initial refund is calculated.

Once the refund is calculated, the RefundMethod objects are generated and allocated. The system will automatically generate the RefundMethod objects and allocate the refund. There is API, including form handler support, to manually allocate the refund to the methods.

Finally, the return must be confirmed where it is validated and committed to the repository. In some cases, the return will be settled at confirm time. In most business models, the return is settled when the items being returned are physically received by the merchant. The return remains in a pending state until there are no items pending receipt.

Settlement will issue the credits and also submit the replacement order (for exchanges). Settlement can occur immediately upon confirmation if the isProcessImmediately() is set to true, or if all items being returned have ReturnItem.isReturnShipmentRequired() set to false.

Returns are handled in the following steps.

Creating the return
This is where the ReturnRequest is instantiated. See #createReturnRequest(String, ProcessName, Map)
Selecting items to be returned.
Choosing the items to be returned and calculating an initial refund. See {@link #applySelectedItems(ReturnRequest, ProcessName, Map)
Manually allocating the refund across the RefundMethods
Optional. Allocate the refund credit across the avaialble RefundMethods. An automatic allocation is done when the RefundMethods are initially created. {@link #applyRefundMethodAllocations(ReturnRequest, Map)
Confirmation
Validate and save the return to the repository. See {@link #confirmReturn(ReturnRequest, Map)
Settlement
Issue the refund credits and submit replacement orders to fulfillment. Typically, returns are settled when all items being returned are received. Replacement orders are also submitted for fulfillment. See {@link #settleReturnRequest(ReturnRequest, String, Map)} Settlement can occur immediately upon confirmation if the {@link #isProcessImmediately()} is set to true, or if all items being returned have {@link atg.commerce.csr.returns.ReturnItem#isReturnShipmentRequired()} set to false .

Much of the API required to perform the aforementioned steps is modeled using pipelines. All of the pipeline chain ids are configurable in the ReturnManager. {@link #getCreateReturnRequestPipelineChainId()}, {@link #getApplySelectedItemsPipelineChainId()}, {@link #getApplyRefundAllocationsPipelineChainId()}, {@link #getConfirmReturnRequestPipelineChainId()}, {@link #getSettleReturnRequestPipelineChainId()}, {@link #getGenerateReplacementOrderPipelineChainId()},{@link #getCalculateRefundAmountsPipelineChainId()}, {@link #getReceiveItemPipelineChainId()}


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected  java.lang.String mAmountCreditedPropertyName
           
protected  java.lang.String mApplyRefundAllocationsPipelineChainId
           
protected  java.lang.String mApplySelectedItemsPipelineChainId
           
protected  java.lang.String mCalculateRefundAmountsPipelineChainId
           
protected  ClaimableManager mClaimableManager
           
protected  CommerceItemManager mCommerceItemManager
           
protected  java.lang.String mConfirmReturnRequestPipelineChainId
           
protected  java.lang.String mCreatePromotionEvaluationOrderPipeline
           
protected  java.lang.String mCreateReturnAdjustedOrderPipeline
           
protected  java.lang.String mCreateReturnCalculationOrderPipeline
           
protected  java.lang.String mCreateReturnRequestPipelineChainId
           
protected  java.lang.String mCreditCardType
           
protected  double mDefaultReturnFee
           
protected  boolean mDoShippingRefunds
           
protected  java.util.Properties mExchangeOrderExcludedProperties
           
protected  java.util.Map mExchangeOrderExcludedPropertiesMap
           
protected  java.lang.String mGenerateReplacementOrderPipelineChainId
           
protected  java.lang.String mGiftCertificateType
           
protected  boolean mInitializeActualShippingRefund
           
protected  InventoryManager mInventoryManager
           
protected  OrderManager mOrderManager
           
protected  OrderStates mOrderStates
           
protected  atg.commerce.csr.returns.PaymentGroupCopyManager mPaymentGroupCopyManager
           
protected  PaymentGroupManager mPaymentGroupManager
           
protected  PaymentManager mPaymentManager
           
protected  java.lang.String mPendingCustomerReturnOrderState
           
protected  java.lang.String mPrepareReplacementOrderChainId
           
protected  PricingTools mPricingTools
           
protected  boolean mProcessImmediately
           
protected  Repository mProfileRepository
           
protected  java.lang.String mReceiveItemPipelineChainId
           
protected  atg.commerce.csr.returns.ReturnEventMessageSource mReturnEventMessageSource
           
protected  ReturnItemStates mReturnItemStates
           
protected static ReturnManager mReturnManager
           
static java.lang.String mReturnManagerComponentPath
           
protected  ReturnStates mReturnStates
           
protected  ReturnTools mReturnTools
           
protected  java.lang.String mSalesChannel
           
protected  java.lang.String mSettleReturnRequestPipelineChainId
           
protected  ShippingGroupManager mShippingGroupManager
           
protected  java.lang.String mStoreCreditType
           
protected  java.lang.String mSubmitReplacementOrderPipelineChainId
           
protected  javax.transaction.TransactionManager mTransactionManager
           
protected static java.util.ResourceBundle sResourceBundle
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
ReturnManager()
           
 
Method Summary
 void addPropertyUpdate(java.lang.Object pNewValue, java.lang.Object pOldValue, java.lang.String pPropertyName, java.util.List pUpdates)
          Adds the old and new values of updated property in the list.
protected  void addReplacementItemsToReturnAdjustedOrder(ReturnRequest pReturnRequest, Order pReturnAdjustedOrder)
          For each replacement(exchange) order found in the return tree, the commerce items and shipping groups are copied to the Return Adjusted Order.
protected  void adjustFinalItemAmountForRelationshipRangeValue(ReturnRequest pReturnRequest, CommerceItem pCommerceItem, ShippingGroupCommerceItemRelationship pShippingGroupCommerceItemRelationship, atg.core.util.Range pRange)
          Calculates and sets a new priceInfo amount by subtracting out the value of the range within the given relationship.
 void adjustOrderPayments(ReturnRequest pReturnRequest, double pRefundAmount, boolean pClearRefundMethods)
          Creates or adjusts the refund store credit payment group in the replacement order for the given refund amount.
protected  void adjustReturnAdjustedOrderFinalItemPrices(ReturnRequest pReturnRequest, Order pReturnAdjustedOrder)
          Calculates a new price info amount and new DetailedItemPriceInfos for items that have been marked as final and have some quantity returned already.
protected  void adjustReturnCalculationOrderFinalItemPrices(ReturnRequest pReturnRequest, Order pReturnCalculationOrder)
          Adjusts the amount value for items marked as final in the return calculation order that are being returned.
protected  void adjustReturnCalculationOrderForReturnItems(ReturnRequest pReturnRequest, Order pReturnCalculationOrder)
          Adjusts the quantity of commerce items and shipping group relationships for the items being returned (i.e.
 void adjustSuggestedAmountsForNonReturnItems(ReturnRequest pReturnRequest)
          Adjusts the suggested amounts based on the ItemCostAdjustment objects that reference item/shipping relationships not being returned.
protected  double allocateRefundAmountForReturn(Order pOriginalOrder, ReturnRequest pReturnRequest, double pRefundAmountToBeAllocated, java.util.Collection<RefundMethod> pRefundMethods)
          This method allocates the given refund amount to the given refund methods and returns the total amount that was successfully allocated.
 atg.commerce.csr.returns.ReturnPaymentState applyExchangeProcessPayments(ReturnRequest pReturnRequest)
          Generates the refund store credit and applies it to the replacement order as a payment group.
 void applyRefundMethodAllocations(ReturnRequest pReturnRequest, java.util.Map pExtraParameters)
          This method will execute a pipeline chain to validate and process the new RefundMethod allocations.
 void applySelectedItems(ReturnRequest pReturnRequest, atg.commerce.csr.returns.ProcessName pProcessName, java.util.Map pExtraParameters)
          Executes the process of applying the selected ReturnItems by executing the given pipeline.
 void applyStoreCredit(ReturnRequest pReturnRequest)
          Deprecated.  
protected  void buildRefundMethodList(Order pOriginalOrder, ReturnRequest pReturnRequest, double pStoreCreditAmount, double pTotalRefundAmount)
          Populate the refund methods list for the given return request
protected  void buildRefundMethodList(ReturnRequest pReturnRequest, double pStoreCreditAmount)
          Populate the refund methods list for the given return request
protected  void calculateActualRefundsForReturnItems(ReturnRequest pReturnRequest)
          Calculate the actual shipping and actual tax for return items based on the actual values in the ReturnRequest.
protected  double calculateDetailShare(ReturnItem pReturnItem, java.lang.String pDetailAmountProperty, atg.core.util.Range pReturnRange)
          Calculates the share of the return by looking at the DetailedItemPriceInfos for the range of the item being retured.
 void calculateExchangeManualAdjustmentDiscountValues(ReturnRequest pReturnRequest)
          Generates the Map of manual adjustment to exchange order value.
 void calculateExchangeOrderPromotionDiscountValues(ReturnRequest pReturnRequest)
          Generates the Map of order promotion to exchange order value.
protected  double calculateItemAmountShare(ReturnRequest pReturnRequest, ReturnItem pReturnItem, atg.core.util.Range pReturnRange)
          Calculates the share of the item's amount for the given return item and range.
protected  double calculateManualAdjustmentShare(ReturnRequest pReturnRequest, ReturnItem pReturnItem, atg.core.util.Range pReturnRange)
          Calculates the share of the order level manual adjustments for the given item in the given range.
 void calculateNewAmounts(ReturnRequest pReturnRequest, java.util.Map pExtraParameters)
          This method will calculate new suggested and actual refund amounts, exchange order totals and promotion value adjustments based on the currently selected ReturnItems in the ReturnRequest.
protected  void calculateNewFinalPriceForRAOItem(ReturnRequest pReturnRequest, CommerceItem pRAOItem)
          Called for each item in the RAO that is marked as final and has a returned quantity gt 0.
protected  void calculateNewFinalPriceForRCOItem(ReturnRequest pReturnRequest, CommerceItem pRCOItem, ShippingGroup pShippingGroup, long pQuantityToReturn)
          Calculates a new final price for the given rco item based on the quantity being returned from the shipping group.
protected  double calculateOrderDiscountShare(ReturnRequest pReturnRequest, ReturnItem pReturnItem, atg.core.util.Range pReturnRange)
          Calculates the share of the item's order discount share for the given return item and range.
 void calculateRefundAmounts(ReturnRequest pReturnRequest, java.util.Map pExtraParameters)
          Executes the pipeline configured by the property calculateRefundAmountsPipelineChainId to calculate the refund amounts for the return
protected  double calculateRefundForItem(ReturnRequest pReturnRequest, ReturnItem pReturnItem, atg.core.util.Range pReturnRange)
          Calculates the refund for the given return item.
protected  double calculateReturnFee(ReturnRequest pReturnRequest)
          Calculate the suggested return fee for this request.
 void calculateReturnItemSuggestedRefunds(ReturnRequest pReturnRequest)
          Calculates the suggested refund amounts for the current set of selected ReturnItems.
protected  double calculateShareForRange(ReturnItem pReturnItem, DetailedItemPriceInfo pDetailedItemPriceInfo, atg.core.util.Range pRange, double pAmount)
          Calculates the share of the given amount for the given subset range within the given DetailedItemPriceInfo
protected  void calculateShippingCostShare(ReturnRequest pReturnRequest)
          This method is called at the start of calculating refund amounts for the return.
protected  java.util.Map calculateShippingCostShareMap(ReturnRequest pReturnRequest, Order pOrder)
          Generates a Map of ShippingGroupCommerceItemRelationship ids to their shipping share amount.
protected  double calculateShippingRefundForItem(ReturnRequest pReturnRequest, ReturnItem pReturnItem, atg.core.util.Range pReturnRange)
          Calculates the shipping refund for the given return item.
protected  double calculateShippingShareForRelationship(ReturnRequest pReturnRequest, ShippingGroupCommerceItemRelationship pShippingGroupCommerceItemRelationship, double pShippingGroupTotalAmount, java.util.Map pRelsAlreadyCalculated, long pTotalQuantityInShippingGroup, long pTotalQuantityAlreadyProcessed)
          This utility method is used when calculating the shipping group's share amount for a shipping group relationship.
protected  double calculateShippingShareForRelationship(ReturnRequest pReturnRequest, ShippingGroupCommerceItemRelationship pShippingGroupCommerceItemRelationship, java.util.Map pRelsAlreadyCalculated)
          Provides a default implementation for calculating the shipping cost share for a given ShippingGroupCommerceItemRelationship.
 void calculateSuggestedAmounts(ReturnRequest pReturnRequest)
          Deprecated. in favor of calculateRefundAmounts(ReturnRequest, Map)
protected  double calculateSuggestedRefundAmount(ReturnItem pReturnItem)
          Deprecated. in favor of calculateItemAmountShare
protected  void calculateSuggestedRefunds(ReturnRequest pReturnRequest, java.util.List pReturnItems)
          Calculates the item refund amounts for the given return items.
protected  double calculateTaxRefundForItem(ReturnRequest pReturnRequest, ReturnItem pReturnItem, atg.core.util.Range pReturnRange)
          Calculates the tax refund value for the given return item.
protected  void clearExchangeItemsFromPEO(ReturnRequest pReturnRequest)
          Removes all items from the promotion evaluation order that were created from the items in the new exchange order.
protected  void clearExchangeShippingGroupsFromPEO(ReturnRequest pReturnRequest)
          Removes all shipping groups from the promotion evaluation order that were created from the shipping groups in the new exchange order.
protected  void commitTransaction(javax.transaction.Transaction pTransaction)
          Commits the supplied transaction
 void confirmReturn(ReturnRequest pReturnRequest, java.util.Map pExtraParameters)
          Executes the process of confirmining a return by executing the confirm pipeline.
protected  void copyAgentFinalPriceInfoToPEO(ReturnRequest pReturnRequest)
          This method will determine if any items are marked as final in the exchange order and mark the corresponding items final in the peo using the same amount.
protected  void copyExchangeItemAndShippingGroupInfoToPEO(ReturnRequest pReturnRequest)
          This method makes a copy of each exchange item in the exchange order and puts them in the PEO.
 void copyPaymentGroups(ReturnRequest pReturnRequest, Order pSrcOrder, Order pDestinationOrder)
          This method copies the payment groups from the original order to the exchange order.
protected  java.util.Map createExchangeOrderCloningPropExceptionsMap()
          This method is a helper method which is used when cloning the exchange orders for the replacement items in the RAO.
protected  atg.commerce.csr.returns.ProcessPEOSynchronization createProcessPEOSynchronization(ReturnRequest pReturnRequest)
          Creates a new ProcessPEOSynchronization that's used to handle transaction rollback in the processPromotionEvaluationOrder method.
protected  Order createPromotionEvaluationOrder(ReturnRequest pReturnRequest)
          Creates the Promotion Evaluation Order for the exchange.
protected  java.util.Set createRefundMethods(ReturnRequest pReturnRequest)
          Create refund method items in the repository for the refund methods in a request.
 void createReplacementOrderPaymentGroups(ReturnRequest pReturnRequest)
          Creates the initial set of payment groups for the replacement order
 void createReplacementOrderShippingGroups(ReturnRequest pReturnRequest)
          Creates the initial set of shipping groups for the replacement order
protected  MutableRepositoryItem createRequestItem(ReturnRequest pReturnRequest, Profile pAgentProfile)
          Create a new return request entry in the database
protected  Order createReturnAdjustedOrder(ReturnRequest pReturnRequest)
          Creates the return adjusted order by cloning the originating order, adding all replacement items and shipping groups from all the exchange orders and re-prices.
protected  Order createReturnCalculationOrder(ReturnRequest pReturnRequest)
          Creates the Return Calculation Order by cloning the Return Adjusted Order in the ReturnRequest
 void createReturnItemList(ReturnRequest pReturnRequest)
          The ReturnRequest's returnItemList and returnItemMap are generated based on the ReturnItem objects with a quantityToProcess.
protected  java.util.Set createReturnItems(ReturnRequest pReturnRequest, java.lang.String pRequestId)
          Create records in the repository for the items in a request.
 ReturnRequest createReturnRequest(Order pOrder)
          Deprecated.  
 ReturnRequest createReturnRequest(Order pOrder, atg.commerce.csr.returns.ProcessName pProcessName, java.util.Map pExtraParameters)
          Creates a new return request object for the given Order.
 ReturnRequest createReturnRequest(java.lang.String pOrderId, atg.commerce.csr.returns.ProcessName pProcessName, java.util.Map pExtraParameters)
          Creates a ReturnRequest for the given order.
protected  MutableRepositoryItem createStoreCredit(java.lang.String pProfileId, double pAmount, java.util.Date pExpirationDate)
          Create a stored credit record.
protected  MutableRepositoryItem createStoreCredit(java.lang.String pProfileId, double pAmount, java.util.Date pExpirationDate, boolean pTransient)
          Create a stored credit record
 atg.commerce.csr.returns.ReturnPaymentState determineReturnPaymentValues(ReturnRequest pReturnRequest)
          Based on the current state of the return or exchange, rebuilds the return method list, generates store credits and sets the ReturnRequest returnPaymentState property.
protected  javax.transaction.Transaction ensureTransaction()
          This method ensures that a transaction exists before returning.
protected  GiftWithPurchaseSelection findMatchingRCOSelection(ReturnRequest pReturnRequest, CommerceItem pRCOCommerceItem, GiftWithPurchaseSelection pGiftWithPurchaseSelection)
          Returns the GiftWithPurchaseSelection from the given RCO item that matches the given GiftWithPurchaseSelection
 void generateDiscountableMap(ReturnRequest pReturnRequest)
          Generates the Map of discountable flags from the discountable state saved on the originating order and all replacement orders.
 java.util.Collection generateFilteredReturnRequestSelections(ReturnRequest pReturnRequest)
          Starting with the generated GiftWithPurchaseSelection objects for the ReturnRequest, create a new set of GiftWithPurchaseSelection objects that contains only those selections that still have remaining quantity after decrementing quantity for any targeted or selected quantity already in the exchange order.
 void generateGWPSelectionsForReturnItems(ReturnRequest pReturnRequest)
          Generates the order level GiftWithPurchaseSelection objects based on the item level GiftWithPurchaseSelection objects for each item being returned.
protected  ItemCostAdjustment generateItemComparisonAdjustment(ReturnRequest pReturnRequest, Order pOrder, Order pCounterpartOrder, java.lang.String pItemId, java.lang.String pCounterpartItemId, java.lang.String pShippingGroupId, java.lang.String pCounterpartShippingGroupId)
          Creates an ItemCostAdjustment by comparing pricing information of the given item and counterpart item.
 void generateItemCostAdjustments(ReturnRequest pReturnRequest)
          This method (re)generates the ItemCostAdjustment objects for each ReturnItem and non-return item in the ReturnRequest
protected  java.util.Map generateItemPriceSourceParameters(ReturnRequest pReturnRequest, Order pOrder)
          When generated item price source objects from the original and all replacement orders in the return, this method is called to generate the extra parameter map that gets passed to the api that generates the ItemPriceSource objects from the order.
 void generateItemPriceSources(ReturnRequest pReturnRequest)
          This method creates the list of <@link atg.commerce.pricing.ItemPriceSource> objects from the original order and all exchange orders in the return tree.
protected  java.util.Collection generateOrderComparisonAdjustments(ReturnRequest pReturnRequest, Order pOrder, Order pCorrespondingOrder, java.util.Map pItemToCorrespondingItemMap, java.util.Map pShippingGroupToCorrespondingShippingGroupMap)
          Generates a collection of ItemCostAdjustment objects based on pricing deltas between the order and the corresponding order.
protected  void generatePreReturnPromotionValueMap(ReturnRequest pReturnRequest)
          This method will generate pre return promotion value map and store it in the preReturnPromotionValue property of the ReturnRequest
protected  java.util.Collection generatePromotionEvaluationAdjustments(ReturnRequest pReturnRequest)
          Creates ItemCostAdjustment objects based on the pricing deltas between the return calculation and promotion evaluation orders.
protected  RefundMethod generateRefundMethodFromPaymentGroup(PaymentGroup pPaymentGroup)
          Generates a RefundMethod based on the given payment group.
protected  java.util.List<RefundMethod> generateRefundMethodsForReturn(ReturnRequest pReturnRequest)
          Generates refund methods based on the ReturnRequest originating order and all related replacement orders.
protected  java.util.List generateRefundMethodsFromOrder(Order pOrder)
          Generates a list of refund methods based on the given order
 void generateReplacementOrder(ReturnRequest pReturnRequest, java.util.Map pExtraParameters)
          Creates a new replacement order for the given ReturnRequest
protected  java.util.Collection generateReturnCalculationAdjustments(ReturnRequest pReturnRequest)
          Creates ItemCostAdjustment objects based on the pricing deltas between the return adjusted and return calculation orders.
protected  java.util.Collection generateShippingRefundAdjustments(ReturnRequest pReturnRequest)
          Creates ItemCostAdjustment objects for each ReturnItem in the ReturnRequest that detail the calculated shipping refund for each item being returned.
 java.util.Map generateSubmitReplacementOrderParameterMap(ReturnRequest pReturnRequest, java.util.Locale pLocale, java.util.Map pExtraParmeters)
          Generates the extra paremeter map used to submit the replacement order through the processOrder pipeline
 java.lang.String getAmountCreditedPropertyName()
          Returns the AmountCreditedPropertyName property
 java.lang.String getApplyRefundAllocationsPipelineChainId()
           
 java.lang.String getApplySelectedItemsPipelineChainId()
           
 java.lang.String getCalculateRefundAmountsPipelineChainId()
          The id of the pipeline used to calculate the refund for the return.
 ClaimableManager getClaimableManager()
           
 CloneEditManager getCloneEditManager()
          Returns a reference to the CloneEditManager used to generate the working orders.
 CommerceItemManager getCommerceItemManager()
           
 java.lang.String getConfirmReturnRequestPipelineChainId()
          Returns the name of the pipeline that is executed when a ReturnRequest is confirmed
 java.lang.String getCreatePromotionEvaluationOrderPipeline()
           
 java.lang.String getCreateReturnAdjustedOrderPipeline()
           
 java.lang.String getCreateReturnCalculationOrderPipeline()
           
 java.lang.String getCreateReturnRequestPipelineChainId()
          Returns the name of the pipeline that is executed when a ReturnRequest initially created
 java.lang.String getCreditCardType()
          Returns the creditCardType.
 double getDefaultReturnFee()
          Returns the fee associated with the return
 java.util.Properties getExchangeOrderExcludedProperties()
          Returns the excluded order properties
 java.util.Map getExchangeOrderExcludedPropertiesMap()
          returns the property ExchangeOrderExcludedPropertiesMap
 java.lang.String getGenerateReplacementOrderPipelineChainId()
          The id of the pipeline used to create the replacement order.
 java.lang.String getGiftCertificateType()
          Returns the giftCertificateType.
 InventoryManager getInventoryManager()
           
 double getMaximumRefundAmount(CreditCard pCreditCard)
          Returns the maximum amount that can be credited to pCreditCard
 double getMaximumRefundAmount(PaymentGroup pPaymentGroup)
          Returns the maximum refund amount that be credited to the given payment group.
 double getMaxStoreCreditRefundAmount(RepositoryItem pStoreCredit)
          Returns the maximum amount that can be credited to this store credit.
 OrderManager getOrderManager()
          Returns the order manager
 OrderStates getOrderStates()
          Returns the order states
 atg.commerce.csr.returns.PaymentGroupCopyManager getPaymentGroupCopyManager()
          Returns the paymentGroupCopyManager
 java.lang.String getPaymentGroupCopyManagerPath()
          Returns the paymentGroupCopyManagerPath.
 PaymentGroupManager getPaymentGroupManager()
          Returns the PaymentGroupManager to use in creating the StoreCredit.
 PaymentManager getPaymentManager()
           
 java.lang.String getPendingCustomerReturnOrderState()
           
 java.lang.String getPrepareReplacementOrderChainId()
          Returns the prepareReplacementOrderChainId
 PricingTools getPricingTools()
           
 java.util.HashMap getProcessOrderMap(java.util.Locale pLocale)
          Deprecated. in favor of generateSubmitReplacementOrderParameterMap(ReturnRequest, Locale, Map)
 Repository getProfileRepository()
           
protected  atg.core.util.Range getRangeWithinDetail(DetailedItemPriceInfo pDetailedItemPriceInfo, atg.core.util.Range pRange)
          Determines the range of the DetailedItemPriceInfo that is included in the given range.
 java.lang.String getReceiveItemPipelineChainId()
           
protected  RefundMethod getRefundAmountRemaningRefundMethod()
          This method is called by the refund allocation process to return a refund method where any unallocated refund amount can be allocated.
 atg.commerce.csr.returns.ReturnEventMessageSource getReturnEventMessageSource()
           
 ReturnItemStates getReturnItemStates()
          Returns the returned item states
static ReturnManager getReturnManager()
          Returns the ReturnManager component.
 ReturnStates getReturnStates()
           
 ReturnTools getReturnTools()
           
 java.lang.String getSalesChannel()
          Returns the salesChannel.
 java.lang.String getSettleReturnRequestPipelineChainId()
           
 ShippingGroupManager getShippingGroupManager()
          Returns the ShippingGroup manager
 java.lang.String getStoreCreditType()
          Returns the PaymentGroup type used to create StoreCredits.
 java.lang.String getSubmitReplacementOrderPipelineChainId()
          Returns the pipeline used to submit a replacement order to fulfillment
 javax.transaction.TransactionManager getTransactionManager()
          Returns the transaction manager to use
 void initializeRefundMethodList(ReturnRequest pReturnRequest)
          Initializes the refund methods based on the total refund amount in the ReturnRequest
 void initializeReplacementOrderGWPMetaData(ReturnRequest pReturnRequest)
          Initializes the GWP meta-data on the replacement Order needed for exchanging gifts.
 void initPreReturnPromotionValues(ReturnRequest pReturnRequest)
           
 void initReturnAdjustedOrder(ReturnRequest pReturnRequest)
          Creates a new Return Adjusted Order in the ReturnRequest
 void initReturnCalculationOrder(ReturnRequest pReturnRequest)
          Creates a new Return Calculation Order in the ReturnRequest
 void initShippingCostShares(ReturnRequest pReturnRequest)
          Creates the shipping cost share map in the ReturnRequest
 void instantiateReplacementOrder(ReturnRequest pReturnRequest)
          Creates a new order using OrderManager and places it in the ReturnRequest's replacementOrder property.
 boolean isDoShippingRefunds()
          The flag determines if shipping refunds are calculated.
 boolean isInitializeActualShippingRefund()
          The flag determines if the actual shipping refund on the ReturnRequest and each ReturnItem is initialized from the suggested values.
protected  boolean isOrderPaymentGroupsAuthorized(Order pOrder)
          If any of the payment groups have non empty authorization status, then the payment groups in the order are considered to be already authorized.
 boolean isProcessImmediately()
          returns the 'process immediately' setting
 boolean isReadyForSettlement(ReturnRequest pReturnRequest)
          Returns true if the ReturnRequest is ready for settlement (e.g.
 void issueAlternateCreditType(Order pOrder, ReturnRequest pReturnRequest, java.util.Vector pCredits, java.lang.String pProfileId, RefundMethod pRefundMethod, double pRefundAmount)
          This method is called by {@link #issueCredits(Order, ReturnRequest) to settle the credit on a RefundMethod type that is not handled by the core implementation
protected  java.util.List issueCredits(Order pOrder, ReturnRequest pReturnRequest)
          Settles the credits for each RefundMethod in the return.
protected  boolean isTransactionMarkedAsRollBack()
          Returns true if the transaction associated with the current thread is marked for roll back.
 boolean isValidExchangeRefundValue(ReturnRequest pReturnRequest)
          determines if the refund value is appropriate for an exchange.
 boolean isValidRefundValue(ReturnRequest pReturnRequest)
          Deprecated. use isValidExchangeRefundValue and isValidReturnRefundValue
 boolean isValidReturnRefundValue(ReturnRequest pReturnRequest)
          determines if the refund value is appropriate for a return.
 void markReturnRequestAsProcessed(ReturnRequest pReturnRequest)
          Sets the processed property to true.
protected  Order prepareReplacementOrder(ReturnRequest pReturnRequest)
          Deprecated. in favor of generateReplacementOrder(ReturnRequest, Map)
protected  void prepareReplacementOrderToSubmit(ReturnRequest pReturnRequest)
           
 void prepareReplacementOrderToSubmit(ReturnRequest pReturnRequest, java.util.Map pExtraParameters)
          Executes the pre-submission process on the replacement order.
 void processPromotionEvaluationOrder(ReturnRequest pReturnRequest)
          This method is called whenever the exchange order is priced.
protected  void processRequest(Order pOrder, ReturnRequest pReturnRequest)
          Deprecated. in favor of settleReturnRequest(ReturnRequest, String, Map)
 void processSelectedReturnItems(ReturnRequest pReturnRequest)
          Deprecated. in favor of applySelectedItems(ReturnRequest, ProcessName, Map)
 void recordMerchandiseReturn(ReturnRequest pReturnRequest, ReturnItem pReturnItem, long pQuantityReceived, java.lang.String pDisposition, java.util.Map pExtraParameters)
          Record the receipt of returned merchandise
 void recordMerchandiseReturn(java.lang.String pReturnRequestId, java.util.Map<java.lang.String,java.lang.Long> pQuantityBeingReceived, java.util.Map<java.lang.String,java.lang.String> pDispositionReceived, java.util.Map pExtraParameters)
          Records a batch of items being received.
 void registerProcessPEOSynchronization(ReturnRequest pReturnRequest)
          Registers a synchronization object that will invalidate the promotion evaluation order and reset the item and shipping group maps used to map peo objects to the exchange order objects when the transaction is rolled back.
protected  void removeGWPMetaDataFromExchangeOrder(ReturnRequest pReturnRequest)
          Removes all gwp meta-data from the exchange order
protected  void resetCommerceIds(ReturnRequest pReturnRequest, java.util.Collection pAdjustments)
          Updates each adjustment's commerce item id and shipping group id to reference the original commerce item and shipping group id.
 void resetGWPMetaData(ReturnRequest pReturnRequest)
          Resets the GWP meta-data for determining GWP selections and removes all GWP meta-data from the exchange order.
 void resetPromotionEvaluationProperties(ReturnRequest pReturnRequest)
          Resets all ReturnRequest properties generated from the processing the promotion evaluation order.
 void resetRefundAmounts(ReturnRequest pReturnRequest)
          Resets the suggested and actual refund amounts in the ReturnRequest and selected ReturnItems to 0.
 void resetReplacementOrderProperties(ReturnRequest pReturnRequest, java.util.Map pExtraParameters)
          This method will reset the replacement order and generated store credit values of the ReturnRequest.
protected  void resetReturnRequestForCurrentProcess(ReturnRequest pReturnRequest, atg.commerce.csr.returns.ProcessName pNewProcessName, java.util.Map pExtraParameters)
          This method will reset the properties of the ReturnRequest based on the value of the processName property.
 void returnCommerceItems(ReturnRequest pReturnRequest)
          Calls {@link CommerceItemManager#returnCommerceItem(Order, String, String, long)) for each ReturnItem in the ReturnRequest
 void saveReturnRequest(ReturnRequest pReturnRequest, Profile pAgentProfile)
          Deprecated. in favor of confirmReturn(ReturnRequest, Map)
 void saveReturnRequestToRepository(ReturnRequest pReturnRequest)
          Adds the necessary repository items for saving the ReturnRequest and sets the requestId property of the ReturnRequest
 void sendReturnCompletedEvent(ReturnRequest pReturnRequest)
          Sends the event that indicates a return has been completed.
 void sendReturnMerchandiseReceivedEvent(ReturnRequest pReturnRequest, java.util.Map<java.lang.String,java.lang.Long> pReturnItemToQuantityReceived, java.util.Map<java.lang.String,java.lang.String> pReturnItemToReceivedDisposition)
          Sends the event that indicates returned merchandise has been received.
 void sendReturnSubmittedEvent(ReturnRequest pReturnRequest)
          Sends the event the indicated a new return has been submitted.
 void setActualRefundsFromSuggestedRefunds(ReturnRequest pReturnRequest)
          Sets the actual refumds amounts for the ReturnRequest and each selected ReturnItem.
 void setApplyRefundAllocationsPipelineChainId(java.lang.String pApplyRefundAllocationsPipelineChainId)
           
 void setApplySelectedItemsPipelineChainId(java.lang.String pApplySelectedItemsPipelineChainId)
           
 void setCalculateRefundAmountsPipelineChainId(java.lang.String pCalculateRefundAmountsPipelineChainId)
           
 void setClaimableManager(ClaimableManager pClaimableManager)
          Sets the Claimable manager
 void setCloneEditManager(CloneEditManager pCloneEditManager)
           
 void setCommerceItemManager(CommerceItemManager pCommerceItemManager)
          Sets the CommerceItem manager
 void setConfirmReturnRequestPipelineChainId(java.lang.String pConfirmReturnRequestPipelineChainId)
           
 void setCreatePromotionEvaluationOrderPipeline(java.lang.String pCreatePromotionEvaluationOrderPipeline)
          Sets the name of the pipeline used to generate the Promotion Evaluation Order
 void setCreateReturnAdjustedOrderPipeline(java.lang.String pCreateReturnAdjustedOrderPipeline)
          Sets the name of the pipeline used to generate the Return Adjusted Order
 void setCreateReturnCalculationOrderPipeline(java.lang.String pCreateReturnCalculationOrderPipeline)
          Sets the name of the pipeline used to generate the Return Calculation Order
 void setCreateReturnRequestPipelineChainId(java.lang.String pCreateReturnRequestPipelineChainId)
           
 void setCreditCardType(java.lang.String pCreditCardType)
          Sets the creditCardType.
 void setDefaultReturnFee(double pDefaultReturnFee)
          Sets the default fee associated with a return
 void setDoShippingRefunds(boolean pDoShippingRefunds)
           
 void setExchangeOrderExcludedProperties(java.util.Properties pExchangeOrderExcludedProperties)
          set the property ExchangeOrderExcludedProperties
 void setGenerateReplacementOrderPipelineChainId(java.lang.String pGenerateReplacementOrderPipelineChainId)
           
 void setGiftCertificateType(java.lang.String pGiftCertificateType)
          Sets the giftCertificateType.
 void setInitializeActualShippingRefund(boolean pInitializeActualShippingRefund)
           
 void setInventoryManager(InventoryManager pInventoryManager)
          Sets the inventory manager
 void setOrderManager(OrderManager pOrderManager)
          Sets the order manager
 void setOrderStates(OrderStates pOrderStates)
          Sets the order states
 void setPaymentGroupCopyManager(atg.commerce.csr.returns.PaymentGroupCopyManager pPaymentGroupCopyManager)
          Sets the paymentGroupCopyManager
 void setPaymentGroupCopyManagerPath(java.lang.String pPaymentGroupCopyManagerPath)
          Sets the paymentGroupCopyManagerPath.
 void setPaymentGroupManager(PaymentGroupManager pPaymentGroupManager)
          Specifies the PaymentGroupManager to use in creating the StoreCredit.
 void setPaymentManager(PaymentManager pPaymentManager)
          Sets the payment manager
 void setPendingCustomerReturnOrderState(java.lang.String pPendingCustomerReturnOrderState)
          Sets the state that indicates that processing of the order is pending a customer return
 void setPrepareReplacementOrderChainId(java.lang.String pPrepareReplacementOrderChainId)
          Sets the prepareReplacementOrderChainId
 void setPricingTools(PricingTools pPricingTools)
          sets the pricing tools component
 void setProcessImmediately(boolean pProcessImmediately)
          sets the 'process immediately' setting
 void setProfileRepository(Repository pProfileRepository)
          Sets the repository
 void setReceiveItemPipelineChainId(java.lang.String pReceiveItemPipelineChainId)
           
 void setReturnEventMessageSource(atg.commerce.csr.returns.ReturnEventMessageSource pReturnEventMessageSource)
           
 void setReturnFee(ReturnRequest pReturnRequest)
          Sets the return fee value for the request.
 void setReturnItemStates(ReturnItemStates pReturnItemStates)
          Sets the returned item states
 void setReturnPaymentState(ReturnRequest pReturnRequest)
          Deprecated. This value is now determined by ReturnRequest.getReturnPaymentState()
 void setReturnShipmentRequiredForReturnItem(ReturnItem pReturnItem, ReturnRequest pReturnRequest)
          This method sets the returnShipmentRequired property of the ReturnItem.
 void setReturnStates(ReturnStates pReturnStates)
          Sets the return request states
 void setReturnTools(ReturnTools pReturnTools)
          Sets the return tools
 void setSalesChannel(java.lang.String pSalesChannel)
          Sets the salesChannel.
 void setSettleReturnRequestPipelineChainId(java.lang.String pSettleReturnRequestPipelineChainId)
           
 void setShippingGroupManager(ShippingGroupManager pShippingGroupManager)
          Sets the ShippingGroup manager
 void setStoreCreditType(java.lang.String pStoreCreditType)
          Specifies the PaymentGroup type used to create StoreCredits.
 void setSubmitReplacementOrderPipelineChainId(java.lang.String pSubmitReplacementOrderPipelineChainId)
           
 void setSuggestedAmountsFromItems(ReturnRequest pReturnRequest)
          Sets the suggested shipping and tax amounts in the ReturnRequest based on the suggested amounts in the selected ReturnItems.
 java.util.List settleCredits(ReturnRequest pReturnRequest)
          Settles the credit (refunds) for the RefundMethods in the return request.
 void settleReturnRequest(ReturnRequest pReturnRequest, java.lang.String pSettleReturnRequestPipelineChainId, java.util.Map pExtraParameters)
          Executes the pipeline to settle the return request.
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Sets the transaction manager to use
protected  java.lang.String stateToString(ObjectStates pObjectStates, java.lang.String pStateString)
          Convert a state string
 void submitReplacementOrder(ReturnRequest pReturnRequest, java.util.Map pExtraParameters)
          Submits the replacement order for fulfillment processing
 void updateAmountOfStoreCredits(ReturnRequest pReturnRequest)
          The List of refund methods can include up to two StoreCreditRefundMethods, which are automatically created for the return or exchange.
 void updateInventoryOnReceive(ReturnRequest pReturnRequest, ReturnItem pReturnItem, long pQuantityReceived)
          Updates the inventory based on the item being received
protected  void updatePromotionEvaluationOrder(ReturnRequest pReturnRequest)
          This method does the work of updating the Promotion Evaluation Order.
 void updateReplacementOrderStateOnConfirm(ReturnRequest pReturnRequest)
          Sets the state of the replacement order when a return request is confirmed
 void updateReturnItemOnReceive(ReturnRequest pReturnRequest, ReturnItem pReturnItem, long pQuantityReceived, java.lang.String pDisposition)
          Updates the given ReturnItem on receive.
protected  boolean updateReturnItemState(ReturnItem pReturnItem)
          Update the state of a returned item based on its current quantity values and its returnShipmentRequired value.
protected  boolean updateReturnState(ReturnRequest pReturnRequest)
          Review the state of all items in a return request and update the state of the return, if necessary.
 boolean updateStateFromReturnItemState(ReturnRequest pReturnRequest)
          Updates the state of the ReturnRequest based on the state of the ReturnItems
 void updateStateOfReturnItems(ReturnRequest pReturnRequest)
          Iterates over the ReturnItems and sets their state based on their current values.
 void updateStoreCreditAmount(atg.commerce.csr.returns.StoreCreditRefundMethod pStoreCreditRefundMethod, java.util.List pRefundMethodsList, ReturnRequest pReturnRequest)
          Adjusts the amount of the store credit claimable to match the amount in the StoreCreditRefundMethod.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


mReturnEventMessageSource

protected atg.commerce.csr.returns.ReturnEventMessageSource mReturnEventMessageSource

mPrepareReplacementOrderChainId

protected java.lang.String mPrepareReplacementOrderChainId

sResourceBundle

protected static java.util.ResourceBundle sResourceBundle

mGenerateReplacementOrderPipelineChainId

protected java.lang.String mGenerateReplacementOrderPipelineChainId

mCalculateRefundAmountsPipelineChainId

protected java.lang.String mCalculateRefundAmountsPipelineChainId

mApplySelectedItemsPipelineChainId

protected java.lang.String mApplySelectedItemsPipelineChainId

mApplyRefundAllocationsPipelineChainId

protected java.lang.String mApplyRefundAllocationsPipelineChainId

mReceiveItemPipelineChainId

protected java.lang.String mReceiveItemPipelineChainId

mSettleReturnRequestPipelineChainId

protected java.lang.String mSettleReturnRequestPipelineChainId

mSubmitReplacementOrderPipelineChainId

protected java.lang.String mSubmitReplacementOrderPipelineChainId

mConfirmReturnRequestPipelineChainId

protected java.lang.String mConfirmReturnRequestPipelineChainId

mCreateReturnRequestPipelineChainId

protected java.lang.String mCreateReturnRequestPipelineChainId

mCreateReturnAdjustedOrderPipeline

protected java.lang.String mCreateReturnAdjustedOrderPipeline

mCreateReturnCalculationOrderPipeline

protected java.lang.String mCreateReturnCalculationOrderPipeline

mCreatePromotionEvaluationOrderPipeline

protected java.lang.String mCreatePromotionEvaluationOrderPipeline

mExchangeOrderExcludedProperties

protected java.util.Properties mExchangeOrderExcludedProperties

mExchangeOrderExcludedPropertiesMap

protected java.util.Map mExchangeOrderExcludedPropertiesMap

mSalesChannel

protected java.lang.String mSalesChannel

mProcessImmediately

protected boolean mProcessImmediately

mDoShippingRefunds

protected boolean mDoShippingRefunds

mInitializeActualShippingRefund

protected boolean mInitializeActualShippingRefund

mPaymentGroupCopyManager

protected atg.commerce.csr.returns.PaymentGroupCopyManager mPaymentGroupCopyManager

mGiftCertificateType

protected java.lang.String mGiftCertificateType

mCreditCardType

protected java.lang.String mCreditCardType

mAmountCreditedPropertyName

protected java.lang.String mAmountCreditedPropertyName

mClaimableManager

protected ClaimableManager mClaimableManager

mCommerceItemManager

protected CommerceItemManager mCommerceItemManager

mDefaultReturnFee

protected double mDefaultReturnFee

mInventoryManager

protected InventoryManager mInventoryManager

mOrderManager

protected OrderManager mOrderManager

mOrderStates

protected OrderStates mOrderStates

mPaymentGroupManager

protected PaymentGroupManager mPaymentGroupManager

mPaymentManager

protected PaymentManager mPaymentManager

mPendingCustomerReturnOrderState

protected java.lang.String mPendingCustomerReturnOrderState

mPricingTools

protected PricingTools mPricingTools

mProfileRepository

protected Repository mProfileRepository

mReturnItemStates

protected ReturnItemStates mReturnItemStates

mReturnTools

protected ReturnTools mReturnTools

mReturnStates

protected ReturnStates mReturnStates

mShippingGroupManager

protected ShippingGroupManager mShippingGroupManager

mStoreCreditType

protected java.lang.String mStoreCreditType

mTransactionManager

protected javax.transaction.TransactionManager mTransactionManager

mReturnManager

protected static ReturnManager mReturnManager

mReturnManagerComponentPath

public static java.lang.String mReturnManagerComponentPath
Constructor Detail

ReturnManager

public ReturnManager()
Method Detail

getReturnEventMessageSource

public atg.commerce.csr.returns.ReturnEventMessageSource getReturnEventMessageSource()

setReturnEventMessageSource

public void setReturnEventMessageSource(atg.commerce.csr.returns.ReturnEventMessageSource pReturnEventMessageSource)

getPrepareReplacementOrderChainId

public java.lang.String getPrepareReplacementOrderChainId()
Returns the prepareReplacementOrderChainId

Returns:
the prepareReplacementOrderChainId

setPrepareReplacementOrderChainId

public void setPrepareReplacementOrderChainId(java.lang.String pPrepareReplacementOrderChainId)
Sets the prepareReplacementOrderChainId

Parameters:
pPrepareReplacementOrderChainId - the prepareReplacementOrderChainId to set

getGenerateReplacementOrderPipelineChainId

public java.lang.String getGenerateReplacementOrderPipelineChainId()
The id of the pipeline used to create the replacement order.


setGenerateReplacementOrderPipelineChainId

public void setGenerateReplacementOrderPipelineChainId(java.lang.String pGenerateReplacementOrderPipelineChainId)

getCalculateRefundAmountsPipelineChainId

public java.lang.String getCalculateRefundAmountsPipelineChainId()
The id of the pipeline used to calculate the refund for the return.


setCalculateRefundAmountsPipelineChainId

public void setCalculateRefundAmountsPipelineChainId(java.lang.String pCalculateRefundAmountsPipelineChainId)

getApplySelectedItemsPipelineChainId

public java.lang.String getApplySelectedItemsPipelineChainId()
Returns:
the name of the pipeline that is executed when applying the selected items for return

setApplySelectedItemsPipelineChainId

public void setApplySelectedItemsPipelineChainId(java.lang.String pApplySelectedItemsPipelineChainId)

getApplyRefundAllocationsPipelineChainId

public java.lang.String getApplyRefundAllocationsPipelineChainId()
Returns:
the name of the pipeline that is executed when applying the refund method allocations

setApplyRefundAllocationsPipelineChainId

public void setApplyRefundAllocationsPipelineChainId(java.lang.String pApplyRefundAllocationsPipelineChainId)

getReceiveItemPipelineChainId

public java.lang.String getReceiveItemPipelineChainId()
Returns:
the name of the pipeline that is executed when a ReturnItem is received

setReceiveItemPipelineChainId

public void setReceiveItemPipelineChainId(java.lang.String pReceiveItemPipelineChainId)

getSettleReturnRequestPipelineChainId

public java.lang.String getSettleReturnRequestPipelineChainId()
Returns:
the name of the pipeline that is executed when the ReturnRequest is settled (e.g. credits issued and submission of the exchange order)

setSettleReturnRequestPipelineChainId

public void setSettleReturnRequestPipelineChainId(java.lang.String pSettleReturnRequestPipelineChainId)

getSubmitReplacementOrderPipelineChainId

public java.lang.String getSubmitReplacementOrderPipelineChainId()
Returns the pipeline used to submit a replacement order to fulfillment

Returns:

setSubmitReplacementOrderPipelineChainId

public void setSubmitReplacementOrderPipelineChainId(java.lang.String pSubmitReplacementOrderPipelineChainId)

getConfirmReturnRequestPipelineChainId

public java.lang.String getConfirmReturnRequestPipelineChainId()
Returns the name of the pipeline that is executed when a ReturnRequest is confirmed

Returns:

setConfirmReturnRequestPipelineChainId

public void setConfirmReturnRequestPipelineChainId(java.lang.String pConfirmReturnRequestPipelineChainId)

getCreateReturnRequestPipelineChainId

public java.lang.String getCreateReturnRequestPipelineChainId()
Returns the name of the pipeline that is executed when a ReturnRequest initially created

Returns:

setCreateReturnRequestPipelineChainId

public void setCreateReturnRequestPipelineChainId(java.lang.String pCreateReturnRequestPipelineChainId)

getCreateReturnAdjustedOrderPipeline

public java.lang.String getCreateReturnAdjustedOrderPipeline()
Returns:
the name of the pipeline used to generate the Return Adjusted Order

setCreateReturnAdjustedOrderPipeline

public void setCreateReturnAdjustedOrderPipeline(java.lang.String pCreateReturnAdjustedOrderPipeline)
Sets the name of the pipeline used to generate the Return Adjusted Order


getCreateReturnCalculationOrderPipeline

public java.lang.String getCreateReturnCalculationOrderPipeline()
Returns:
the name of the pipeline used to generate the Return Calculation Order

setCreateReturnCalculationOrderPipeline

public void setCreateReturnCalculationOrderPipeline(java.lang.String pCreateReturnCalculationOrderPipeline)
Sets the name of the pipeline used to generate the Return Calculation Order


getCreatePromotionEvaluationOrderPipeline

public java.lang.String getCreatePromotionEvaluationOrderPipeline()
Returns:
the name of the pipeline used to generate the Promotion Evaluation Order

setCreatePromotionEvaluationOrderPipeline

public void setCreatePromotionEvaluationOrderPipeline(java.lang.String pCreatePromotionEvaluationOrderPipeline)
Sets the name of the pipeline used to generate the Promotion Evaluation Order


getCloneEditManager

public CloneEditManager getCloneEditManager()
Returns a reference to the CloneEditManager used to generate the working orders.


setCloneEditManager

public void setCloneEditManager(CloneEditManager pCloneEditManager)

setExchangeOrderExcludedProperties

public void setExchangeOrderExcludedProperties(java.util.Properties pExchangeOrderExcludedProperties)
set the property ExchangeOrderExcludedProperties

Parameters:
pExchangeOrderExcludedProperties - the value to set for property ExchangeOrderExcludedProperties

getExchangeOrderExcludedProperties

public java.util.Properties getExchangeOrderExcludedProperties()
Returns the excluded order properties


getExchangeOrderExcludedPropertiesMap

public java.util.Map getExchangeOrderExcludedPropertiesMap()
returns the property ExchangeOrderExcludedPropertiesMap

Returns:
returns property ExchangeOrderExcludedProperties

getSalesChannel

public java.lang.String getSalesChannel()
Returns the salesChannel.

Returns the sales channel which is used to submit the order. This could be "Web", "Call Center",
or "Scheduled Orders". These values are defined in the order repository.

Returns:
salesChannel

setSalesChannel

public void setSalesChannel(java.lang.String pSalesChannel)
Sets the salesChannel.

Sets the sales channel which is used to submit the order. This could be "Web", "Call Center",
or "Scheduled Orders". These values are defined in the order repository.

Parameters:
pSalesChannel -

setProcessImmediately

public void setProcessImmediately(boolean pProcessImmediately)
sets the 'process immediately' setting

Parameters:
pProcessImmediately - a boolean indicating if this request should be processed immediately

isProcessImmediately

public boolean isProcessImmediately()
returns the 'process immediately' setting


isDoShippingRefunds

public boolean isDoShippingRefunds()
The flag determines if shipping refunds are calculated. If false the suggested refund amounts are always zero.

Default is true

Returns:
true if suggested shipping refunds are calculated for returns

setDoShippingRefunds

public void setDoShippingRefunds(boolean pDoShippingRefunds)

isInitializeActualShippingRefund

public boolean isInitializeActualShippingRefund()
The flag determines if the actual shipping refund on the ReturnRequest and each ReturnItem is initialized from the suggested values.

Default is true

Returns:
true if suggested shipping refunds are calculated for returns

setInitializeActualShippingRefund

public void setInitializeActualShippingRefund(boolean pInitializeActualShippingRefund)

getPaymentGroupCopyManagerPath

public java.lang.String getPaymentGroupCopyManagerPath()
Returns the paymentGroupCopyManagerPath.

Returns:
paymentGroupCopyManagerPath

setPaymentGroupCopyManagerPath

public void setPaymentGroupCopyManagerPath(java.lang.String pPaymentGroupCopyManagerPath)
Sets the paymentGroupCopyManagerPath.

Parameters:
pPaymentGroupCopyManagerPath -

getGiftCertificateType

public java.lang.String getGiftCertificateType()
Returns the giftCertificateType.

Returns:
giftCertificateType

setGiftCertificateType

public void setGiftCertificateType(java.lang.String pGiftCertificateType)
Sets the giftCertificateType.

Parameters:
pGiftCertificateType -

getCreditCardType

public java.lang.String getCreditCardType()
Returns the creditCardType.

Returns:
creditCardType

setCreditCardType

public void setCreditCardType(java.lang.String pCreditCardType)
Sets the creditCardType.

Parameters:
pCreditCardType -

getAmountCreditedPropertyName

public java.lang.String getAmountCreditedPropertyName()
Returns the AmountCreditedPropertyName property

Returns:
the value of the amount credited property name

setClaimableManager

public void setClaimableManager(ClaimableManager pClaimableManager)
Sets the Claimable manager

Parameters:
pClaimableManager - the claimable manager

getClaimableManager

public ClaimableManager getClaimableManager()
Returns:
the Claimable manager

setCommerceItemManager

public void setCommerceItemManager(CommerceItemManager pCommerceItemManager)
Sets the CommerceItem manager

Parameters:
pCommerceItemManager - the commerce item manager

getCommerceItemManager

public CommerceItemManager getCommerceItemManager()
Returns:
the CommerceItem manager

setDefaultReturnFee

public void setDefaultReturnFee(double pDefaultReturnFee)
Sets the default fee associated with a return

Parameters:
pDefaultReturnFee - the default fee associated with a return

getDefaultReturnFee

public double getDefaultReturnFee()
Returns the fee associated with the return


setInventoryManager

public void setInventoryManager(InventoryManager pInventoryManager)
Sets the inventory manager

Parameters:
pInventoryManager - the inventory manager

getInventoryManager

public InventoryManager getInventoryManager()
Returns:
the inventory manager

setOrderManager

public void setOrderManager(OrderManager pOrderManager)
Sets the order manager

Parameters:
pOrderManager - the order manager

getOrderManager

public OrderManager getOrderManager()
Returns the order manager


setOrderStates

public void setOrderStates(OrderStates pOrderStates)
Sets the order states

Parameters:
pOrderStates - the order states

getOrderStates

public OrderStates getOrderStates()
Returns the order states


setPaymentGroupManager

public void setPaymentGroupManager(PaymentGroupManager pPaymentGroupManager)
Specifies the PaymentGroupManager to use in creating the StoreCredit.

Parameters:
pPaymentGroupManager - a PaymentGroupManager value

getPaymentGroupManager

public PaymentGroupManager getPaymentGroupManager()
Returns the PaymentGroupManager to use in creating the StoreCredit.

Returns:
a PaymentGroupManager value

setPaymentManager

public void setPaymentManager(PaymentManager pPaymentManager)
Sets the payment manager

Parameters:
pPaymentManager - the payment manager

getPaymentManager

public PaymentManager getPaymentManager()
Returns:
the payment manager

setPendingCustomerReturnOrderState

public void setPendingCustomerReturnOrderState(java.lang.String pPendingCustomerReturnOrderState)
Sets the state that indicates that processing of the order is pending a customer return

Parameters:
pPendingCustomerReturnOrderState - the state that indicates that processing of the order is pending a customer return

getPendingCustomerReturnOrderState

public java.lang.String getPendingCustomerReturnOrderState()
Returns:
the state that indicates that processing of the order is pending a customer return

setPricingTools

public void setPricingTools(PricingTools pPricingTools)
sets the pricing tools component

Parameters:
pPricingTools - the pricing tools component

getPricingTools

public PricingTools getPricingTools()
Returns:
the pricing tools component

setProfileRepository

public void setProfileRepository(Repository pProfileRepository)
Sets the repository

Parameters:
pProfileRepository - the profile repository

getProfileRepository

public Repository getProfileRepository()
Returns:
the profile repository

setReturnItemStates

public void setReturnItemStates(ReturnItemStates pReturnItemStates)
Sets the returned item states

Parameters:
pReturnItemStates - the returned item states

getReturnItemStates

public ReturnItemStates getReturnItemStates()
Returns the returned item states


setReturnTools

public void setReturnTools(ReturnTools pReturnTools)
Sets the return tools

Parameters:
pReturnTools - the return tools

getReturnTools

public ReturnTools getReturnTools()
Returns:
the return tools

setReturnStates

public void setReturnStates(ReturnStates pReturnStates)
Sets the return request states

Parameters:
pReturnStates - the return request states

getReturnStates

public ReturnStates getReturnStates()
Returns:
the return request states

setShippingGroupManager

public void setShippingGroupManager(ShippingGroupManager pShippingGroupManager)
Sets the ShippingGroup manager

Parameters:
pShippingGroupManager - the shipping group manager

getShippingGroupManager

public ShippingGroupManager getShippingGroupManager()
Returns the ShippingGroup manager


setStoreCreditType

public void setStoreCreditType(java.lang.String pStoreCreditType)
Specifies the PaymentGroup type used to create StoreCredits.

Parameters:
pStoreCreditType - a String value

getStoreCreditType

public java.lang.String getStoreCreditType()
Returns the PaymentGroup type used to create StoreCredits.

Returns:
a String value

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Sets the transaction manager to use

Parameters:
pTransactionManager - the transaction manager

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Returns the transaction manager to use


setPaymentGroupCopyManager

public void setPaymentGroupCopyManager(atg.commerce.csr.returns.PaymentGroupCopyManager pPaymentGroupCopyManager)
Sets the paymentGroupCopyManager

Parameters:
pPaymentGroupCopyManager - the paymentGroupCopyManager to set

getPaymentGroupCopyManager

public atg.commerce.csr.returns.PaymentGroupCopyManager getPaymentGroupCopyManager()
Returns the paymentGroupCopyManager

Returns:
PaymentGroupCopyManager

applyStoreCredit

public void applyStoreCredit(ReturnRequest pReturnRequest)
                      throws CommerceException
Deprecated. 

This method takes the StoreCredit RefundMethod in the return request, creates
PaymentGroup based on it, and adds it to the replacement order

Parameters:
pReturnRequest - the return request
Throws:
CommerceException

initializeRefundMethodList

public void initializeRefundMethodList(ReturnRequest pReturnRequest)
                                throws ReturnException
Initializes the refund methods based on the total refund amount in the ReturnRequest

Parameters:
pReturnRequest -
Throws:
ReturnException
See Also:
buildRefundMethodList(ReturnRequest, double), applyExchangeProcessPayments(ReturnRequest)

resetReturnRequestForCurrentProcess

protected void resetReturnRequestForCurrentProcess(ReturnRequest pReturnRequest,
                                                   atg.commerce.csr.returns.ProcessName pNewProcessName,
                                                   java.util.Map pExtraParameters)
                                            throws ReturnException
This method will reset the properties of the ReturnRequest based on the value of the processName property.

Parameters:
pReturnRequest - The ReturnRequest
pNewProcessName - Optional new ProcessName to use. The ReturnRequest processName property will be set to the this value before resetting any other ReturnRequest values.
pExtraParameters -
Throws:
ReturnException
See Also:
resetReplacementOrderProperties(ReturnRequest, Map), resetPromotionEvaluationProperties(ReturnRequest)

buildRefundMethodList

protected void buildRefundMethodList(ReturnRequest pReturnRequest,
                                     double pStoreCreditAmount)
                              throws ReturnException
Populate the refund methods list for the given return request

Parameters:
pReturnRequest -
pStoreCreditAmount -
Throws:
ReturnException

buildRefundMethodList

protected void buildRefundMethodList(Order pOriginalOrder,
                                     ReturnRequest pReturnRequest,
                                     double pStoreCreditAmount,
                                     double pTotalRefundAmount)
                              throws ReturnException
Populate the refund methods list for the given return request

This method uses generateRefundMethodsForReturn(ReturnRequest) to generate all refund methods from an order.

After generating refund methods, this method calls allocateRefundAmountForReturn(Order, ReturnRequest, double, Collection) to distribute the refund amount to the given refund methods. If the refund amount is not fully allocated and there is any remaining amount, then remaining refund amount is added to the getRefundAmountRemaningRefundMethod().

If the pStoreCreditAmount is greater than zero, then the store credit refund amount is added to the getRefundAmountRemaningRefundMethod(). In that case the getRefundAmountRemaningRefundMethod() should return StoreCreditRefundMethod.

Parameters:
pOriginalOrder -
pReturnRequest -
pStoreCreditAmount -
pTotalRefundAmount - The total refund amount to be allocated
Throws:
ReturnException - if the refund amount is not fully allocated to the refund methods then this exception is thrown.
See Also:
allocateRefundAmountForReturn(Order, ReturnRequest, double, Collection), generateRefundMethodsForReturn(ReturnRequest), getRefundAmountRemaningRefundMethod()

getRefundAmountRemaningRefundMethod

protected RefundMethod getRefundAmountRemaningRefundMethod()
                                                    throws ReturnException
This method is called by the refund allocation process to return a refund method where any unallocated refund amount can be allocated.

The unallocated amount is any refund amount that could not be allocated to the other refund methods during the allocation process.

By default, this method returns a store credit refund method with no upper limit

Returns:
the refund method to be allocated the unallocated refund amount.
Throws:
ReturnException
See Also:
StoreCreditRefundMethod, ReturnTools#createRefundMethodInstance(String)}, buildRefundMethodList(Order, ReturnRequest, double, double), StoreCreditRefundMethod

allocateRefundAmountForReturn

protected double allocateRefundAmountForReturn(Order pOriginalOrder,
                                               ReturnRequest pReturnRequest,
                                               double pRefundAmountToBeAllocated,
                                               java.util.Collection<RefundMethod> pRefundMethods)
                                        throws ReturnException
This method allocates the given refund amount to the given refund methods and returns the total amount that was successfully allocated.

This method takes pRefundAmountToBeAllocated and allocates the amount to pRefundMethods.

Note that it may not be possible to allocated the entire amount to the refund methods if their maximum refund amount total is less that the amount being allocated. In this case, the returned allocated amount will be less than the given amount to be allocated.

Parameters:
pOriginalOrder - the original purchase order
pReturnRequest - the return request object
pRefundAmountToBeAllocated - The amount to be allocated
pRefundMethods - The refund amount allocated to these refund methods.
Returns:
the total allocated amount in this method
Throws:
ReturnException

generateRefundMethodsForReturn

protected java.util.List<RefundMethod> generateRefundMethodsForReturn(ReturnRequest pReturnRequest)
                                                               throws ReturnException
Generates refund methods based on the ReturnRequest originating order and all related replacement orders.

Parameters:
pReturnRequest -
Returns:
List of RefundMethod
Throws:
ReturnException
See Also:
ReturnRequest.getOriginatingOrder(), ReturnRequest.getRelatedReplacementOrders(), generateRefundMethodsFromOrder(Order)

generateRefundMethodsFromOrder

protected java.util.List generateRefundMethodsFromOrder(Order pOrder)
                                                 throws ReturnException
Generates a list of refund methods based on the given order

Iterates over the payment groups in the order and calls generateRefundMethodFromPaymentGroup for each one.

If a refund method is generated for a payment group with a maximum refund amount greater than 0, it is included in the list of returned refund methods.

Parameters:
pOrder - the order from which refund methods are to be generated.
Returns:
List of RefundMethods
Throws:
ReturnException
See Also:
generateRefundMethodFromPaymentGroup(PaymentGroup), getMaximumRefundAmount(PaymentGroup)

generateRefundMethodFromPaymentGroup

protected RefundMethod generateRefundMethodFromPaymentGroup(PaymentGroup pPaymentGroup)
                                                     throws ReturnException
Generates a RefundMethod based on the given payment group.

This implementation will generate a RefundMethod for CreditCard payment groups only. Extend this method to generate RefundMethod for other types of payment groups.

Parameters:
pPaymentGroup -
Returns:
RefundMethod
Throws:
ReturnException

calculateSuggestedRefunds

protected void calculateSuggestedRefunds(ReturnRequest pReturnRequest,
                                         java.util.List pReturnItems)
Calculates the item refund amounts for the given return items. Each of the return items is assumed to reference the same commerce item.

All refunds are calculated based on the range of the item being returned. The range highbound starts as the commerce item's quantity - 1. The range lowbound starts as the highbound + returnItem.quantityToReturn + 1. As each return item is processed, the highbound is adjusted down by the last returnItem.quantityToReturn. Lowbound is always adjusted to maintain the original relativity to the highbound.

Note that the commerce item's quantity referenced in the return items is adjusted as each return is processed.

The item, shipping and tax refunds are all calculated for each item.

Note that shipping refund is only calculated if the property doShippingRefunds is true

Parameters:
pReturnRequest - the return request
pReturnItems - list of return items that reference the same commerce item
See Also:
calculateRefundForItem(ReturnRequest, ReturnItem, Range), calculateTaxRefundForItem(ReturnRequest, ReturnItem, Range), calculateShippingRefundForItem(ReturnRequest, ReturnItem, Range)

calculateSuggestedAmounts

public void calculateSuggestedAmounts(ReturnRequest pReturnRequest)
Deprecated. in favor of calculateRefundAmounts(ReturnRequest, Map)

Calculate the suggested refund amounts for all items associated with this return request.


calculateRefundAmounts

public void calculateRefundAmounts(ReturnRequest pReturnRequest,
                                   java.util.Map pExtraParameters)
                            throws ReturnException,
                                   PipelineErrorReturnException
Executes the pipeline configured by the property calculateRefundAmountsPipelineChainId to calculate the refund amounts for the return

Parameters:
pReturnRequest -
pExtraParameters -
Throws:
ReturnException
PipelineErrorReturnException

calculateReturnItemSuggestedRefunds

public void calculateReturnItemSuggestedRefunds(ReturnRequest pReturnRequest)
Calculates the suggested refund amounts for the current set of selected ReturnItems.

Parameters:
pReturnRequest -

setActualRefundsFromSuggestedRefunds

public void setActualRefundsFromSuggestedRefunds(ReturnRequest pReturnRequest)
                                          throws ReturnException
Sets the actual refumds amounts for the ReturnRequest and each selected ReturnItem.

Parameters:
pReturnRequest -
Throws:
ReturnException

setSuggestedAmountsFromItems

public void setSuggestedAmountsFromItems(ReturnRequest pReturnRequest)
                                  throws ReturnException
Sets the suggested shipping and tax amounts in the ReturnRequest based on the suggested amounts in the selected ReturnItems.

Parameters:
pReturnRequest -
Throws:
ReturnException

resetRefundAmounts

public void resetRefundAmounts(ReturnRequest pReturnRequest)
Resets the suggested and actual refund amounts in the ReturnRequest and selected ReturnItems to 0.

Parameters:
pReturnRequest -

adjustSuggestedAmountsForNonReturnItems

public void adjustSuggestedAmountsForNonReturnItems(ReturnRequest pReturnRequest)
                                             throws ReturnException
Adjusts the suggested amounts based on the ItemCostAdjustment objects that reference item/shipping relationships not being returned.

This method will adjust the suggestedTaxRefund, suggestedShippingRefund and totalItemRefund of the ReturnRequest based on the ItemCostAdjustments made to the non-return items. These adjustments are avaiable in the nonReturnItemCostAdjustments of the ReturnRequest.

Parameters:
pReturnRequest -
Throws:
ReturnException

generateItemCostAdjustments

public void generateItemCostAdjustments(ReturnRequest pReturnRequest)
                                 throws ReturnException
This method (re)generates the ItemCostAdjustment objects for each ReturnItem and non-return item in the ReturnRequest

Parameters:
pReturnRequest -
Throws:
ReturnException
See Also:
generateReturnCalculationAdjustments(ReturnRequest), generatePromotionEvaluationAdjustments(ReturnRequest), generateShippingRefundAdjustments(ReturnRequest)

processSelectedReturnItems

public void processSelectedReturnItems(ReturnRequest pReturnRequest)
                                throws ReturnException
Deprecated. in favor of applySelectedItems(ReturnRequest, ProcessName, Map)

This method is used to adjust the values stored in the ReturnRequest based on the current set of selectedReturnItems.

Parameters:
pReturnRequest -
Throws:
ReturnException

calculateNewAmounts

public void calculateNewAmounts(ReturnRequest pReturnRequest,
                                java.util.Map pExtraParameters)
                         throws ReturnException
This method will calculate new suggested and actual refund amounts, exchange order totals and promotion value adjustments based on the currently selected ReturnItems in the ReturnRequest.

Parameters:
pReturnRequest -
pExtraParameters -
Throws:
ReturnException

createReturnItemList

public void createReturnItemList(ReturnRequest pReturnRequest)
                          throws ReturnException
The ReturnRequest's returnItemList and returnItemMap are generated based on the ReturnItem objects with a quantityToProcess.

Parameters:
pReturnRequest -
Throws:
ReturnException

resetReplacementOrderProperties

public void resetReplacementOrderProperties(ReturnRequest pReturnRequest,
                                            java.util.Map pExtraParameters)
                                     throws ReturnException
This method will reset the replacement order and generated store credit values of the ReturnRequest.

For a return, the replacement order is nulled out. For an exchange, the replacement is created if currently null.

The generated store credit is nulled out.

Parameters:
pReturnRequest -
pExtraParameters -
Throws:
ReturnException
See Also:
generateReplacementOrder(ReturnRequest, Map)

resetPromotionEvaluationProperties

public void resetPromotionEvaluationProperties(ReturnRequest pReturnRequest)
Resets all ReturnRequest properties generated from the processing the promotion evaluation order.

The promotionEvaluationOrder, exchangeItemManualAdjustmentValue and exchangeItemOrderPromotionValue properties are reset.

Parameters:
pReturnRequest -

removeGWPMetaDataFromExchangeOrder

protected void removeGWPMetaDataFromExchangeOrder(ReturnRequest pReturnRequest)
Removes all gwp meta-data from the exchange order

Parameters:
pReturnRequest -

resetGWPMetaData

public void resetGWPMetaData(ReturnRequest pReturnRequest)
                      throws ReturnException
Resets the GWP meta-data for determining GWP selections and removes all GWP meta-data from the exchange order.

Parameters:
pReturnRequest -
Throws:
ReturnException

calculateActualRefundsForReturnItems

protected void calculateActualRefundsForReturnItems(ReturnRequest pReturnRequest)
Calculate the actual shipping and actual tax for return items based on the actual values in the ReturnRequest.

The end result is the actual values for the return items plus the non-return item adjustments equals the return request's total actual value.

The actual tax and shipping values are distributed to the return item's actual values based on the following order of precedence. The following describes how tax is distributed but the same order of precedence is used for shipping.

  • If the sum of return item suggestedTaxRefunds gt 0, use the ratio of the item's suggested tax refund to the total return item suggestedTaxRefund
  • If the sum of return item suggestRefundAmounts gt 0, use the ratio of the item's suggestedRefundAmount to the total return item suggestedRefundAmounts
  • The actualTax divided evenly using the ((actualTax / total quantity of items being returned) * returnItem's quantityToReturn).

Parameters:
pReturnRequest - return request

initShippingCostShares

public void initShippingCostShares(ReturnRequest pReturnRequest)
                            throws ReturnException
Creates the shipping cost share map in the ReturnRequest

Parameters:
pReturnRequest -
Throws:
ReturnException
See Also:
calculateShippingCostShare(ReturnRequest)

calculateShippingCostShare

protected void calculateShippingCostShare(ReturnRequest pReturnRequest)
This method is called at the start of calculating refund amounts for the return. Its job is to generate the shipping cost share Map in the ReturnRequest. This map is used to calculate the shipping refunds for the returned items.

The shipping cost share map in the ReturnRequest maps each ShippingGroupCommerceItemRelationship in the order to a shipping cost share within its shipping group. These values are likely to be calculated differently for each application. To integrate custom allocations, the application should override the calculateShippingShareForRelationship method, which is called by this method for each ShippingGroupCommerceItemRealtionship in the order.

Parameters:
pReturnRequest -
See Also:
calculateShippingCostShareMap(ReturnRequest, Order)

calculateShippingShareForRelationship

protected double calculateShippingShareForRelationship(ReturnRequest pReturnRequest,
                                                       ShippingGroupCommerceItemRelationship pShippingGroupCommerceItemRelationship,
                                                       java.util.Map pRelsAlreadyCalculated)
Provides a default implementation for calculating the shipping cost share for a given ShippingGroupCommerceItemRelationship.

See Also:
calculateShippingShareForRelationship(ReturnRequest, ShippingGroupCommerceItemRelationship, double, Map, long, long)

calculateShippingCostShareMap

protected java.util.Map calculateShippingCostShareMap(ReturnRequest pReturnRequest,
                                                      Order pOrder)
                                               throws ReturnException
Generates a Map of ShippingGroupCommerceItemRelationship ids to their shipping share amount.

This method iterates over each ShippingGroupCommerceItemRelationship in the given Order as calls calculateShippingShareForRelationship to calculate the shipping share value for the given relationship.

Parameters:
pReturnRequest - the current return request
pOrder - the order from which to generate the share Map
Returns:
A map of ShippingGroupCommerceItemRelationship ids to their shipping share amount.
Throws:
ReturnException
See Also:
calculateShippingShareForRelationship(ReturnRequest, ShippingGroupCommerceItemRelationship, Map)

calculateShippingShareForRelationship

protected double calculateShippingShareForRelationship(ReturnRequest pReturnRequest,
                                                       ShippingGroupCommerceItemRelationship pShippingGroupCommerceItemRelationship,
                                                       double pShippingGroupTotalAmount,
                                                       java.util.Map pRelsAlreadyCalculated,
                                                       long pTotalQuantityInShippingGroup,
                                                       long pTotalQuantityAlreadyProcessed)
This utility method is used when calculating the shipping group's share amount for a shipping group relationship.

This implementation calculates a share by evenly distributing the shipping group's amount amongst all relationships in the shipping group.

It is expected that applications will need to override this method to calculate the values based on application specific shipping calculations.

Parameters:
pReturnRequest - the current ReturnRequest
pShippingGroupCommerceItemRelationship - the relationship for which to calculate the share
pShippingGroupTotalAmount - the total amount of the shipping group for which to calculate the share value
pRelsAlreadyCalculated - the map of relationship id to share value already calculated for the shipping group
pTotalQuantityInShippingGroup - the total quantity of items in the shipping group (i.e. the sum of all the rel quantities)
pTotalQuantityAlreadyProcessed - the total quantity of items alread calculated in the share map
Returns:
the share value for the relationship.

calculateReturnFee

protected double calculateReturnFee(ReturnRequest pReturnRequest)
Calculate the suggested return fee for this request.

By default, this method returns the configured return fee

Applications should override this method to calculate a custom return fee.

Parameters:
pReturnRequest - the return request
Returns:
double the suggested return fee
See Also:
getDefaultReturnFee()

setReturnFee

public void setReturnFee(ReturnRequest pReturnRequest)
                  throws ReturnException
Sets the return fee value for the request.

Parameters:
pReturnRequest -
Throws:
ReturnException
See Also:
calculateReturnFee(ReturnRequest)

calculateSuggestedRefundAmount

protected double calculateSuggestedRefundAmount(ReturnItem pReturnItem)
Deprecated. in favor of calculateItemAmountShare

Calculate the suggested refund amount for this item.

Parameters:
pReturnItem - the item being returned
Returns:
double the suggested refund amount

calculateOrderDiscountShare

protected double calculateOrderDiscountShare(ReturnRequest pReturnRequest,
                                             ReturnItem pReturnItem,
                                             atg.core.util.Range pReturnRange)
Calculates the share of the item's order discount share for the given return item and range.

Parameters:
pReturnRequest -
pReturnItem -
pReturnRange -
Returns:
share of the item's order discount share for the given return item and range

calculateManualAdjustmentShare

protected double calculateManualAdjustmentShare(ReturnRequest pReturnRequest,
                                                ReturnItem pReturnItem,
                                                atg.core.util.Range pReturnRange)
Calculates the share of the order level manual adjustments for the given item in the given range.

Parameters:
pReturnRequest -
pReturnItem -
pReturnRange -
Returns:
share of adjustments. Note that manual adjustment credits will be returned as a negative value and debits as a positive value.

calculateShippingRefundForItem

protected double calculateShippingRefundForItem(ReturnRequest pReturnRequest,
                                                ReturnItem pReturnItem,
                                                atg.core.util.Range pReturnRange)
Calculates the shipping refund for the given return item.

This method sums the total adjustments to shipping share based on the ItemCostAdjustments for the given item

Parameters:
pReturnRequest -
pReturnItem -
pReturnRange - the range of the item that is being returned. This parameter is no longer used by this implementation.
Returns:
shipping refund for the item

calculateRefundForItem

protected double calculateRefundForItem(ReturnRequest pReturnRequest,
                                        ReturnItem pReturnItem,
                                        atg.core.util.Range pReturnRange)
Calculates the refund for the given return item.

This method sums the total adjustments to amount, manual adjustment share and order discount share based on the ItemCostAdjustments for the given item

Parameters:
pReturnRequest - the return request
pReturnItem - the return item for which the refund is calculated
pReturnRange - the range of the item that is being returned. This parameter is no longer used by this implementation.
Returns:
the suggested refund for the item.

calculateItemAmountShare

protected double calculateItemAmountShare(ReturnRequest pReturnRequest,
                                          ReturnItem pReturnItem,
                                          atg.core.util.Range pReturnRange)
Calculates the share of the item's amount for the given return item and range.

Parameters:
pReturnRequest -
pReturnItem -
pReturnRange -
Returns:
share of the items amount for the given return item and range.

calculateShareForRange

protected double calculateShareForRange(ReturnItem pReturnItem,
                                        DetailedItemPriceInfo pDetailedItemPriceInfo,
                                        atg.core.util.Range pRange,
                                        double pAmount)
Calculates the share of the given amount for the given subset range within the given DetailedItemPriceInfo

The given detail is assumed to cover all or a portion of the given range.

The result is the share of the given amount for the quantity covered by the detail.

Parameters:
pReturnItem -
pDetailedItemPriceInfo -
pRange -
Returns:
the calculated share of the given amount for the quantity covered by the detail

calculateDetailShare

protected double calculateDetailShare(ReturnItem pReturnItem,
                                      java.lang.String pDetailAmountProperty,
                                      atg.core.util.Range pReturnRange)
Calculates the share of the return by looking at the DetailedItemPriceInfos for the range of the item being retured. The amount used in calculating the share is obtained from the detail's property named pDetailAmountProperty.

The return range highbound is the item's quantity - quantity already returned - 1

The return range lowbound is the highbound - quantity to return + 1

The details that cover the range being returned are extracted from the item's price info and the share for each detail is individually calculated.

Parameters:
pReturnItem -
pDetailAmountProperty -
pReturnRange - The range of the item being returned
Returns:
the portion of the amount that should be refunded for the item in the given return range.
See Also:
calculateShareForRange(ReturnItem, DetailedItemPriceInfo, Range, double)

getRangeWithinDetail

protected atg.core.util.Range getRangeWithinDetail(DetailedItemPriceInfo pDetailedItemPriceInfo,
                                                   atg.core.util.Range pRange)
Determines the range of the DetailedItemPriceInfo that is included in the given range.

Parameters:
pDetailedItemPriceInfo -
pRange - the range covered
Returns:
Range within the DetailedItemPriceInfo that is included in the given range.

calculateTaxRefundForItem

protected double calculateTaxRefundForItem(ReturnRequest pReturnRequest,
                                           ReturnItem pReturnItem,
                                           atg.core.util.Range pReturnRange)
Calculates the tax refund value for the given return item.

This method sums the total adjustments to tax share based on the ItemCostAdjustments for the given item

Parameters:
pReturnRequest - the return request
pReturnItem - the return item
pReturnRange - the range of the item that is being returned. This parameter is no longer used by this implementation.
Returns:
double

createRefundMethods

protected java.util.Set createRefundMethods(ReturnRequest pReturnRequest)
                                     throws RepositoryException
Create refund method items in the repository for the refund methods in a request.

Parameters:
pReturnRequest - the return request to save
Throws:
RepositoryException

createRequestItem

protected MutableRepositoryItem createRequestItem(ReturnRequest pReturnRequest,
                                                  Profile pAgentProfile)
                                           throws RepositoryException,
                                                  javax.servlet.ServletException,
                                                  CommerceException
Create a new return request entry in the database

Parameters:
pReturnRequest - the return request to save
pAgentProfile - the agent profile. This parameter is options is currently not used by this API.
Throws:
RepositoryException
CommerceException
javax.servlet.ServletException

createReturnItems

protected java.util.Set createReturnItems(ReturnRequest pReturnRequest,
                                          java.lang.String pRequestId)
                                   throws RepositoryException,
                                          CommerceException
Create records in the repository for the items in a request.

Parameters:
pReturnRequest - the return request to save
pRequestId -
Throws:
RepositoryException
CommerceException

returnCommerceItems

public void returnCommerceItems(ReturnRequest pReturnRequest)
                         throws ReturnException
Calls {@link CommerceItemManager#returnCommerceItem(Order, String, String, long)) for each ReturnItem in the ReturnRequest

Parameters:
pReturnRequest -
Throws:
ReturnException

createReturnRequest

public ReturnRequest createReturnRequest(Order pOrder)
                                  throws CommerceException
Deprecated. 

Create a new return request for the given order.

Parameters:
pOrder - the order to create a return request for
Returns:
the new return request
Throws:
CommerceException
See Also:
createReturnRequest(Order, ProcessName, Map)

createReturnRequest

public ReturnRequest createReturnRequest(java.lang.String pOrderId,
                                         atg.commerce.csr.returns.ProcessName pProcessName,
                                         java.util.Map pExtraParameters)
                                  throws CommerceException,
                                         PipelineErrorReturnException
Creates a ReturnRequest for the given order.

Throws:
CommerceException
PipelineErrorReturnException
See Also:
createReturnRequest(Order, ProcessName, Map)

createReturnRequest

public ReturnRequest createReturnRequest(Order pOrder,
                                         atg.commerce.csr.returns.ProcessName pProcessName,
                                         java.util.Map pExtraParameters)
                                  throws CommerceException,
                                         PipelineErrorReturnException
Creates a new return request object for the given Order.

Parameters:
pOrder - the original purchase Order from which items are being returned.
pProcessName - optional ProcessName that will be used for the return.
pExtraParameters - Map of parameters that will be passed to the initilization pipline
Returns:
A new, initialized ReturnRequest object.
Throws:
CommerceException
PipelineErrorReturnException

createStoreCredit

protected MutableRepositoryItem createStoreCredit(java.lang.String pProfileId,
                                                  double pAmount,
                                                  java.util.Date pExpirationDate)
                                           throws ReturnException,
                                                  CommerceException
Create a stored credit record. This store credit is persisted in the database.

Parameters:
pProfileId - owner of the store credit
pAmount - amount of the store credit
pExpirationDate - expiration date of the store credit
Throws:
ReturnException
CommerceException

createStoreCredit

protected MutableRepositoryItem createStoreCredit(java.lang.String pProfileId,
                                                  double pAmount,
                                                  java.util.Date pExpirationDate,
                                                  boolean pTransient)
                                           throws ReturnException,
                                                  CommerceException
Create a stored credit record

Parameters:
pProfileId - owner of the store credit
pAmount - amount of the store credit
pExpirationDate - expiration date of the store credit
Throws:
ReturnException
CommerceException

getMaximumRefundAmount

public double getMaximumRefundAmount(CreditCard pCreditCard)
Returns the maximum amount that can be credited to pCreditCard

The maximum amount is calculated as follows:

  • If the pCreditCard is null, returns -1
  • Otherwise this method returns max refund amount = credit card's debited - credited value.

Parameters:
pCreditCard - the credit card that is used to find the maximum amount that could be credited.
Returns:
double the maximum amount that can be credited to this credit card.

getMaximumRefundAmount

public double getMaximumRefundAmount(PaymentGroup pPaymentGroup)
                              throws ReturnException
Returns the maximum refund amount that be credited to the given payment group.

This implementation will get maximum refund amount for CreditCard payment groups only. Extend this method for other types of payment groups.

Parameters:
pPaymentGroup -
Returns:
the maximum refund amount that be credited to the given payment group.
Throws:
ReturnException
See Also:
getMaximumRefundAmount(CreditCard)

getMaxStoreCreditRefundAmount

public double getMaxStoreCreditRefundAmount(RepositoryItem pStoreCredit)
Returns the maximum amount that can be credited to this store credit.

The maximum amount is calculated as follows:

Parameters:
pStoreCredit - the store credit that is used to find the maximum amount that could be credited.
Returns:
double the maximum amount that can be credited to this store credit

issueAlternateCreditType

public void issueAlternateCreditType(Order pOrder,
                                     ReturnRequest pReturnRequest,
                                     java.util.Vector pCredits,
                                     java.lang.String pProfileId,
                                     RefundMethod pRefundMethod,
                                     double pRefundAmount)
This method is called by {@link #issueCredits(Order, ReturnRequest) to settle the credit on a RefundMethod type that is not handled by the core implementation

Parameters:
pOrder - - The order that is being credited
pReturnRequest - - The return request
pCredits - - The list of credits applied to the order
pProfileId - - The ID of the profile that is being credited
pRefundMethod - - The refund method
pRefundAmount - - The amount to be credited

issueCredits

protected java.util.List issueCredits(Order pOrder,
                                      ReturnRequest pReturnRequest)
                               throws ClaimableException,
                                      CommerceException,
                                      ReturnException,
                                      RepositoryException
Settles the credits for each RefundMethod in the return. This implementation handles credit cards and store credits. For other types, {@link #issueAlternateCreditType(Order, ReturnRequest, Vector, String, RefundMethod, double) will be called.

If a credit amount exceeds the maximum allowed for the payment group referenced by the RefundMethod, a store credit is automatically created to allocate the difference.

Parameters:
pOrder -
pReturnRequest -
Returns:
Throws:
ClaimableException
CommerceException
ReturnException
RepositoryException

settleCredits

public java.util.List settleCredits(ReturnRequest pReturnRequest)
                             throws ReturnException
Settles the credit (refunds) for the RefundMethods in the return request.

Parameters:
pReturnRequest - the return request
Returns:
a list of credits that were created
Throws:
ClaimableException
CommerceException
ReturnException
See Also:
issueCredits(Order, ReturnRequest)

prepareReplacementOrder

protected Order prepareReplacementOrder(ReturnRequest pReturnRequest)
                                 throws CommerceException
Deprecated. in favor of generateReplacementOrder(ReturnRequest, Map)

Creates the replacement order for the return request.

A new order is created that contains a copy of each shipping group and payment group in the original purchase order.

Parameters:
pReturnRequest - the request for which a replacement order is created
Throws:
CommerceException

instantiateReplacementOrder

public void instantiateReplacementOrder(ReturnRequest pReturnRequest)
                                 throws ReturnException
Creates a new order using OrderManager and places it in the ReturnRequest's replacementOrder property.

Parameters:
pReturnRequest -
Throws:
ReturnException

createReplacementOrderShippingGroups

public void createReplacementOrderShippingGroups(ReturnRequest pReturnRequest)
                                          throws ReturnException
Creates the initial set of shipping groups for the replacement order

Parameters:
pReturnRequest -
Throws:
ReturnException

createReplacementOrderPaymentGroups

public void createReplacementOrderPaymentGroups(ReturnRequest pReturnRequest)
                                         throws ReturnException
Creates the initial set of payment groups for the replacement order

Parameters:
pReturnRequest -
Throws:
ReturnException

initializeReplacementOrderGWPMetaData

public void initializeReplacementOrderGWPMetaData(ReturnRequest pReturnRequest)
                                           throws ReturnException
Initializes the GWP meta-data on the replacement Order needed for exchanging gifts.

This is acheived by mirroring the GWP meta-data from the Return Calculation Order.

Parameters:
pReturnRequest -
Throws:
ReturnException

generateReplacementOrder

public void generateReplacementOrder(ReturnRequest pReturnRequest,
                                     java.util.Map pExtraParameters)
                              throws ReturnException
Creates a new replacement order for the given ReturnRequest

This method executes the pipeline defined by the property generateReplacementOrderPipelineChainId to create the replacement order.

Parameters:
pReturnRequest - the ReturnRequest for which a replacement order is created
pExtraParameters - the extra parameter map that is passed to the pipeline execution
Throws:
ReturnException

processRequest

protected void processRequest(Order pOrder,
                              ReturnRequest pReturnRequest)
                       throws RepositoryException,
                              ClaimableException,
                              CommerceException,
                              ReturnException
Deprecated. in favor of settleReturnRequest(ReturnRequest, String, Map)

Process a return request

Parameters:
pOrder - the order that the return request is related to
pReturnRequest - the return request
Throws:
RepositoryException
ClaimableException
CommerceException
ReturnException

updateReplacementOrderStateOnConfirm

public void updateReplacementOrderStateOnConfirm(ReturnRequest pReturnRequest)
                                          throws CommerceException
Sets the state of the replacement order when a return request is confirmed

By default, the state will be set to the configurable pendingCustomerReturnOrderState property value.

Parameters:
pReturnRequest -
Throws:
CommerceException

recordMerchandiseReturn

public void recordMerchandiseReturn(java.lang.String pReturnRequestId,
                                    java.util.Map<java.lang.String,java.lang.Long> pQuantityBeingReceived,
                                    java.util.Map<java.lang.String,java.lang.String> pDispositionReceived,
                                    java.util.Map pExtraParameters)
                             throws ReturnException,
                                    PipelineErrorReturnException
Records a batch of items being received.

Parameters:
pReturnRequestId - the return containing the items being received
pQuantityBeingReceived - a Map of return item id to quantity being received
pDispositionReceived - a Map of return item id to recieve disposition
pExtraParameters - extra parameter map passed to the executed pipelines.
Throws:
ReturnException
PipelineErrorReturnException

recordMerchandiseReturn

public void recordMerchandiseReturn(ReturnRequest pReturnRequest,
                                    ReturnItem pReturnItem,
                                    long pQuantityReceived,
                                    java.lang.String pDisposition,
                                    java.util.Map pExtraParameters)
                             throws ReturnException,
                                    PipelineErrorReturnException
Record the receipt of returned merchandise

Parameters:
pReturnRequest - the return request
pReturnItem - the id of the returned item
pQuantityReceived - the quantity that was returned
pDisposition - the disposition of the item
pExtraParameters - the extra parameter map that is passed to the pipeline execution
Throws:
ReturnException
PipelineErrorReturnException
See Also:
getReceiveItemPipelineChainId()

updateInventoryOnReceive

public void updateInventoryOnReceive(ReturnRequest pReturnRequest,
                                     ReturnItem pReturnItem,
                                     long pQuantityReceived)
                              throws ReturnException
Updates the inventory based on the item being received

Parameters:
pReturnRequest - the ReturnRequest
pReturnItem - the ReturnItem being received
pQuantityReceived - The quantity of item being received
Throws:
ReturnException
See Also:
ReturnTools.shouldUpdateInventory(ReturnItem), InventoryManager.increaseStockLevel(String, long)

updateReturnItemOnReceive

public void updateReturnItemOnReceive(ReturnRequest pReturnRequest,
                                      ReturnItem pReturnItem,
                                      long pQuantityReceived,
                                      java.lang.String pDisposition)
                               throws ReturnException
Updates the given ReturnItem on receive.

Parameters:
pReturnRequest - the ReturnRequest
pReturnItem - the ReturnItem being received
pQuantityReceived - the quantity being received
pDisposition - the disposition of the quantity being received
Throws:
ReturnException

saveReturnRequest

public void saveReturnRequest(ReturnRequest pReturnRequest,
                              Profile pAgentProfile)
                       throws CommerceException,
                              RepositoryException,
                              javax.servlet.ServletException
Deprecated. in favor of confirmReturn(ReturnRequest, Map)

Throws:
CommerceException
RepositoryException
javax.servlet.ServletException

saveReturnRequestToRepository

public void saveReturnRequestToRepository(ReturnRequest pReturnRequest)
                                   throws ReturnException
Adds the necessary repository items for saving the ReturnRequest and sets the requestId property of the ReturnRequest

Parameters:
pReturnRequest -
Throws:
ReturnException

confirmReturn

public void confirmReturn(ReturnRequest pReturnRequest,
                          java.util.Map pExtraParameters)
                   throws ReturnException,
                          PipelineErrorReturnException
Executes the process of confirmining a return by executing the confirm pipeline.

The confirm pipeline id can be configured using the ConfirmReturnRequestPipelineChainId property.

Parameters:
pReturnRequest - the ReturnRequest
pExtraParameters - the extra parameter map that will be passed to the pipeline execution
Throws:
ReturnException
PipelineErrorReturnException

applySelectedItems

public void applySelectedItems(ReturnRequest pReturnRequest,
                               atg.commerce.csr.returns.ProcessName pProcessName,
                               java.util.Map pExtraParameters)
                        throws ReturnException,
                               PipelineErrorReturnException
Executes the process of applying the selected ReturnItems by executing the given pipeline.

Parameters:
pReturnRequest - the ReturnRequest
pProcessName - Optional. If provided, the ProcessName in the ReturnRequest is set to this value before executing the pipeline. This param can be used to change the process for which the items are being selected. (i.e. switch from return to exchange or exchange to return).
pExtraParameters - the extra parameter map that will be passed to the pipeline execution
Throws:
ReturnException, - PipelineErrorReturnException
ReturnException
PipelineErrorReturnException

applyRefundMethodAllocations

public void applyRefundMethodAllocations(ReturnRequest pReturnRequest,
                                         java.util.Map pExtraParameters)
                                  throws ReturnException,
                                         PipelineErrorReturnException
This method will execute a pipeline chain to validate and process the new RefundMethod allocations.

If a chain id is not provided, the chain id defined by the applyRefundAllocationsPipelineChainId property is used.

Parameters:
pReturnRequest - the ReturnRequest object
pExtraParameters - the optional extra parameter map that will be passed to the chain execution
Throws:
ReturnException, - PipelineErrorReturnException
ReturnException
PipelineErrorReturnException

stateToString

protected java.lang.String stateToString(ObjectStates pObjectStates,
                                         java.lang.String pStateString)
Convert a state string

Parameters:
pObjectStates - the object states object to use
pStateString - the state string to convert

submitReplacementOrder

public void submitReplacementOrder(ReturnRequest pReturnRequest,
                                   java.util.Map pExtraParameters)
                            throws ReturnException,
                                   PipelineErrorReturnException
Submits the replacement order for fulfillment processing

The pipeline executed can be configured using the submitReplacementOrderPipelineChainId property.

Parameters:
pReturnRequest - the return request that has a replacement order to submit
pExtraParameter - the extra parameter map passed to the pipeline execution.
Throws:
ReturnException
PipelineErrorReturnException
See Also:
generateSubmitReplacementOrderParameterMap(ReturnRequest, Locale, Map)

markReturnRequestAsProcessed

public void markReturnRequestAsProcessed(ReturnRequest pReturnRequest)
Sets the processed property to true. This prevents any future attempt to settle the ReturnRequest

Parameters:
pReturnRequest -

settleReturnRequest

public void settleReturnRequest(ReturnRequest pReturnRequest,
                                java.lang.String pSettleReturnRequestPipelineChainId,
                                java.util.Map pExtraParameters)
                         throws ReturnException,
                                PipelineErrorReturnException
Executes the pipeline to settle the return request. The pipeline id can be configured using the settleReturnRequestPipelineChainId property.

Parameters:
pReturnRequest - the ReturnRequest to settle
pSettleReturnRequestPipelineChainId - the pipeline chaing to execute
pExtraParameters - the extra parameter Map to be passed to the pipeline execution
Throws:
ReturnException
PipelineErrorReturnException

updateReturnItemState

protected boolean updateReturnItemState(ReturnItem pReturnItem)
                                 throws RepositoryException
Update the state of a returned item based on its current quantity values and its returnShipmentRequired value.

The underlying ReturnItem repository item is also updated if it has already been created.

Parameters:
pReturnItem - the returned item
Returns:
true if the state was changed
Throws:
RepositoryException
See Also:
ReturnItemStates

updateStateOfReturnItems

public void updateStateOfReturnItems(ReturnRequest pReturnRequest)
                              throws RepositoryException
Iterates over the ReturnItems and sets their state based on their current values.

Parameters:
pReturnRequest -
Throws:
RepositoryException
See Also:
updateReturnItemState(ReturnItem)

updateReturnState

protected boolean updateReturnState(ReturnRequest pReturnRequest)
                             throws RepositoryException,
                                    ReturnException
Review the state of all items in a return request and update the state of the return, if necessary.

Parameters:
pReturnRequest - the return request
Returns:
true if the state of the return was changed.
Throws:
ReturnException
RepositoryException

updateStateFromReturnItemState

public boolean updateStateFromReturnItemState(ReturnRequest pReturnRequest)
                                       throws ReturnException
Updates the state of the ReturnRequest based on the state of the ReturnItems

Parameters:
pReturnRequest -
Returns:
true if the state was changed
Throws:
RepositoryException
ReturnException
See Also:
updateReturnState(ReturnRequest)

isReadyForSettlement

public boolean isReadyForSettlement(ReturnRequest pReturnRequest)
Returns true if the ReturnRequest is ready for settlement (e.g. ready to issue the refund credits and submit the replacement order).

Parameters:
pReturnRequest -
Returns:
true if the ReturnRequest is ready for settlement

ensureTransaction

protected javax.transaction.Transaction ensureTransaction()
This method ensures that a transaction exists before returning. If there is no transaction, a new one is started and returned. In this case, you must call commitTransaction when the transaction completes.

Returns:
a Transaction value

commitTransaction

protected void commitTransaction(javax.transaction.Transaction pTransaction)
Commits the supplied transaction

Parameters:
pTransaction - a Transaction value

isTransactionMarkedAsRollBack

protected boolean isTransactionMarkedAsRollBack()
Returns true if the transaction associated with the current thread is marked for roll back. This is useful if you do not want to perform some action (e.g. updating the order) if some other sub-service already needs the transaction rolled back.

Returns:
a boolean value

addPropertyUpdate

public void addPropertyUpdate(java.lang.Object pNewValue,
                              java.lang.Object pOldValue,
                              java.lang.String pPropertyName,
                              java.util.List pUpdates)
Adds the old and new values of updated property in the list.

Parameters:
pNewValue - is the new value of property
pOldValue - is the old value of property
pPropertyName - is the name of property
pUpdates - stores the new and old values of property

applyExchangeProcessPayments

public atg.commerce.csr.returns.ReturnPaymentState applyExchangeProcessPayments(ReturnRequest pReturnRequest)
                                                                         throws ReturnException
Generates the refund store credit and applies it to the replacement order as a payment group. The value of the store credit will be for the entire refund value when the refund amount exceeds or equals the amount of the replacement order. Otherwise, its value is equal to the amount of the replacement order.

In the case where the refund exceeds the amount of the exchange order, an additional store credit refund method is generated and added to the return request, so it can be used to refund the excess amount.

Returns:
ReturnPaymentState
Throws:
ReturnException
See Also:
ReturnPaymentState, buildRefundMethodList(Order, ReturnRequest, double, double)

determineReturnPaymentValues

public atg.commerce.csr.returns.ReturnPaymentState determineReturnPaymentValues(ReturnRequest pReturnRequest)
                                                                         throws ReturnException
Based on the current state of the return or exchange, rebuilds the return method list, generates store credits and sets the ReturnRequest returnPaymentState property.

Parameters:
pReturnRequest -
Returns:
the current ReturnPaymentState
Throws:
ReturnException
See Also:
initializeRefundMethodList(ReturnRequest)

setReturnPaymentState

public void setReturnPaymentState(ReturnRequest pReturnRequest)
                           throws ReturnException
Deprecated. This value is now determined by ReturnRequest.getReturnPaymentState()

Sets the returnPaymentState property of the ReturnRequest based on the current state of the return balance.

The ReturnPaymentState indicates the current state of the balance for the return, which can be one of the three states:

No balance
For a return only, this means the total refund value is currently 0. For an exchange, this means the total refund value is equal the total cost of the replacement order
Refund
For a return only, this means the total refund amount is greater than 0. For an exchange, this means the total refund value is greater than the total cost of the replacement order
Payment Due
For a return only, this means the total refund amount is less than 0. For an exchange, this means the total refund value is less than the total cost of the replacement order

Parameters:
pReturnRequest -
Throws:
ReturnException

adjustOrderPayments

public void adjustOrderPayments(ReturnRequest pReturnRequest,
                                double pRefundAmount,
                                boolean pClearRefundMethods)
                         throws ReturnException
Creates or adjusts the refund store credit payment group in the replacement order for the given refund amount.

This method will also create the refund method in the return request for the store credit.

Parameters:
pReturnRequest -
pRefundAmount - the amount to be for the store credit value.
pClearRefundMethods - if true, the refund method list is cleared before adding the store credit refund method to the list.
Throws:
ReturnException

copyPaymentGroups

public void copyPaymentGroups(ReturnRequest pReturnRequest,
                              Order pSrcOrder,
                              Order pDestinationOrder)
                       throws ReturnException
This method copies the payment groups from the original order to the exchange order. This method first clears out any existing payment groups from the exchange order and copies the payment group from the original order to the exchange order.

Parameters:
pReturnRequest - -- Current return request
pSrcOrder - -- source order
pDestinationOrder - -- Destination order
Throws:
ReturnException

updateStoreCreditAmount

public void updateStoreCreditAmount(atg.commerce.csr.returns.StoreCreditRefundMethod pStoreCreditRefundMethod,
                                    java.util.List pRefundMethodsList,
                                    ReturnRequest pReturnRequest)
                             throws ReturnException
Adjusts the amount of the store credit claimable to match the amount in the StoreCreditRefundMethod.

If the refund method is the replacement order store credit, this method will reapply the payment group for the amount on the refund method.

Parameters:
pStoreCreditRefundMethod -
pRefundMethodsList - the full List of RefundMethods for the return.
pReturnRequest - a reference to the ReturnRequest
Throws:
ReturnException

updateAmountOfStoreCredits

public void updateAmountOfStoreCredits(ReturnRequest pReturnRequest)
                                throws ReturnException
The List of refund methods can include up to two StoreCreditRefundMethods, which are automatically created for the return or exchange. Each StoreCreditRefundMethod references its associated store credit claimable item. This method will update the amount of the claimable item to the refund allocated to the StoreCreditRefundMethod.

One store credit refund method is always created for allocating a refund to the user. This refund method may or may not get used. There is no upper limit to this store credit. This method will update the amount store credit claimable to be the same as the refund amount allocated to the StoreCreditRefundMethod.

Another StoreCreditRefundMethod is created for exchanges and the associated store credit claimable is applied as a payment method on the replacement order. This method will reapply that StoreCredit payment group based on the amount allocated to the StoreCreditRefundMethod. Both store credits will exist when doing an exchange where the refund amount exceeds the amount of the replacement order.

Parameters:
pReturnRequest - a reference to the ReturnRequest
Throws:
ReturnException

getProcessOrderMap

public java.util.HashMap getProcessOrderMap(java.util.Locale pLocale)
                                     throws CommerceException
Deprecated. in favor of generateSubmitReplacementOrderParameterMap(ReturnRequest, Locale, Map)

Throws:
CommerceException

generateSubmitReplacementOrderParameterMap

public java.util.Map generateSubmitReplacementOrderParameterMap(ReturnRequest pReturnRequest,
                                                                java.util.Locale pLocale,
                                                                java.util.Map pExtraParmeters)
                                                         throws CommerceException
Generates the extra paremeter map used to submit the replacement order through the processOrder pipeline

params added: sales channel, bypass payment group auth and bypass expired promotion check

Parameters:
pReturnRequest - the ReturnRequest containing the replacement order
pLocale - the display locale
pExtraParmeters - the incoming extra parameter Map. This can be null.
Returns:
Map of extra parameters passed to the processOrder pipeline
Throws:
CommerceException
See Also:
OrderTools.addBypassPaymentGroupAuthorizationParameter(Map), OrderTools.addBypassExpiredPromotionsCheckParameter(Map), OrderTools.addAllowPartialInStorePayment(Map), PipelineConstants.SALESCHANNEL

setReturnShipmentRequiredForReturnItem

public void setReturnShipmentRequiredForReturnItem(ReturnItem pReturnItem,
                                                   ReturnRequest pReturnRequest)
                                            throws ReturnException
This method sets the returnShipmentRequired property of the ReturnItem. It is called once for each ReturnItem that is selected for return.

If the processImmediately property of the ReturnRequest is true, the return shipment required property will be set to false. It will also be set to false if the shipping group for the ReturnItem is an ElectronicShippingGroup.

Extend this method to include other business rules that determine if a item must be returned.

Parameters:
pReturnItem - The return item that requires the flag to be set
pReturnRequest - The return request is used to get necessary information to decide the flag value.
Throws:
ReturnException

generateShippingRefundAdjustments

protected java.util.Collection generateShippingRefundAdjustments(ReturnRequest pReturnRequest)
                                                          throws ReturnException
Creates ItemCostAdjustment objects for each ReturnItem in the ReturnRequest that detail the calculated shipping refund for each item being returned.

This is calculated using the map of relationship to shipping cost map previously generated and stored in the ReturnRequest's returnShippingShareMap property.

The cost of the relationship is divided evenly by the total units in the relationship and then multiplied by the units being returned to determine the shipping refund value of the units being returned.

Parameters:
pReturnRequest -
Throws:
ReturnException

generateReturnCalculationAdjustments

protected java.util.Collection generateReturnCalculationAdjustments(ReturnRequest pReturnRequest)
                                                             throws ReturnException
Creates ItemCostAdjustment objects based on the pricing deltas between the return adjusted and return calculation orders.

Parameters:
pReturnRequest -
Throws:
ReturnException
See Also:
generateOrderComparisonAdjustments(ReturnRequest, Order, Order, Map, Map), resetCommerceIds(ReturnRequest, Collection)

resetCommerceIds

protected void resetCommerceIds(ReturnRequest pReturnRequest,
                                java.util.Collection pAdjustments)
Updates each adjustment's commerce item id and shipping group id to reference the original commerce item and shipping group id.

Parameters:
pReturnRequest - the ReturnRequest
pAdjustments - the collection of ItemCostAdjustments for which the ids are updated
See Also:
#findOriginalItemForWorkingItem(ReturnRequest, String)

generatePromotionEvaluationAdjustments

protected java.util.Collection generatePromotionEvaluationAdjustments(ReturnRequest pReturnRequest)
                                                               throws ReturnException
Creates ItemCostAdjustment objects based on the pricing deltas between the return calculation and promotion evaluation orders.

Parameters:
pReturnRequest -
Returns:
a Collection of ItemCostAdjustments
Throws:
ReturnException
See Also:
generateOrderComparisonAdjustments(ReturnRequest, Order, Order, Map, Map), resetCommerceIds(ReturnRequest, Collection)

generateOrderComparisonAdjustments

protected java.util.Collection generateOrderComparisonAdjustments(ReturnRequest pReturnRequest,
                                                                  Order pOrder,
                                                                  Order pCorrespondingOrder,
                                                                  java.util.Map pItemToCorrespondingItemMap,
                                                                  java.util.Map pShippingGroupToCorrespondingShippingGroupMap)
                                                           throws ReturnException
Generates a collection of ItemCostAdjustment objects based on pricing deltas between the order and the corresponding order. Presumably, the order and correpsonding order began as clones of each other, and the item and shipping group maps were generated at that time.

It iterates over the items in the given pOrder and compares pricing values to the corresponding items in the pCorrespondingOrder.

Parameters:
pReturnRequest - the return request object
pOrder - the order that will be compared to the corresponding order
pCorrespondingOrder - the order that was generated from the given order.
pItemToCorrespondingItemMap - this maps item ids in the order to the items in the corresponding order. This map was was generated when the order was original copied to create the correponding order.
pShippingGroupToCorrespondingShippingGroupMap - this maps shipping group ids in the order to the shipping group ids in the corresponding order. This map was was generated when the order was originally cloned to create the corresponding order.
Returns:
a collection of ItemCostAdjustment objects based on a deltas between the order with its corresponding order.
Throws:
ReturnException
See Also:
generateItemComparisonAdjustment(ReturnRequest, Order, Order, String, String, String, String)

generateItemComparisonAdjustment

protected ItemCostAdjustment generateItemComparisonAdjustment(ReturnRequest pReturnRequest,
                                                              Order pOrder,
                                                              Order pCounterpartOrder,
                                                              java.lang.String pItemId,
                                                              java.lang.String pCounterpartItemId,
                                                              java.lang.String pShippingGroupId,
                                                              java.lang.String pCounterpartShippingGroupId)
                                                       throws CommerceException
Creates an ItemCostAdjustment by comparing pricing information of the given item and counterpart item. The following pricing values are summarized for both the item and counterpart item and the deltas stored in the ItemCostAdjustment

amount
determined by aggregating the amount property of the DetailItemPriceDetail objects associated with the relationship's range
orderDiscountShare
determined by aggregating the orderDiscountShare property of the DetailItemPriceDetail objects associated with the relationship's range
tax
determined by aggregating the tax property of the DetailItemPriceDetail objects associated with the relationship's range
orderManualAdjustmentShare
determined by aggregating the orderManualAdjustmentShare property of the DetailItemPriceDetail objects associated with the relationship's range
shippingGroupShare
determined by extracting the shipping share cost from given shipping share Maps using the item to shipping group relationship

Note that it's possible the pCounterpartItemId no longer exists in the pCounterpartOrder. For example, in the case of the RCO, items are removed if they are being fully returned.

Note that it's possible the pCounterpartItemId no longer has a relationship with the pCounterpartShippingGroupId. For example, in the case of the Return Calculation Order, item relationships may have been removed based on the items being returned.

Parameters:
pReturnRequest - the return request
pOrder - the order that contains the given pItem
pCounterpartOrder - the order that contains the given pCounterpartItemId
pItemId - the item in the order that is compared to the counterpart item
pCounterpartItemId - the item in the counterpart order that is compared to the item
pShippingGroupId - the shipping group in the pOrder to which the comparison is limited by pRange associated with the item's relationship
pCounterpartShippingGroupId - the shipping group in the pCounterpartOrder to which the comparison is limited by pRange associated with the counterpart item's relationship
Returns:
ItemCostAdjustment
Throws:
CommerceException
See Also:
#sumDetails(CommerceItem, Range, String)

createReturnAdjustedOrder

protected Order createReturnAdjustedOrder(ReturnRequest pReturnRequest)
                                   throws ReturnException
Creates the return adjusted order by cloning the originating order, adding all replacement items and shipping groups from all the exchange orders and re-prices.

The CloneEditManager is used to perform the cloning process using the pipeline specified by the configurable createReturnAdjustedOrderPipeline property.

Parameters:
pReturnRequest -
Returns:
Return Adjusted Order
Throws:
ReturnException
See Also:
#createPipelineExtraParameterMap(ReturnRequest), addReplacementItemsToReturnAdjustedOrder(ReturnRequest, Order), #removeZeroQuantityItems(Order), #removeZeroQuantityRelationships(Order)

generateItemPriceSources

public void generateItemPriceSources(ReturnRequest pReturnRequest)
                              throws ReturnException
This method creates the list of <@link atg.commerce.pricing.ItemPriceSource> objects from the original order and all exchange orders in the return tree. It puts the resulting list in the itemPriceSources property of the given return request.

These price source objects are used in all pricing operations that determine the refund and the price of the exchange order.

Parameters:
pReturnRequest -
Throws:
ReturnException
See Also:
ItemPriceSource, ReturnRequest.getItemPriceSources()

generateDiscountableMap

public void generateDiscountableMap(ReturnRequest pReturnRequest)
Generates the Map of discountable flags from the discountable state saved on the originating order and all replacement orders.

Parameters:
pReturnRequest -

generateItemPriceSourceParameters

protected java.util.Map generateItemPriceSourceParameters(ReturnRequest pReturnRequest,
                                                          Order pOrder)
When generated item price source objects from the original and all replacement orders in the return, this method is called to generate the extra parameter map that gets passed to the api that generates the ItemPriceSource objects from the order.

By default, this method returns null.

Parameters:
pReturnRequest -
pOrder -
Returns:
Map of extra parameters used to generate item price source objects from the Order.

adjustReturnCalculationOrderFinalItemPrices

protected void adjustReturnCalculationOrderFinalItemPrices(ReturnRequest pReturnRequest,
                                                           Order pReturnCalculationOrder)
                                                    throws ReturnException
Adjusts the amount value for items marked as final in the return calculation order that are being returned.

This must be done manually because the pricing engine will not calculate a new price for an item that has been marked as final.

Parameters:
pReturnRequest -
pReturnCalculationOrder -
Throws:
ReturnException
See Also:
calculateNewFinalPriceForRCOItem(ReturnRequest, CommerceItem, ShippingGroup, long)

adjustReturnAdjustedOrderFinalItemPrices

protected void adjustReturnAdjustedOrderFinalItemPrices(ReturnRequest pReturnRequest,
                                                        Order pReturnAdjustedOrder)
                                                 throws ReturnException
Calculates a new price info amount and new DetailedItemPriceInfos for items that have been marked as final and have some quantity returned already. It is necessary to do this manually because the pricing engine will not calculate a new price for items marked as final.

Parameters:
pReturnRequest - the return request object
pReturnAdjustedOrder -
Throws:
ReturnException
See Also:
calculateNewFinalPriceForRAOItem(ReturnRequest, CommerceItem)

calculateNewFinalPriceForRAOItem

protected void calculateNewFinalPriceForRAOItem(ReturnRequest pReturnRequest,
                                                CommerceItem pRAOItem)
                                         throws ReturnException
Called for each item in the RAO that is marked as final and has a returned quantity gt 0.

Parameters:
pReturnRequest -
pRAOItem -
Throws:
ReturnException
See Also:
adjustFinalItemAmountForRelationshipRangeValue(ReturnRequest, CommerceItem, ShippingGroupCommerceItemRelationship, Range)

calculateNewFinalPriceForRCOItem

protected void calculateNewFinalPriceForRCOItem(ReturnRequest pReturnRequest,
                                                CommerceItem pRCOItem,
                                                ShippingGroup pShippingGroup,
                                                long pQuantityToReturn)
                                         throws ReturnException
Calculates a new final price for the given rco item based on the quantity being returned from the shipping group.

Parameters:
pReturnRequest - the return request
pRCOItem - the item in the RCO for which a new final price is calculated
pShippingGroup - the shipping group in the RCO that contains the quantity being returned.
pQuantityToReturn - the quantity being returned.
Throws:
ReturnException
See Also:
adjustFinalItemAmountForRelationshipRangeValue(ReturnRequest, CommerceItem, ShippingGroupCommerceItemRelationship, Range)

adjustFinalItemAmountForRelationshipRangeValue

protected void adjustFinalItemAmountForRelationshipRangeValue(ReturnRequest pReturnRequest,
                                                              CommerceItem pCommerceItem,
                                                              ShippingGroupCommerceItemRelationship pShippingGroupCommerceItemRelationship,
                                                              atg.core.util.Range pRange)
                                                       throws ReturnException
Calculates and sets a new priceInfo amount by subtracting out the value of the range within the given relationship. DetailItemPriceInfos are also re-generated based on the item's new amount.

Parameters:
pReturnRequest - the return request object
pCommerceItem - the commerce item with the final price
pShippingGroupCommerceItemRelationship - the relationship for which a value of each unit will be determined and used to adjust the item's amount.
pRange - the range within the relationship for which the value will be determined and used to adjust the item's amount.
Throws:
ReturnException
See Also:
#calculateAmountDetailShareForRange(DetailedItemPriceInfo, Range)

createExchangeOrderCloningPropExceptionsMap

protected java.util.Map createExchangeOrderCloningPropExceptionsMap()
This method is a helper method which is used when cloning the exchange orders for the replacement items in the RAO. It creates a Map that will be used by the cloneItem method in RepositoryUtils class as a PropExceptions parameter. The user should override this method if the order item descriptor has changed or some properties which previously requires deep copy now requires shallow copy or vice versa.

This method returns null by default

Returns:
the Map
See Also:
RepositoryUtils

adjustReturnCalculationOrderForReturnItems

protected void adjustReturnCalculationOrderForReturnItems(ReturnRequest pReturnRequest,
                                                          Order pReturnCalculationOrder)
                                                   throws ReturnException
Adjusts the quantity of commerce items and shipping group relationships for the items being returned (i.e. ReturnItems with a quantityToReturn)

Parameters:
pReturnRequest -
pReturnCalculationOrder -
Throws:
CommerceException
ReturnException

generateFilteredReturnRequestSelections

public java.util.Collection generateFilteredReturnRequestSelections(ReturnRequest pReturnRequest)
                                                             throws CommerceException,
                                                                    ReturnException
Starting with the generated GiftWithPurchaseSelection objects for the ReturnRequest, create a new set of GiftWithPurchaseSelection objects that contains only those selections that still have remaining quantity after decrementing quantity for any targeted or selected quantity already in the exchange order.

Parameters:
pReturnRequest -
Returns:
only the return request's gwp selections that have a quantity > 0.
Throws:
CommerceException
ReturnException

generateGWPSelectionsForReturnItems

public void generateGWPSelectionsForReturnItems(ReturnRequest pReturnRequest)
                                         throws ReturnException
Generates the order level GiftWithPurchaseSelection objects based on the item level GiftWithPurchaseSelection objects for each item being returned. These generated GiftWithPurchaseSelection objects are used to provide gift selection links on the exchange order cart page for any gifts that are being returned.

A GiftWithPurchaseSelection object is created for each gift that is being returned. The selection's quantity property is set to the gift quantity deltas for the corresponding items in the RAO and RCO.

Parameters:
pReturnRequest -
Throws:
ReturnException

findMatchingRCOSelection

protected GiftWithPurchaseSelection findMatchingRCOSelection(ReturnRequest pReturnRequest,
                                                             CommerceItem pRCOCommerceItem,
                                                             GiftWithPurchaseSelection pGiftWithPurchaseSelection)
                                                      throws ReturnException
Returns the GiftWithPurchaseSelection from the given RCO item that matches the given GiftWithPurchaseSelection

Parameters:
pReturnRequest -
pRCOCommerceItem -
pGiftWithPurchaseSelection -
Returns:
the matching selection object, if found. otherwise null.
Throws:
ReturnException

addReplacementItemsToReturnAdjustedOrder

protected void addReplacementItemsToReturnAdjustedOrder(ReturnRequest pReturnRequest,
                                                        Order pReturnAdjustedOrder)
                                                 throws CommerceException
For each replacement(exchange) order found in the return tree, the commerce items and shipping groups are copied to the Return Adjusted Order.

This is done by iterating over all the related exchange orders, making a clone copy of each one moving the clone items, shipping group relationships and shipping groups to the return adjusted order.

The related exchange orders is pre-generated and stored in the exchangeOrders property of the ReturnRequest

Parameters:
pReturnRequest -
pReturnAdjustedOrder -
Throws:
CommerceException

copyAgentFinalPriceInfoToPEO

protected void copyAgentFinalPriceInfoToPEO(ReturnRequest pReturnRequest)
                                     throws ReturnException
This method will determine if any items are marked as final in the exchange order and mark the corresponding items final in the peo using the same amount.

This is done by calling markAsFinal on the peo item price info

Parameters:
pReturnRequest -
Throws:
ReturnException

createReturnCalculationOrder

protected Order createReturnCalculationOrder(ReturnRequest pReturnRequest)
                                      throws ReturnException
Creates the Return Calculation Order by cloning the Return Adjusted Order in the ReturnRequest

The CloneEditManager is used to perform the cloning process using the pipeline specified by the configurable createReturnCalculationOrderPipeline property.

After cloning is complete, the item/shipping group quantities are adjusted based on the ReturnItems in the ReturnRequest. A new amount is calculated and new details generated for items being returned that are marked as final.

Parameters:
pReturnRequest -
Returns:
the Return Calculation Order
Throws:
ReturnException
See Also:
adjustReturnCalculationOrderForReturnItems(ReturnRequest, Order), adjustReturnCalculationOrderFinalItemPrices(ReturnRequest, Order)

initReturnAdjustedOrder

public void initReturnAdjustedOrder(ReturnRequest pReturnRequest)
                             throws ReturnException
Creates a new Return Adjusted Order in the ReturnRequest

Parameters:
pReturnRequest -
Throws:
ReturnException
See Also:
createReturnAdjustedOrder(ReturnRequest)

initReturnCalculationOrder

public void initReturnCalculationOrder(ReturnRequest pReturnRequest)
                                throws ReturnException
Creates a new Return Calculation Order in the ReturnRequest

Parameters:
pReturnRequest -
Throws:
ReturnException
See Also:
createReturnCalculationOrder(ReturnRequest)

createPromotionEvaluationOrder

protected Order createPromotionEvaluationOrder(ReturnRequest pReturnRequest)
                                        throws ReturnException
Creates the Promotion Evaluation Order for the exchange.

The Return Calculation Order is cloned to create the Promotion Evaluation Order. Hence the PEO starts out as an exact copy of the Return Calculation Order. This order is modified whenever the exchange order is priced to incorporate a copy of each exchange item and determine pricing adjustments.

The CloneEditManager is used to perform the cloning process using the pipeline specified by the configurable createPromtoionEvaluationOrderPipeline property.

Parameters:
pReturnRequest -
Returns:
the Promotion Evaluation Order
Throws:
ReturnException

clearExchangeItemsFromPEO

protected void clearExchangeItemsFromPEO(ReturnRequest pReturnRequest)
                                  throws ReturnException
Removes all items from the promotion evaluation order that were created from the items in the new exchange order.

Using the ReturnRequest's exchangeToPEOItemMap, removes all the items based on the values in the map.

Parameters:
pReturnRequest -
Throws:
ReturnException

clearExchangeShippingGroupsFromPEO

protected void clearExchangeShippingGroupsFromPEO(ReturnRequest pReturnRequest)
                                           throws ReturnException
Removes all shipping groups from the promotion evaluation order that were created from the shipping groups in the new exchange order.

Using the ReturnRequest's ExchangeToPEOShippingGroupMap, removes all the shipping groups based on the values in the map.

Parameters:
pReturnRequest -
Throws:
ReturnException

updatePromotionEvaluationOrder

protected void updatePromotionEvaluationOrder(ReturnRequest pReturnRequest)
                                       throws RepositoryException,
                                              MarkerException,
                                              CommerceException
This method does the work of updating the Promotion Evaluation Order. It will create the PEO if it doesn't exist yet, make a copy of the replacement order items for it, generate its GWP meta-data and price it.

Parameters:
pReturnRequest -
Throws:
ReturnException
RepositoryException
MarkerException
CommerceException
See Also:
registerProcessPEOSynchronization(ReturnRequest), copyExchangeItemAndShippingGroupInfoToPEO(ReturnRequest)

processPromotionEvaluationOrder

public void processPromotionEvaluationOrder(ReturnRequest pReturnRequest)
                                     throws ReturnException
This method is called whenever the exchange order is priced.

It does the work to updating the promotion evaluation order with a fresh copy of the exchange items and shipping groups, re-pricing the PEO, (re)calculating new refund amounts and {re)calculating the change in promotion values Map.

The return's refund amounts are recalculated as part of the process since changes in the PEO can affect the suggested refund values.

Parameters:
pReturnRequest -
Throws:
ReturnException
See Also:
updatePromotionEvaluationOrder(ReturnRequest), ReturnTools.generatePromotionValueAdjustmentMap(ReturnRequest), #calculateRefundAmounts(ReturnRequest)

copyExchangeItemAndShippingGroupInfoToPEO

protected void copyExchangeItemAndShippingGroupInfoToPEO(ReturnRequest pReturnRequest)
                                                  throws ReturnException
This method makes a copy of each exchange item in the exchange order and puts them in the PEO. This process will remove any items and shipping groups in the PEO that were copied from the exchange order previously, copy the exchange items and shipping groups again and recreate the exchangeItemToPEOItemMap and exchangeShippingGroupsMap

This method also takes care of copying the price info for items marked as final in the exchange order over to their corresponding items in the PEO.

Parameters:
pReturnRequest -
Throws:
ReturnException
See Also:
in the return request.

registerProcessPEOSynchronization

public void registerProcessPEOSynchronization(ReturnRequest pReturnRequest)
Registers a synchronization object that will invalidate the promotion evaluation order and reset the item and shipping group maps used to map peo objects to the exchange order objects when the transaction is rolled back.

Parameters:
pReturnRequest - the return request
See Also:
ProcessPEOSynchronization

createProcessPEOSynchronization

protected atg.commerce.csr.returns.ProcessPEOSynchronization createProcessPEOSynchronization(ReturnRequest pReturnRequest)
Creates a new ProcessPEOSynchronization that's used to handle transaction rollback in the processPromotionEvaluationOrder method.

Parameters:
pReturnRequest -
Returns:
a new ProcessPEOSynchronization

calculateExchangeOrderPromotionDiscountValues

public void calculateExchangeOrderPromotionDiscountValues(ReturnRequest pReturnRequest)
                                                   throws ReturnException
Generates the Map of order promotion to exchange order value.

The value of each order promotion applied to the replacement items in the promotion evaluation order is calculated. This value map is used when pricing the exchange order to apply the correct order promotion adjustment to the exchange order.

Parameters:
pReturnRequest -
Throws:
ReturnException
See Also:
ExchangeOrderDiscountCalculator, ReturnRequest#getExchangeItemOrderPromotionValue()()

generatePreReturnPromotionValueMap

protected void generatePreReturnPromotionValueMap(ReturnRequest pReturnRequest)
This method will generate pre return promotion value map and store it in the preReturnPromotionValue property of the ReturnRequest

By default, this method generates the map against the Return Adjusted Order

Parameters:
pReturnRequest -
See Also:
#createPromotionValueMap(Order)

initPreReturnPromotionValues

public void initPreReturnPromotionValues(ReturnRequest pReturnRequest)
                                  throws ReturnException
Throws:
ReturnException

calculateExchangeManualAdjustmentDiscountValues

public void calculateExchangeManualAdjustmentDiscountValues(ReturnRequest pReturnRequest)
                                                     throws ReturnException
Generates the Map of manual adjustment to exchange order value. This map is stored in the exchangeItemManualAdjustmentValue property of the ReturnRequest

The value of each manual adjustment applied to the replacement items in the promotion evaluation order is calculated. This value map is used when pricing the exchange order to apply the correct manual adjustment value to the exchange order.

Parameters:
pReturnRequest -
Throws:
ReturnException
See Also:
ExchangeOrderAdjustmentCalculator, ReturnRequest.getExchangeManualAdjustmentValue()

getReturnManager

public static ReturnManager getReturnManager()
Returns the ReturnManager component. if the mReturnManager is null, then the ReturnManager is resolved using Nucleus#getGlobalNucleus()#resolveName(String) and the mReturnManager variable is set.

Returns:
ReturnManager return the resolved ReturnManager component.

prepareReplacementOrderToSubmit

protected void prepareReplacementOrderToSubmit(ReturnRequest pReturnRequest)
                                        throws ReturnException
Throws:
ReturnException
See Also:
prepareReplacementOrderToSubmit(ReturnRequest, Map)

prepareReplacementOrderToSubmit

public void prepareReplacementOrderToSubmit(ReturnRequest pReturnRequest,
                                            java.util.Map pExtraParameters)
                                     throws ReturnException,
                                            PipelineErrorReturnException
Executes the pre-submission process on the replacement order. This process is executed when the replacement order is saved for submission at a later time (i.e. waiting for items to be received). It will handle things like payment group authorizations, etc.

The caller of this API is responsible for calling OrderManager.updateOrder(Order) The pipeline that is executed is identified by the getPrepareReplacementOrderChainId() property.

Parameters:
pReturnRequest -
pExtraParameters -
Throws:
ReturnException
PipelineErrorReturnException

isOrderPaymentGroupsAuthorized

protected boolean isOrderPaymentGroupsAuthorized(Order pOrder)
If any of the payment groups have non empty authorization status, then the payment groups in the order are considered to be already authorized.

Parameters:
pOrder - From this order payment groups are obtained
Returns:

isValidRefundValue

public boolean isValidRefundValue(ReturnRequest pReturnRequest)
Deprecated. use isValidExchangeRefundValue and isValidReturnRefundValue

determines if the refund value in the request is appropriate for a return or an exchange.

Parameters:
pReturnRequest -
Returns:
false if the refund value is not valid.
See Also:
isValidExchangeRefundValue(ReturnRequest), isValidReturnRefundValue(ReturnRequest)

isValidReturnRefundValue

public boolean isValidReturnRefundValue(ReturnRequest pReturnRequest)
determines if the refund value is appropriate for a return.

For a return the refund must be higher than 0.

Parameters:
pReturnRequest -
Returns:
false if the refund value is not valid.

isValidExchangeRefundValue

public boolean isValidExchangeRefundValue(ReturnRequest pReturnRequest)
determines if the refund value is appropriate for an exchange.

For an exchange, the refund must be 0 or higher.

Parameters:
pReturnRequest -
Returns:
false if the refund value is not valid.

sendReturnSubmittedEvent

public void sendReturnSubmittedEvent(ReturnRequest pReturnRequest)
Sends the event the indicated a new return has been submitted.

Parameters:
pReturnRequest -

sendReturnCompletedEvent

public void sendReturnCompletedEvent(ReturnRequest pReturnRequest)
Sends the event that indicates a return has been completed.

Parameters:
pReturnRequest -

sendReturnMerchandiseReceivedEvent

public void sendReturnMerchandiseReceivedEvent(ReturnRequest pReturnRequest,
                                               java.util.Map<java.lang.String,java.lang.Long> pReturnItemToQuantityReceived,
                                               java.util.Map<java.lang.String,java.lang.String> pReturnItemToReceivedDisposition)
Sends the event that indicates returned merchandise has been received.

Parameters:
pReturnRequest -
pReturnItemToQuantityReceived - Maps the return item id to the quantity being received
pReturnItemToReceivedDisposition - Maps the return item id to the received disposition