Class MoneyUtil

java.lang.Object
com.commercetools.api.models.common.MoneyUtil

public class MoneyUtil extends Object
Utility methods to convert from MonetaryAmount to Money and vice versa
  • Constructor Details

    • MoneyUtil

      public MoneyUtil()
  • Method Details

    • toMonetaryAmount

      public static javax.money.MonetaryAmount toMonetaryAmount(Money money)
    • toMonetaryAmount

      public static javax.money.MonetaryAmount toMonetaryAmount(TypedMoneyDraft money)
    • toMonetaryAmount

      public static javax.money.MonetaryAmount toMonetaryAmount(CentPrecisionMoneyDraft money)
    • toMonetaryAmount

      public static javax.money.MonetaryAmount toMonetaryAmount(HighPrecisionMoneyDraft money)
    • toMonetaryAmount

      public static javax.money.MonetaryAmount toMonetaryAmount(TypedMoney money)
    • toMonetaryAmount

      public static javax.money.MonetaryAmount toMonetaryAmount(CentPrecisionMoney money)
    • toMonetaryAmount

      public static javax.money.MonetaryAmount toMonetaryAmount(HighPrecisionMoney money)
    • zeroAmount

      public static javax.money.MonetaryAmount zeroAmount(String currency)
    • zeroAmount

      public static javax.money.MonetaryAmount zeroAmount(javax.money.CurrencyUnit currency)
    • of

      public static CentPrecisionMoney of(javax.money.MonetaryAmount monetaryAmount)
    • of

      public static HighPrecisionMoney of(javax.money.MonetaryAmount monetaryAmount, int fractionDigits)
    • draftOf

      public static CentPrecisionMoneyDraft draftOf(javax.money.MonetaryAmount monetaryAmount)
    • draftOf

      public static HighPrecisionMoneyDraft draftOf(javax.money.MonetaryAmount monetaryAmount, int fractionDigits)
    • builder

      public static CentPrecisionMoneyBuilder builder(javax.money.MonetaryAmount monetaryAmount)
    • builder

      public static HighPrecisionMoneyBuilder builder(javax.money.MonetaryAmount monetaryAmount, int fractionDigits)
    • draftBuilder

      public static CentPrecisionMoneyDraftBuilder draftBuilder(javax.money.MonetaryAmount monetaryAmount)
    • draftBuilder

      public static HighPrecisionMoneyDraftBuilder draftBuilder(javax.money.MonetaryAmount monetaryAmount, int fractionDigits)
    • amountToCents

      public static long amountToCents(javax.money.MonetaryAmount monetaryAmount)
    • amountToPreciseAmount

      public static long amountToPreciseAmount(javax.money.MonetaryAmount monetaryAmount, int fractionDigits)
    • calculateAppliedTaxes

      public static javax.money.MonetaryAmount calculateAppliedTaxes(TaxedItemPrice taxedPrice)
      Calculates the taxes applied to the pricing.
      Parameters:
      taxedPrice - the items taxed price
      Returns:
      the monetary amount
    • calculateGrossPrice

      public static javax.money.MonetaryAmount calculateGrossPrice(javax.money.MonetaryAmount amount, TaxRate taxRate)
      Calculates the gross price of the given amount according to its tax rate. Whether the provided amount is already gross or net is determined by the tax rate.
      Parameters:
      amount - the monetary amount
      taxRate - the tax rate used for calculating the gross price
      Returns:
      the monetary amount
    • calculateNetPrice

      public static javax.money.MonetaryAmount calculateNetPrice(javax.money.MonetaryAmount amount, TaxRate taxRate)
      Calculates the net price of the given amount according to its tax rate. Whether the provided amount is already net or gross is determined by the tax rate.
      Parameters:
      amount - the monetary amount
      taxRate - the tax rate corresponding to the amount
      Returns:
      the net monetary amount
    • convertNetToGrossPrice

      public static javax.money.MonetaryAmount convertNetToGrossPrice(javax.money.MonetaryAmount netAmount, double taxRate)
      Converts the given net amount (i.e. without taxes) to gross (i.e. with taxes included) according to the provided tax rate.
      Parameters:
      netAmount - the net monetary amount
      taxRate - the given tax rate, e.g. 0.19 for 19% tax
      Returns:
      the gross monetary amount
    • convertGrossToNetPrice

      public static javax.money.MonetaryAmount convertGrossToNetPrice(javax.money.MonetaryAmount grossAmount, double taxRate)
      Converts the given gross amount (i.e. with taxes included) to net (i.e. without taxes) according to the provided tax rate.
      Parameters:
      grossAmount - the gross monetary amount
      taxRate - the given tax rate, e.g. 0.19 for 19% tax
      Returns:
      the net monetary amount