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 void
calculateCartItemsTotals(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Calculates and setsCartItem.getAdjustmentsTotal()
andCartItem.getTotal()
for all items.protected void
calculateCartItemTotals(@NonNull com.broadleafcommerce.cart.client.domain.CartItem item, javax.money.CurrencyUnit expectedCurrency)
Calculates and setsCartItem.getAdjustmentsTotal()
andCartItem.getTotal()
.javax.money.MonetaryAmount
calculateCartSubtotal(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
CalculatesCartPricing.getSubtotal()
.javax.money.MonetaryAmount
calculateCartTotalAfterTax(@NonNull com.broadleafcommerce.cart.client.domain.CartPricing cartPricing)
Calculates theCartPricing.getTotal()
including tax.javax.money.MonetaryAmount
calculateCartTotalBeforeTax(@NonNull com.broadleafcommerce.cart.client.domain.CartPricing cartPricing)
Calculates theCartPricing.getTotal()
without tax.protected void
calculateFulfillmentGroupsTotals(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
Calculates and setsFulfillmentGroup.getTotalFulfillmentPrice()
for the group andFulfillmentItem.getFulfillmentTotal()
andFulfillmentItem.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 setsFulfillmentGroup.getTotalFulfillmentPrice()
for each group andFulfillmentItem.getFulfillmentTotal()
andFulfillmentItem.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 setsFulfillmentItem.getFulfillmentTotal()
andFulfillmentItem.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 theFulfillmentItem.getFulfillmentTotal()
for an item.javax.money.MonetaryAmount
calculateFulfillmentTotal(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
CalculatesCartPricing.getFulfillmentTotal()
.protected FulfillmentPricingService
getFulfillmentPricingService()
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
setFulfillmentPricingService(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:CartTotalsCalculator
CalculatesCartPricing.getSubtotal()
. This will also calculate and setCartItem.getAdjustmentsTotal()
andCartItem.getTotal()
.- Specified by:
calculateCartSubtotal
in 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:CartTotalsCalculator
CalculatesCartPricing.getFulfillmentTotal()
. This will also calculate and set the totals forFulfillmentGroups
andFulfillmentItems
.- Specified by:
calculateFulfillmentTotal
in 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:CartTotalsCalculator
Calculates theCartPricing.getTotal()
without tax. This will include the subtotal, adjustments total, and fulfillment total.- Specified by:
calculateCartTotalBeforeTax
in 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:CartTotalsCalculator
Calculates theCartPricing.getTotal()
including tax. This will include the subtotal, adjustments total, total tax, and fulfillment total.- Specified by:
calculateCartTotalAfterTax
in 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 theCartItems
related 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 theCartItems
related 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()
-
-