Пример #1
0
        private void GenerateMasterForecast(int M_Product_ID, decimal?totalQtyTeam, Decimal?totalQtyOpp, decimal?avgPrice)
        {
            sql = "select c_uom_id from m_product where m_product_id = " + M_Product_ID;
            MMasterForecastLine mfLine = new MMasterForecastLine(GetCtx(), 0, null);

            mfLine.SetAD_Client_ID(mf.GetAD_Client_ID());
            mfLine.SetAD_Org_ID(mf.GetAD_Org_ID());
            mfLine.SetM_Product_ID(M_Product_ID);
            mfLine.SetC_MasterForecast_ID(mf.GetC_MasterForecast_ID());
            mfLine.SetForcastQty(totalQtyTeam);
            mfLine.SetOppQty(totalQtyOpp);
            Decimal?total = Decimal.Add(totalQtyOpp.Value, totalQtyTeam.Value);

            mfLine.SetTotalQty(total);
            mfLine.SetPrice(avgPrice);
            mfLine.SetC_UOM_ID(Util.GetValueOfInt(DB.ExecuteScalar(sql, null, null)));
            mfLine.SetProcessed(true);
            Decimal?planRevenue = Decimal.Round(Decimal.Multiply(avgPrice.Value, total.Value), 2, MidpointRounding.AwayFromZero);

            mfLine.SetPlannedRevenue(planRevenue);
            if (!mfLine.Save())
            {
                log.SaveError("MasterForecastLineNotSaved", "MasterForecastLineNotSaved");
            }
        }