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);
  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;
}

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 ) ; 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 ; }
create new project by copying
