org.broadleafcommerce.core.pricing.service.workflow
Class FulfillmentItemPricingActivity

java.lang.Object
  extended by org.broadleafcommerce.core.workflow.BaseActivity
      extended by org.broadleafcommerce.core.pricing.service.workflow.FulfillmentItemPricingActivity
All Implemented Interfaces:
Activity, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware

public class FulfillmentItemPricingActivity
extends BaseActivity

Called during the pricing workflow to set each item's merchandise total and taxable total

Author:
Brian Polster

Constructor Summary
FulfillmentItemPricingActivity()
           
 
Method Summary
 long applyDifferenceToAmount(FulfillmentGroupItem fgItem, long numApplicationsNeeded, Money unitAmount)
           
 long applyDifferenceToProratedAdj(FulfillmentGroupItem fgItem, long numApplicationsNeeded, Money unitAmount)
           
 long applyTaxDifference(FulfillmentGroupItem fgItem, long numApplicationsNeeded, Money unitAmount)
           
protected  Money calculateTotalPriceForAllFulfillmentItems(Order order)
          Returns the total price for all fulfillment items.
 long countNumberOfUnits(Money difference)
           
protected  Money distributeOrderSavingsToItems(Order order, BigDecimal totalAllItems)
          Distributes the order adjustments (if any) to the individual fulfillment group items.
 ProcessContext execute(ProcessContext context)
          Called by the encompassing processor to activate the execution of the Activity
protected  void fixItemTotalRoundingIssues(Order order, Map<OrderItem,List<FulfillmentGroupItem>> partialOrderItemMap)
          Because an item may have multiple price details that don't round cleanly, we may have pennies left over that need to be distributed.
protected  void fixOrderSavingsRoundingIssues(Order order, Money totalOrderAdjustmentDistributed)
          It is possible due to rounding that the order adjustments do not match the total.
protected  BroadleafCurrency getCurrency(FulfillmentGroup fg)
           
protected  Money getOrderSavingsToDistribute(Order order)
          Returns the order adjustment value or zero if none exists
 Money getUnitAmount(Money difference)
          Returns the unit amount (e.g.
protected  void populateItemTotalAmount(Order order, Map<OrderItem,List<FulfillmentGroupItem>> partialOrderItemMap)
          Sets the fulfillment amount which includes the relative portion of the total price for the corresponding order item.
protected  Money sumItemAmount(List<FulfillmentGroupItem> items, Order order)
           
protected  Money sumTaxAmount(List<FulfillmentGroupItem> items, Order order)
           
protected  void updateTaxableAmountsOnItems(Order order)
          Returns the total price for all fulfillment items.
 
Methods inherited from class org.broadleafcommerce.core.workflow.BaseActivity
getAutomaticallyRegisterRollbackHandler, getBeanName, getErrorHandler, getRollbackHandler, getRollbackRegion, getStateConfiguration, setAutomaticallyRegisterRollbackHandler, setBeanName, setErrorHandler, setRollbackHandler, setRollbackRegion, setStateConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FulfillmentItemPricingActivity

public FulfillmentItemPricingActivity()
Method Detail

getCurrency

protected BroadleafCurrency getCurrency(FulfillmentGroup fg)

getOrderSavingsToDistribute

protected Money getOrderSavingsToDistribute(Order order)
Returns the order adjustment value or zero if none exists

Parameters:
order -
Returns:

execute

public ProcessContext execute(ProcessContext context)
                       throws Exception
Description copied from interface: Activity
Called by the encompassing processor to activate the execution of the Activity

Parameters:
context - - process context for this workflow
Returns:
resulting process context
Throws:
Exception

populateItemTotalAmount

protected void populateItemTotalAmount(Order order,
                                       Map<OrderItem,List<FulfillmentGroupItem>> partialOrderItemMap)
Sets the fulfillment amount which includes the relative portion of the total price for the corresponding order item.

Parameters:
order -
partialOrderItemMap -

fixItemTotalRoundingIssues

protected void fixItemTotalRoundingIssues(Order order,
                                          Map<OrderItem,List<FulfillmentGroupItem>> partialOrderItemMap)
Because an item may have multiple price details that don't round cleanly, we may have pennies left over that need to be distributed.

Parameters:
order -
partialOrderItemMap -

calculateTotalPriceForAllFulfillmentItems

protected Money calculateTotalPriceForAllFulfillmentItems(Order order)
Returns the total price for all fulfillment items.

Parameters:
order -
Returns:

distributeOrderSavingsToItems

protected Money distributeOrderSavingsToItems(Order order,
                                              BigDecimal totalAllItems)
Distributes the order adjustments (if any) to the individual fulfillment group items.

Parameters:
order -
totalAllItems -
Returns:

fixOrderSavingsRoundingIssues

protected void fixOrderSavingsRoundingIssues(Order order,
                                             Money totalOrderAdjustmentDistributed)
It is possible due to rounding that the order adjustments do not match the total. This method fixes by adding or removing the pennies.

Parameters:
order -
partialOrderItemMap -

updateTaxableAmountsOnItems

protected void updateTaxableAmountsOnItems(Order order)
Returns the total price for all fulfillment items.

Parameters:
order -

sumItemAmount

protected Money sumItemAmount(List<FulfillmentGroupItem> items,
                              Order order)

sumTaxAmount

protected Money sumTaxAmount(List<FulfillmentGroupItem> items,
                             Order order)

countNumberOfUnits

public long countNumberOfUnits(Money difference)

getUnitAmount

public Money getUnitAmount(Money difference)
Returns the unit amount (e.g. .01 for US)

Parameters:
currency -
Returns:

applyDifferenceToAmount

public long applyDifferenceToAmount(FulfillmentGroupItem fgItem,
                                    long numApplicationsNeeded,
                                    Money unitAmount)

applyDifferenceToProratedAdj

public long applyDifferenceToProratedAdj(FulfillmentGroupItem fgItem,
                                         long numApplicationsNeeded,
                                         Money unitAmount)

applyTaxDifference

public long applyTaxDifference(FulfillmentGroupItem fgItem,
                               long numApplicationsNeeded,
                               Money unitAmount)


Copyright © 2013. All Rights Reserved.