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
     
  • Method Summary

    Modifier and Type
    Method
    Description
    javax.money.MonetaryAmount
    calculateCartFeesTotal(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
    Calculates CartPricing.getFeesTotal().
    protected void
    calculateCartItemsTotals(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
    Calculates and sets CartItem.getAdjustmentsTotal() and CartItem.getTotal() for all items.
    protected void
    calculateCartItemTotals(@NonNull com.broadleafcommerce.cart.client.domain.CartItem item, javax.money.CurrencyUnit expectedCurrency)
    Calculates and sets CartItem.getAdjustmentsTotal() and CartItem.getTotal().
    javax.money.MonetaryAmount
    calculateCartSubtotal(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
    Calculates CartPricing.getSubtotal().
    javax.money.MonetaryAmount
    calculateCartTotalAfterTax(@NonNull com.broadleafcommerce.cart.client.domain.CartPricing cartPricing)
    Calculates the CartPricing.getTotal() including tax.
    javax.money.MonetaryAmount
    calculateCartTotalBeforeTax(@NonNull com.broadleafcommerce.cart.client.domain.CartPricing cartPricing)
    Calculates the CartPricing.getTotal() without tax.
    protected void
    calculateFulfillmentGroupsTotals(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
    Calculates and sets FulfillmentGroup.getTotalFulfillmentPrice() for the group and FulfillmentItem.getFulfillmentTotal() and FulfillmentItem.getMerchandiseTotalAmount() for all items.
    protected void
    calculateFulfillmentGroupTotal(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)
    Calculates and sets FulfillmentGroup.getTotalFulfillmentPrice() for each group and FulfillmentItem.getFulfillmentTotal() and FulfillmentItem.getMerchandiseTotalAmount() for all items.
    protected void
    calculateFulfillmentItemsTotals(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)
    Calculates and sets FulfillmentItem.getFulfillmentTotal() and FulfillmentItem.getMerchandiseTotalAmount() for all items in the group.
    protected javax.money.MonetaryAmount
    calculateFulfillmentItemTotal(@NonNull com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, javax.money.CurrencyUnit expectedCurrency)
    Calculates the FulfillmentItem.getFulfillmentTotal() for an item.
    javax.money.MonetaryAmount
    calculateFulfillmentTotal(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
    Calculates CartPricing.getFulfillmentTotal().
     
    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.
    void
     

    Methods inherited from class java.lang.Object

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

    • DefaultCartTotalsCalculator

      public DefaultCartTotalsCalculator()
  • Method Details

    • 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: CartTotalsCalculator
      Calculates CartPricing.getSubtotal(). This will also calculate and set CartItem.getAdjustmentsTotal() and CartItem.getTotal().
      Specified by:
      calculateCartSubtotal in interface CartTotalsCalculator
      Parameters:
      cart - Cart for which to calculate a subtotal
      Returns:
      Subtotal for the cart.
    • calculateCartFeesTotal

      public javax.money.MonetaryAmount calculateCartFeesTotal(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
      Description copied from interface: CartTotalsCalculator
      Calculates CartPricing.getFeesTotal().
      Specified by:
      calculateCartFeesTotal in interface CartTotalsCalculator
      Parameters:
      cart - Cart for which to calculate a fees total
      Returns:
      Fees total for the cart.
    • calculateFulfillmentTotal

      public javax.money.MonetaryAmount calculateFulfillmentTotal(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
      Description copied from interface: CartTotalsCalculator
      Calculates CartPricing.getFulfillmentTotal(). This will also calculate and set the totals for FulfillmentGroups and FulfillmentItems.
      Specified by:
      calculateFulfillmentTotal in interface CartTotalsCalculator
      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: CartTotalsCalculator
      Calculates the CartPricing.getTotal() without tax. This will include the subtotal, adjustments total, and fulfillment total.
      Specified by:
      calculateCartTotalBeforeTax in interface CartTotalsCalculator
      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: CartTotalsCalculator
      Calculates the CartPricing.getTotal() including tax. This will include the subtotal, adjustments total, total tax, and fulfillment total.
      Specified by:
      calculateCartTotalAfterTax in interface CartTotalsCalculator
      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 sets CartItem.getAdjustmentsTotal() and CartItem.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 sets CartItem.getAdjustmentsTotal() and CartItem.getTotal().
      Parameters:
      item - Item to total.
    • calculateFulfillmentGroupsTotals

      protected void calculateFulfillmentGroupsTotals(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
      Calculates and sets FulfillmentGroup.getTotalFulfillmentPrice() for the group and FulfillmentItem.getFulfillmentTotal() and FulfillmentItem.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 sets FulfillmentGroup.getTotalFulfillmentPrice() for each group and FulfillmentItem.getFulfillmentTotal() and FulfillmentItem.getMerchandiseTotalAmount() for all items.
      Parameters:
      cart - Cart with the CartItems related to the group's FulfillmentItems.
      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 sets FulfillmentItem.getFulfillmentTotal() and FulfillmentItem.getMerchandiseTotalAmount() for all items in the group.
      Parameters:
      cart - Cart with the CartItems related to the group's FulfillmentItems.
      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 the FulfillmentItem.getFulfillmentTotal() for an item.
      Parameters:
      fulfillmentItem - Item to total
      Returns:
      the FulfillmentItem.getFulfillmentTotal() for an item.
    • getFulfillmentPricingService

      protected FulfillmentPricingService getFulfillmentPricingService()