Class CreateReturnRequestController
java.lang.Object
org.zkoss.zk.ui.event.GenericEventListener
org.zkoss.zk.ui.util.GenericComposer<T>
org.zkoss.zk.ui.util.GenericAutowireComposer<T>
org.zkoss.zk.ui.util.GenericForwardComposer<org.zkoss.zk.ui.Component>
com.hybris.cockpitng.util.ViewAnnotationAwareComposer
com.hybris.cockpitng.util.DefaultWidgetController
de.hybris.platform.omsbackoffice.widgets.returns.createreturnrequest.CreateReturnRequestController
- All Implemented Interfaces:
com.hybris.cockpitng.core.WidgetController,com.hybris.cockpitng.dnd.WidgetDragAndDropAware,com.hybris.cockpitng.engine.WidgetInstanceManagerAware,Serializable,org.zkoss.zk.ui.event.EventListener,org.zkoss.zk.ui.event.SerializableEventListener,org.zkoss.zk.ui.util.ComponentActivationListener,org.zkoss.zk.ui.util.ComponentCloneListener,org.zkoss.zk.ui.util.Composer<org.zkoss.zk.ui.Component>,org.zkoss.zk.ui.util.ComposerExt<org.zkoss.zk.ui.Component>
public class CreateReturnRequestController
extends com.hybris.cockpitng.util.DefaultWidgetController
This controller creates a pop-up to create a
ReturnRequestModel. It offers to select manually the reason of
the return as well as the custom amount to refund for each item. If not specified, the amount to refund will be
automatically set to the base price of the product. It also offer to set an optional comment.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final Objectprotected static final intprotected static final Stringprotected static final StringFields inherited from class org.zkoss.zk.ui.util.GenericAutowireComposer
_separator, application, applicationScope, arg, componentScope, desktop, desktopScope, execution, page, pageScope, param, requestScope, self, session, sessionScope, spaceOwner, spaceScopeFields inherited from class org.zkoss.zk.ui.util.GenericComposer
_applied -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdd listeners on Intbox, Combobox and Textbox so that when a change happens on one of these components, we are catching it.protected voidapplyToGrid(Object data, int childrenIndex) Apply a value to the elements contained in the gridprotected voidapplyToRow(Object data, int childrenIndex, org.zkoss.zk.ui.Component row) Apply a specific change to a specific row of the gridprotected voidautoSelect(org.zkoss.zk.ui.event.Event event) Automatically select the checkbox in front of the rowprotected voidCalculate an estimate of the tax for the return to display it to the end userprotected voidcalculateIndividualTaxEstimate(ReturnEntryToCreateDto returnEntryDto) Calculates the individual tax amount for aRefundEntryModelprotected voidcalculateRowAmount(org.zkoss.zul.Row myRow, ReturnEntryToCreateDto myReturnEntry, int qtyEntered) Calculates the total refund amount for a specific return entry according to the the quantity to returnprotected voidCalculate the total refund amount to display it to the end uservoidCreate the return requestprotected RefundEntryModelcreateRefundWithCustomAmount(ReturnRequestModel returnRequest, ReturnEntryToCreateDto entry) Create and set the custom price of the refund entry.protected com.hybris.cockpitng.core.events.CockpitEventQueueprotected BackofficeLocaleServiceprotected Optional<RefundReason>getCustomSelectedRefundReason(org.zkoss.zk.ui.event.Event event) Gets the label for the selected refund reason in case the event has a target of Comboboxprotected intgetDigitsNumber(RefundEntryModel refundEntryModel) Retrieves the number of digits to display for the amount.protected EnumerationServiceprotected ModelServiceprotected com.hybris.cockpitng.util.notifications.NotificationServiceprotected OrderModelgetOrder()protected intgetReasonIndex(RefundReason refundReason) Gets the reason index within the combobox modelprotected RefundServiceorg.zkoss.zul.Gridprotected Optional<RefundReason>getSelectedRefundReason(org.zkoss.zk.ui.event.Event event) get the corresponding refund reason according to the selected item in the combobox if existingprotected voidhandleGlobalComment(org.zkoss.zk.ui.event.Event event) Updates all entries with the selected global commentprotected voidhandleGlobalReason(org.zkoss.zk.ui.event.Event event) Updates all entries with the selected global reasonprotected voidhandleIndividualAmountToReturn(org.zkoss.zk.ui.event.Event event) Calculates the row amount for a return for the selected entry after an event was triggeredprotected voidhandleIndividualAmountToReturnBlur(org.zkoss.zk.ui.event.Event event) rounding the row amount after an event was triggeredprotected voidhandleIndividualAmountToReturnFocus(org.zkoss.zk.ui.event.Event event) reset the row amount after an event was triggeredprotected voidhandleIndividualQuantityToReturn(org.zkoss.zk.ui.event.Event event) Calculates the row amount for a return for the selected entry after an event was triggeredprotected voidhandleIndividualRefundReason(org.zkoss.zk.ui.event.Event event) Applies a refund reason to an individual entry after an event is triggered.protected voidhandleRow(org.zkoss.zul.Row row) Set or Reset the given row with the appropriate default informationsvoidinitCreateReturnRequestForm(OrderModel inputOrder) Initialize the popup to create aReturnRequestModelprotected Optional<RefundReason>matchingComboboxReturnReason(String refundReasonLabel) Retrieve theRefundReasonaccording to the selected label in the comboboxvoidreset()Reinitialize the popup.protected voidSelect or unselect all the rows of the grid and sets the default values for each of themvoidsetCockpitEventQueue(com.hybris.cockpitng.core.events.CockpitEventQueue cockpitEventQueue) voidsetCockpitLocaleService(BackofficeLocaleService cockpitLocaleService) voidsetEnumerationService(EnumerationService enumerationService) voidsetEventService(EventService eventService) voidsetModelService(ModelService modelService) voidsetNotificationService(com.hybris.cockpitng.util.notifications.NotificationService notificationService) voidsetOrder(OrderModel order) voidsetRefundService(RefundService refundService) voidsetReturnEntries(org.zkoss.zul.Grid returnEntries) voidsetReturnService(ReturnService returnService) protected voidSets the total discounts doublebox based onOrderModelapplied discountsprotected org.zkoss.zk.ui.ComponenttargetFieldToApplyValidation(String stringToValidate, int indexLabelToCheck, int indexTargetComponent) Retrieve the row who needs to apply a validation messageprotected voidCheck if the data provided by the form are compliant with the validation rulesprotected voidValidate each return entry and throw aWrongValueExceptionif it fails any checkMethods inherited from class com.hybris.cockpitng.util.DefaultWidgetController
doAfterCompose, doBeforeCompose, doBeforeComposeChildren, executeOperation, getDragAndDropStrategy, getLabel, getLabel, getModel, getValue, getWidgetDragAndDropStrategyRepository, getWidgetInstanceManager, getWidgetRoot, getWidgetSettings, getWidgetslot, getWidgetTitle, getWidgetUtils, initDragAndDropAwareness, initialize, initWidgetSetting, initWidgetSetting, initWidgetSetting, initWidgetSetting, initWidgetSetting, invokeListenerMethod, onSocketInput, preInitialize, sendOutput, sendOutputAfterOperation, sendOutputAfterOperation, sendOutputAfterOperation, setValue, setWidgetInstanceManager, setWidgetTitleMethods inherited from class com.hybris.cockpitng.util.ViewAnnotationAwareComposer
scanEventListenersMethods inherited from class org.zkoss.zk.ui.util.GenericAutowireComposer
alert, didActivate, getPage, willClone, willPassivateMethods inherited from class org.zkoss.zk.ui.util.GenericComposer
doCatch, doFinallyMethods inherited from class org.zkoss.zk.ui.event.GenericEventListener
bindComponent, getController, onEvent, unbindComponent
-
Field Details
-
IN_SOCKET
- See Also:
-
OUT_CONFIRM
- See Also:
-
COMPLETED
-
COLUMN_INDEX_RETURNABLE_QUANTITY
protected static final int COLUMN_INDEX_RETURNABLE_QUANTITY- See Also:
-
COLUMN_INDEX_RETURN_QUANTITY
protected static final int COLUMN_INDEX_RETURN_QUANTITY- See Also:
-
COLUMN_INDEX_RETURN_AMOUNT
protected static final int COLUMN_INDEX_RETURN_AMOUNT- See Also:
-
COLUMN_INDEX_RETURN_REASON
protected static final int COLUMN_INDEX_RETURN_REASON- See Also:
-
COLUMN_INDEX_RETURN_COMMENT
protected static final int COLUMN_INDEX_RETURN_COMMENT- See Also:
-
DEFAULT_AMOUNT_SCALE
protected static final int DEFAULT_AMOUNT_SCALE- See Also:
-
-
Constructor Details
-
CreateReturnRequestController
public CreateReturnRequestController()
-
-
Method Details
-
initCreateReturnRequestForm
Initialize the popup to create aReturnRequestModel- Parameters:
inputOrder- the order for which we want to create the return request
-
addListeners
protected void addListeners()Add listeners on Intbox, Combobox and Textbox so that when a change happens on one of these components, we are catching it. -
handleIndividualAmountToReturn
protected void handleIndividualAmountToReturn(org.zkoss.zk.ui.event.Event event) Calculates the row amount for a return for the selected entry after an event was triggered- Parameters:
event- the on change event that was triggered by the user
-
handleIndividualAmountToReturnFocus
protected void handleIndividualAmountToReturnFocus(org.zkoss.zk.ui.event.Event event) reset the row amount after an event was triggered- Parameters:
event- the on focus that was triggered by the user
-
handleIndividualAmountToReturnBlur
protected void handleIndividualAmountToReturnBlur(org.zkoss.zk.ui.event.Event event) rounding the row amount after an event was triggered- Parameters:
event- the blur event that was triggered by the user
-
getDigitsNumber
Retrieves the number of digits to display for the amount. Default number is 2- Parameters:
refundEntryModel- the object from which we can define how many digits to display- Returns:
- the number of digits to display
-
calculateIndividualTaxEstimate
Calculates the individual tax amount for aRefundEntryModel- Parameters:
returnEntryDto- the DTO representing aRefundEntryModelon the UI
-
handleIndividualQuantityToReturn
protected void handleIndividualQuantityToReturn(org.zkoss.zk.ui.event.Event event) Calculates the row amount for a return for the selected entry after an event was triggered- Parameters:
event- the on change event that was triggered by the user
-
handleIndividualRefundReason
protected void handleIndividualRefundReason(org.zkoss.zk.ui.event.Event event) Applies a refund reason to an individual entry after an event is triggered.- Parameters:
event- the on select event that was triggered by the user
-
handleGlobalComment
protected void handleGlobalComment(org.zkoss.zk.ui.event.Event event) Updates all entries with the selected global comment- Parameters:
event- the event that triggered the change
-
handleGlobalReason
protected void handleGlobalReason(org.zkoss.zk.ui.event.Event event) Updates all entries with the selected global reason- Parameters:
event- the event that triggered the change
-
calculateRowAmount
protected void calculateRowAmount(org.zkoss.zul.Row myRow, ReturnEntryToCreateDto myReturnEntry, int qtyEntered) Calculates the total refund amount for a specific return entry according to the the quantity to return- Parameters:
myRow- the row I want the calculation to applymyReturnEntry- the targeted return entryqtyEntered- the quantity to be returned
-
calculateTotalRefundAmount
protected void calculateTotalRefundAmount()Calculate the total refund amount to display it to the end user -
calculateEstimatedTax
protected void calculateEstimatedTax()Calculate an estimate of the tax for the return to display it to the end user -
autoSelect
protected void autoSelect(org.zkoss.zk.ui.event.Event event) Automatically select the checkbox in front of the row- Parameters:
event- the event that triggered the autoselect
-
handleRow
protected void handleRow(org.zkoss.zul.Row row) Set or Reset the given row with the appropriate default informations- Parameters:
row- the row to set/reset
-
selectAllEntries
protected void selectAllEntries()Select or unselect all the rows of the grid and sets the default values for each of them -
getReasonIndex
Gets the reason index within the combobox model- Parameters:
refundReason- the reason for which we want to know the index- Returns:
- the index of the given refund reason
-
getSelectedRefundReason
get the corresponding refund reason according to the selected item in the combobox if existing- Parameters:
event- the select event on the combobox- Returns:
- the corresponding refund reason
-
getCustomSelectedRefundReason
Gets the label for the selected refund reason in case the event has a target of Combobox- Parameters:
event- the event that was fired- Returns:
- the RefundReason corresponding to the label
-
applyToGrid
Apply a value to the elements contained in the grid- Parameters:
data- the value to pass to the gridchildrenIndex- the index indicating where to find the right component in the grid
-
applyToRow
Apply a specific change to a specific row of the grid- Parameters:
data- the new value to setchildrenIndex- the index of the component in the gridrow- the row to which the change needs to be applied
-
reset
public void reset()Reinitialize the popup. -
confirmCreation
public void confirmCreation()Create the return request -
createRefundWithCustomAmount
protected RefundEntryModel createRefundWithCustomAmount(ReturnRequestModel returnRequest, ReturnEntryToCreateDto entry) Create and set the custom price of the refund entry.- Parameters:
returnRequest- the associatedReturnRequestModelto theRefundEntryModelentry- theRefundEntryModeluse to get the custom informations- Returns:
- the newly
RefundEntryModelcreated
-
validateReturnEntry
Validate each return entry and throw aWrongValueExceptionif it fails any check- Parameters:
entry- the individual entry to validate
-
validateRequest
protected void validateRequest()Check if the data provided by the form are compliant with the validation rules -
targetFieldToApplyValidation
protected org.zkoss.zk.ui.Component targetFieldToApplyValidation(String stringToValidate, int indexLabelToCheck, int indexTargetComponent) Retrieve the row who needs to apply a validation message- Parameters:
stringToValidate- the string to compare to identify a specific row in the gridindexLabelToCheck- the index of the label to which we want to compare the passed stringindexTargetComponent- the index of the grid where the target component is located
-
matchingComboboxReturnReason
Retrieve theRefundReasonaccording to the selected label in the combobox- Parameters:
refundReasonLabel- aString- Returns:
- the return reason corresponding to the label
-
setTotalDiscounts
protected void setTotalDiscounts()Sets the total discounts doublebox based onOrderModelapplied discounts -
getOrder
-
setOrder
-
getReturnEntries
public org.zkoss.zul.Grid getReturnEntries() -
setReturnEntries
public void setReturnEntries(org.zkoss.zul.Grid returnEntries) -
getReturnService
-
setReturnService
-
getEventService
-
setEventService
-
getEnumerationService
-
setEnumerationService
-
getModelService
-
setModelService
-
getCockpitLocaleService
-
setCockpitLocaleService
-
getCockpitEventQueue
protected com.hybris.cockpitng.core.events.CockpitEventQueue getCockpitEventQueue() -
setCockpitEventQueue
public void setCockpitEventQueue(com.hybris.cockpitng.core.events.CockpitEventQueue cockpitEventQueue) -
getRefundService
-
setRefundService
-
getNotificationService
protected com.hybris.cockpitng.util.notifications.NotificationService getNotificationService() -
setNotificationService
public void setNotificationService(com.hybris.cockpitng.util.notifications.NotificationService notificationService)
-