Class InclusiveTaxHelper

java.lang.Object
com.broadleafcommerce.orderoperation.service.util.InclusiveTaxHelper

public class InclusiveTaxHelper extends Object
Utility to facilitate getting inclusive taxes from FulfillmentItemTaxDetail and OrderFulfillmentItemTaxDetail. Includes predicates for filtering inclusive/exclusive taxes, filtering merchandise/fulfillment taxes, and summing tax/taxable amount fields. This class only includes methods that are needed by the framework. Extensions of this class can use the included predicates to easily compose new tax calculation methods as needed. Duplicate methods of this class may be found in OrderServices.
Author:
Cade Rea (cade-rea)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Default name of the TaxDetail for taxes associated with fulfillment, shipping, and handling.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected <T> javax.money.MonetaryAmount
    calculateTaxesWithPredicates(Stream<T> stream, Predicate<T> isFulfillmentTaxPredicate, Predicate<T> isTaxInclusivePredicate, Function<T,javax.money.MonetaryAmount> fieldPredicate, javax.money.CurrencyUnit currency)
     
    javax.money.MonetaryAmount
    getAllIncludedTax(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, javax.money.CurrencyUnit currency)
    Get the sum of all (merchandise and fulfillment) inclusive taxes from the given FulfillmentItem.
    javax.money.MonetaryAmount
    getAllIncludedTax(com.broadleafcommerce.order.client.domain.OrderFulfillment orderFulfillment)
    Get the sum of all (merchandise and fulfillment) inclusive taxes from the given OrderFulfillment.
    javax.money.MonetaryAmount
    getFulfillmentIncludedTax(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)
    Get the sum of inclusive fulfillment taxes from the given FulfillmentGroup.
    javax.money.MonetaryAmount
    getFulfillmentIncludedTax(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, javax.money.CurrencyUnit currency)
    Get the sum of inclusive fulfillment taxes from the given FulfillmentItem.
    javax.money.MonetaryAmount
    getFulfillmentIncludedTax(com.broadleafcommerce.order.client.domain.OrderFulfillment orderFulfillment)
    Get the sum of fulfillment inclusive taxes from the given OrderFulfillment.
    protected String
     
    javax.money.MonetaryAmount
    getMerchIncludedTax(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, javax.money.CurrencyUnit currency)
    Get the sum of inclusive merchandise taxes from the given FulfillmentItem.
    javax.money.MonetaryAmount
    getMerchIncludedTax(com.broadleafcommerce.order.client.domain.OrderFulfillment orderFulfillment)
    Get the sum of merchandise inclusive taxes from the given OrderFulfillment.
    javax.money.MonetaryAmount
    getMerchIncludedTax(com.broadleafcommerce.order.client.domain.OrderFulfillmentItem orderFulfillmentItem, javax.money.CurrencyUnit currency)
    Get the sum of inclusive merchandise taxes from the given OrderFulfillmentItem.
    protected boolean
    isExclusiveTax(com.broadleafcommerce.cart.client.domain.FulfillmentItemTaxDetail taxDetail)
     
    protected boolean
    isExclusiveTax(com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail taxDetail)
     
    protected boolean
    isFulfillmentFeeTaxDetail(com.broadleafcommerce.cart.client.domain.FulfillmentItemTaxDetail taxDetail)
     
    protected boolean
    isFulfillmentFeeTaxDetail(com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail taxDetail)
     
    protected boolean
     
    protected boolean
    isInclusiveTax(com.broadleafcommerce.cart.client.domain.FulfillmentItemTaxDetail taxDetail)
     
    protected boolean
    isInclusiveTax(com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail taxDetail)
     
    protected boolean
    isMerchandiseTaxDetail(com.broadleafcommerce.cart.client.domain.FulfillmentItemTaxDetail taxDetail)
     
    protected boolean
    isMerchandiseTaxDetail(com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail taxDetail)
     
    protected boolean
     
    protected javax.money.MonetaryAmount
    sumTaxableAmount(com.broadleafcommerce.cart.client.domain.FulfillmentItemTaxDetail fulfillmentItemTaxDetail)
     
    protected javax.money.MonetaryAmount
    sumTaxableAmount(com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail orderFulfillmentItemTaxDetail)
     
    protected javax.money.MonetaryAmount
    sumTaxCalculated(com.broadleafcommerce.cart.client.domain.FulfillmentItemTaxDetail fulfillmentItemTaxDetail)
     
    protected javax.money.MonetaryAmount
    sumTaxCalculated(com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail orderFulfillmentItemTaxDetail)
     

    Methods inherited from class java.lang.Object

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

    • DEFAULT_FULFILLMENT_TAX_NAME

      public static final String DEFAULT_FULFILLMENT_TAX_NAME
      Default name of the TaxDetail for taxes associated with fulfillment, shipping, and handling.
      See Also:
  • Constructor Details

    • InclusiveTaxHelper

      public InclusiveTaxHelper()
  • Method Details

    • getAllIncludedTax

      public javax.money.MonetaryAmount getAllIncludedTax(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, javax.money.CurrencyUnit currency)
      Get the sum of all (merchandise and fulfillment) inclusive taxes from the given FulfillmentItem.
      Parameters:
      fulfillmentItem - The FulfillmentItem on which to operate.
      currency - The currency of the operation.
      Returns:
      The sum of inclusive taxes on the given FulfillmentItem.
    • getMerchIncludedTax

      public javax.money.MonetaryAmount getMerchIncludedTax(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, javax.money.CurrencyUnit currency)
      Get the sum of inclusive merchandise taxes from the given FulfillmentItem.
      Parameters:
      fulfillmentItem - The FulfillmentItem on which to operate.
      currency - The currency of the operation.
      Returns:
      The sum of inclusive merchandise taxes from the given FulfillmentItem.
    • getMerchIncludedTax

      public javax.money.MonetaryAmount getMerchIncludedTax(com.broadleafcommerce.order.client.domain.OrderFulfillment orderFulfillment)
      Get the sum of merchandise inclusive taxes from the given OrderFulfillment.
      Parameters:
      orderFulfillment - The OrderFulfillment to operate on.
      Returns:
      The sum of merchandise inclusive taxes from the given OrderFulfillment.
    • getFulfillmentIncludedTax

      public javax.money.MonetaryAmount getFulfillmentIncludedTax(com.broadleafcommerce.cart.client.domain.FulfillmentItem fulfillmentItem, javax.money.CurrencyUnit currency)
      Get the sum of inclusive fulfillment taxes from the given FulfillmentItem.
      Parameters:
      fulfillmentItem - The FulfillmentItem on which to operate.
      currency - The currency of the operation.
      Returns:
      The sum of inclusive fulfillment taxes from the given FulfillmentItem.
    • getFulfillmentIncludedTax

      public javax.money.MonetaryAmount getFulfillmentIncludedTax(com.broadleafcommerce.cart.client.domain.FulfillmentGroup fulfillmentGroup)
      Get the sum of inclusive fulfillment taxes from the given FulfillmentGroup.
      Parameters:
      fulfillmentGroup - The FulfillmentGroup whose FulfillmentItem's contain the fulfillment taxes as FulfillmentItemTaxDetails.
      Returns:
      The sum of inclusive fulfillment taxes from the given FulfillmentGroup.
    • getAllIncludedTax

      public javax.money.MonetaryAmount getAllIncludedTax(com.broadleafcommerce.order.client.domain.OrderFulfillment orderFulfillment)
      Get the sum of all (merchandise and fulfillment) inclusive taxes from the given OrderFulfillment.
      Parameters:
      orderFulfillment - The OrderFulfillment to operate on.
      Returns:
      The sum of all (merchandise and fulfillment) inclusive taxes from the given OrderFulfillment.
    • getFulfillmentIncludedTax

      public javax.money.MonetaryAmount getFulfillmentIncludedTax(com.broadleafcommerce.order.client.domain.OrderFulfillment orderFulfillment)
      Get the sum of fulfillment inclusive taxes from the given OrderFulfillment.
      Parameters:
      orderFulfillment - The OrderFulfillment to operate on.
      Returns:
      The sum of fulfillment inclusive taxes from the given OrderFulfillment.
    • getMerchIncludedTax

      public javax.money.MonetaryAmount getMerchIncludedTax(com.broadleafcommerce.order.client.domain.OrderFulfillmentItem orderFulfillmentItem, javax.money.CurrencyUnit currency)
      Get the sum of inclusive merchandise taxes from the given OrderFulfillmentItem.
      Parameters:
      orderFulfillmentItem - The OrderFulfillmentItem on which to operate.
      currency - The currency of the operation.
      Returns:
      The sum of inclusive merchandise taxes from the given OrderFulfillmentItem.
    • calculateTaxesWithPredicates

      protected <T> javax.money.MonetaryAmount calculateTaxesWithPredicates(Stream<T> stream, Predicate<T> isFulfillmentTaxPredicate, Predicate<T> isTaxInclusivePredicate, Function<T,javax.money.MonetaryAmount> fieldPredicate, javax.money.CurrencyUnit currency)
    • sumTaxCalculated

      protected javax.money.MonetaryAmount sumTaxCalculated(com.broadleafcommerce.cart.client.domain.FulfillmentItemTaxDetail fulfillmentItemTaxDetail)
    • sumTaxCalculated

      protected javax.money.MonetaryAmount sumTaxCalculated(com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail orderFulfillmentItemTaxDetail)
    • sumTaxableAmount

      protected javax.money.MonetaryAmount sumTaxableAmount(com.broadleafcommerce.cart.client.domain.FulfillmentItemTaxDetail fulfillmentItemTaxDetail)
    • sumTaxableAmount

      protected javax.money.MonetaryAmount sumTaxableAmount(com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail orderFulfillmentItemTaxDetail)
    • isInclusiveTax

      protected boolean isInclusiveTax(com.broadleafcommerce.cart.client.domain.FulfillmentItemTaxDetail taxDetail)
    • isExclusiveTax

      protected boolean isExclusiveTax(com.broadleafcommerce.cart.client.domain.FulfillmentItemTaxDetail taxDetail)
    • isInclusiveTax

      protected boolean isInclusiveTax(com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail taxDetail)
    • isExclusiveTax

      protected boolean isExclusiveTax(com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail taxDetail)
    • passthroughFilter

      protected boolean passthroughFilter(Object o)
    • isFulfillmentFeeTaxDetail

      protected boolean isFulfillmentFeeTaxDetail(com.broadleafcommerce.cart.client.domain.FulfillmentItemTaxDetail taxDetail)
    • isMerchandiseTaxDetail

      protected boolean isMerchandiseTaxDetail(com.broadleafcommerce.cart.client.domain.FulfillmentItemTaxDetail taxDetail)
    • isFulfillmentFeeTaxDetail

      protected boolean isFulfillmentFeeTaxDetail(com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail taxDetail)
    • isMerchandiseTaxDetail

      protected boolean isMerchandiseTaxDetail(com.broadleafcommerce.order.client.domain.OrderFulfillmentItemTaxDetail taxDetail)
    • isFulfillmentTaxName

      protected boolean isFulfillmentTaxName(String taxName)
    • getFulfillmentTaxName

      protected String getFulfillmentTaxName()