Class DocumentEngine

java.lang.Object
org.compiere.process.DocumentEngine
All Implemented Interfaces:
DocAction

public class DocumentEngine extends Object implements DocAction
Document Action Engine
Version:
$Id: DocumentEngine.java,v 1.2 2006/07/30 00:54:44 jjanke Exp $
Author:
Jorg Janke, Karsten Thiemann FR [ 1782412 ], victor.perez@e-evolution.com www.e-evolution.com FR [ 1866214 ] https://sourceforge.net/p/adempiere/feature-requests/298/
  • Field Details

    • DOCUMENT_POST_IMMEDIATE_AFTER_COMPLETE

      public static final String DOCUMENT_POST_IMMEDIATE_AFTER_COMPLETE
      When client accounting is immediate, set this PO attribute to override the default of immediate posting after complete of document
      See Also:
  • Constructor Details

    • DocumentEngine

      public DocumentEngine(DocAction po)
      Doc Engine (Drafted)
      Parameters:
      po - document
    • DocumentEngine

      public DocumentEngine(DocAction po, String docStatus)
      Doc Engine
      Parameters:
      po - document
      docStatus - initial document status
  • Method Details

    • getDocStatus

      public String getDocStatus()
      Get Doc Status
      Specified by:
      getDocStatus in interface DocAction
      Returns:
      document status
    • setDocStatus

      public void setDocStatus(String ignored)
      Set Doc Status - Ignored
      Specified by:
      setDocStatus in interface DocAction
      Parameters:
      ignored - Status is not set directly
      See Also:
    • isDrafted

      public boolean isDrafted()
      Is current Document Status is Drafted
      Returns:
      true if current status is drafted
    • isInvalid

      public boolean isInvalid()
      Is current Document Status is Invalid
      Returns:
      true if current status is Invalid
    • isInProgress

      public boolean isInProgress()
      Is current Document Status is In Progress
      Returns:
      true if current status is In Progress
    • isApproved

      public boolean isApproved()
      Is current Document Status is Approved
      Returns:
      true if current status is Approved
    • isNotApproved

      public boolean isNotApproved()
      Is current Document Status is Not Approved
      Returns:
      true if current status is Not Approved
    • isWaiting

      public boolean isWaiting()
      Is current Document Status is Waiting Payment or Confirmation
      Returns:
      true if current status is Waiting Payment
    • isCompleted

      public boolean isCompleted()
      Is current Document Status is Completed
      Returns:
      true if current status is Completed
    • isReversed

      public boolean isReversed()
      Is current Document Status is Reversed
      Returns:
      true if current status is Reversed
    • isClosed

      public boolean isClosed()
      Is current Document Status is Closed
      Returns:
      true if current status is Closed
    • isVoided

      public boolean isVoided()
      Is current Document Status is Voided
      Returns:
      true if current status is Voided
    • isUnknown

      public boolean isUnknown()
      Is current Document Status is Unknown
      Returns:
      true if current status is unknown
    • processIt

      public boolean processIt(String processAction, String docAction)
      Process document action.
      Checks if user (document) action is valid and then process action.
      Calls the individual actions which call the document action.
      Parameters:
      processAction - document action value from workflow
      docAction - document action value from document (PO)
      Returns:
      true if performed
    • processIt

      public boolean processIt(String action)
      Process document action - internal API, do not call directly.
      Calls the individual actions which call the document action.
      Specified by:
      processIt in interface DocAction
      Parameters:
      action - document action
      Returns:
      true if performed
    • unlockIt

      public boolean unlockIt()
      Unlock Document.
      Status: Drafted.
      Specified by:
      unlockIt in interface DocAction
      Returns:
      true if success
      See Also:
    • invalidateIt

      public boolean invalidateIt()
      Invalidate Document.
      Status: Invalid.
      Specified by:
      invalidateIt in interface DocAction
      Returns:
      true if success
      See Also:
    • prepareIt

      public String prepareIt()
      Prepare Document.
      Status is set by document action method.
      Specified by:
      prepareIt in interface DocAction
      Returns:
      new status (In Progress or Invalid)
      See Also:
    • approveIt

      public boolean approveIt()
      Approve Document.
      Status: Approved.
      Specified by:
      approveIt in interface DocAction
      Returns:
      true if success
      See Also:
    • rejectIt

      public boolean rejectIt()
      Reject Approval.
      Status: Not Approved.
      Specified by:
      rejectIt in interface DocAction
      Returns:
      true if success
      See Also:
    • completeIt

      public String completeIt()
      Complete Document.
      Status is set by document action method.
      Specified by:
      completeIt in interface DocAction
      Returns:
      new document status (Complete, In Progress, Invalid, Waiting ..)
      See Also:
    • postIt

      public boolean postIt()
      Post Document.
      Does not change status.
      Returns:
      true if success
    • voidIt

      public boolean voidIt()
      Void Document.
      Status: Voided.
      Specified by:
      voidIt in interface DocAction
      Returns:
      true if success
      See Also:
    • closeIt

      public boolean closeIt()
      Close Document.
      Status: Closed.
      Specified by:
      closeIt in interface DocAction
      Returns:
      true if success
      See Also:
    • reverseCorrectIt

      public boolean reverseCorrectIt()
      Reverse Correct Document.
      Status: Reversed.
      Specified by:
      reverseCorrectIt in interface DocAction
      Returns:
      true if success
      See Also:
    • reverseAccrualIt

      public boolean reverseAccrualIt()
      Reverse Accrual Document.
      Status: Reversed.
      Specified by:
      reverseAccrualIt in interface DocAction
      Returns:
      true if success
      See Also:
    • reActivateIt

      public boolean reActivateIt()
      Re-activate Document.
      Status: In Progress.
      Specified by:
      reActivateIt in interface DocAction
      Returns:
      true if success
      See Also:
    • setStatus

      protected void setStatus(String newStatus)
      Set Document Status to new Status
      Parameters:
      newStatus - new status
    • getActionOptions

      public String[] getActionOptions()
      Get available Document Actions based on current Document Status.
      Returns:
      array of actions
    • isValidAction

      public boolean isValidAction(String action)
      Is The Action Valid based on current document status.
      Parameters:
      action - action
      Returns:
      true if valid
    • getProcessMsg

      public String getProcessMsg()
      Get Process Message
      Specified by:
      getProcessMsg in interface DocAction
      Returns:
      clear text error message
    • setProcessMsg

      public void setProcessMsg(String msg)
      Set Process Message
      Parameters:
      msg - clear text error message
    • getSummary

      public String getSummary()
      Not applicable, throw exception
      Specified by:
      getSummary in interface DocAction
      Returns:
      Summary of Document
    • getDocumentNo

      public String getDocumentNo()
      Not applicable, throw exception
      Specified by:
      getDocumentNo in interface DocAction
      Returns:
      Document No
    • getDocumentInfo

      public String getDocumentInfo()
      Not applicable, throw exception
      Specified by:
      getDocumentInfo in interface DocAction
      Returns:
      Type and Document No
    • getDoc_User_ID

      public int getDoc_User_ID()
      Not applicable, throw exception
      Specified by:
      getDoc_User_ID in interface DocAction
      Returns:
      AD_User_ID
    • getC_Currency_ID

      public int getC_Currency_ID()
      Not applicable, throw exception
      Specified by:
      getC_Currency_ID in interface DocAction
      Returns:
      C_Currency_ID
    • getApprovalAmt

      public BigDecimal getApprovalAmt()
      Not applicable, throw exception
      Specified by:
      getApprovalAmt in interface DocAction
      Returns:
      amount
    • getAD_Client_ID

      public int getAD_Client_ID()
      Not applicable, throw exception
      Specified by:
      getAD_Client_ID in interface DocAction
      Returns:
      AD_Client_ID
    • getAD_Org_ID

      public int getAD_Org_ID()
      Not applicable, throw exception
      Specified by:
      getAD_Org_ID in interface DocAction
      Returns:
      AD_Org_ID
    • getDocAction

      public String getDocAction()
      Get Doc Action
      Specified by:
      getDocAction in interface DocAction
      Returns:
      Document Action
    • save

      public boolean save()
      Not applicable, throw exception
      Specified by:
      save in interface DocAction
      Returns:
      true if saved
    • saveEx

      public void saveEx() throws AdempiereException
      Not applicable, throw exception
      Specified by:
      saveEx in interface DocAction
      Throws:
      AdempiereException - if save fail
      See Also:
    • getCtx

      public Properties getCtx()
      Get Context
      Specified by:
      getCtx in interface DocAction
      Returns:
      context
    • get_ID

      public int get_ID()
      Get ID of record
      Specified by:
      get_ID in interface DocAction
      Returns:
      ID
    • get_Table_ID

      public int get_Table_ID()
      Get AD_Table_ID
      Specified by:
      get_Table_ID in interface DocAction
      Returns:
      AD_Table_ID
    • get_Logger

      public CLogger get_Logger()
      Get Logger
      Specified by:
      get_Logger in interface DocAction
      Returns:
      logger
    • get_TrxName

      public String get_TrxName()
      Get Transaction
      Specified by:
      get_TrxName in interface DocAction
      Returns:
      trx name
    • createPDF

      public File createPDF()
      CreatePDF
      Specified by:
      createPDF in interface DocAction
      Returns:
      null
    • getValidActions

      public static int getValidActions(String docStatus, Object processing, String orderType, String isSOTrx, int AD_Table_ID, String[] docAction, String[] options, boolean periodOpen, PO po)
      Get list of valid document action into the options array parameter.
      Set default document action into the docAction array parameter.
      Parameters:
      docStatus -
      processing -
      orderType -
      isSOTrx -
      AD_Table_ID -
      docAction -
      options -
      periodOpen - - flag indicating if the period is Open - to avoid including Void and ReverseCorrect options in the list
      Returns:
      End index of valid options[] (exclusive)
    • readReferenceList

      public static void readReferenceList(ArrayList<String> v_value, ArrayList<String> v_name, ArrayList<String> v_description)
      Fill lists with DocAction Ref_List(135) values
      Parameters:
      v_value -
      v_name -
      v_description -
    • checkActionAccess

      public static int checkActionAccess(int clientId, int roleId, int docTypeId, String[] options, int maxIndex)
      Checks the access rights of the given role/client for the given document actions.
      Parameters:
      clientId -
      roleId -
      docTypeId -
      options -
      maxIndex -
      Returns:
      End index of valid options[] (exclusive)
    • postImmediate

      public static String postImmediate(Properties ctx, int AD_Client_ID, int AD_Table_ID, int Record_ID, boolean force, String trxName)
      Perform immediate posting of document
      Parameters:
      ctx - Client Context
      AD_Client_ID - Client ID of Document
      AD_Table_ID - Table ID of Document
      Record_ID - Record ID of this document
      force - force posting
      trxName - ignore, retained for backward compatibility
      Returns:
      null, if success or error message
    • processIt

      public static boolean processIt(DocAction doc, String processAction)
      Process document action. This replaces DocAction.processIt().
      Parameters:
      doc -
      processAction -
      Returns:
      true if performed
    • readStatusReferenceList

      public static void readStatusReferenceList(ArrayList<String> v_value, ArrayList<String> v_name, ArrayList<String> v_description)
      Fill lists with DocAction Ref_List(131) values
      Parameters:
      v_value -
      v_name -
      v_description -