Class DefaultFulfillmentSplittingService
- All Implemented Interfaces:
FulfillmentSplittingService<com.broadleafcommerce.order.client.domain.OrderFulfillment>
-
Constructor Summary
ConstructorDescriptionDefaultFulfillmentSplittingService
(com.broadleafcommerce.common.extension.TypeFactory typeFactory, FulfillmentSplitRoundingService roundingService, FulfillmentOperationHelper helper) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
assignOrderFulfillmentNumbers
(List<com.broadleafcommerce.order.client.domain.OrderFulfillment> fulfillments, String originalFulfillmentNumber) Assigns theorderFulfillmentNumbers
for the splitfulfillments
.protected <T> BiConsumer<Function<T,
javax.money.MonetaryAmount>, BiConsumer<T, javax.money.MonetaryAmount>> bindAmountSplitter
(List<BigDecimal> splitProportions, T original, List<T> splits) Produces aBiConsumer
which can split a certain amount betweenoriginal
andsplit
with a specific splitting proportion.protected void
calculateAndSplitTotalFulfillmentPrices
(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits) Calculate theOrderFulfillment#totalFulfillmentPrice
for thesplits
based on their totals, and then give the remainder from the original amount to theoriginal
.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 thetax 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 cloneOrderFulfillment
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 cloneOrderFulfillmentItem
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 theMonetaryAmounts
for each given object using the givenamountGetter function
.protected FulfillmentOperationHelper
protected OrderOperationServiceOfferUtils
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 FulfillmentSplitRoundingService
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 splitOrderFulfillments
from the given list of splitOrderFulfillmentItems
.protected com.broadleafcommerce.common.extension.TypeFactory
void
setOfferUtils
(OrderOperationServiceOfferUtils offerUtils) 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 fromoriginal
between all of the splitoriginal
andsplits
.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.splitItems
(List<com.broadleafcommerce.order.client.domain.OrderFulfillmentItem> items, List<Map<String, Integer>> itemQuantities) Split the fulfillment items into two lists based on the requesteditemQuantities
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 fromoriginal
betweenoriginal
andsplit
, based on thesplitProportion
.protected void
updateFulfillmentAdjustmentsTotal
(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits) Handles splittingOrderFulfillment.getFulfillmentAdjustmentsTotal()
.protected void
updateFulfillmentCharge
(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits) Split the originalOrderFulfillment.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 splittingOrderFulfillment.getProratedOrderFulfillmentAdjustments()
.protected void
updateGrandTotal
(com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits) Update theOrderFulfillment.grandTotal
for thesplits
based on their totals, and then give the remainder from the original amount to theoriginal
.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 fromoriginal
betweenoriginal
andsplit
, based on thesplitProportion
.protected void
updateMerchandiseTotal
(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits) Split the originalOrderFulfillment.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 itemOfferItemDetails
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
updateTotalFulfillmentPrices
(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits) Calculate and split theOrderFulfillment#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 originalOrderFulfillment#totalTax
between the split fulfillments.
-
Constructor Details
-
DefaultFulfillmentSplittingService
public DefaultFulfillmentSplittingService(com.broadleafcommerce.common.extension.TypeFactory typeFactory, FulfillmentSplitRoundingService roundingService, FulfillmentOperationHelper helper)
-
-
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 byitemQuantities
.- Specified by:
splitFulfillment
in interfaceFulfillmentSplittingService<com.broadleafcommerce.order.client.domain.OrderFulfillment>
- Parameters:
original
- the original fulfillment to splititemQuantities
- 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 splitOrderFulfillments
from the given list of splitOrderFulfillmentItems
.- Parameters:
original
- the originalOrderFulfillment
prior the splitsplitItems
- a list ofOrderFulfillmentItems
representing how they're split- Returns:
- a list of split
OrderFulfillments
from the given list of splitOrderFulfillmentItems
-
createSplitFulfillment
protected com.broadleafcommerce.order.client.domain.OrderFulfillment createSplitFulfillment(com.broadleafcommerce.order.client.domain.OrderFulfillment original) Set up a new cloneOrderFulfillment
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 requesteditemQuantities
to split.- Parameters:
items
- the list of fulfillment items to splititemQuantities
- 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 itemOfferItemDetails
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 newids
.- Parameters:
splits
- lists of fulfillment items which were split from the original fulfillmentsnewItemIdsByOriginalItemIds
- 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 splitrequestedQuantities
- the quantities to put into each ofsplits
leftover
- list of remaining fulfillment items which were not requestedsplits
- lists of fulfillment items which were requestednewItemIdsByOriginalItemIds
- 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 cloneOrderFulfillmentItem
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 thetax details
from the original item to the new item.- Parameters:
originalItem
- The original fulfillment itemsplitItem
- 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 splittingoriginalItem
- the split item with the quantity that was leftoversplitItems
- 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) -
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 fromoriginal
betweenoriginal
andsplit
, based on thesplitProportion
.- Parameters:
splitProportions
- the decimal fractions of the amounts being split offoriginal
- the split adjustments for the leftover items or fulfillmentssplits
- 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 fromoriginal
betweenoriginal
andsplit
, based on thesplitProportion
.- Parameters:
splitProportions
- the decimal fractions of the amounts being split offoriginal
- the original item with the quantity that was leftoversplits
- 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 partsplits
- 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 splitsplits
- The new fulfillments made by splittingoriginal
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 splitsplits
- The new fulfillments made by splittingoriginal
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 splittingOrderFulfillment.getProratedOrderFulfillmentAdjustments()
.- Parameters:
splitProportions
- The ratios used to prorate the original pricing among the new fulfillments.original
- Original fulfillment that was splitsplits
- The new fulfillments made by splittingoriginal
-
updateFulfillmentAdjustmentsTotal
protected void updateFulfillmentAdjustmentsTotal(List<BigDecimal> splitProportions, com.broadleafcommerce.order.client.domain.OrderFulfillment original, List<com.broadleafcommerce.order.client.domain.OrderFulfillment> splits) Handles splittingOrderFulfillment.getFulfillmentAdjustmentsTotal()
.- Parameters:
splitProportions
- The ratios used to prorate the original pricing among the new fulfillments.original
- Original fulfillment that was splitsplits
- The new fulfillments made by splittingoriginal
-
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 originalOrderFulfillment.merchandiseTotal
between the split fulfillments.- Parameters:
splitProportions
- the decimal fractions of the amounts being split offoriginal
- the original fulfillment with the leftover item quantitiessplits
- 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 originalOrderFulfillment.fulfillmentCharge
between the split fulfillments.- Parameters:
splitProportions
- the decimal fractions of the amounts being split offoriginal
- the original fulfillment with the leftover item quantitiessplits
- 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 theOrderFulfillment#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 thesplit
fulfillment.- Parameters:
splitProportions
- the decimal fractions of the amounts being split offoriginal
- the original fulfillment with the leftover item quantitiessplits
- 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 theOrderFulfillment#totalFulfillmentPrice
for thesplits
based on their totals, and then give the remainder from the original amount to theoriginal
.- Parameters:
original
- the original fulfillment with the leftover item quantitiessplits
- 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 originalOrderFulfillment#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. Theoriginal
tax will be the remainder of the original amount left over.- Parameters:
original
- the original fulfillment with the leftover item quantitiessplits
- 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 quantitiessplits
- the fulfillments which were split off from the original- Returns:
- the fulfillment price 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 theOrderFulfillment.grandTotal
for thesplits
based on their totals, and then give the remainder from the original amount to theoriginal
.- Parameters:
original
- the original fulfillment with the leftover item quantitiessplits
- the fulfillments which were split off from the original
-
bindAmountSplitter
protected <T> BiConsumer<Function<T,javax.money.MonetaryAmount>, bindAmountSplitterBiConsumer<T, javax.money.MonetaryAmount>> (List<BigDecimal> splitProportions, T original, List<T> splits) Produces aBiConsumer
which can split a certain amount betweenoriginal
andsplit
with a specific splitting proportion.- Type Parameters:
T
- the type of the split domain- Parameters:
splitProportions
- the decimal fractions of the amounts being split offoriginal
- the original domain, which will be updated to the leftover amountsplits
- 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 fromoriginal
between bothoriginal
andsplit
based on the givensplitProportion
-
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 fromoriginal
between all of the splitoriginal
andsplits
. The split amount is not rounded, and must be reconciled later.- Type Parameters:
T
- the type of the split domain- Parameters:
getAmount
- getter onDefaultFulfillmentSplittingService
to get the amount to splitsetAmount
- setter onDefaultFulfillmentSplittingService
to set the split amountsplitProportions
- the decimal fractions of the amounts being split offoriginal
- the original domain, which will be updated to the leftover amountsplits
- 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 theorderFulfillmentNumbers
for the splitfulfillments
.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 produceVENDOR-1-1
andVENDOR-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 fororiginalFulfillmentNumber
- 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 theMonetaryAmounts
for each given object using the givenamountGetter function
.- Type Parameters:
T
- the type of the object- Parameters:
objects
- a list of objects to sumamountGetter
- theFunction
used to get theMonetaryAmounts
from the given objectscurrency
- theCurrencyUnit
- Returns:
- the total amount summed from the given objects
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getRoundingService
-
getHelper
-
getOfferUtils
-
setOfferUtils
-