Class SalesDocumentERP

    • Field Detail

      • STRATEGY_FACTORY_ERP

        public static final java.lang.String STRATEGY_FACTORY_ERP
        constant naming the key referenced in factory-config.xml where the strategy class is specified
        See Also:
        Constant Field Values
      • ORDER_ITEM_STRUCTURE

        public static final java.lang.String ORDER_ITEM_STRUCTURE
        UI controller relevant constant for 'OrderItemStructure'
        See Also:
        Constant Field Values
      • ORDER_HEADER_STRUCTURE

        public static final java.lang.String ORDER_HEADER_STRUCTURE
        UI controller relevant constant for 'OrderHeaderStructure'
        See Also:
        Constant Field Values
      • isUMEDisabledWarningNecessary

        protected boolean isUMEDisabledWarningNecessary
        Warning message in case UME is disabled. Then we only have one session in ERP, and we cannot fully support multiple documents. UME disabling will not be possible in productive environments.
      • getAllStrategy

        protected GetAllStrategy getAllStrategy
        Strategy pattern to support various LO-API versions
      • itemVariantMap

        protected java.util.Map<java.lang.String,​java.lang.String> itemVariantMap
      • showInlineConfig

        protected boolean showInlineConfig
      • headerCondTypeFreight

        protected java.lang.String headerCondTypeFreight
      • isIncompletionLogRequested

        protected boolean isIncompletionLogRequested
      • deliveryPriority

        protected java.lang.String deliveryPriority
      • erroneous

        protected boolean erroneous
      • createProcess

        protected boolean createProcess
    • Constructor Detail

      • SalesDocumentERP

        protected SalesDocumentERP()
    • Method Detail

      • getItemBuffer

        public ItemBuffer getItemBuffer()
        Returns:
        the itemBuffer
      • setItemBuffer

        public void setItemBuffer​(ItemBuffer itemBuffer)
        Parameters:
        itemBuffer - the itemBuffer to set
      • getGetAllStrategy

        public GetAllStrategy getGetAllStrategy()
        Returns:
        the getAllStrategy
      • setGetAllStrategy

        public void setGetAllStrategy​(GetAllStrategy getAllStrategy)
        Parameters:
        getAllStrategy - the getAllStrategy to set
      • getLrdActionsStrategy

        public LrdActionsStrategy getLrdActionsStrategy()
        Returns:
        the lrdActionsStrategy
      • setLrdActionsStrategy

        public void setLrdActionsStrategy​(LrdActionsStrategy lrdActionsStrategy)
        Parameters:
        lrdActionsStrategy - the lrdActionsStrategy to set
      • getSetStrategy

        public SetStrategy getSetStrategy()
        Returns:
        the setStrategy
      • setSetStrategy

        public void setSetStrategy​(SetStrategy setStrategy)
        Parameters:
        setStrategy - the setStrategy to set
      • isDocumentInitial

        public boolean isDocumentInitial()
        Specified by:
        isDocumentInitial in interface BackendState
        Returns:
        Sales document is initial
      • setSoldToHandle

        public void setSoldToHandle​(java.lang.String soldTo)
        Description copied from interface: BackendState
        Sets handle of soldTo partner
        Specified by:
        setSoldToHandle in interface BackendState
        Parameters:
        soldTo - handle of the soldto partner function
      • setPayerHandle

        public void setPayerHandle​(java.lang.String payer)
        Description copied from interface: BackendState
        Sets handle of payer
        Specified by:
        setPayerHandle in interface BackendState
        Parameters:
        payer - handle of the payer partner function
      • getPayerHandle

        public java.lang.String getPayerHandle()
        Specified by:
        getPayerHandle in interface BackendState
        Returns:
        handle of the payer
      • getSoldToHandle

        public java.lang.String getSoldToHandle()
        Specified by:
        getSoldToHandle in interface BackendState
        Returns:
        handle of the soldTo partner
      • setDocumentInitial

        public void setDocumentInitial​(boolean isInitial)
        Description copied from interface: BackendState
        Sales document is initial. The first update might need to do specific shipto handling
        Specified by:
        setDocumentInitial in interface BackendState
        Parameters:
        isInitial - true if document is initial
      • createInBackend

        public void createInBackend​(SalesDocument salesDocument)
                             throws BackendException
        Create back end representation of the object
        Parameters:
        salesDocument - sales document to be created in back end
        Throws:
        BackendException - case of a back-end error
      • createInBackend

        public void createInBackend​(TransactionConfiguration transactionConfiguration,
                                    SalesDocument salesDocument)
                             throws BackendException
        Create back end representation of the object without providing information about the user. This may happen in the B2C scenario where the login may be done later.
        Specified by:
        createInBackend in interface SalesDocumentBackend
        Parameters:
        transactionConfiguration - The current shop
        salesDocument - The document to read the data in
        Throws:
        BackendException - in case of a back-end or communication error
      • handleInvalidHeaderAfterUpdate

        protected void handleInvalidHeaderAfterUpdate​(SalesDocument salesDocument)
                                               throws BackendException
        Document couldn't be created. Now the header needs to be corrected, and the document is again sent to ERP.
        Throws:
        BackendException
      • restoreErroneousHeaderAfterSet

        protected void restoreErroneousHeaderAfterSet​(Header header)
        Restoring header: Initializing delivery date.
        Parameters:
        header -
      • fixErroneousHeader

        protected void fixErroneousHeader​(SalesDocument document)
        Fixing a header which cannot be digested from ERP. This implementation sets a delivery date because this is the only error which can be corrected by means of attributes available in WCEM
      • emptyInBackend

        public void emptyInBackend​(SalesDocument salesDocument)
                            throws BackendException
        Description copied from interface: SalesDocumentBackend
        Empties the representation of the provided object in the underlying storage. This means that all items and the header information are cleared. The provided document itself is not changed, so you are responsible for clearing the data representation on the business object layer on your own.
        Specified by:
        emptyInBackend in interface SalesDocumentBackend
        Parameters:
        salesDocument - the document to remove the representation in the storage
        Throws:
        BackendException - in case of a back-end or communication error
      • fixErroneousItem

        protected void fixErroneousItem​(Item item)
      • isCreateProcess

        public boolean isCreateProcess()
        Description copied from interface: BackendState
        In case an order has just been created, or just been saved, we do not expect certain data to be present already. For Example DocFlow data. So for performance reasons it makes sense not to request those data.
        Specified by:
        isCreateProcess in interface BackendState
        Returns:
        true, if the salesdocument is just created
      • isErroneous

        public boolean isErroneous()
        Returns:
        true, if error occured
      • isMultipleAddressesSupported

        public boolean isMultipleAddressesSupported()
        Description copied from interface: SalesDocumentBackend
        Checks in the back end whether the multiple addresses are supported.
        Specified by:
        isMultipleAddressesSupported in interface SalesDocumentBackend
        Returns:
        true when the back end supports the multiple addresses
      • checkForInitializationError

        protected boolean checkForInitializationError​(SalesDocument salesDocument)
      • isInBackend

        protected boolean isInBackend​(SalesDocument salesDocument)
      • readFromBackend

        public void readFromBackend​(SalesDocument salesDocument,
                                    TransactionConfiguration transConf,
                                    boolean directRead)
                             throws BackendException
        Description copied from interface: SalesDocumentBackend
        Reads Data from the back end. Every document consists of two parts: the header and the items. This method retrieves the header and the item information. If a soldTo is set in the partner list, ship to information should be read
        Specified by:
        readFromBackend in interface SalesDocumentBackend
        Parameters:
        salesDocument - Sales Document to be read
        transConf - Transaction Configuration object that holds the configuration settings
        directRead - In case other sessions/channels update the sales document in parallel, it is only guaranteed that the most recent data is returned if direct read is set to true, otherwise the data might be returned from a buffer.
        Throws:
        BackendException - in case of a back-end or communication error
      • handleInvalidHeaderAfterRead

        protected void handleInvalidHeaderAfterRead​(SalesDocument salesDocument)
        Actions which are needed for the header after a read step. Messages might need to be restored, because the header has been temporarily adjusted before.
      • restoreErroneousHeaderAfterRead

        protected void restoreErroneousHeaderAfterRead​(SalesDocument salesDocument)
        Restore invalid header after read step. Restore required delivery date and messages.
      • handleInvalidItemsAfterRead

        protected void handleInvalidItemsAfterRead​(SalesDocument salesDocument)
        Restores the sales document items after read and adds the information which needed to be removed before.
        Parameters:
        salesDocument - The cart sales document.
      • restoreErroneousItem

        protected void restoreErroneousItem​(Item savedState,
                                            Item errItm)
        If an item has been fixed so that LO-API can consume it, we later on need to restore the user inputs, so that the user sees the data he/she has entered which need to be corrected.
        Parameters:
        savedState - The original, saved state of the item
        errItm - State of the erroneous item after LO-API can digest it
      • getErroneousItems

        public java.util.Map<TechKey,​Item> getErroneousItems()
        Description copied from interface: BackendState
        Returns the previously stored information about erroneous items. Even if the sales document items are technically ok and can be sent via LO-API, this list holds the information which causes the trouble, and which needs to be put to the items after read to persist the user entry
        Specified by:
        getErroneousItems in interface BackendState
        Returns:
        Map for all erroneous items
      • handleInvalidItems

        protected boolean handleInvalidItems​(SalesDocument salesDocument)
                                      throws BackendException
        Checks for invalid items and initialises them, so that they can be deleted afterwards. This call is done before the LO-API is called for reading item information.
        The items which cannot be digested by LO-API are fixed, the info needed to restore the document are kept in getErroneousItems()
        Parameters:
        salesDocument - Cart sales document
        Returns:
        Could we fix the document.
        Throws:
        BackendException
      • addErroneousItem

        public void addErroneousItem​(Item item)
        Description copied from interface: BackendState
        Stores an erroneous item to be later able to restore its attrtibutes
        Specified by:
        addErroneousItem in interface BackendState
        Parameters:
        item - The item (including message list, productId which we need to restore
      • recoverFromBackend

        public boolean recoverFromBackend​(SalesDocument salesDoc,
                                          TechKey basketGuid)
                                   throws BackendException
        Description copied from interface: SalesDocumentBackend
        Recovers the whole document for the given TechKey from the back end. Before calling this method, it should be checked if the back end is capable of recovering a document. This can be done by calling checkRecoveryInBackend. So far the recovery feature is only available for the java basket (see SalesDocumentDB), it is used during startup to recover a basket via a cookie (see BasketCookieHandler).
        Specified by:
        recoverFromBackend in interface SalesDocumentBackend
        Parameters:
        salesDoc - The document to load the data in.
        basketGuid - The TechKey of the basket to read
        Returns:
        success true when the recovering is successful
        Throws:
        BackendException - in case of a back-end or communication error
      • setErroneous

        public void setErroneous​(boolean bool)
        Description copied from interface: BackendState
        Set the error state read from the backend
        Specified by:
        setErroneous in interface BackendState
        Parameters:
        bool - true if ERRKZ is 'X', otherwise false
      • updateInBackend

        public void updateInBackend​(SalesDocument salesDocument)
                             throws BackendException
        Description copied from interface: SalesDocumentBackend
        Updates object in the back end without supplying extra information about the transactionConfiguration. This method is normally necessary only for the B2C scenario.
        Note: For a correct support of the business event AddToDocument the techkey of the items should be filled from the back end.
        Specified by:
        updateInBackend in interface SalesDocumentBackend
        Parameters:
        salesDocument - the object to update
        Throws:
        BackendException - in case of a back-end or communication error
      • afterWriteDocument

        protected void afterWriteDocument​(SalesDocument salesDocument,
                                          JCoConnection aJCoCon)
        Parameters:
        salesDocument -
        aJCoCon -
      • handleInvalidHeaderBeforeUpdate

        protected void handleInvalidHeaderBeforeUpdate​(SalesDocument salesDocument)
        Actions which are needed before an update call if error situations occur. Implementation re-initializes the required delivery date in case nothing was entered
        Parameters:
        salesDocument - Sales document
      • handleInvalidItemsAfterUpdate

        protected void handleInvalidItemsAfterUpdate​(SalesDocument salesDocument)
        Clear session storage of erroneous items for those items which are fine after the set call to SD
        Parameters:
        salesDocument -
      • checkShippingConditions

        protected void checkShippingConditions​(SalesDocument salesDocument)
                                        throws BackendException
        Check whether shipping conditions have been changed, and trigger a new pricing if necessary.
        Parameters:
        salesDocument -
        Throws:
        BackendException
      • setShippingCondition

        public void setShippingCondition​(java.lang.String currentShippingCondition)
        Description copied from interface: BackendState
        Sets stored shipping condition. We need this to decide whether a pricing update is necessary.
        Specified by:
        setShippingCondition in interface BackendState
        Parameters:
        currentShippingCondition - Shipping condition
      • getShippingCondition

        public java.lang.String getShippingCondition()
        Description copied from interface: BackendState
        Returns stored shipping condition. We need this to decide whether a pricing update is necessary.
        Specified by:
        getShippingCondition in interface BackendState
        Returns:
        Shipping condition
      • updateInBackend

        public void updateInBackend​(SalesDocument salesDocument,
                                    TransactionConfiguration transactionConfiguration,
                                    java.util.List<TechKey> itemsToDelete)
                             throws BackendException
        Description copied from interface: SalesDocumentBackend
        Updates object in the back end by putting the data into the underlying storage.
        Note: For a correct support of the business event AddToDocument the techkey of the items should be filled from the back end.
        Specified by:
        updateInBackend in interface SalesDocumentBackend
        Parameters:
        salesDocument - the document to update
        transactionConfiguration - Transaction Configuration object that holds the configuration settings
        itemsToDelete - List of techkeys of the items to be deleted in the back end
        Throws:
        BackendException - This exception is thrown if an error occurs in the back end
      • getErroneousHeader

        public Header getErroneousHeader()
        Description copied from interface: BackendState
        Returns the previously stored information about the erroneous header.
        Specified by:
        getErroneousHeader in interface BackendState
        Returns:
        Sales document header
      • setErroneousHeader

        public void setErroneousHeader​(Header header)
        Description copied from interface: BackendState
        Sets erroneous header.
        Specified by:
        setErroneousHeader in interface BackendState
        Parameters:
        header - Sales document header
      • isItemBasedAvailability

        public boolean isItemBasedAvailability()
        Description copied from interface: SalesDocumentBackend
        Checks if availability is compiled only based on item information.
        Specified by:
        isItemBasedAvailability in interface SalesDocumentBackend
        Returns:
        Availability is compiled only based on item information?
      • getAdditionalPricing

        public AdditionalPricing getAdditionalPricing()
        Returns:
        the additionalPricing
      • setAdditionalPricing

        public void setAdditionalPricing​(AdditionalPricing additionalPricing)
        Parameters:
        additionalPricing - the additionalPricing to set
      • prepareForValidation

        protected ItemList prepareForValidation​(SalesDocument salesDocument)
        Prepares the sales document for the validation call. In this implementation, to be sure to get all warnings related to order quantity: Changes all item quantities
        Parameters:
        salesDocument -
        Returns:
        Item list in its initial state
      • getCloseStrategy

        protected LrdCloseStrategy getCloseStrategy()
        Returns:
        the closeStrategy
      • setCloseStrategy

        public void setCloseStrategy​(LrdCloseStrategy closeStrategy)
        Parameters:
        closeStrategy - the closeStrategy to set
      • getSalesDocumentERPHooks

        public java.util.List<SalesDocumentERPHook> getSalesDocumentERPHooks()
        Returns:
        the salesDocumentERPHooks
      • setSalesDocumentERPHooks

        public void setSalesDocumentERPHooks​(java.util.List<SalesDocumentERPHook> salesDocumentERPHooks)
        Parameters:
        salesDocumentERPHooks - the salesDocumentERPHooks to set