Search in sources :

Example 1 with MAcctSchemaGL

use of org.compiere.model.MAcctSchemaGL in project adempiere by adempiere.

the class AcctSchemaCopyAcct method copyGL.

//	doIt
/**
	 * 	Copy GL 
	 *	@param targetAS target
	 *	@throws Exception
	 */
private void copyGL(MAcctSchema targetAS) throws Exception {
    MAcctSchemaGL source = MAcctSchemaGL.get(getCtx(), p_SourceAcctSchema_ID);
    MAcctSchemaGL target = new MAcctSchemaGL(getCtx(), 0, get_TrxName());
    target.setC_AcctSchema_ID(p_TargetAcctSchema_ID);
    ArrayList<KeyNamePair> list = source.getAcctInfo();
    for (int i = 0; i < list.size(); i++) {
        KeyNamePair pp = list.get(i);
        int sourceC_ValidCombination_ID = pp.getKey();
        String columnName = pp.getName();
        MAccount sourceAccount = MAccount.get(getCtx(), sourceC_ValidCombination_ID);
        MAccount targetAccount = createAccount(targetAS, sourceAccount);
        target.setValue(columnName, new Integer(targetAccount.getC_ValidCombination_ID()));
    }
    if (!target.save())
        throw new AdempiereSystemError("Could not Save GL");
}
Also used : MAcctSchemaGL(org.compiere.model.MAcctSchemaGL) AdempiereSystemError(org.compiere.util.AdempiereSystemError) MAccount(org.compiere.model.MAccount) KeyNamePair(org.compiere.util.KeyNamePair)

Aggregations

MAccount (org.compiere.model.MAccount)1 MAcctSchemaGL (org.compiere.model.MAcctSchemaGL)1 AdempiereSystemError (org.compiere.util.AdempiereSystemError)1 KeyNamePair (org.compiere.util.KeyNamePair)1