Class FulfillmentItemPricingActivity
java.lang.Object
org.broadleafcommerce.core.workflow.BaseActivity<ProcessContext<Order>>
org.broadleafcommerce.core.pricing.service.workflow.FulfillmentItemPricingActivity
- All Implemented Interfaces:
Activity<ProcessContext<Order>>,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.core.Ordered
@Component("blFulfillmentItemPricingActivity")
public class FulfillmentItemPricingActivity
extends BaseActivity<ProcessContext<Order>>
Called during the pricing workflow to set each item's merchandise total and taxable total
- Author:
- Brian Polster
-
Field Summary
FieldsFields inherited from class org.broadleafcommerce.core.workflow.BaseActivity
automaticallyRegisterRollbackHandler, beanName, errorHandler, order, rollbackHandler, rollbackRegion, stateConfigurationFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongapplyDifferenceToAmount(FulfillmentGroupItem fgItem, long numApplicationsNeeded, org.broadleafcommerce.common.money.Money unitAmount) longapplyDifferenceToProratedAdj(FulfillmentGroupItem fgItem, long numApplicationsNeeded, org.broadleafcommerce.common.money.Money unitAmount) longapplyTaxDifference(FulfillmentGroupItem fgItem, long numApplicationsNeeded, org.broadleafcommerce.common.money.Money unitAmount) protected org.broadleafcommerce.common.money.MoneyReturns the total price for all fulfillment items.longcountNumberOfUnits(org.broadleafcommerce.common.money.Money difference) protected org.broadleafcommerce.common.money.MoneydistributeOrderSavingsToItems(Order order, BigDecimal totalAllItems) Distributes the order adjustments (if any) to the individual fulfillment group items.execute(ProcessContext<Order> context) Called by the encompassing processor to activate the execution of the Activityprotected voidfixItemTotalRoundingIssues(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 voidfixOrderSavingsRoundingIssues(Order order, org.broadleafcommerce.common.money.Money totalOrderAdjustmentDistributed) It is possible due to rounding that the order adjustments do not match the total.protected org.broadleafcommerce.common.currency.domain.BroadleafCurrencyprotected org.broadleafcommerce.common.money.MoneygetOrderSavingsToDistribute(Order order) Returns the order adjustment value or zero if none existsorg.broadleafcommerce.common.money.MoneygetUnitAmount(org.broadleafcommerce.common.money.Money difference) Returns the unit amount (e.g. .01 for US)protected voidpopulateItemTotalAmount(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 org.broadleafcommerce.common.money.MoneysumItemAmount(List<FulfillmentGroupItem> items, Order order) protected org.broadleafcommerce.common.money.MoneysumTaxAmount(List<FulfillmentGroupItem> items, Order order) protected voidupdateTaxableAmountsOnItems(Order order) Returns the total price for all fulfillment items.Methods inherited from class org.broadleafcommerce.core.workflow.BaseActivity
getAutomaticallyRegisterRollbackHandler, getBeanName, getErrorHandler, getOrder, getRollbackHandler, getRollbackRegion, getStateConfiguration, setAutomaticallyRegisterRollbackHandler, setBeanName, setErrorHandler, setOrder, setRollbackHandler, setRollbackRegion, setStateConfiguration, shouldExecute
-
Field Details
-
ORDER
public static final int ORDER- See Also:
-
-
Constructor Details
-
FulfillmentItemPricingActivity
public FulfillmentItemPricingActivity()
-
-
Method Details
-
getCurrency
protected org.broadleafcommerce.common.currency.domain.BroadleafCurrency getCurrency(FulfillmentGroup fg) -
getOrderSavingsToDistribute
Returns the order adjustment value or zero if none exists- Parameters:
order-- Returns:
-
execute
Description copied from interface:ActivityCalled 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.This method may not be needed because the sum of the item amounts is derived from a double price (OrderItem's total) being multiplied and divided by whole numbers of which guarantees that each item amount is a clean multiple of the price of a single unit of that item. This behavior being enforced in populateItemTotalAmount. So we will never get a fraction of a cent that could cause totalItemAmount and totalFGItemAmount to be different values.
- Parameters:
order-partialOrderItemMap-
-
calculateTotalPriceForAllFulfillmentItems
protected org.broadleafcommerce.common.money.Money calculateTotalPriceForAllFulfillmentItems(Order order) Returns the total price for all fulfillment items.- Parameters:
order-- Returns:
-
distributeOrderSavingsToItems
protected org.broadleafcommerce.common.money.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, org.broadleafcommerce.common.money.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-totalOrderAdjustmentDistributed-
-
updateTaxableAmountsOnItems
Returns the total price for all fulfillment items.- Parameters:
order-
-
sumItemAmount
protected org.broadleafcommerce.common.money.Money sumItemAmount(List<FulfillmentGroupItem> items, Order order) -
sumTaxAmount
protected org.broadleafcommerce.common.money.Money sumTaxAmount(List<FulfillmentGroupItem> items, Order order) -
countNumberOfUnits
public long countNumberOfUnits(org.broadleafcommerce.common.money.Money difference) -
getUnitAmount
public org.broadleafcommerce.common.money.Money getUnitAmount(org.broadleafcommerce.common.money.Money difference) Returns the unit amount (e.g. .01 for US)- Parameters:
difference-- Returns:
-
applyDifferenceToAmount
public long applyDifferenceToAmount(FulfillmentGroupItem fgItem, long numApplicationsNeeded, org.broadleafcommerce.common.money.Money unitAmount) -
applyDifferenceToProratedAdj
public long applyDifferenceToProratedAdj(FulfillmentGroupItem fgItem, long numApplicationsNeeded, org.broadleafcommerce.common.money.Money unitAmount) -
applyTaxDifference
public long applyTaxDifference(FulfillmentGroupItem fgItem, long numApplicationsNeeded, org.broadleafcommerce.common.money.Money unitAmount)
-