📄 documentengine.java
字号:
{
m_status = m_document.completeIt();
m_document.setDocStatus(m_status);
}
return m_status;
} // completeIt
/**
* Post Document
* Does not change status
* @return true if success
*/
public boolean postIt()
{
if (!isValidAction(ACTION_Post)
|| m_document == null)
return false;
try
{
// Should work on Client and Server
InitialContext ctx = CConnection.get().getInitialContext(true);
ServerHome serverHome = (ServerHome)ctx.lookup (ServerHome.JNDI_NAME);
if (serverHome != null)
{
Server server = serverHome.create();
if (server != null)
{
String error = server.postImmediate(Env.getCtx(),
m_document.getAD_Client_ID(),
m_document.get_Table_ID(), m_document.get_ID(),
true, m_document.get_TrxName());
m_document.get_Logger().config("Server: " + error == null ? "OK" : error);
return error == null;
}
}
else
m_document.get_Logger().config("NoServerHome");
}
catch (Exception e)
{
m_document.get_Logger().config("(ex) " + e.getMessage());
}
return false;
} // postIt
/**
* Void Document.
* Status: Voided
* @return true if success
* @see org.compiere.process.DocAction#voidIt()
*/
public boolean voidIt()
{
if (!isValidAction(ACTION_Void))
return false;
if (m_document != null)
{
if (m_document.voidIt())
{
m_status = STATUS_Voided;
m_document.setDocStatus(m_status);
return true;
}
return false;
}
m_status = STATUS_Voided;
return true;
} // voidIt
/**
* Close Document.
* Status: Closed
* @return true if success
* @see org.compiere.process.DocAction#closeIt()
*/
public boolean closeIt()
{
if (m_document != null // orders can be closed any time
&& m_document.get_Table_ID() == X_C_Order.Table_ID)
;
else if (!isValidAction(ACTION_Close))
return false;
if (m_document != null)
{
if (m_document.closeIt())
{
m_status = STATUS_Closed;
m_document.setDocStatus(m_status);
return true;
}
return false;
}
m_status = STATUS_Closed;
return true;
} // closeIt
/**
* Reverse Correct Document.
* Status: Reversed
* @return true if success
* @see org.compiere.process.DocAction#reverseCorrectIt()
*/
public boolean reverseCorrectIt()
{
if (!isValidAction(ACTION_Reverse_Correct))
return false;
if (m_document != null)
{
if (m_document.reverseCorrectIt())
{
m_status = STATUS_Reversed;
m_document.setDocStatus(m_status);
return true;
}
return false;
}
m_status = STATUS_Reversed;
return true;
} // reverseCorrectIt
/**
* Reverse Accrual Document.
* Status: Reversed
* @return true if success
* @see org.compiere.process.DocAction#reverseAccrualIt()
*/
public boolean reverseAccrualIt()
{
if (!isValidAction(ACTION_Reverse_Accrual))
return false;
if (m_document != null)
{
if (m_document.reverseAccrualIt())
{
m_status = STATUS_Reversed;
m_document.setDocStatus(m_status);
return true;
}
return false;
}
m_status = STATUS_Reversed;
return true;
} // reverseAccrualIt
/**
* Re-activate Document.
* Status: In Progress
* @return true if success
* @see org.compiere.process.DocAction#reActivateIt()
*/
public boolean reActivateIt()
{
if (!isValidAction(ACTION_ReActivate))
return false;
if (m_document != null)
{
if (m_document.reActivateIt())
{
m_status = STATUS_InProgress;
m_document.setDocStatus(m_status);
return true;
}
return false;
}
m_status = STATUS_InProgress;
return true;
} // reActivateIt
/**
* Set Document Status to new Status
* @param newStatus new status
*/
void setStatus (String newStatus)
{
m_status = newStatus;
} // setStatus
/**************************************************************************
* Get Action Options based on current Status
* @return array of actions
*/
public String[] getActionOptions()
{
if (isInvalid())
return new String[] {ACTION_Prepare, ACTION_Invalidate,
ACTION_Unlock, ACTION_Void};
if (isDrafted())
return new String[] {ACTION_Prepare, ACTION_Invalidate, ACTION_Complete,
ACTION_Unlock, ACTION_Void};
if (isInProgress() || isApproved())
return new String[] {ACTION_Complete, ACTION_WaitComplete,
ACTION_Approve, ACTION_Reject,
ACTION_Unlock, ACTION_Void, ACTION_Prepare};
if (isNotApproved())
return new String[] {ACTION_Reject, ACTION_Prepare,
ACTION_Unlock, ACTION_Void};
if (isWaiting())
return new String[] {ACTION_Complete, ACTION_WaitComplete,
ACTION_ReActivate, ACTION_Void, ACTION_Close};
if (isCompleted())
return new String[] {ACTION_Close, ACTION_ReActivate,
ACTION_Reverse_Accrual, ACTION_Reverse_Correct,
ACTION_Post, ACTION_Void};
if (isClosed())
return new String[] {ACTION_Post, ACTION_ReOpen};
if (isReversed() || isVoided())
return new String[] {ACTION_Post};
return new String[] {};
} // getActionOptions
/**
* Is The Action Valid based on current state
* @param action action
* @return true if valid
*/
public boolean isValidAction (String action)
{
String[] options = getActionOptions();
for (int i = 0; i < options.length; i++)
{
if (options[i].equals(action))
return true;
}
return false;
} // isValidAction
/**
* Get Process Message
* @return clear text error message
*/
public String getProcessMsg ()
{
return m_message;
} // getProcessMsg
/**
* Get Process Message
* @param msg clear text error message
*/
public void setProcessMsg (String msg)
{
m_message = msg;
} // setProcessMsg
/** Document Exception Message */
private static String EXCEPTION_MSG = "Document Engine is no Document";
/*************************************************************************
* Get Summary
* @return throw exception
*/
public String getSummary()
{
throw new IllegalStateException(EXCEPTION_MSG);
}
/**
* Get Document No
* @return throw exception
*/
public String getDocumentNo()
{
throw new IllegalStateException(EXCEPTION_MSG);
}
/**
* Get Document Info
* @return throw exception
*/
public String getDocumentInfo()
{
throw new IllegalStateException(EXCEPTION_MSG);
}
/**
* Get Document Owner
* @return throw exception
*/
public int getDoc_User_ID()
{
throw new IllegalStateException(EXCEPTION_MSG);
}
/**
* Get Document Currency
* @return throw exception
*/
public int getC_Currency_ID()
{
throw new IllegalStateException(EXCEPTION_MSG);
}
/**
* Get Document Approval Amount
* @return throw exception
*/
public BigDecimal getApprovalAmt()
{
throw new IllegalStateException(EXCEPTION_MSG);
}
/**
* Get Document Client
* @return throw exception
*/
public int getAD_Client_ID()
{
throw new IllegalStateException(EXCEPTION_MSG);
}
/**
* Get Document Organization
* @return throw exception
*/
public int getAD_Org_ID()
{
throw new IllegalStateException(EXCEPTION_MSG);
}
/**
* Get Doc Action
* @return Document Action
*/
public String getDocAction()
{
return m_action;
}
/**
* Save Document
* @return throw exception
*/
public boolean save()
{
throw new IllegalStateException(EXCEPTION_MSG);
}
/**
* Get Context
* @return context
*/
public Properties getCtx()
{
if (m_document != null)
return m_document.getCtx();
throw new IllegalStateException(EXCEPTION_MSG);
} // getCtx
/**
* Get ID of record
* @return ID
*/
public int get_ID()
{
if (m_document != null)
return m_document.get_ID();
throw new IllegalStateException(EXCEPTION_MSG);
} // get_ID
/**
* Get AD_Table_ID
* @return AD_Table_ID
*/
public int get_Table_ID()
{
if (m_document != null)
return m_document.get_Table_ID();
throw new IllegalStateException(EXCEPTION_MSG);
} // get_Table_ID
/**
* Get Logger
* @return logger
*/
public CLogger get_Logger()
{
if (m_document != null)
return m_document.get_Logger();
throw new IllegalStateException(EXCEPTION_MSG);
} // get_Logger
/**
* Get Transaction
* @return trx name
*/
public String get_TrxName()
{
return null;
} // get_TrxName
/**
* CreatePDF
* @return null
*/
public File createPDF ()
{
return null;
}
} // DocumentEnine
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -