Example #1
0
  @Override
  public I_C_DocType createDocType(
      final Properties ctx,
      final String entityType,
      final String Name,
      final String PrintName,
      final String DocBaseType,
      final String DocSubType,
      final int C_DocTypeShipment_ID,
      final int C_DocTypeInvoice_ID,
      final int StartNo,
      final int GL_Category_ID,
      final String trxName) {

    final MSequence sequence;
    if (StartNo != 0) {
      sequence = new MSequence(ctx, Env.getAD_Client_ID(ctx), Name, StartNo, trxName);
      sequence.saveEx();
    } else {
      sequence = null;
    }

    final MDocType dt = new MDocType(ctx, DocBaseType, Name, trxName);

    if (PrintName != null && PrintName.length() > 0) {
      dt.setPrintName(PrintName); // Defaults to Name
    }
    if (DocSubType != null) {
      dt.setDocSubType(DocSubType);
    }
    if (C_DocTypeShipment_ID != 0) {
      dt.setC_DocTypeShipment_ID(C_DocTypeShipment_ID);
    }
    if (C_DocTypeInvoice_ID != 0) {
      dt.setC_DocTypeInvoice_ID(C_DocTypeInvoice_ID);
    }
    if (GL_Category_ID != 0) {
      dt.setGL_Category_ID(GL_Category_ID);
    }
    if (sequence == null) {
      dt.setIsDocNoControlled(false);
    } else {
      dt.setIsDocNoControlled(true);
      dt.setDocNoSequence_ID(sequence.getAD_Sequence_ID());
    }
    dt.setIsSOTrx();

    final I_C_DocType result = POWrapper.create(dt, I_C_DocType.class);
    result.setEntityType(entityType);

    return result;
  } // createDocType
 private void createSequence(MTable table, String trxName) {
   if (!table.isView()) {
     if (!MSequence.createTableSequence(getCtx(), table.getTableName(), trxName)) {
       throw new AdempiereException(
           "Can not create Native Sequence for table " + table.getTableName());
     } else {
       this.addLog("Create Native Sequence for : " + table.getTableName());
     }
   }
 }