GL-Category Sequence in adempiere

89 Views Asked by At

I want to make a GL-Category Sequence like document sequence for every cash journal.

I added a field in cash journal window called journal number.

I want to generate a number for every cash journal and increment it by 1?

1

There are 1 best solutions below

0
Michael McKay On

The document sequence is managed by the PO.java class in ADempiere. To use it, you need to add a column with the column name "DocumentNo" to your table. You will need to add the entry in the Sequence table to keep track of the numbers.

Here is the code from PO.java which is run when the record is first saved.

    //  Set new DocumentNo
    String columnName = "DocumentNo";
    int index = p_info.getColumnIndex(columnName);
    if (index != -1 && p_info.getColumn(index).ColumnSQL == null)
    {
        String value = (String)get_Value(index);
        if (value != null && value.startsWith("<") && value.endsWith(">"))
            value = null;
        if (value == null || value.length() == 0)
        {
            int dt = p_info.getColumnIndex("C_DocTypeTarget_ID");
            if (dt == -1)
                dt = p_info.getColumnIndex("C_DocType_ID");
            if (dt != -1)       //  get based on Doc Type (might return null)
                value = DB.getDocumentNo(get_ValueAsInt(dt), m_trxName, false, this);
            if (value == null)  //  not overwritten by DocType and not manually entered
                value = DB.getDocumentNo(getAD_Client_ID(), p_info.getTableName(), m_trxName, this);
            set_ValueNoCheck(columnName, value);
        }
    }