Class 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.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:
    Serialized Form
    • Field Detail

      • 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
    • Constructor Detail

      • CreateReturnRequestController

        public CreateReturnRequestController()
    • Method Detail

      • initCreateReturnRequestForm

        public void initCreateReturnRequestForm​(OrderModel inputOrder)
        Initialize the popup to create a ReturnRequestModel
        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
      • 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 apply
        myReturnEntry - the targeted return entry
        qtyEntered - 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 grid
        childrenIndex - 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 set
        childrenIndex - the index of the component in the grid
        row - 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
      • validateReturnEntry

        protected void validateReturnEntry​(ReturnEntryToCreateDto entry)
        Validate each return entry and throw a WrongValueException if 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 grid
        indexLabelToCheck - the index of the label to which we want to compare the passed string
        indexTargetComponent - the index of the grid where the target component is located
      • matchingComboboxReturnReason

        protected java.util.Optional<RefundReason> matchingComboboxReturnReason​(java.lang.String refundReasonLabel)
        Retrieve the RefundReason according to the selected label in the combobox
        Parameters:
        refundReasonLabel - a String
        Returns:
        the return reason corresponding to the label
      • setTotalDiscounts

        protected void setTotalDiscounts()
        Sets the total discounts doublebox based on OrderModel applied discounts
      • setOrder

        public void setOrder​(OrderModel order)
      • getReturnEntries

        public org.zkoss.zul.Grid getReturnEntries()
      • setReturnEntries

        public void setReturnEntries​(org.zkoss.zul.Grid returnEntries)
      • setReturnService

        public void setReturnService​(ReturnService returnService)
      • setEventService

        public void setEventService​(EventService eventService)
      • setEnumerationService

        public void setEnumerationService​(EnumerationService enumerationService)
      • getModelService

        protected ModelService getModelService()
      • setModelService

        public void setModelService​(ModelService modelService)
      • getCockpitEventQueue

        protected com.hybris.cockpitng.core.events.CockpitEventQueue getCockpitEventQueue()
      • setCockpitEventQueue

        public void setCockpitEventQueue​(com.hybris.cockpitng.core.events.CockpitEventQueue cockpitEventQueue)
      • 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)