Class DefaultFulfillmentSplittingService

java.lang.Object
com.broadleafcommerce.orderoperation.service.split.DefaultFulfillmentSplittingService
All Implemented Interfaces:
FulfillmentSplittingService<com.broadleafcommerce.order.client.domain.OrderFulfillment>

public class DefaultFulfillmentSplittingService extends Object implements FulfillmentSplittingService<com.broadleafcommerce.order.client.domain.OrderFulfillment>
Responsible for splitting a fulfillment by moving all non-requested items and quantities into a newly generated fulfillment.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultFulfillmentSplittingService(com.broadleafcommerce.common.extension.TypeFactory typeFactory, FulfillmentSplitRoundingService roundingService, FulfillmentOperationHelper helper)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    assignOrderFulfillmentNumbers(List<com.broadleafcommerce.order.client.domain.OrderFulfillment> fulfillments, String originalFulfillmentNumber)
    Assigns the orderFulfillmentNumbers for the split fulfillments.
    protected <T> BiConsumer<Function<T,javax.money.MonetaryAmount>,BiConsumer<T,javax.money.MonetaryAmount>>
    bindAmountSplitter(List<BigDecimal> splitProportions, T original, List<T> splits)
    Produces a BiConsumer which can split a certain amount between original and split with a specific splitting proportion.
    protected void
    calculateAndSplitTotalFulfillmentPrices(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
    Calculate the OrderFulfillment#totalFulfillmentPrice for the splits based on their totals, and then give the remainder from the original amount to the original.
    protected javax.money.MonetaryAmount
    calculateFulfillmentItemsTotal(com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment)
     
    protected javax.money.MonetaryAmount
    calculateMerchandiseTotal(com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment)
     
    protected void
    copyTaxDetails(com.broadleafcommerce.order.client.domain.OrderFulfillmentItem originalItem, com.broadleafcommerce.order.client.domain.OrderFulfillmentItem splitItem)
    Copies the tax details from the original item to the new item.
    protected com.broadleafcommerce.order.client.domain.OrderFulfillment
    createSplitFulfillment(com.broadleafcommerce.order.client.domain.OrderFulfillment original)
    Set up a new clone OrderFulfillment to be used for the requested part of the fulfillment to split off.
    protected com.broadleafcommerce.order.client.domain.OrderFulfillmentItem
    createSplitItem(com.broadleafcommerce.order.client.domain.OrderFulfillmentItem item)
    Set up a new clone OrderFulfillmentItem to be used for the split quantity of the fulfillment item.
    protected <T> javax.money.MonetaryAmount
    getAmountTotal(@NonNull List<T> objects, @NonNull Function<T,javax.money.MonetaryAmount> amountGetter, @NonNull javax.money.CurrencyUnit currency)
    Helper method to sum up the MonetaryAmounts for each given object using the given amountGetter function.
     
     
    protected List<BigDecimal>
    getPerFulfillmentMerchandiseSplits(List<com.broadleafcommerce.order.client.domain.OrderFulfillment> fulfillments)
    Determine the proportions by which per-fulfillment prices should be split.
    protected List<BigDecimal>
    getPerFulfillmentPriceSplits(List<com.broadleafcommerce.order.client.domain.OrderFulfillment> fulfillments)
    Determine the proportions by which per-fulfillment prices should be split.
     
    protected List<javax.money.MonetaryAmount>
    getSplitFulfillmentIncludedTaxes(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
    Get the included tax for the fulfillment total of the new split fulfillments.
    protected List<javax.money.MonetaryAmount>
    getSplitFulfillmentPriceTaxes(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
    Get the tax just for the fulfillment prices for the new split fulfillments, not including tax on the merchandise price.
    protected List<com.broadleafcommerce.order.client.domain.OrderFulfillment>
    getSplitFulfillments(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem>> splitItems)
    Gets a list of split OrderFulfillments from the given list of split OrderFulfillmentItems.
    protected List<javax.money.MonetaryAmount>
    getSplitMerchandiseIncludedTaxes(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
    Get the included tax for the merchandise total of the new split fulfillments.
    protected List<javax.money.MonetaryAmount>
    getSplitMerchandiseTotalTaxes(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
    Get the tax for the merchandise total of the new split fulfillments, not including tax on the fulfillment price.
    protected com.broadleafcommerce.common.extension.TypeFactory
     
    void
     
    protected <T> void
    splitAmount(Function<T,javax.money.MonetaryAmount> getAmount, BiConsumer<T,javax.money.MonetaryAmount> setAmount, List<BigDecimal> splitProportions, T original, List<T> splits)
    Splits a certain amount from original between all of the split original and splits.
    List<com.broadleafcommerce.order.client.domain.OrderFulfillment>
    splitFulfillment(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<Map<String,Integer>> itemQuantities)
    Splits the given fulfillment into multiple.
    protected List<List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem>>
    splitItems(List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> items, List<Map<String,Integer>> itemQuantities)
    Split the fulfillment items into two lists based on the requested itemQuantities to split.
    protected void
    splitRequestedItem(com.broadleafcommerce.order.client.domain.OrderFulfillmentItem item, List<Integer> requestedQuantities, List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> leftover, List<List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem>> splits, List<Map<String,String>> newItemIdsByOriginalItemIds)
    Split the fulfillment item quantities between the split item lists.
    protected void
    updateAdjustments(List<BigDecimal> splitProportions, List<com.broadleafcommerce.order.common.domain.Adjustment> original, List<List<com.broadleafcommerce.order.common.domain.Adjustment>> splits)
    Splits the original adjustment amounts from original between original and split, based on the splitProportion.
    protected void
    updateFulfillmentAdjustmentsTotal(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
    Handles splitting OrderFulfillment.getFulfillmentAdjustmentsTotal().
    protected void
    updateFulfillmentCharge(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
    Split the original OrderFulfillment.fulfillmentCharge between the split fulfillments.
    protected void
    updateFulfillmentFulfillmentPricing(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> allFulfillments)
    Handles splitting and prorating the fulfillment pricing.
    protected void
    updateFulfillmentMerchandisePricing(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> allFulfillments)
    Handles splitting and prorating the merchandise pricing.
    protected void
    updateFulfillmentPricing(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
    Update the price amounts for the newly split fulfillments.
    protected void
    updateFulfillmentProratedAdjustments(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
    Handles splitting OrderFulfillment.getProratedOrderFulfillmentAdjustments().
    protected void
    updateGrandTotal(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
    Update the OrderFulfillment.grandTotal for the splits based on their totals, and then give the remainder from the original amount to the original.
    protected void
    updateItemPricing(Integer originalQuantity, com.broadleafcommerce.order.client.domain.OrderFulfillmentItem originalItem, List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> splitItems)
    Update the price amounts for the new split fulfillment item quantities.
    protected void
    updateItemPricingAmounts(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillmentItem original, List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> splits)
    Splits the original pricing amounts from original between original and split, based on the splitProportion.
    protected void
    updateMerchandiseTotal(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
    Split the original OrderFulfillment.merchandiseTotal between the split fulfillments.
    protected void
    updateSplitItemsQualifierFulfillmentItemDetails(List<List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem>> splits, List<Map<String,String>> newItemIdsByOriginalItemIds)
    Builds and adds the qualifier fulfillment item OfferItemDetails for newly created split fulfillment items.
    protected void
    updateTaxDetailsAmounts(List<BigDecimal> splitProportions, List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail> original, List<List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail>> splits)
     
    protected void
    updateTaxFieldsAmounts(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillmentItem original, List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> splits)
     
    protected void
    updateTotalFulfillmentPrices(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
    Calculate and split the OrderFulfillment#totalFulfillmentPrice between the split fulfillments.
    protected void
    updateTotalTaxes(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
    Split the original OrderFulfillment#totalTax between the split fulfillments.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • splitFulfillment

      public List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splitFulfillment(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<Map<String,Integer>> itemQuantities)
      Description copied from interface: FulfillmentSplittingService
      Splits the given fulfillment into multiple. The first split fulfillment will contain the remainder of the original fulfillment, while the rest will contain the portions requested by itemQuantities.
      Specified by:
      splitFulfillment in interface FulfillmentSplittingService<com.broadleafcommerce.order.client.domain.OrderFulfillment>
      Parameters:
      original - the original fulfillment to split
      itemQuantities - the quantities of each item to put into each fulfillment, with each map having the fulfillment item ID as the key, and the quantity to include in that fulfillment as the value
      Returns:
      a list containing the original fulfillment now containing the remainder of the original fulfillment, and all of the new fulfillments each containing the items requested
    • getSplitFulfillments

      protected List<com.broadleafcommerce.order.client.domain.OrderFulfillment> getSplitFulfillments(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem>> splitItems)
      Gets a list of split OrderFulfillments from the given list of split OrderFulfillmentItems.
      Parameters:
      original - the original OrderFulfillment prior the split
      splitItems - a list of OrderFulfillmentItems representing how they're split
      Returns:
      a list of split OrderFulfillments from the given list of split OrderFulfillmentItems
    • createSplitFulfillment

      protected com.broadleafcommerce.order.client.domain.OrderFulfillment createSplitFulfillment(com.broadleafcommerce.order.client.domain.OrderFulfillment original)
      Set up a new clone OrderFulfillment to be used for the requested part of the fulfillment to split off.
      Parameters:
      original - the fulfillment to clone to be split
      Returns:
      a new fulfillment with no items matching the non-unique values of the original
    • splitItems

      protected List<List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem>> splitItems(List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> items, List<Map<String,Integer>> itemQuantities)
      Split the fulfillment items into two lists based on the requested itemQuantities to split.
      Parameters:
      items - the list of fulfillment items to split
      itemQuantities - requested items and their quantities to split
      Returns:
      two lists of fulfillment items, the first with the remaining items, and the second with the split item quantities requested by itemQuantities
    • updateSplitItemsQualifierFulfillmentItemDetails

      protected void updateSplitItemsQualifierFulfillmentItemDetails(List<List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem>> splits, List<Map<String,String>> newItemIdsByOriginalItemIds)
      Builds and adds the qualifier fulfillment item OfferItemDetails for newly created split fulfillment items.

      Whenever split fulfillment items are created, their ids are changed. Therefore we need to create new qualifier fulfillment item OfferItemDetails with the new ids.

      Parameters:
      splits - lists of fulfillment items which were split from the original fulfillments
      newItemIdsByOriginalItemIds - maps of new fulfillment item ids by original fulfillment item ids prior the split
    • splitRequestedItem

      protected void splitRequestedItem(com.broadleafcommerce.order.client.domain.OrderFulfillmentItem item, List<Integer> requestedQuantities, List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> leftover, List<List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem>> splits, List<Map<String,String>> newItemIdsByOriginalItemIds)
      Split the fulfillment item quantities between the split item lists.
      Parameters:
      item - the fulfillment item to split
      requestedQuantities - the quantities to put into each of splits
      leftover - list of remaining fulfillment items which were not requested
      splits - lists of fulfillment items which were requested
      newItemIdsByOriginalItemIds - maps of new fulfillment item ids by original fulfillment item ids prior the split
    • createSplitItem

      protected com.broadleafcommerce.order.client.domain.OrderFulfillmentItem createSplitItem(com.broadleafcommerce.order.client.domain.OrderFulfillmentItem item)
      Set up a new clone OrderFulfillmentItem to be used for the split quantity of the fulfillment item.
      Parameters:
      item - the fulfillment item to clone to be split
      Returns:
      a new fulfillment item with no quantity matching the non-unique values of the original item
    • copyTaxDetails

      protected void copyTaxDetails(com.broadleafcommerce.order.client.domain.OrderFulfillmentItem originalItem, com.broadleafcommerce.order.client.domain.OrderFulfillmentItem splitItem)
      Copies the tax details from the original item to the new item.
      Parameters:
      originalItem - The original fulfillment item
      splitItem - The split item
    • updateItemPricing

      protected void updateItemPricing(Integer originalQuantity, com.broadleafcommerce.order.client.domain.OrderFulfillmentItem originalItem, List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> splitItems)
      Update the price amounts for the new split fulfillment item quantities.

      Splits amounts proportionally based on the quantity of each new item.

      Parameters:
      originalQuantity - the original quantity of the item before splitting
      originalItem - the split item with the quantity that was leftover
      splitItems - the split items with the quantities that are being split off
    • updateTaxDetailsAmounts

      protected void updateTaxDetailsAmounts(List<BigDecimal> splitProportions, List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail> original, List<List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail>> splits)
    • updateTaxFieldsAmounts

      protected void updateTaxFieldsAmounts(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillmentItem original, List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> splits)
    • updateAdjustments

      protected void updateAdjustments(List<BigDecimal> splitProportions, List<com.broadleafcommerce.order.common.domain.Adjustment> original, List<List<com.broadleafcommerce.order.common.domain.Adjustment>> splits)
      Splits the original adjustment amounts from original between original and split, based on the splitProportion.
      Parameters:
      splitProportions - the decimal fractions of the amounts being split off
      original - the split adjustments for the leftover items or fulfillments
      splits - the split adjustments for the items or fulfillments being split off
    • updateItemPricingAmounts

      protected void updateItemPricingAmounts(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillmentItem original, List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> splits)
      Splits the original pricing amounts from original between original and split, based on the splitProportion.
      Parameters:
      splitProportions - the decimal fractions of the amounts being split off
      original - the original item with the quantity that was leftover
      splits - the split item with the quantities that are being split off
    • updateFulfillmentPricing

      protected void updateFulfillmentPricing(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
      Update the price amounts for the newly split fulfillments.
      Parameters:
      original - the original fulfillment, which is now only a split part
      splits - the fulfillments which were split off from the original
    • updateFulfillmentMerchandisePricing

      protected void updateFulfillmentMerchandisePricing(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> allFulfillments)
      Handles splitting and prorating the merchandise pricing.
      Parameters:
      original - Original fulfillment that was split
      splits - The new fulfillments made by splitting original
      allFulfillments - All of the fulfillments. Used to determine ratios for prorating the original pricing.
    • updateFulfillmentFulfillmentPricing

      protected void updateFulfillmentFulfillmentPricing(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> allFulfillments)
      Handles splitting and prorating the fulfillment pricing.
      Parameters:
      original - Original fulfillment that was split
      splits - The new fulfillments made by splitting original
      allFulfillments - All of the fulfillments. Used to determine ratios for prorating the original pricing.
    • updateFulfillmentProratedAdjustments

      protected void updateFulfillmentProratedAdjustments(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
      Handles splitting OrderFulfillment.getProratedOrderFulfillmentAdjustments().
      Parameters:
      splitProportions - The ratios used to prorate the original pricing among the new fulfillments.
      original - Original fulfillment that was split
      splits - The new fulfillments made by splitting original
    • updateFulfillmentAdjustmentsTotal

      protected void updateFulfillmentAdjustmentsTotal(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
      Handles splitting OrderFulfillment.getFulfillmentAdjustmentsTotal().
      Parameters:
      splitProportions - The ratios used to prorate the original pricing among the new fulfillments.
      original - Original fulfillment that was split
      splits - The new fulfillments made by splitting original
    • getPerFulfillmentPriceSplits

      protected List<BigDecimal> getPerFulfillmentPriceSplits(List<com.broadleafcommerce.order.client.domain.OrderFulfillment> fulfillments)
      Determine the proportions by which per-fulfillment prices should be split.

      The default is to split proportionally based on the total of the OrderFulfillmentItem.fulfillmentTotal for each fulfillment.

      Parameters:
      fulfillments - the fulfillments which were split, including the original/leftover
      Returns:
      list of the proportions by which per-fulfillment prices should be split for each fulfillment
    • calculateFulfillmentItemsTotal

      protected javax.money.MonetaryAmount calculateFulfillmentItemsTotal(com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment)
    • getPerFulfillmentMerchandiseSplits

      protected List<BigDecimal> getPerFulfillmentMerchandiseSplits(List<com.broadleafcommerce.order.client.domain.OrderFulfillment> fulfillments)
      Determine the proportions by which per-fulfillment prices should be split.

      The default is to split proportionally based on the total of the OrderFulfillmentItem.merchandiseTotal for each fulfillment.

      Parameters:
      fulfillments - the fulfillments which were split, including the original/leftover
      Returns:
      list of the proportions by which per-fulfillment prices should be split for each fulfillment
    • calculateMerchandiseTotal

      protected javax.money.MonetaryAmount calculateMerchandiseTotal(com.broadleafcommerce.order.client.domain.OrderFulfillment fulfillment)
    • updateMerchandiseTotal

      protected void updateMerchandiseTotal(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
      Split the original OrderFulfillment.merchandiseTotal between the split fulfillments.
      Parameters:
      splitProportions - the decimal fractions of the amounts being split off
      original - the original fulfillment with the leftover item quantities
      splits - the fulfillments which were split off from the original
    • updateFulfillmentCharge

      protected void updateFulfillmentCharge(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
      Split the original OrderFulfillment.fulfillmentCharge between the split fulfillments.
      Parameters:
      splitProportions - the decimal fractions of the amounts being split off
      original - the original fulfillment with the leftover item quantities
      splits - the fulfillments which were split off from the original
    • updateTotalFulfillmentPrices

      protected void updateTotalFulfillmentPrices(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
      Calculate and split the OrderFulfillment#totalFulfillmentPrice between the split fulfillments.

      If it is an overridden price, it will be split proportionally.

      Otherwise, the amount for the original fulfillment will be calculated based on its other totals, and then the remainder from the original amount will be set on the split fulfillment.

      Parameters:
      splitProportions - the decimal fractions of the amounts being split off
      original - the original fulfillment with the leftover item quantities
      splits - the fulfillments which were split off from the original
    • calculateAndSplitTotalFulfillmentPrices

      protected void calculateAndSplitTotalFulfillmentPrices(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
      Calculate the OrderFulfillment#totalFulfillmentPrice for the splits based on their totals, and then give the remainder from the original amount to the original.
      Parameters:
      original - the original fulfillment with the leftover item quantities
      splits - the fulfillments which were split off from the original
    • updateTotalTaxes

      protected void updateTotalTaxes(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
      Split the original OrderFulfillment#totalTax between the split fulfillments.

      The split tax will be its merchandise total tax plus a portion of the original fulfillment tax, based on the split fulfillment taxable amounts. The original tax will be the remainder of the original amount left over.

      Parameters:
      original - the original fulfillment with the leftover item quantities
      splits - the fulfillments which were split off from the original
    • getSplitFulfillmentPriceTaxes

      protected List<javax.money.MonetaryAmount> getSplitFulfillmentPriceTaxes(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
      Get the tax just for the fulfillment prices for the new split fulfillments, not including tax on the merchandise price.
      Parameters:
      original - the original fulfillment with the leftover item quantities
      splits - the fulfillments which were split off from the original
      Returns:
      the fulfillment price taxes for each of the new splits fulfillments
    • getSplitMerchandiseTotalTaxes

      protected List<javax.money.MonetaryAmount> getSplitMerchandiseTotalTaxes(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
      Get the tax for the merchandise total of the new split fulfillments, not including tax on the fulfillment price.
      Parameters:
      original - the original fulfillment with the leftover item quantities
      splits - the fulfillments which were split off from the original
      Returns:
      the merchandise total taxes for each of the new splits fulfillments
    • getSplitMerchandiseIncludedTaxes

      protected List<javax.money.MonetaryAmount> getSplitMerchandiseIncludedTaxes(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
      Get the included tax for the merchandise total of the new split fulfillments.
      Parameters:
      original - the original fulfillment with the leftover item quantities
      splits - the fulfillments which were split off from the original
      Returns:
      the merchandise included taxes for each of the new splits fulfillments
    • getSplitFulfillmentIncludedTaxes

      protected List<javax.money.MonetaryAmount> getSplitFulfillmentIncludedTaxes(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
      Get the included tax for the fulfillment total of the new split fulfillments.
      Parameters:
      original - the original fulfillment with the leftover item quantities
      splits - the fulfillments which were split off from the original
      Returns:
      the fulfillment included taxes for each of the new splits fulfillments
    • updateGrandTotal

      protected void updateGrandTotal(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits)
      Update the OrderFulfillment.grandTotal for the splits based on their totals, and then give the remainder from the original amount to the original.
      Parameters:
      original - the original fulfillment with the leftover item quantities
      splits - the fulfillments which were split off from the original
    • bindAmountSplitter

      protected <T> BiConsumer<Function<T,javax.money.MonetaryAmount>,BiConsumer<T,javax.money.MonetaryAmount>> bindAmountSplitter(List<BigDecimal> splitProportions, T original, List<T> splits)
      Produces a BiConsumer which can split a certain amount between original and split with a specific splitting proportion.
      Type Parameters:
      T - the type of the split domain
      Parameters:
      splitProportions - the decimal fractions of the amounts being split off
      original - the original domain, which will be updated to the leftover amount
      splits - the parts of the domain which are being split off
      Returns:
      a function which, when called with the getter and setter for an amount on DefaultFulfillmentSplittingService, can split that amount from original between both original and split based on the given splitProportion
    • splitAmount

      protected <T> void splitAmount(Function<T,javax.money.MonetaryAmount> getAmount, BiConsumer<T,javax.money.MonetaryAmount> setAmount, List<BigDecimal> splitProportions, T original, List<T> splits)
      Splits a certain amount from original between all of the split original and splits. The split amount is not rounded, and must be reconciled later.
      Type Parameters:
      T - the type of the split domain
      Parameters:
      getAmount - getter on DefaultFulfillmentSplittingService to get the amount to split
      setAmount - setter on DefaultFulfillmentSplittingService to set the split amount
      splitProportions - the decimal fractions of the amounts being split off
      original - the original domain, which will be updated to the leftover amount
      splits - the parts of the domain which are being split off
    • assignOrderFulfillmentNumbers

      protected void assignOrderFulfillmentNumbers(List<com.broadleafcommerce.order.client.domain.OrderFulfillment> fulfillments, String originalFulfillmentNumber)
      Assigns the orderFulfillmentNumbers for the split fulfillments.

      The new numbers are the number of the original fulfillment, followed by an incrementing sequence count for each split fulfillment. For example, splitting a fulfillment with the number VENDOR-1 into two would produce VENDOR-1-1 and VENDOR-1-2.

      If there was no number for the original fulfillment, this will not assign any new fulfillment numbers.

      Parameters:
      fulfillments - the generated fulfillments to assign new numbers for
      originalFulfillmentNumber - the order fulfillment number of the original fulfillment
    • getAmountTotal

      protected <T> javax.money.MonetaryAmount getAmountTotal(@NonNull @NonNull List<T> objects, @NonNull @NonNull Function<T,javax.money.MonetaryAmount> amountGetter, @NonNull @NonNull javax.money.CurrencyUnit currency)
      Helper method to sum up the MonetaryAmounts for each given object using the given amountGetter function.
      Type Parameters:
      T - the type of the object
      Parameters:
      objects - a list of objects to sum
      amountGetter - the Function used to get the MonetaryAmounts from the given objects
      currency - the CurrencyUnit
      Returns:
      the total amount summed from the given objects
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getRoundingService

      protected FulfillmentSplitRoundingService getRoundingService()
    • getHelper

      protected FulfillmentOperationHelper getHelper()
    • getOfferUtils

      protected OrderOperationServiceOfferUtils getOfferUtils()
    • setOfferUtils

      @Autowired public void setOfferUtils(OrderOperationServiceOfferUtils offerUtils)