/// <summary> /// Get Cost Queue Records in Lifo/Fifo order /// </summary> /// <param name="product">product</param> /// <param name="M_ASI_ID">costing level ASI</param> /// <param name="mas">accounting schema</param> /// <param name="Org_ID">costing level org</param> /// <param name="ce">Cost Element</param> /// <param name="trxName">transaction</param> /// <returns>cost queue or null</returns> public static MCostQueue[] GetQueue(MProduct product, int M_ASI_ID, MAcctSchema mas, int Org_ID, MCostElement ce, Trx trxName) { List <MCostQueue> list = new List <MCostQueue>(); String sql = "SELECT * FROM M_CostQueue " + "WHERE AD_Client_ID=@client AND AD_Org_ID=@org" + " AND M_Product_ID=@prod" + " AND M_CostType_ID=@ct AND C_AcctSchema_ID=@accs" + " AND M_CostElement_ID=@ce"; if (M_ASI_ID != 0) { sql += " AND M_AttributeSetInstance_ID=@asi"; } sql += " AND CurrentQty<>0 " + "ORDER BY M_AttributeSetInstance_ID "; if (!ce.IsFifo()) { sql += "DESC"; } try { SqlParameter[] param = null; if (M_ASI_ID != 0) { param = new SqlParameter[7]; } else { param = new SqlParameter[6]; } param[0] = new SqlParameter("@client", product.GetAD_Client_ID()); param[1] = new SqlParameter("@org", Org_ID); param[2] = new SqlParameter("@prod", product.GetM_Product_ID()); param[3] = new SqlParameter("@ct", mas.GetM_CostType_ID()); param[4] = new SqlParameter("@accs", mas.GetC_AcctSchema_ID()); param[5] = new SqlParameter("@ce", ce.GetM_CostElement_ID()); if (M_ASI_ID != 0) { param[6] = new SqlParameter("@asi", M_ASI_ID); } DataSet ds = DataBase.DB.ExecuteDataset(sql, param, trxName); if (ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { list.Add(new MCostQueue(product.GetCtx(), dr, trxName)); } } } catch (Exception e) { _log.Log(Level.SEVERE, sql, e); } MCostQueue[] costQ = new MCostQueue[list.Count]; costQ = list.ToArray(); return(costQ); }
/// <summary> /// Get Trial Products for Entity Type /// </summary> /// <param name="ctx">ctx</param> /// <param name="entityType">entity type</param> /// <returns>trial product or null</returns> public static MProduct GetTrial(Ctx ctx, String entityType) { if (Utility.Util.IsEmpty(entityType)) { _log.Warning("No Entity Type"); return(null); } MProduct retValue = null; String sql = "SELECT * FROM M_Product " + "WHERE LicenseInfo LIKE '%" + entityType + "%' AND TrialPhaseDays > 0 AND IsActive='Y'"; //String entityTypeLike = "%" + entityType + "%"; //pstmt.setString(1, entityTypeLike); DataSet ds = new DataSet(); try { ds = DataBase.DB.ExecuteDataset(sql, null, null); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow dr = ds.Tables[0].Rows[i]; retValue = new MProduct(ctx, dr, null); } ds = null; } catch (Exception e) { _log.Log(Level.SEVERE, sql, e); } if (retValue != null && retValue.GetAD_Client_ID() != ctx.GetAD_Client_ID()) { _log.Warning("ProductClient_ID=" + retValue.GetAD_Client_ID() + " <> EnvClient_ID=" + ctx.GetAD_Client_ID()); } if (retValue != null && retValue.GetA_Asset_Group_ID() == 0) { _log.Warning("Product has no Asset Group - " + retValue); return(null); } if (retValue == null) { _log.Warning("No Product for EntityType - " + entityType); } return(retValue); }
public MCostForeignCurrency(int AD_Org_ID, MProduct product, int M_AttributeSetInstance_ID, int M_CostElement_ID, int C_BPartner_ID, int C_Currency_ID) : this(product.GetCtx(), 0, product.Get_TrxName()) { SetClientOrg(product.GetAD_Client_ID(), AD_Org_ID); SetM_Product_ID(product.GetM_Product_ID()); SetM_AttributeSetInstance_ID(M_AttributeSetInstance_ID); SetM_CostElement_ID(M_CostElement_ID); SetC_BPartner_ID(C_BPartner_ID); SetC_Currency_ID(C_Currency_ID); }
/// <summary> /// Parent Constructor /// </summary> /// <param name="product">product</param> /// <param name="M_AttributeSetInstance_ID">Attribute Set Instance</param> /// <param name="mas">Acct Schema</param> /// <param name="AD_Org_ID">org</param> /// <param name="M_CostElement_ID">cost element</param> /// <param name="trxName">transaction</param> public MCostQueue(MProduct product, int M_AttributeSetInstance_ID, MAcctSchema mas, int AD_Org_ID, int M_CostElement_ID, Trx trxName) : this(product.GetCtx(), 0, trxName) { SetClientOrg(product.GetAD_Client_ID(), AD_Org_ID); SetC_AcctSchema_ID(mas.GetC_AcctSchema_ID()); SetM_CostType_ID(mas.GetM_CostType_ID()); SetM_Product_ID(product.GetM_Product_ID()); SetM_AttributeSetInstance_ID(M_AttributeSetInstance_ID); SetM_CostElement_ID(M_CostElement_ID); }
public static MCostForeignCurrency Get(MProduct product, int M_AttributeSetInstance_ID, int AD_Org_ID, int M_CostElement_ID, int C_BPartner_ID, int C_Currency_ID) { MCostForeignCurrency foreignCurrency = null; String sql = "SELECT * " + "FROM M_Cost_ForeignCurrency c " + "WHERE AD_Client_ID=" + product.GetAD_Client_ID() + " AND AD_Org_ID=" + AD_Org_ID + " AND M_Product_ID=" + product.GetM_Product_ID() + " AND NVL(M_AttributeSetInstance_ID , 0) =" + M_AttributeSetInstance_ID + " AND M_CostElement_ID=" + M_CostElement_ID + " AND C_BPartner_ID = " + C_BPartner_ID + " AND C_Currency_ID = " + C_Currency_ID; DataTable dt = null; IDataReader idr = null; try { idr = DB.ExecuteReader(sql, null, product.Get_TrxName()); dt = new DataTable(); dt.Load(idr); idr.Close(); foreach (DataRow dr in dt.Rows) { foreignCurrency = new MCostForeignCurrency(product.GetCtx(), dr, product.Get_TrxName()); } } catch (Exception e) { if (idr != null) { idr.Close(); } _log.Log(Level.SEVERE, sql, e); } finally { dt = null; } // New if (foreignCurrency == null) { foreignCurrency = new MCostForeignCurrency(AD_Org_ID, product, M_AttributeSetInstance_ID, M_CostElement_ID, C_BPartner_ID, C_Currency_ID); } return(foreignCurrency); }
/// <summary> /// Get/Create Cost Queue Record. /// CostingLevel is not validated /// </summary> /// <param name="product">product</param> /// <param name="M_AttributeSetInstance_ID">real asi</param> /// <param name="mas">accounting schema</param> /// <param name="AD_Org_ID">real org</param> /// <param name="M_CostElement_ID">element</param> /// <param name="trxName">transaction</param> /// <returns>cost queue or null</returns> public static MCostQueue Get(MProduct product, int M_AttributeSetInstance_ID, MAcctSchema mas, int AD_Org_ID, int M_CostElement_ID, Trx trxName) { MCostQueue costQ = null; String sql = "SELECT * FROM M_CostQueue " + "WHERE AD_Client_ID=@client AND AD_Org_ID=@org" + " AND M_Product_ID=@pro" + " AND M_AttributeSetInstance_ID=@asi" + " AND M_CostType_ID=@ct AND C_AcctSchema_ID=@accs" + " AND M_CostElement_ID=@ce"; try { SqlParameter[] param = new SqlParameter[7]; param[0] = new SqlParameter("@client", product.GetAD_Client_ID()); param[1] = new SqlParameter("@org", AD_Org_ID); param[2] = new SqlParameter("@pro", product.GetM_Product_ID()); param[3] = new SqlParameter("@asi", M_AttributeSetInstance_ID); param[4] = new SqlParameter("@ct", mas.GetM_CostType_ID()); param[5] = new SqlParameter("@accs", mas.GetC_AcctSchema_ID()); param[6] = new SqlParameter("@ce", M_CostElement_ID); DataSet ds = DataBase.DB.ExecuteDataset(sql, param); if (ds.Tables.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { costQ = new MCostQueue(product.GetCtx(), dr, trxName); } } } catch (Exception e) { _log.Log(Level.SEVERE, sql, e); } // New if (costQ == null) { costQ = new MCostQueue(product, M_AttributeSetInstance_ID, mas, AD_Org_ID, M_CostElement_ID, trxName); } return(costQ); }