Class DefaultCartTotalsCalculator
- java.lang.Object
-
- com.broadleafcommerce.cartoperation.service.pricing.DefaultCartTotalsCalculator
-
- All Implemented Interfaces:
CartTotalsCalculator
public class DefaultCartTotalsCalculator extends Object implements CartTotalsCalculator
- Author:
- Nathan Moore (nathandmoore)
-
-
Constructor Summary
Constructors Constructor Description DefaultCartTotalsCalculator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcalculateCartItemsTotals(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)Calculates and setsCartItem.getAdjustmentsTotal()andCartItem.getTotal()for all items.protected voidcalculateCartItemTotals(@NonNull com.broadleafcommerce.cart.client.domain.CartItem item, javax.money.CurrencyUnit expectedCurrency)Calculates and setsCartItem.getAdjustmentsTotal()andCartItem.getTotal().javax.money.MonetaryAmountcalculateCartSubtotal(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)CalculatesCartPricing.getSubtotal().javax.money.MonetaryAmountcalculateCartTotalAfterTax(@NonNull com.broadleafcommerce.cart.client.domain.CartPricing cartPricing)Calculates theCartPricing.getTotal()including tax.javax.money.MonetaryAmountcalculateCartTotalBeforeTax(@NonNull com.broadleafcommerce.cart.client.domain.CartPricing cartPricing)Calculates theCartPricing.getTotal()without tax.protected voidcalculateFulfillmentGroupsTotals(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)Calculates and setsFulfillmentGroup.getTotalFulfillmentPrice()for the group andFulfillmentItem.getFulfillmentTotal()andFulfillmentItem.getMerchandiseTotalAmount()for all items.protected voidcalculateFulfillmentGroupTotal(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)Calculates and setsFulfillmentGroup.getTotalFulfillmentPrice()for each group andFulfillmentItem.getFulfillmentTotal()andFulfillmentItem.getMerchandiseTotalAmount()for all items.protected voidcalculateFulfillmentItemsTotals(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)Calculates and setsFulfillmentItem.getFulfillmentTotal()andFulfillmentItem.getMerchandiseTotalAmount()for all items in the group.protected javax.money.MonetaryAmountcalculateFulfillmentItemTotal(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, javax.money.CurrencyUnit expectedCurrency)Calculates theFulfillmentItem.getFulfillmentTotal()for an item.javax.money.MonetaryAmountcalculateFulfillmentTotal(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)CalculatesCartPricing.getFulfillmentTotal().protected FulfillmentPricingServicegetFulfillmentPricingService()protected javax.money.MonetaryAmountgetNonIncludedTax(com.broadleafcommerce.cart.client.domain.CartPricing cartPricing)Determine the amount of tax that was not included in the subtotal and therefore should be added to the subtotal to get the grand total.voidsetFulfillmentPricingService(FulfillmentPricingService fulfillmentPricingService)
-
-
-
Method Detail
-
setFulfillmentPricingService
@Autowired public void setFulfillmentPricingService(FulfillmentPricingService fulfillmentPricingService)
-
calculateCartSubtotal
public javax.money.MonetaryAmount calculateCartSubtotal(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)Description copied from interface:CartTotalsCalculatorCalculatesCartPricing.getSubtotal(). This will also calculate and setCartItem.getAdjustmentsTotal()andCartItem.getTotal().- Specified by:
calculateCartSubtotalin interfaceCartTotalsCalculator- Parameters:
cart- Cart for which to calculate a subtotal- Returns:
- Subtotal for the cart.
-
calculateFulfillmentTotal
public javax.money.MonetaryAmount calculateFulfillmentTotal(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)Description copied from interface:CartTotalsCalculatorCalculatesCartPricing.getFulfillmentTotal(). This will also calculate and set the totals forFulfillmentGroupsandFulfillmentItems.- Specified by:
calculateFulfillmentTotalin interfaceCartTotalsCalculator- Parameters:
cart- Cart for which to calculate a subtotal- Returns:
- Fulfillment total for the cart
-
calculateCartTotalBeforeTax
public javax.money.MonetaryAmount calculateCartTotalBeforeTax(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartPricing cartPricing)Description copied from interface:CartTotalsCalculatorCalculates theCartPricing.getTotal()without tax. This will include the subtotal, adjustments total, and fulfillment total.- Specified by:
calculateCartTotalBeforeTaxin interfaceCartTotalsCalculator- Parameters:
cartPricing- The pricing fields of a Cart to total.- Returns:
- The cart total before tax
-
calculateCartTotalAfterTax
public javax.money.MonetaryAmount calculateCartTotalAfterTax(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartPricing cartPricing)Description copied from interface:CartTotalsCalculatorCalculates theCartPricing.getTotal()including tax. This will include the subtotal, adjustments total, total tax, and fulfillment total.- Specified by:
calculateCartTotalAfterTaxin interfaceCartTotalsCalculator- Parameters:
cartPricing- The pricing fields of a Cart to total.- Returns:
- The cart total including tax
-
getNonIncludedTax
protected javax.money.MonetaryAmount getNonIncludedTax(com.broadleafcommerce.cart.client.domain.CartPricing cartPricing)
Determine the amount of tax that was not included in the subtotal and therefore should be added to the subtotal to get the grand total.- Parameters:
cartPricing- The pricing fields of a Cart to total.- Returns:
- The amount of tax that should be added to the subtotal to get the grand total.
-
calculateCartItemsTotals
protected void calculateCartItemsTotals(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)Calculates and setsCartItem.getAdjustmentsTotal()andCartItem.getTotal()for all items.- Parameters:
cart- whose items to total.
-
calculateCartItemTotals
protected void calculateCartItemTotals(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.CartItem item, javax.money.CurrencyUnit expectedCurrency)Calculates and setsCartItem.getAdjustmentsTotal()andCartItem.getTotal().- Parameters:
item- Item to total.
-
calculateFulfillmentGroupsTotals
protected void calculateFulfillmentGroupsTotals(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)Calculates and setsFulfillmentGroup.getTotalFulfillmentPrice()for the group andFulfillmentItem.getFulfillmentTotal()andFulfillmentItem.getMerchandiseTotalAmount()for all items.- Parameters:
cart- Cart whose fulfillment groups to total
-
calculateFulfillmentGroupTotal
protected void calculateFulfillmentGroupTotal(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)Calculates and setsFulfillmentGroup.getTotalFulfillmentPrice()for each group andFulfillmentItem.getFulfillmentTotal()andFulfillmentItem.getMerchandiseTotalAmount()for all items.- Parameters:
cart- Cart with theCartItemsrelated to the group'sFulfillmentItems.fulfillmentGroup- Fulfillment group to total
-
calculateFulfillmentItemsTotals
protected void calculateFulfillmentItemsTotals(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)Calculates and setsFulfillmentItem.getFulfillmentTotal()andFulfillmentItem.getMerchandiseTotalAmount()for all items in the group.- Parameters:
cart- Cart with theCartItemsrelated to the group'sFulfillmentItems.fulfillmentGroup- Fulfillment group with items to total
-
calculateFulfillmentItemTotal
protected javax.money.MonetaryAmount calculateFulfillmentItemTotal(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, javax.money.CurrencyUnit expectedCurrency)Calculates theFulfillmentItem.getFulfillmentTotal()for an item.- Parameters:
fulfillmentItem- Item to total- Returns:
- the
FulfillmentItem.getFulfillmentTotal()for an item.
-
getFulfillmentPricingService
protected FulfillmentPricingService getFulfillmentPricingService()
-
-