/** * Get AccountSchema of Client * * @param ctx context * @param AD_Client_ID client or 0 for all * @param trxName optional trx * @return Array of AcctSchema of Client */ public static MAcctSchema[] getClientAcctSchema( Properties ctx, int AD_Client_ID, String trxName) { // Check Cache Integer key = new Integer(AD_Client_ID); if (s_schema.containsKey(key)) return (MAcctSchema[]) s_schema.get(key); // Create New ArrayList<MAcctSchema> list = new ArrayList<MAcctSchema>(); MClientInfo info = MClientInfo.get(ctx, AD_Client_ID, trxName); MAcctSchema as = MAcctSchema.get(ctx, info.getC_AcctSchema1_ID(), trxName); if (as.get_ID() != 0) list.add(as); ArrayList<Object> params = new ArrayList<Object>(); StringBuilder whereClause = new StringBuilder("IsActive=? ") .append( " AND EXISTS (SELECT * FROM C_AcctSchema_GL gl WHERE C_AcctSchema.C_AcctSchema_ID=gl.C_AcctSchema_ID)") .append( " AND EXISTS (SELECT * FROM C_AcctSchema_Default d WHERE C_AcctSchema.C_AcctSchema_ID=d.C_AcctSchema_ID)"); params.add("Y"); if (AD_Client_ID != 0) { whereClause.append(" AND AD_Client_ID=?"); params.add(AD_Client_ID); } List<MAcctSchema> ass = new Query(ctx, I_C_AcctSchema.Table_Name, whereClause.toString(), trxName) .setParameters(params) .setOrderBy(MAcctSchema.COLUMNNAME_C_AcctSchema_ID) .list(); for (MAcctSchema acctschema : ass) { if (acctschema.get_ID() != info.getC_AcctSchema1_ID()) // already in list { if (acctschema.get_ID() != 0) list.add(acctschema); } } // Save MAcctSchema[] retValue = new MAcctSchema[list.size()]; list.toArray(retValue); s_schema.put(key, retValue); return retValue; } // getClientAcctSchema
/** * Before Save * * @param newRecord new * @return true */ protected boolean beforeSave(boolean newRecord) { if (getAD_Org_ID() != 0) setAD_Org_ID(0); if (super.getTaxCorrectionType() == null) setTaxCorrectionType( isDiscountCorrectsTax() ? TAXCORRECTIONTYPE_Write_OffAndDiscount : TAXCORRECTIONTYPE_None); checkCosting(); // Check Primary if (getAD_OrgOnly_ID() != 0) { MClientInfo info = MClientInfo.get(getCtx(), getAD_Client_ID()); if (info.getC_AcctSchema1_ID() == getC_AcctSchema_ID()) setAD_OrgOnly_ID(0); } return true; } // beforeSave