Class TaxRateBuilder

java.lang.Object
com.commercetools.api.models.tax_category.TaxRateBuilder
All Implemented Interfaces:
Builder<TaxRate>

public class TaxRateBuilder extends Object implements Builder<TaxRate>
TaxRateBuilder
Example to create an instance using the builder pattern

     TaxRate taxRate = TaxRate.builder()
             .name("{name}")
             .amount(0.3)
             .includedInPrice(true)
             .country("{country}")
             .build()
 
  • Constructor Details

    • TaxRateBuilder

      public TaxRateBuilder()
  • Method Details

    • id

      public TaxRateBuilder id(@Nullable String id)

      Present if the TaxRate is part of a TaxCategory. Absent for external TaxRates in LineItem, CustomLineItem, and ShippingInfo.

      Parameters:
      id - value to be set
      Returns:
      Builder
    • key

      public TaxRateBuilder key(@Nullable String key)

      User-defined identifier of the TaxRate. Unique within the TaxCategory containing it. Present when set using TaxRateDraft. Not available for external TaxRates created using ExternalTaxRateDraft.

      Parameters:
      key - value to be set
      Returns:
      Builder
    • name

      public TaxRateBuilder name(String name)

      Name of the TaxRate.

      Parameters:
      name - value to be set
      Returns:
      Builder
    • amount

      public TaxRateBuilder amount(Double amount)

      Tax rate. If subrates are used, the amount is the sum of all rates in subRates.

      Parameters:
      amount - value to be set
      Returns:
      Builder
    • includedInPrice

      public TaxRateBuilder includedInPrice(Boolean includedInPrice)

      Whether tax is included in Embedded Prices or Standalone Prices, and the taxedPrice is present on LineItems. In this case, the totalNet price on TaxedPrice includes the TaxRate.

      Parameters:
      includedInPrice - value to be set
      Returns:
      Builder
    • country

      public TaxRateBuilder country(String country)

      Country in which the tax rate is applied in ISO 3166-1 alpha-2 format.

      Parameters:
      country - value to be set
      Returns:
      Builder
    • state

      public TaxRateBuilder state(@Nullable String state)

      State within the country, such as Texas in the United States. The value is case-sensitive and must use the same casing as the state value in the Cart shippingAddress.

      A TaxRate whose state is omitted does not act as a wildcard: it only matches a Cart whose shippingAddress also has no state value. To apply the same rate across states, either define an individual TaxRate for each state, or use the region field or a Custom Field on the shipping address as described in Address matching.

      Parameters:
      state - value to be set
      Returns:
      Builder
    • subRates

      public TaxRateBuilder subRates(@Nullable SubRate... subRates)

      Used when the total tax is a combination of multiple taxes (for example, local, state/provincial, and/or federal taxes). The total of all subrates must equal the TaxRate amount. These subrates are used to calculate the taxPortions field of a Cart or Order and the taxedPrice field of LineItems, CustomLineItems, and ShippingInfos.

      Parameters:
      subRates - value to be set
      Returns:
      Builder
    • subRates

      public TaxRateBuilder subRates(@Nullable List<SubRate> subRates)

      Used when the total tax is a combination of multiple taxes (for example, local, state/provincial, and/or federal taxes). The total of all subrates must equal the TaxRate amount. These subrates are used to calculate the taxPortions field of a Cart or Order and the taxedPrice field of LineItems, CustomLineItems, and ShippingInfos.

      Parameters:
      subRates - value to be set
      Returns:
      Builder
    • plusSubRates

      public TaxRateBuilder plusSubRates(@Nullable SubRate... subRates)

      Used when the total tax is a combination of multiple taxes (for example, local, state/provincial, and/or federal taxes). The total of all subrates must equal the TaxRate amount. These subrates are used to calculate the taxPortions field of a Cart or Order and the taxedPrice field of LineItems, CustomLineItems, and ShippingInfos.

      Parameters:
      subRates - value to be set
      Returns:
      Builder
    • plusSubRates

      public TaxRateBuilder plusSubRates(Function<SubRateBuilder,SubRateBuilder> builder)

      Used when the total tax is a combination of multiple taxes (for example, local, state/provincial, and/or federal taxes). The total of all subrates must equal the TaxRate amount. These subrates are used to calculate the taxPortions field of a Cart or Order and the taxedPrice field of LineItems, CustomLineItems, and ShippingInfos.

      Parameters:
      builder - function to build the subRates value
      Returns:
      Builder
    • withSubRates

      public TaxRateBuilder withSubRates(Function<SubRateBuilder,SubRateBuilder> builder)

      Used when the total tax is a combination of multiple taxes (for example, local, state/provincial, and/or federal taxes). The total of all subrates must equal the TaxRate amount. These subrates are used to calculate the taxPortions field of a Cart or Order and the taxedPrice field of LineItems, CustomLineItems, and ShippingInfos.

      Parameters:
      builder - function to build the subRates value
      Returns:
      Builder
    • addSubRates

      public TaxRateBuilder addSubRates(Function<SubRateBuilder,SubRate> builder)

      Used when the total tax is a combination of multiple taxes (for example, local, state/provincial, and/or federal taxes). The total of all subrates must equal the TaxRate amount. These subrates are used to calculate the taxPortions field of a Cart or Order and the taxedPrice field of LineItems, CustomLineItems, and ShippingInfos.

      Parameters:
      builder - function to build the subRates value
      Returns:
      Builder
    • setSubRates

      public TaxRateBuilder setSubRates(Function<SubRateBuilder,SubRate> builder)

      Used when the total tax is a combination of multiple taxes (for example, local, state/provincial, and/or federal taxes). The total of all subrates must equal the TaxRate amount. These subrates are used to calculate the taxPortions field of a Cart or Order and the taxedPrice field of LineItems, CustomLineItems, and ShippingInfos.

      Parameters:
      builder - function to build the subRates value
      Returns:
      Builder
    • taxRoundingTarget

      public TaxRateBuilder taxRoundingTarget(@Nullable TaxRoundingTarget taxRoundingTarget)

      Determines which of the net price and the tax amount the taxRoundingMode of the Cart or Order is applied to, when this TaxRate is included in the price. Ignored if includedInPrice is false.

      Always returned by the API. Can be omitted when a TaxRate is supplied as input, such as in OrderImportDraft, and then defaults to Net.

      Parameters:
      taxRoundingTarget - value to be set
      Returns:
      Builder
    • getId

      @Nullable public String getId()

      Present if the TaxRate is part of a TaxCategory. Absent for external TaxRates in LineItem, CustomLineItem, and ShippingInfo.

      Returns:
      id
    • getKey

      @Nullable public String getKey()

      User-defined identifier of the TaxRate. Unique within the TaxCategory containing it. Present when set using TaxRateDraft. Not available for external TaxRates created using ExternalTaxRateDraft.

      Returns:
      key
    • getName

      public String getName()

      Name of the TaxRate.

      Returns:
      name
    • getAmount

      public Double getAmount()

      Tax rate. If subrates are used, the amount is the sum of all rates in subRates.

      Returns:
      amount
    • getIncludedInPrice

      public Boolean getIncludedInPrice()

      Whether tax is included in Embedded Prices or Standalone Prices, and the taxedPrice is present on LineItems. In this case, the totalNet price on TaxedPrice includes the TaxRate.

      Returns:
      includedInPrice
    • getCountry

      public String getCountry()

      Country in which the tax rate is applied in ISO 3166-1 alpha-2 format.

      Returns:
      country
    • getState

      @Nullable public String getState()

      State within the country, such as Texas in the United States. The value is case-sensitive and must use the same casing as the state value in the Cart shippingAddress.

      A TaxRate whose state is omitted does not act as a wildcard: it only matches a Cart whose shippingAddress also has no state value. To apply the same rate across states, either define an individual TaxRate for each state, or use the region field or a Custom Field on the shipping address as described in Address matching.

      Returns:
      state
    • getSubRates

      @Nullable public List<SubRate> getSubRates()

      Used when the total tax is a combination of multiple taxes (for example, local, state/provincial, and/or federal taxes). The total of all subrates must equal the TaxRate amount. These subrates are used to calculate the taxPortions field of a Cart or Order and the taxedPrice field of LineItems, CustomLineItems, and ShippingInfos.

      Returns:
      subRates
    • getTaxRoundingTarget

      @Nullable public TaxRoundingTarget getTaxRoundingTarget()

      Determines which of the net price and the tax amount the taxRoundingMode of the Cart or Order is applied to, when this TaxRate is included in the price. Ignored if includedInPrice is false.

      Always returned by the API. Can be omitted when a TaxRate is supplied as input, such as in OrderImportDraft, and then defaults to Net.

      Returns:
      taxRoundingTarget
    • build

      public TaxRate build()
      builds TaxRate with checking for non-null required values
      Specified by:
      build in interface Builder<TaxRate>
      Returns:
      TaxRate
    • buildUnchecked

      public TaxRate buildUnchecked()
      builds TaxRate without checking for non-null required values
      Returns:
      TaxRate
    • of

      public static TaxRateBuilder of()
      factory method for an instance of TaxRateBuilder
      Returns:
      builder
    • of

      public static TaxRateBuilder of(TaxRate template)
      create builder for TaxRate instance
      Parameters:
      template - instance with prefilled values for the builder
      Returns:
      builder