Class DefaultCommerceQuoteService

java.lang.Object
de.hybris.platform.commerceservices.order.impl.DefaultCommerceQuoteService
All Implemented Interfaces:
CommerceQuoteService

public class DefaultCommerceQuoteService extends Object implements CommerceQuoteService
Default implementation for CommerceQuoteService.
  • Field Details

  • Constructor Details

    • DefaultCommerceQuoteService

      public DefaultCommerceQuoteService()
  • Method Details

    • createQuoteFromCart

      public QuoteModel createQuoteFromCart(CartModel cartModel, UserModel userModel)
      Description copied from interface: CommerceQuoteService
      Creates a new quote based on given cart. Please note that it's the caller's responsibility to persist the new quote. The cart passed into this method is not affected by its business logic.
      Specified by:
      createQuoteFromCart in interface CommerceQuoteService
      Parameters:
      cartModel - the cart model
      userModel - the user performing the operation on the quote
      Returns:
      the new quote model
    • createQuoteFromCartInternal

      protected QuoteModel createQuoteFromCartInternal(CartModel cartModel, UserModel userModel)
    • hasQuoteInSessionCart

      protected boolean hasQuoteInSessionCart()
    • loadQuoteAsSessionCart

      public CartModel loadQuoteAsSessionCart(QuoteModel quoteModel, UserModel userModel)
      Description copied from interface: CommerceQuoteService
      Loads the given quote into a new session cart or returns the existing session cart if existing session cart already has the quote loaded. If the quote needs to be loaded into a new session cart, it first checks if the action can be performed for the quote. If the action cannot be performed, then a runtime exception is thrown. The method also updates the quote state and saves the existing session cart before replacing it with a new session cart, if needed.
      Specified by:
      loadQuoteAsSessionCart in interface CommerceQuoteService
      Parameters:
      quoteModel - the quote to process
      userModel - the user performing the operation on the quote
      Returns:
      the new session cart loaded with the given quote or the existing session cart if existing session cart already has the quote loaded
    • removeQuoteCart

      public void removeQuoteCart(QuoteModel quote)
      Description copied from interface: CommerceQuoteService
      Removes the cart related to the given quote
      Specified by:
      removeQuoteCart in interface CommerceQuoteService
      Parameters:
      quote - the quote to detach cart from
    • updateAndLoadQuoteCartWithAction

      protected CartModel updateAndLoadQuoteCartWithAction(QuoteModel quoteModel, QuoteAction quoteAction, UserModel userModel)
    • getCurrentDateTimeFormatted

      protected String getCurrentDateTimeFormatted(String format)
    • getQuoteFromSessionCart

      protected Optional<QuoteModel> getQuoteFromSessionCart()
    • submitQuote

      public QuoteModel submitQuote(QuoteModel quoteModel, UserModel userModel)
      Description copied from interface: CommerceQuoteService
      Submits a quote from buyer to seller representative or from seller representative to seller approver. A new version of the same quote will be created on the seller representative or seller approver side.
      Specified by:
      submitQuote in interface CommerceQuoteService
      Parameters:
      quoteModel - the quote to process
      userModel - the user performing the operation on the quote
      Returns:
      the updated quote
    • validateQuoteThreshold

      public void validateQuoteThreshold(QuoteModel quote, UserModel user, CartModel sessionCart) throws QuoteUnderThresholdException
      Description copied from interface: CommerceQuoteService
      Validates if quote meets threshold.
      Specified by:
      validateQuoteThreshold in interface CommerceQuoteService
      Parameters:
      quote - the quote to validate
      user - the user performing the operation on the quote
      sessionCart - the cart in session
      Throws:
      QuoteUnderThresholdException - if quote does not meet threshold
    • isRequestThresholdRequired

      protected boolean isRequestThresholdRequired(QuoteModel quote, UserModel user, CartModel sessionCart)
      Checks if quote is in a state that requires checking the request threshold.
      Parameters:
      quote -
      user -
      sessionCart -
      Returns:
      true is request threshold is required.
    • getQuoteRequestThreshold

      public double getQuoteRequestThreshold(QuoteModel quote, UserModel user, CartModel sessionCart)
      Description copied from interface: CommerceQuoteService
      Get quote request threshold defined in properties. It will return the property defined threshold amount for current site and currency. If the threshold is not defined for the site and currency, it will return global threshold. If none of these are defined, it will return 0. If quote threshold calculation is not required for the quote, will return an negative number.
      Specified by:
      getQuoteRequestThreshold in interface CommerceQuoteService
      Returns:
      quote request threshold
    • validateQuoteTotal

      protected void validateQuoteTotal(QuoteModel quoteModel)
    • approveQuote

      public QuoteModel approveQuote(QuoteModel quoteModel, UserModel userModel)
      Description copied from interface: CommerceQuoteService
      Approve a quote from seller representative. Send a quote on submit event.
      Specified by:
      approveQuote in interface CommerceQuoteService
      Parameters:
      quoteModel - the quote to process
      userModel - the user performing the operation on the quote
      Returns:
      the updated quote
    • rejectQuote

      public QuoteModel rejectQuote(QuoteModel quoteModel, UserModel userModel)
      Description copied from interface: CommerceQuoteService
      Reject a quote from seller representative. Send a quote on submit event.
      Specified by:
      rejectQuote in interface CommerceQuoteService
      Parameters:
      quoteModel - the quote to process
      userModel - the user performing the operation on the quote
      Returns:
      the updated quote
    • createQuoteSnapshot

      protected QuoteModel createQuoteSnapshot(QuoteModel quoteModel)
    • updateQuoteFromCart

      public QuoteModel updateQuoteFromCart(CartModel cartModel, UserModel userModel)
      Description copied from interface: CommerceQuoteService
      Updates quote with data from cart (and existing quote). Sets the cart as cartReference on to the new quote.
      Specified by:
      updateQuoteFromCart in interface CommerceQuoteService
      Parameters:
      cartModel - cart that has an association to a quote
      userModel - the user performing the operation on the quote
      Returns:
      the updated quote
    • requote

      public QuoteModel requote(QuoteModel quote, UserModel user)
      Description copied from interface: CommerceQuoteService
      Re-quote from an existing quote to create a new quote
      Specified by:
      requote in interface CommerceQuoteService
      Parameters:
      quote - the existing quoteModel
      user - the current quote user
      Returns:
      the new created quoteModel
    • getQuoteList

      public SearchPageData<QuoteModel> getQuoteList(CustomerModel customerModel, UserModel quoteUserModel, BaseStoreModel store, PageableData pageableData)
      Description copied from interface: CommerceQuoteService
      Retrieves the paged list of quotes according to the provided selection criteria.
      Specified by:
      getQuoteList in interface CommerceQuoteService
      Parameters:
      customerModel - the customer to be used for selecting the quotes
      quoteUserModel - the user asking for the list.
      store - the store to be used for selecting the quotes
      pageableData - paging information
      Returns:
      the paged search results
    • getQuoteByCodeAndCustomerAndStore

      public QuoteModel getQuoteByCodeAndCustomerAndStore(CustomerModel customerModel, UserModel quoteUserModel, BaseStoreModel store, String quoteCode)
      Description copied from interface: CommerceQuoteService
      Finds a quote with highest version by code, customer and store.
      Specified by:
      getQuoteByCodeAndCustomerAndStore in interface CommerceQuoteService
      Parameters:
      customerModel - the customer to be used for selecting the quote
      quoteUserModel - the user asking for the list.
      store - the store to be used for selecting the quote
      quoteCode - the code of the quote
      Returns:
      the quote
    • validateListNotEmpty

      protected void validateListNotEmpty(Collection paramToCheck, String unknownIdException)
    • getAllowedActions

      public Set<QuoteAction> getAllowedActions(QuoteModel quoteModel, UserModel userModel)
      Description copied from interface: CommerceQuoteService
      Get currently allowed actions for a quote.
      Specified by:
      getAllowedActions in interface CommerceQuoteService
      Parameters:
      quoteModel - the quote to process
      userModel - the user for which the allowed actions will be determined
      Returns:
      the allowed action. Empty set will be returned if none of the actions is allowed.
    • acceptAndPrepareCheckout

      public CartModel acceptAndPrepareCheckout(QuoteModel quoteModel, UserModel userModel)
      Description copied from interface: CommerceQuoteService
      Accept and prepare checkout. Similar to CommerceQuoteService.loadQuoteAsSessionCart(QuoteModel, UserModel) but for checkout.
      Specified by:
      acceptAndPrepareCheckout in interface CommerceQuoteService
      Parameters:
      quoteModel - the quote to process
      userModel - the user performing the operation on the quote
      Returns:
      the cart for checkout
    • applyQuoteDiscount

      public void applyQuoteDiscount(AbstractOrderModel abstractOrderModel, UserModel userModel, Double discountRate, DiscountType discountType)
      Description copied from interface: CommerceQuoteService
      Applies a quote specific discount to abstract order model given the discount rate and discount type.
      Specified by:
      applyQuoteDiscount in interface CommerceQuoteService
      Parameters:
      abstractOrderModel - the abstract order model to add a discount to. Must either be a QuoteModel or a CartModel associated with a quote.
      userModel - the user performing the operation on the quote
      discountRate - the discount rate to be applied
      discountType - the type of discount to be applied
    • validateDiscountRate

      protected void validateDiscountRate(Double discountRate, DiscountType discountType, AbstractOrderModel abstractOrderModel)
    • cancelQuote

      public void cancelQuote(QuoteModel quoteModel, UserModel userModel)
      Description copied from interface: CommerceQuoteService
      Cancels a quote. The version of the quote visible to the user will have the state set to canceled.
      Specified by:
      cancelQuote in interface CommerceQuoteService
      Parameters:
      quoteModel - the quote to cancel
      userModel - the user performing the operation on the quote
    • assignQuoteToUser

      public void assignQuoteToUser(QuoteModel quote, UserModel assignee, UserModel assigner)
      Description copied from interface: CommerceQuoteService
      Assigns quote to an assignee
      Specified by:
      assignQuoteToUser in interface CommerceQuoteService
      Parameters:
      quote - the quote to be assigned
      assignee - the user to which the quote should be assigned
      assigner - the user assigning the quote to the assignee
    • unassignQuote

      public void unassignQuote(QuoteModel quote, UserModel assigner)
      Description copied from interface: CommerceQuoteService
      Unassigns the assignee from the quote
      Specified by:
      unassignQuote in interface CommerceQuoteService
      Parameters:
      quote - the quote to be unassigned
      assigner - the user un-assigning the quote from the assignee
    • shouldAutoApproveTheQuoteForSellerApproval

      public boolean shouldAutoApproveTheQuoteForSellerApproval(QuoteModel quoteModel)
      Description copied from interface: CommerceQuoteService
      Checks whether a quote can be auto approved or requires seller approval based on the configured threshold.
      Specified by:
      shouldAutoApproveTheQuoteForSellerApproval in interface CommerceQuoteService
      Parameters:
      quoteModel - the quote to inspect for auto approval
      Returns:
      true if the quote should be auto approved, false otherwise
    • getQuotesCountForStoreAndUser

      public Integer getQuotesCountForStoreAndUser(CustomerModel customerModel, UserModel quoteUserModel, BaseStoreModel store)
      Description copied from interface: CommerceQuoteService
      Get the number of quotes for the specified user and store.
      Specified by:
      getQuotesCountForStoreAndUser in interface CommerceQuoteService
      Parameters:
      customerModel - the customer to be used for selecting the quotes
      quoteUserModel - the user asking for the number of quotes
      store - the store to be used for selecting the quotes
      Returns:
      the total number
    • isQuoteCartValidForCheckout

      public boolean isQuoteCartValidForCheckout(CartModel cart)
      Description copied from interface: CommerceQuoteService
      Validates if the quote cart can be checked-out or not
      Specified by:
      isQuoteCartValidForCheckout in interface CommerceQuoteService
      Parameters:
      cart - the cart to validate
      Returns:
      true if quoteCart is valid for check out, false otherwise
    • createQuoteSnapshotWithState

      public QuoteModel createQuoteSnapshotWithState(QuoteModel quoteModel, QuoteState quoteState)
      Description copied from interface: CommerceQuoteService
      Create a new quote snapshot for a given quote state and persist the model.
      Specified by:
      createQuoteSnapshotWithState in interface CommerceQuoteService
      Parameters:
      quoteModel - the quoteModel to create a snapshot from
      quoteState - the new quoteState
      Returns:
      the newly created quote
    • updateQuoteFromCartInternal

      protected QuoteModel updateQuoteFromCartInternal(CartModel cartModel)
    • executeQuoteAssignment

      protected void executeQuoteAssignment(QuoteModel quote, UserModel assignee, String errorMsg)
    • setAssigneeOnQuote

      protected void setAssigneeOnQuote(QuoteModel quote, UserModel assignee)
    • saveUpdate

      protected QuoteModel saveUpdate(CartModel cart, QuoteModel outdatedQuote, QuoteModel updatedQuote)
    • createDiscountValue

      protected Optional<DiscountValue> createDiscountValue(Double discountRate, DiscountType discountType, String currencyIsoCode)
    • isSessionQuoteSameAsRequestedQuote

      protected boolean isSessionQuoteSameAsRequestedQuote(QuoteModel quoteModel)
    • validateQuoteCart

      protected void validateQuoteCart(CartModel cartModel)
    • getCommerceQuoteDao

      protected CommerceQuoteDao getCommerceQuoteDao()
    • setCommerceQuoteDao

      public void setCommerceQuoteDao(CommerceQuoteDao commerceQuoteDao)
    • getCartService

      protected CartService getCartService()
    • setCartService

      public void setCartService(CartService cartService)
    • getModelService

      protected ModelService getModelService()
    • setModelService

      public void setModelService(ModelService modelService)
    • getCommerceSaveCartService

      protected CommerceSaveCartService getCommerceSaveCartService()
    • setCommerceSaveCartService

      public void setCommerceSaveCartService(CommerceSaveCartService commerceSaveCartService)
    • getSessionService

      protected SessionService getSessionService()
    • setSessionService

      public void setSessionService(SessionService sessionService)
    • getCommerceCartService

      protected CommerceCartService getCommerceCartService()
    • setCommerceCartService

      public void setCommerceCartService(CommerceCartService commerceCartService)
    • getQuoteStateSelectionStrategy

      protected QuoteStateSelectionStrategy getQuoteStateSelectionStrategy()
    • setQuoteStateSelectionStrategy

      public void setQuoteStateSelectionStrategy(QuoteStateSelectionStrategy quoteStateSelectionStrategy)
    • getQuoteActionValidationStrategy

      protected QuoteActionValidationStrategy getQuoteActionValidationStrategy()
    • setQuoteActionValidationStrategy

      public void setQuoteActionValidationStrategy(QuoteActionValidationStrategy quoteActionValidationStrategy)
    • getQuoteUpdateStateStrategy

      protected QuoteUpdateStateStrategy getQuoteUpdateStateStrategy()
    • setQuoteUpdateStateStrategy

      public void setQuoteUpdateStateStrategy(QuoteUpdateStateStrategy quoteUpdateStateStrategy)
    • getCalculationService

      protected CalculationService getCalculationService()
    • setCalculationService

      public void setCalculationService(CalculationService calculationService)
    • getQuoteService

      protected QuoteService getQuoteService()
    • setQuoteService

      public void setQuoteService(QuoteService quoteService)
    • getUpdateQuoteFromCartStrategy

      protected UpdateQuoteFromCartStrategy getUpdateQuoteFromCartStrategy()
    • setUpdateQuoteFromCartStrategy

      public void setUpdateQuoteFromCartStrategy(UpdateQuoteFromCartStrategy updateQuoteFromCartStrategy)
    • getQuoteAssignmentValidationStrategy

      protected QuoteAssignmentValidationStrategy getQuoteAssignmentValidationStrategy()
    • setQuoteAssignmentValidationStrategy

      public void setQuoteAssignmentValidationStrategy(QuoteAssignmentValidationStrategy quoteAssignmentValidationStrategy)
    • getQuoteSnapshotStateTransitionMap

      protected Map<QuoteState,QuoteState> getQuoteSnapshotStateTransitionMap()
    • setQuoteSnapshotStateTransitionMap

      public void setQuoteSnapshotStateTransitionMap(Map<QuoteState,QuoteState> quoteSnapshotStateTransitionMap)
    • getQuoteUserTypeIdentificationStrategy

      protected QuoteUserTypeIdentificationStrategy getQuoteUserTypeIdentificationStrategy()
    • setQuoteUserTypeIdentificationStrategy

      public void setQuoteUserTypeIdentificationStrategy(QuoteUserTypeIdentificationStrategy quoteUserTypeIdentificationStrategy)
    • getEventService

      protected EventService getEventService()
    • setEventService

      public void setEventService(EventService eventService)
    • getQuoteSellerApproverAutoApprovalStrategy

      protected QuoteSellerApproverAutoApprovalStrategy getQuoteSellerApproverAutoApprovalStrategy()
    • setQuoteSellerApproverAutoApprovalStrategy

      public void setQuoteSellerApproverAutoApprovalStrategy(QuoteSellerApproverAutoApprovalStrategy quoteSellerApproverAutoApprovalStrategy)
    • getQuoteCartValidationStrategy

      protected QuoteCartValidationStrategy getQuoteCartValidationStrategy()
    • setQuoteCartValidationStrategy

      public void setQuoteCartValidationStrategy(QuoteCartValidationStrategy quoteCartValidationStrategy)
    • getOrderQuoteDiscountValuesAccessor

      protected OrderQuoteDiscountValuesAccessor getOrderQuoteDiscountValuesAccessor()
    • setOrderQuoteDiscountValuesAccessor

      public void setOrderQuoteDiscountValuesAccessor(OrderQuoteDiscountValuesAccessor orderQuoteDiscountValuesAccessor)
    • getQuoteUpdateExpirationTimeStrategy

      protected QuoteUpdateExpirationTimeStrategy getQuoteUpdateExpirationTimeStrategy()
    • setQuoteUpdateExpirationTimeStrategy

      public void setQuoteUpdateExpirationTimeStrategy(QuoteUpdateExpirationTimeStrategy quoteUpdateExpirationTimeStrategy)
    • getQuoteMetadataValidationStrategy

      protected QuoteMetadataValidationStrategy getQuoteMetadataValidationStrategy()
    • setQuoteMetadataValidationStrategy

      public void setQuoteMetadataValidationStrategy(QuoteMetadataValidationStrategy quoteMetadataValidationStrategy)
    • getQuoteExpirationTimeValidationStrategy

      protected QuoteExpirationTimeValidationStrategy getQuoteExpirationTimeValidationStrategy()
    • setQuoteExpirationTimeValidationStrategy

      public void setQuoteExpirationTimeValidationStrategy(QuoteExpirationTimeValidationStrategy quoteExpirationTimeValidationStrategy)
    • getUserService

      protected UserService getUserService()
    • setUserService

      public void setUserService(UserService userService)
    • getCommerceQuoteUtils

      protected CommerceQuoteUtils getCommerceQuoteUtils()
    • setCommerceQuoteUtils

      public void setCommerceQuoteUtils(CommerceQuoteUtils commerceQuoteUtils)
    • getRequoteStrategy

      protected RequoteStrategy getRequoteStrategy()
    • setRequoteStrategy

      public void setRequoteStrategy(RequoteStrategy requoteStrategy)