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 Details

  • Constructor Details

    • CreateReturnRequestController

      public CreateReturnRequestController()
  • Method Details

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

      protected int getDigitsNumber(RefundEntryModel refundEntryModel)
      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

      protected void calculateIndividualTaxEstimate(ReturnEntryToCreateDto returnEntryDto)
      Calculates the individual tax amount for a RefundEntryModel
      Parameters:
      returnEntryDto - the DTO representing a RefundEntryModel on 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 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 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 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(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(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
    • createRefundWithCustomAmount

      protected RefundEntryModel createRefundWithCustomAmount(ReturnRequestModel returnRequest, ReturnEntryToCreateDto entry)
      Create and set the custom price of the refund entry.
      Parameters:
      returnRequest - the associated ReturnRequestModel to the RefundEntryModel
      entry - the RefundEntryModel use to get the custom informations
      Returns:
      the newly RefundEntryModel created
    • 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(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 Optional<RefundReason> matchingComboboxReturnReason(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
    • 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)