Beispiel #1
0
        /// <SUMmary>
        /// Create Master Forecast
        /// </SUMmary>
        /// <param name="M_Product_ID">Product </param>
        /// <param name="totalQtyTeam">Forecast Qty</param>
        /// <param name="totalQtyOpp">Opportunity Qty</param>
        /// <param name="avgPrice">Price</param>
        /// <param name="totalQtySO">Total </param>
        /// <returns>odject</returns>
        private MMasterForecastLine GenerateMasterForecast(int M_Product_ID, int M_AttributeSetInstance, decimal?totalQtyTeam, Decimal?totalQtyOpp, decimal?avgPrice)
        {
            MMasterForecastLine mfLine = MMasterForecastLine.GetOrCreate(mf, M_Product_ID, M_AttributeSetInstance);

            mfLine.SetC_MasterForecast_ID(mf.GetC_MasterForecast_ID());
            mfLine.SetForcastQty(totalQtyTeam);
            mfLine.SetOppQty(totalQtyOpp + mfLine.GetOppQty());
            Decimal?total = Decimal.Add(totalQtyOpp.Value, totalQtyTeam.Value);

            mfLine.SetTotalQty(total + mfLine.GetTotalQty());
            mfLine.SetPrice(avgPrice + mfLine.GetPrice());
            Decimal?planRevenue = Decimal.Round(Decimal.Multiply(mfLine.GetPrice(), mfLine.GetTotalQty()), StdPrecision, MidpointRounding.AwayFromZero);

            mfLine.SetPlannedRevenue(planRevenue);

            return(mfLine);
        }
        /// <SUMmary>
        /// Create Master Forecast
        /// </SUMmary>
        /// <param name="M_Product_ID">Product </param>
        /// <param name="totalQtyTeam">Forecast Qty</param>
        /// <param name="totalQtyOpp">Opportunity Qty</param>
        /// <param name="avgPrice">Price</param>
        /// <param name="totalQtySO">Total </param>
        /// <returns>object</returns>
        private MMasterForecastLine GenerateMasterForecast(int M_Product_ID, int M_AttributeSetInstance, decimal?totalQtyTeam, Decimal?totalQtyOpp, decimal?avgPrice)
        {
            MMasterForecastLine mfLine = MMasterForecastLine.GetOrCreate(mf, M_Product_ID, M_AttributeSetInstance);
            Decimal?            qty    = mfLine.GetOppQty();

            mfLine.SetC_MasterForecast_ID(mf.GetC_MasterForecast_ID());
            if (totalQtyOpp > 0 && totalQtyTeam > 0)
            {
                mfLine.SetForcastQty(totalQtyTeam + mfLine.GetForcastQty());
                mfLine.SetOppQty(totalQtyOpp);
            }
            else
            {
                mfLine.SetForcastQty(totalQtyTeam);
                mfLine.SetOppQty(totalQtyOpp + mfLine.GetOppQty());
            }
            //Decimal? totalqty = Decimal.Add(mfLine.GetForcastQty(), mfLine.GetOppQty());
            mfLine.SetTotalQty(mfLine.GetForcastQty() + mfLine.GetOppQty());
            //calculate average price for opportunit case only
            if (totalQtyOpp > 0 && totalQtyTeam == 0)
            {
                avgPrice = ((mfLine.GetPrice() * qty) + (avgPrice * totalQtyOpp)) / mfLine.GetTotalQty();
                avgPrice = Decimal.Round(avgPrice.Value, StdPrecision, MidpointRounding.AwayFromZero);
                mfLine.SetPrice(avgPrice);
            }
            //Team Forecast case
            else
            {
                mfLine.SetPrice(avgPrice);
            }
            Decimal?planRevenue = Decimal.Round(Decimal.Multiply(mfLine.GetPrice(), mfLine.GetTotalQty()), StdPrecision, MidpointRounding.AwayFromZero);

            mfLine.SetPlannedRevenue(planRevenue);

            return(mfLine);
        }