Class DefaultCartTotalsCalculator
java.lang.Object
com.broadleafcommerce.cartoperation.service.pricing.DefaultCartTotalsCalculator
- All Implemented Interfaces:
CartTotalsCalculator
- Author:
- Nathan Moore (nathandmoore)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionjavax.money.MonetaryAmount
calculateCartFeesTotal
(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) CalculatesCartPricing.getFeesTotal()
.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
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)
-
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
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.
-
calculateCartFeesTotal
public javax.money.MonetaryAmount calculateCartFeesTotal(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Description copied from interface:CartTotalsCalculator
CalculatesCartPricing.getFeesTotal()
.- Specified by:
calculateCartFeesTotal
in interfaceCartTotalsCalculator
- 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
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
-