public class CartPricingRoundingHelper extends Object
Constructor and Description |
---|
CartPricingRoundingHelper() |
Modifier and Type | Method and Description |
---|---|
protected javax.money.MonetaryAmount |
getUnitAmount(javax.money.CurrencyUnit currency)
Determines the smallest unit amount of money for the
CurrencyUnit . |
Map<String,javax.money.MonetaryAmount> |
roundListOfMonetaryAmounts(Map<String,javax.money.MonetaryAmount> amounts,
javax.money.MonetaryAmount totalAmount,
javax.money.CurrencyUnit currency)
Given a list of amounts that should round to the provided total, calculates and performs the
rounding logic to add the remainder unit amounts.
|
protected Map<String,javax.money.MonetaryAmount> |
roundListOfMonetaryAmounts(Map<String,javax.money.MonetaryAmount> amounts,
javax.money.MonetaryAmount totalAmount,
javax.money.MonetaryAmount unitAmount)
Given a list of amounts that should round to the provided total, calculates and performs the
rounding logic to add the remainder unit amounts.
|
<D extends com.broadleafcommerce.cart.client.domain.FulfillmentItem> |
roundProratedOrderAdjustmentsAcrossFulfillmentItems(Collection<D> fulfillmentItems,
javax.money.MonetaryAmount orderAdjustmentsTotal,
javax.money.CurrencyUnit currency)
Rounds split amounts for prorated order adjustments on fulfillment items.
|
protected <D extends com.broadleafcommerce.cart.client.domain.FulfillmentItem> |
updateFulfillmentItemsWithRoundedAdjustments(Collection<D> fulfillmentItems,
Map<String,javax.money.MonetaryAmount> proratedOrderAdjustmentAmounts,
javax.money.CurrencyUnit currency)
Sets the new rounded adjustment values on the fulfillment items.
|
public <D extends com.broadleafcommerce.cart.client.domain.FulfillmentItem> void roundProratedOrderAdjustmentsAcrossFulfillmentItems(Collection<D> fulfillmentItems, javax.money.MonetaryAmount orderAdjustmentsTotal, javax.money.CurrencyUnit currency)
fulfillmentItems
- the collection of fulfillment itemsorderAdjustmentsTotal
- the total adjustment amountcurrency
- the currency of the amounts to roundpublic Map<String,javax.money.MonetaryAmount> roundListOfMonetaryAmounts(Map<String,javax.money.MonetaryAmount> amounts, javax.money.MonetaryAmount totalAmount, javax.money.CurrencyUnit currency)
amounts
- list of amounts to round, mapped to a key for lookup on returntotalAmount
- the total adjustment amountprotected <D extends com.broadleafcommerce.cart.client.domain.FulfillmentItem> void updateFulfillmentItemsWithRoundedAdjustments(Collection<D> fulfillmentItems, Map<String,javax.money.MonetaryAmount> proratedOrderAdjustmentAmounts, javax.money.CurrencyUnit currency)
fulfillmentItems
- the collection of fulfillment itemsproratedOrderAdjustmentAmounts
- a mapping of fulfillment item reference numbers to the
rounded adjustment amountcurrency
- the currency of the amounts to roundprotected Map<String,javax.money.MonetaryAmount> roundListOfMonetaryAmounts(Map<String,javax.money.MonetaryAmount> amounts, javax.money.MonetaryAmount totalAmount, javax.money.MonetaryAmount unitAmount)
amounts
- list of amounts to round, mapped to a key for lookup on returntotalAmount
- the total adjustment amountunitAmount
- the smallest unit amount of money for the currencyprotected javax.money.MonetaryAmount getUnitAmount(javax.money.CurrencyUnit currency)
CurrencyUnit
.
For example, a currency with 2 fraction digits (like USD) will provide the amount "0.01".
currency
- the currency to get the smallest unit amount forCopyright © 2021. All rights reserved.