示例#1
0
  /**
   * Create new Project by copying
   *
   * @param ctx context
   * @param C_Project_ID project
   * @param dateDoc date of the document date
   * @param trxName transaction
   * @return Project
   */
  public static MProject copyFrom(
      Properties ctx, int C_Project_ID, Timestamp dateDoc, String trxName) {
    MProject from = new MProject(ctx, C_Project_ID, trxName);
    if (from.getC_Project_ID() == 0)
      throw new IllegalArgumentException("From Project not found C_Project_ID=" + C_Project_ID);
    //
    MProject to = new MProject(ctx, 0, trxName);
    PO.copyValues(from, to, from.getAD_Client_ID(), from.getAD_Org_ID());
    to.set_ValueNoCheck("C_Project_ID", I_ZERO);
    //	Set Value with Time
    String Value = to.getValue() + " ";
    String Time = dateDoc.toString();
    int length = Value.length() + Time.length();
    if (length <= 40) Value += Time;
    else Value += Time.substring(length - 40);
    to.setValue(Value);
    to.setInvoicedAmt(Env.ZERO);
    to.setProjectBalanceAmt(Env.ZERO);
    to.setProcessed(false);
    //
    if (!to.save()) throw new IllegalStateException("Could not create Project");

    if (to.copyDetailsFrom(from) == 0)
      throw new IllegalStateException("Could not create Project Details");

    return to;
  } //	copyFrom
 /**
  * Get DocumentNo
  *
  * @return document no
  */
 public String getDocumentNo() {
   MProject p = m_issue.getParent();
   if (p != null) return p.getValue() + " #" + m_issue.getLine();
   return "(" + m_issue.get_ID() + ")";
 } //	getDocumentNo