/// <summary>
 /// Parent Constructor
 /// </summary>
 /// <param name="plv">list version</param>
 /// <param name="M_Product_ID">product</param>
 /// <param name="PriceList">list price</param>
 /// <param name="PriceStd">standard price</param>
 /// <param name="PriceLimit">limit price</param>
 public MProductPrice(MPriceListVersion plv, int M_Product_ID,
                      Decimal PriceList, Decimal PriceStd, Decimal PriceLimit)
     : this(plv.GetCtx(), 0, plv.Get_TrxName())
 {
     SetClientOrg(plv);
     SetM_PriceList_Version_ID(plv.GetM_PriceList_Version_ID());
     SetM_Product_ID(M_Product_ID);
     SetPrices(PriceList, PriceStd, PriceLimit);
 }
Beispiel #2
0
        /// <summary>
        /// Get Price List Version
        /// </summary>
        /// <param name="valid">date where PLV must be valid or today if null</param>
        /// <returns>PLV</returns>
        public MPriceListVersion GetPriceListVersion(DateTime?valid)
        {
            if (valid == null)
            {
                valid = new DateTime(CommonFunctions.CurrentTimeMillis());
            }
            //	Assume there is no later
            //if (_plv != null && _plv.GetValidFrom().before(valid))
            if (_plv != null && _plv.GetValidFrom() < valid)
            {
                return(_plv);
            }

            String sql = "SELECT * FROM M_PriceList_Version "
                         + "WHERE M_PriceList_ID=" + GetM_PriceList_ID()
                         + " AND TRUNC(ValidFrom,'DD')<='" + valid + "' AND IsActive='Y'"
                         + "ORDER BY ValidFrom DESC";
            DataSet ds = new DataSet();

            try
            {
                ds = DataBase.DB.ExecuteDataset(sql, null, Get_TrxName());
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];
                    _plv = new MPriceListVersion(GetCtx(), dr, Get_TrxName());
                }
                ds = null;
            }
            catch (Exception e)
            {
                log.Log(Level.SEVERE, sql, e);
            }

            if (_plv == null)
            {
                log.Warning("None found M_PriceList_ID="
                            + GetM_PriceList_ID() + " - " + valid + " - " + sql);
            }
            else
            {
                log.Fine(_plv.ToString());
            }
            return(_plv);
        }