Interface CommerceQuoteService

    • Method Detail

      • createQuoteFromCart

        QuoteModel createQuoteFromCart​(CartModel cartModel,
                                       UserModel userModel)
        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.
        Parameters:
        cartModel - the cart model
        userModel - the user performing the operation on the quote
        Returns:
        the new quote model
        Throws:
        java.lang.IllegalArgumentException - if any of the parameters is null
      • getQuoteList

        SearchPageData<QuoteModel> getQuoteList​(CustomerModel customerModel,
                                                UserModel quoteUserModel,
                                                BaseStoreModel store,
                                                PageableData pageableData)
        Retrieves the paged list of quotes according to the provided selection criteria.
        Parameters:
        pageableData - paging information
        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
        Returns:
        the paged search results
        Throws:
        java.lang.IllegalArgumentException - if any of the parameters is null
      • getQuoteByCodeAndCustomerAndStore

        QuoteModel getQuoteByCodeAndCustomerAndStore​(CustomerModel customerModel,
                                                     UserModel quoteUserModel,
                                                     BaseStoreModel store,
                                                     java.lang.String quoteCode)
        Finds a quote with highest version by code, customer and store.
        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
        Throws:
        java.lang.IllegalArgumentException - if any of the parameters is null
      • loadQuoteAsSessionCart

        CartModel loadQuoteAsSessionCart​(QuoteModel quoteModel,
                                         UserModel userModel)
        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.
        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
      • submitQuote

        QuoteModel submitQuote​(QuoteModel quoteModel,
                               UserModel userModel)
        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.
        Parameters:
        quoteModel - the quote to process
        userModel - the user performing the operation on the quote
        Returns:
        the updated quote
        Throws:
        java.lang.IllegalArgumentException - if any of the parameters is null
      • getQuoteRequestThreshold

        double getQuoteRequestThreshold​(QuoteModel quote,
                                        UserModel user,
                                        CartModel sessionCart)
        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.
        Parameters:
        quote -
        user -
        sessionCart -
        Returns:
        quote request threshold
      • approveQuote

        QuoteModel approveQuote​(QuoteModel quoteModel,
                                UserModel userModel)
        Approve a quote from seller representative. Send a quote on submit event.
        Parameters:
        quoteModel - the quote to process
        userModel - the user performing the operation on the quote
        Returns:
        the updated quote
        Throws:
        java.lang.IllegalArgumentException - if any of the parameters is null
      • rejectQuote

        QuoteModel rejectQuote​(QuoteModel quoteModel,
                               UserModel userModel)
        Reject a quote from seller representative. Send a quote on submit event.
        Parameters:
        quoteModel - the quote to process
        userModel - the user performing the operation on the quote
        Returns:
        the updated quote
        Throws:
        java.lang.IllegalArgumentException - if any of the parameters is null
      • updateQuoteFromCart

        QuoteModel updateQuoteFromCart​(CartModel cartModel,
                                       UserModel userModel)
        Updates quote with data from cart (and existing quote). Sets the cart as cartReference on to the new quote.
        Parameters:
        cartModel - cart that has an association to a quote
        userModel - the user performing the operation on the quote
        Returns:
        the updated quote
        Throws:
        java.lang.IllegalArgumentException - if any of the parameters is null
      • getAllowedActions

        java.util.Set<QuoteAction> getAllowedActions​(QuoteModel quoteModel,
                                                     UserModel userModel)
        Get currently allowed actions for a quote.
        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.
        Throws:
        java.lang.IllegalArgumentException - if any of the parameter is null
      • applyQuoteDiscount

        void applyQuoteDiscount​(AbstractOrderModel abstractOrderModel,
                                UserModel userModel,
                                java.lang.Double discountRate,
                                DiscountType discountType)
        Applies a quote specific discount to abstract order model given the discount rate and discount type.
        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
        Throws:
        java.lang.IllegalArgumentException - In case
        • any of the parameters is null,
        • the given order is neither a QuoteModel nor a CartModel associated with a quote or
        • the discount rate is out of range.
        SystemException - if an error occurs during cart calculation
      • cancelQuote

        void cancelQuote​(QuoteModel quoteModel,
                         UserModel userModel)
        Cancels a quote. The version of the quote visible to the user will have the state set to canceled.
        Parameters:
        quoteModel - the quote to cancel
        userModel - the user performing the operation on the quote
        Throws:
        java.lang.IllegalArgumentException - if any of the parameters is null
      • assignQuoteToUser

        void assignQuoteToUser​(QuoteModel quote,
                               UserModel assignee,
                               UserModel assigner)
        Assigns quote to an assignee
        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
        Throws:
        java.lang.IllegalArgumentException - if any of parameters is null
        CommerceQuoteAssignmentException - if the quote is already assigned to a different user
      • unassignQuote

        void unassignQuote​(QuoteModel quote,
                           UserModel assigner)
        Unassigns the assignee from the quote
        Parameters:
        quote - the quote to be unassigned
        assigner - the user un-assigning the quote from the assignee
        Throws:
        java.lang.IllegalArgumentException - if any of parameters is null
        CommerceQuoteAssignmentException - if the quote is assigned to a different user
      • shouldAutoApproveTheQuoteForSellerApproval

        boolean shouldAutoApproveTheQuoteForSellerApproval​(QuoteModel quoteModel)
        Checks whether a quote can be auto approved or requires seller approval based on the configured threshold.
        Parameters:
        quoteModel - the quote to inspect for auto approval
        Returns:
        true if the quote should be auto approved, false otherwise
      • getQuotesCountForStoreAndUser

        java.lang.Integer getQuotesCountForStoreAndUser​(CustomerModel customerModel,
                                                        UserModel quoteUserModel,
                                                        BaseStoreModel store)
        Get the number of quotes for the specified user and store.
        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
        Throws:
        java.lang.IllegalArgumentException - if any of the parameters is null
      • createQuoteSnapshotWithState

        QuoteModel createQuoteSnapshotWithState​(QuoteModel quoteModel,
                                                QuoteState quoteState)
        Create a new quote snapshot for a given quote state and persist the model.
        Parameters:
        quoteModel - the quoteModel to create a snapshot from
        quoteState - the new quoteState
        Returns:
        the newly created quote
        Throws:
        java.lang.IllegalArgumentException - if any of the parameters is null
      • isQuoteCartValidForCheckout

        boolean isQuoteCartValidForCheckout​(CartModel cart)
        Validates if the quote cart can be checked-out or not
        Parameters:
        cart - the cart to validate
        Returns:
        true if quoteCart is valid for check out, false otherwise
      • removeQuoteCart

        void removeQuoteCart​(QuoteModel quote)
        Removes the cart related to the given quote
        Parameters:
        quote - the quote to detach cart from
      • requote

        QuoteModel requote​(QuoteModel quoteModel,
                           UserModel userModel)
        Re-quote from an existing quote to create a new quote
        Parameters:
        quoteModel - the existing quoteModel
        userModel - the current quote user
        Returns:
        the new created quoteModel