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 Details

  • Constructor Details

    • FulfillmentItemPricingActivity

      public FulfillmentItemPricingActivity()
  • Method Details

    • getCurrency

      protected org.broadleafcommerce.common.currency.domain.BroadleafCurrency getCurrency(FulfillmentGroup fg)
    • getOrderSavingsToDistribute

      protected org.broadleafcommerce.common.money.Money getOrderSavingsToDistribute(Order order)
      Returns the order adjustment value or zero if none exists
      Parameters:
      order -
      Returns:
    • execute

      public ProcessContext<Order> execute(ProcessContext<Order> 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.

      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

      protected void updateTaxableAmountsOnItems(Order order)
      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)