Package com.skava.helper
Class OtherChargesHelper
java.lang.Object
com.skava.helper.OtherChargesHelper
The Class OtherChargesHelper. Used conversion from one entity to other.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.springframework.context.MessageSource
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Instantiates a new cart properties helper. -
Method Summary
Modifier and TypeMethodDescriptionvoid
blockCustomChargesOnCartCreation
(String otherChargeType, String locale) This method is used to validate other charge type and throw exception respectively.getConfigFromCollection
(long collectionId, String locale, String propertyName) getConfigFromCollection
(CollectionDomain collection, String propertyName) This function is used to get collection properties based on collection domain object and property namegetCustomChargeConfig
(long collectionId, String locale) This method is used to get CustomCharges config from collection property and cast it to appropriate object.getCustomChargeConfig
(CartDataRequest cartDataRequest) This method is used to get CustomCharges config from collection property and cast it to appropriate object.getDefaultOtherChargeConfig
(String otherChargesConfiguration, String otherChargeName) This method is used to get default OtherChargeConfiguration.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.getOtherChargesConfig
(long collectionId, String locale) This method is used to get OtherChargesConfiguration from collection properties.getOtherChargesConfig
(CartDataRequest cartDataRequest) This method is used to get OtherChargesConfiguration from collection properties.getOtherChargesFromCollectionAttributes
(String otherChargesConfiguration) This method is used to convert other charges JSON from collection property to object array.static boolean
isCustomCharge
(String otherChargeType) This method is used to check whether the other charge requested is custom or not.static <T> boolean
isListValid
(List<T> list) This util method is used to validate the list object.boolean
This method is used to validate any return item is present for the cart.boolean
isSaleItemAvailableInCart
(List<ItemDomain> items) This method is used to validate any sale item is present for the cart.boolean
processOtherCharges
(long collectionId, String locale) This method will decide whether to process other charges based on collection properties.boolean
processOtherCharges
(CollectionDomain collection) This method will decide whether to process other charges based on collection properties.boolean
processReturnWindow
(long collectionId, String locale) This method will decide whether to process return window based on collection properties.void
validateAndAlignOtherChargesWithConfiguration
(CartDataRequest cartDataRequest) This method is used to validate the OtherCharges creation request and align properties using collection attribute configuration.void
validateCsrChargeType
(CartDataRequest cartDataRequest, OtherCharges otherCharge, CustomChargeDefinition definition) This method is used to validate the CSR defined charge type.void
validateCsrDefinedCharge
(CartDataRequest cartDataRequest, OtherCharges otherCharge, CustomCharges customCharges) This method is used to validate the CSR defined custom chargesboolean
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.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.
-
Field Details
-
messageSource
@Autowired protected org.springframework.context.MessageSource messageSource
-
-
Constructor Details
-
OtherChargesHelper
protected OtherChargesHelper()Instantiates a new cart properties helper.
-
-
Method Details
-
processOtherCharges
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 identifierlocale
- holds locale information- Returns:
- boolean
-
processOtherCharges
This method will decide whether to process other charges based on collection properties.- Parameters:
collectionDomain
- The collection domain object.- Returns:
- boolean
-
processReturnWindow
This method will decide whether to process return window based on collection properties.- Parameters:
collectionId
- holds the unique collection identifierlocale
- holds locale information- Returns:
- boolean
-
getOtherChargesConfig
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
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
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 objectcartId
- unique identifier of cartisReturnItemPresent
- flag denotes whether return item present in cart or notisSaleItemPresent
- flag denotes whether sale item present in cart or not- Returns:
- An instance of
List
<OtherChargesEntity
>
-
validateAndAlignOtherChargesWithConfiguration
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 requestotherCharge
- holds other charge from the requestcustomCharges
- 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 requestotherCharge
- holds other charge from the requestdefinition
- 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
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
This method is used to get CustomCharges config from collection property and cast it to appropriate object.- Parameters:
collectionId
- holds unique collection identifierlocale
- holds the locale information- Returns:
- CustomCharges
-
getCustomChargeConfig
This method is used to get CustomCharges config from collection property and cast it to appropriate object.- Parameters:
collectionId
- holds unique collection identifierlocale
- holds the locale information- Returns:
- CustomCharges
-
isReturnItemAvailableInCart
This method is used to validate any return item is present for the cart.- Parameters:
items
- holds list of Items- Returns:
- boolean
-
isSaleItemAvailableInCart
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
This method is used to validate other charge type and throw exception respectively.- Parameters:
otherChargeType
- other charges type eg. CSRDEFINEDlocale
- holds the locale value
-
isListValid
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
-