Interface CommerceQuoteService
-
- All Known Implementing Classes:
DefaultC4CQuoteService
,DefaultCommerceQuoteService
,DefaultSapCpiQuoteService
public interface CommerceQuoteService
Service interface that provides an API for quote management.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CartModel
acceptAndPrepareCheckout(QuoteModel quoteModel, UserModel userModel)
Accept and prepare checkout.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.QuoteModel
approveQuote(QuoteModel quoteModel, UserModel userModel)
Approve a quote from seller representative.void
assignQuoteToUser(QuoteModel quote, UserModel assignee, UserModel assigner)
Assigns quote to an assigneevoid
cancelQuote(QuoteModel quoteModel, UserModel userModel)
Cancels a quote.QuoteModel
createQuoteFromCart(CartModel cartModel, UserModel userModel)
Creates a new quote based on given cart.QuoteModel
createQuoteSnapshotWithState(QuoteModel quoteModel, QuoteState quoteState)
Create a new quote snapshot for a given quote state and persist the model.java.util.Set<QuoteAction>
getAllowedActions(QuoteModel quoteModel, UserModel userModel)
Get currently allowed actions for a quote.QuoteModel
getQuoteByCodeAndCustomerAndStore(CustomerModel customerModel, UserModel quoteUserModel, BaseStoreModel store, java.lang.String quoteCode)
Finds a quote with highest version by code, customer and store.SearchPageData<QuoteModel>
getQuoteList(CustomerModel customerModel, UserModel quoteUserModel, BaseStoreModel store, PageableData pageableData)
Retrieves the paged list of quotes according to the provided selection criteria.double
getQuoteRequestThreshold(QuoteModel quote, UserModel user, CartModel sessionCart)
Get quote request threshold defined in properties.java.lang.Integer
getQuotesCountForStoreAndUser(CustomerModel customerModel, UserModel quoteUserModel, BaseStoreModel store)
Get the number of quotes for the specified user and store.boolean
isQuoteCartValidForCheckout(CartModel cart)
Validates if the quote cart can be checked-out or notCartModel
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.QuoteModel
rejectQuote(QuoteModel quoteModel, UserModel userModel)
Reject a quote from seller representative.void
removeQuoteCart(QuoteModel quote)
Removes the cart related to the given quoteQuoteModel
requote(QuoteModel quoteModel, UserModel userModel)
Re-quote from an existing quote to create a new quoteboolean
shouldAutoApproveTheQuoteForSellerApproval(QuoteModel quoteModel)
Checks whether a quote can be auto approved or requires seller approval based on the configured threshold.QuoteModel
submitQuote(QuoteModel quoteModel, UserModel userModel)
Submits a quote from buyer to seller representative or from seller representative to seller approver.void
unassignQuote(QuoteModel quote, UserModel assigner)
Unassigns the assignee from the quoteQuoteModel
updateQuoteFromCart(CartModel cartModel, UserModel userModel)
Updates quote with data from cart (and existing quote).void
validateQuoteThreshold(QuoteModel quote, UserModel user, CartModel sessionCart)
Validates if quote meets threshold.
-
-
-
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 modeluserModel
- 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 informationcustomerModel
- the customer to be used for selecting the quotesquoteUserModel
- 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 quotequoteUserModel
- the user asking for the list.store
- the store to be used for selecting the quotequoteCode
- 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 processuserModel
- 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 processuserModel
- the user performing the operation on the quote- Returns:
- the updated quote
- Throws:
java.lang.IllegalArgumentException
- if any of the parameters is null
-
validateQuoteThreshold
void validateQuoteThreshold(QuoteModel quote, UserModel user, CartModel sessionCart) throws QuoteUnderThresholdException
Validates if quote meets threshold.- Parameters:
quote
- the quote to validateuser
- the user performing the operation on the quotesessionCart
- the cart in session- Throws:
QuoteUnderThresholdException
- if quote does not meet threshold
-
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 processuserModel
- 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 processuserModel
- 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 quoteuserModel
- 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 processuserModel
- 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
-
acceptAndPrepareCheckout
CartModel acceptAndPrepareCheckout(QuoteModel quoteModel, UserModel userModel)
Accept and prepare checkout. Similar toloadQuoteAsSessionCart(QuoteModel, UserModel)
but for checkout.- Parameters:
quoteModel
- the quote to processuserModel
- the user performing the operation on the quote- Returns:
- the cart for checkout
- Throws:
java.lang.IllegalArgumentException
- if any of parameters is nullCommerceQuoteExpirationTimeException
- if the quote has expired
-
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 aQuoteModel
or aCartModel
associated with a quote.userModel
- the user performing the operation on the quotediscountRate
- the discount rate to be applieddiscountType
- 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 aCartModel
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 canceluserModel
- 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 assignedassignee
- the user to which the quote should be assignedassigner
- the user assigning the quote to the assignee- Throws:
java.lang.IllegalArgumentException
- if any of parameters is nullCommerceQuoteAssignmentException
- 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 unassignedassigner
- the user un-assigning the quote from the assignee- Throws:
java.lang.IllegalArgumentException
- if any of parameters is nullCommerceQuoteAssignmentException
- 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 quotesquoteUserModel
- the user asking for the number of quotesstore
- 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 fromquoteState
- 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 quoteModeluserModel
- the current quote user- Returns:
- the new created quoteModel
-
-