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,java.io.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.DefaultWidgetControllerThis controller creates a pop-up to create aReturnRequestModel. 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static intCOLUMN_INDEX_RETURN_AMOUNTprotected static intCOLUMN_INDEX_RETURN_COMMENTprotected static intCOLUMN_INDEX_RETURN_QUANTITYprotected static intCOLUMN_INDEX_RETURN_REASONprotected static intCOLUMN_INDEX_RETURNABLE_QUANTITYprotected static java.lang.ObjectCOMPLETEDprotected static java.lang.StringIN_SOCKETprotected static java.lang.StringOUT_CONFIRM
-
Constructor Summary
Constructors Constructor Description CreateReturnRequestController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddListeners()Add listeners on Intbox, Combobox and Textbox so that when a change happens on one of these components, we are catching it.protected voidapplyToGrid(java.lang.Object data, int childrenIndex)Apply a value to the elements contained in the gridprotected voidapplyToRow(java.lang.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 voidcalculateEstimatedTax()Calculate 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 voidcalculateTotalRefundAmount()Calculate the total refund amount to display it to the end uservoidconfirmCreation()Create the return requestprotected RefundEntryModelcreateRefundWithCustomAmount(ReturnRequestModel returnRequest, ReturnEntryToCreateDto entry)Create and set the custom price of the refund entry.protected com.hybris.cockpitng.core.events.CockpitEventQueuegetCockpitEventQueue()protected BackofficeLocaleServicegetCockpitLocaleService()protected java.util.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 EnumerationServicegetEnumerationService()EventServicegetEventService()protected ModelServicegetModelService()protected com.hybris.cockpitng.util.notifications.NotificationServicegetNotificationService()protected OrderModelgetOrder()protected intgetReasonIndex(RefundReason refundReason)Gets the reason index within the combobox modelprotected RefundServicegetRefundService()org.zkoss.zul.GridgetReturnEntries()ReturnServicegetReturnService()protected java.util.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 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 java.util.Optional<RefundReason>matchingComboboxReturnReason(java.lang.String refundReasonLabel)Retrieve theRefundReasonaccording to the selected label in the comboboxvoidreset()Reinitialize the popup.protected voidselectAllEntries()Select 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 voidsetTotalDiscounts()Sets the total discounts doublebox based onOrderModelapplied discountsprotected org.zkoss.zk.ui.ComponenttargetFieldToApplyValidation(java.lang.String stringToValidate, int indexLabelToCheck, int indexTargetComponent)Retrieve the row who needs to apply a validation messageprotected voidvalidateRequest()Check if the data provided by the form are compliant with the validation rulesprotected voidvalidateReturnEntry(ReturnEntryToCreateDto entry)Validate each return entry and throw aWrongValueExceptionif it fails any check-
Methods 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, setWidgetTitle
-
Methods inherited from class com.hybris.cockpitng.util.ViewAnnotationAwareComposer
scanEventListeners
-
Methods inherited from class org.zkoss.zk.ui.util.GenericAutowireComposer
alert, didActivate, getPage, willClone, willPassivate
-
-
-
-
Field Detail
-
IN_SOCKET
protected static final java.lang.String IN_SOCKET
- See Also:
- Constant Field Values
-
OUT_CONFIRM
protected static final java.lang.String OUT_CONFIRM
- See Also:
- Constant Field Values
-
COMPLETED
protected static final java.lang.Object COMPLETED
-
COLUMN_INDEX_RETURNABLE_QUANTITY
protected static final int COLUMN_INDEX_RETURNABLE_QUANTITY
- See Also:
- Constant Field Values
-
COLUMN_INDEX_RETURN_QUANTITY
protected static final int COLUMN_INDEX_RETURN_QUANTITY
- See Also:
- Constant Field Values
-
COLUMN_INDEX_RETURN_AMOUNT
protected static final int COLUMN_INDEX_RETURN_AMOUNT
- See Also:
- Constant Field Values
-
COLUMN_INDEX_RETURN_REASON
protected static final int COLUMN_INDEX_RETURN_REASON
- See Also:
- Constant Field Values
-
COLUMN_INDEX_RETURN_COMMENT
protected static final int COLUMN_INDEX_RETURN_COMMENT
- See Also:
- Constant Field Values
-
-
Method Detail
-
initCreateReturnRequestForm
public void initCreateReturnRequestForm(OrderModel inputOrder)
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
-
calculateIndividualTaxEstimate
protected void calculateIndividualTaxEstimate(ReturnEntryToCreateDto returnEntryDto)
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
protected int getReasonIndex(RefundReason refundReason)
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
protected java.util.Optional<RefundReason> getSelectedRefundReason(org.zkoss.zk.ui.event.Event event)
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
protected java.util.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 Combobox- Parameters:
event- the event that was fired- Returns:
- the RefundReason corresponding to the label
-
applyToGrid
protected void applyToGrid(java.lang.Object data, int childrenIndex)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
protected void applyToRow(java.lang.Object data, int childrenIndex, org.zkoss.zk.ui.Component row)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
protected void validateReturnEntry(ReturnEntryToCreateDto entry)
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(java.lang.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
protected java.util.Optional<RefundReason> matchingComboboxReturnReason(java.lang.String refundReasonLabel)
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
protected OrderModel getOrder()
-
setOrder
public void setOrder(OrderModel order)
-
getReturnEntries
public org.zkoss.zul.Grid getReturnEntries()
-
setReturnEntries
public void setReturnEntries(org.zkoss.zul.Grid returnEntries)
-
getReturnService
public ReturnService getReturnService()
-
setReturnService
public void setReturnService(ReturnService returnService)
-
getEventService
public EventService getEventService()
-
setEventService
public void setEventService(EventService eventService)
-
getEnumerationService
protected EnumerationService getEnumerationService()
-
setEnumerationService
public void setEnumerationService(EnumerationService enumerationService)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getCockpitLocaleService
protected BackofficeLocaleService getCockpitLocaleService()
-
setCockpitLocaleService
public void setCockpitLocaleService(BackofficeLocaleService cockpitLocaleService)
-
getCockpitEventQueue
protected com.hybris.cockpitng.core.events.CockpitEventQueue getCockpitEventQueue()
-
setCockpitEventQueue
public void setCockpitEventQueue(com.hybris.cockpitng.core.events.CockpitEventQueue cockpitEventQueue)
-
getRefundService
protected RefundService getRefundService()
-
setRefundService
public void setRefundService(RefundService refundService)
-
getNotificationService
protected com.hybris.cockpitng.util.notifications.NotificationService getNotificationService()
-
setNotificationService
public void setNotificationService(com.hybris.cockpitng.util.notifications.NotificationService notificationService)
-
-