Class OtherChargesHelper

java.lang.Object
com.skava.helper.OtherChargesHelper

@Component public class OtherChargesHelper extends Object
The Class OtherChargesHelper. Used conversion from one entity to other.
  • Field Details

    • messageSource

      @Autowired protected org.springframework.context.MessageSource messageSource
  • Constructor Details

    • OtherChargesHelper

      protected OtherChargesHelper()
      Instantiates a new cart properties helper.
  • Method Details

    • processOtherCharges

      public boolean processOtherCharges(long collectionId, String locale)
      This method will decide whether to process other charges based on collection properties. This function is deprecated, use function with CollectionDomain as parameter
      Parameters:
      collectionId - holds the unique collection identifier
      locale - holds locale information
      Returns:
      boolean
    • processOtherCharges

      public boolean processOtherCharges(CollectionDomain collection)
      This method will decide whether to process other charges based on collection properties.
      Parameters:
      collectionDomain - The collection domain object.
      Returns:
      boolean
    • processReturnWindow

      public boolean processReturnWindow(long collectionId, String locale)
      This method will decide whether to process return window based on collection properties.
      Parameters:
      collectionId - holds the unique collection identifier
      locale - holds locale information
      Returns:
      boolean
    • getOtherChargesConfig

      public CollectionPropertyDomain getOtherChargesConfig(long collectionId, String locale)
      This method is used to get OtherChargesConfiguration from collection properties.
      Parameters:
      collectionId - to get Collection and its properties.
      locale - to give error message based on locale if collection not exists.
      Returns:
      CollectionPropertyDomain
    • getOtherChargesConfig

      public CollectionPropertyDomain getOtherChargesConfig(CartDataRequest cartDataRequest)
      This method is used to get OtherChargesConfiguration from collection properties.
      Parameters:
      collectionId - to get Collection and its properties.
      locale - to give error message based on locale if collection not exists.
      Returns:
      CollectionPropertyDomain
    • getConfigFromCollection

      public CollectionPropertyDomain getConfigFromCollection(long collectionId, String locale, String propertyName)
      Parameters:
      collectionId - to get Collection and its properties.
      locale - to give error message based on locale if collection not exists.
      propertyName - collection property name.
      Returns:
      CollectionPropertyDomain
    • getConfigFromCollection

      public CollectionPropertyDomain getConfigFromCollection(CollectionDomain collection, String propertyName)
      This function is used to get collection properties based on collection domain object and property name
      Parameters:
      collectionDomain - The collection domain object.
      propertyName - collection property name.
      Returns:
      CollectionPropertyDomain
    • getDefaultOtherChargeConfig

      public OtherCharges getDefaultOtherChargeConfig(String otherChargesConfiguration, String otherChargeName)
      This method is used to get default OtherChargeConfiguration.
      Parameters:
      otherChargesConfiguration - the otherChargesConfiguration.
      otherChargeName - the otherChargeName.
      Returns:
      OtherCharges
    • getOtherChargesFromCollectionAttributes

      public OtherCharges[] getOtherChargesFromCollectionAttributes(String otherChargesConfiguration)
      This method is used to convert other charges JSON from collection property to object array.
      Parameters:
      otherChargesConfiguration - holds the other charges collection property value.
      Returns:
      array of OtherCharges object
    • getDefaultOtherChargesForNewCart

      public List<OtherChargesEntity> getDefaultOtherChargesForNewCart(CartDomain cartDomain, long cartId, boolean isReturnItemPresent, boolean isSaleItemPresent)
      This method is used to fetch all OtherCharges configured as waived by default in collection properties.
      Parameters:
      cartDomain - holds cart domain object
      cartId - unique identifier of cart
      isReturnItemPresent - flag denotes whether return item present in cart or not
      isSaleItemPresent - flag denotes whether sale item present in cart or not
      Returns:
      An instance of List<OtherChargesEntity>
    • validateAndAlignOtherChargesWithConfiguration

      public void validateAndAlignOtherChargesWithConfiguration(CartDataRequest cartDataRequest)
      This method is used to validate the OtherCharges creation request and align properties using collection attribute configuration.
      Parameters:
      cartDataRequest - holds CartDataRequest object
    • validateCsrDefinedCharge

      public void validateCsrDefinedCharge(CartDataRequest cartDataRequest, OtherCharges otherCharge, CustomCharges customCharges)
      This method is used to validate the CSR defined custom charges
      Parameters:
      cartDataRequest - holds the request
      otherCharge - holds other charge from the request
      customCharges - holds the custom charges collection property
    • validateCsrChargeType

      public void validateCsrChargeType(CartDataRequest cartDataRequest, OtherCharges otherCharge, CustomChargeDefinition definition)
      This method is used to validate the CSR defined charge type.
      Parameters:
      cartDataRequest - holds the request
      otherCharge - holds other charge from the request
      definition - holds the custom charges definition object
    • validateOtherChargeRequest

      public OtherCharges validateOtherChargeRequest(CartDataRequest request, OtherCharges otherCharges, CollectionPropertyDomain otherChargesConfiguration)
      This method is used to validate othercharges request against the db configuration and returns the requested other charges DB config.
      Parameters:
      request - to get othercharges to be validated.
      otherCharges - the OtherCharges.
      otherChargesConfiguration - the otherChargesConfiguration.
      Returns:
      OtherCharges
    • isCustomCharge

      public static boolean isCustomCharge(String otherChargeType)
      This method is used to check whether the other charge requested is custom or not.
      Parameters:
      otherChargeType - holds the other charge type
      Returns:
      boolean
    • getCustomChargeConfig

      public CustomCharges getCustomChargeConfig(long collectionId, String locale)
      This method is used to get CustomCharges config from collection property and cast it to appropriate object.
      Parameters:
      collectionId - holds unique collection identifier
      locale - holds the locale information
      Returns:
      CustomCharges
    • getCustomChargeConfig

      public CustomCharges getCustomChargeConfig(CartDataRequest cartDataRequest)
      This method is used to get CustomCharges config from collection property and cast it to appropriate object.
      Parameters:
      collectionId - holds unique collection identifier
      locale - holds the locale information
      Returns:
      CustomCharges
    • isReturnItemAvailableInCart

      public boolean isReturnItemAvailableInCart(List<ItemDomain> items)
      This method is used to validate any return item is present for the cart.
      Parameters:
      items - holds list of Items
      Returns:
      boolean
    • isSaleItemAvailableInCart

      public boolean isSaleItemAvailableInCart(List<ItemDomain> items)
      This method is used to validate any sale item is present for the cart.
      Parameters:
      items - holds list of Items
      Returns:
      boolean
    • validateDefaultOtherCharges

      public boolean validateDefaultOtherCharges(String chargeAgainst, boolean isReturnItemPresent, boolean isSaleItemPresent)
      This method consolidates validation requried to add default other charges for cart if no other charges are given.
      Parameters:
      chargeAgainst - holds ChargeAgainst value of the other charge.
      isReturnItemPresent - flag denotes whether return item present in cart or not.
      isSaleItemPresent - flag denotes whether sale item present in cart or not.
      Returns:
      boolean
    • blockCustomChargesOnCartCreation

      public void blockCustomChargesOnCartCreation(String otherChargeType, String locale)
      This method is used to validate other charge type and throw exception respectively.
      Parameters:
      otherChargeType - other charges type eg. CSRDEFINED
      locale - holds the locale value
    • isListValid

      public static <T> boolean isListValid(List<T> list)
      This util method is used to validate the list object.
      Type Parameters:
      T - - any type of class
      Parameters:
      list - holds the list object
      Returns:
      boolean