/// <summary>
        /// Get Limit Price if exists
        /// </summary>
        /// <returns>limit</returns>
        public Decimal GetLimitPrice()
        {
            Decimal limitPrice = GetPlannedPrice();

            if (GetM_Product_ID() == 0)
            {
                return(limitPrice);
            }
            if (GetProject() == null)
            {
                return(limitPrice);
            }
            bool            isSOTrx = true;
            MProduct        prd     = new MProduct(GetCtx(), GetM_Product_ID(), null);
            MProductPricing pp      = new MProductPricing(GetAD_Client_ID(), GetAD_Org_ID(),
                                                          GetM_Product_ID(), _parent.GetC_BPartner_ID(), GetPlannedQty(), isSOTrx);

            pp.SetM_PriceList_ID(_parent.GetM_PriceList_ID());
            pp.SetM_PriceList_Version_ID(_parent.GetM_PriceList_Version_ID());

            // Get Price according to Attribute set instance if selected on Project line
            if (Get_ColumnIndex("M_AttributeSetInstance_ID") >= 0)
            {
                pp.SetM_AttributeSetInstance_ID(GetM_AttributeSetInstance_ID());
            }

            pp.SetC_UOM_ID(prd.GetC_UOM_ID());
            if (pp.CalculatePrice())
            {
                limitPrice = pp.GetPriceLimit();
            }
            return(limitPrice);
        }
示例#2
0
        /**
         *  Set Price for Product and PriceList
         *  @param M_PriceList_ID price list
         */
        public void SetPrice(int M_PriceList_ID)
        {
            try
            {
                if (GetM_Product_ID() == 0)
                {
                    return;
                }
                //
                log.Fine("M_PriceList_ID=" + M_PriceList_ID);
                bool            isSOTrx = false;
                MProductPricing pp      = new MProductPricing(GetAD_Client_ID(), GetAD_Org_ID(),
                                                              GetM_Product_ID(), GetC_BPartner_ID(), GetQty(), isSOTrx);
                pp.SetM_PriceList_ID(M_PriceList_ID);

                //
                // JID_0495_1: Set unit price on Requisition Line based on selected Pricelist on header
                if (Env.IsModuleInstalled("ED011_"))
                {
                    pp.SetC_UOM_ID(Util.GetValueOfInt(Get_Value("C_UOM_ID")));
                }

                //	pp.setPriceDate(getDateOrdered());
                //
                SetPriceActual(pp.GetPriceStd());
            }
            catch
            {
                MessageBox.Show("MRequisitionLine--SetPrice(int M_PriceList_ID)");
            }
        }
        }       //	setS_ResourceAssignment_ID

        /// <summary>
        /// Set Product - Callout
        /// </summary>
        /// <param name="oldM_Product_ID">old value</param>
        /// <param name="newM_Product_ID">new value</param>
        /// <param name="windowNo">window</param>
        public void SetM_Product_ID(String oldM_Product_ID,
                                    String newM_Product_ID, int windowNo)
        {
            if (newM_Product_ID == null || newM_Product_ID.Length == 0)
            {
                return;
            }
            //int M_Product_ID = Integer.parseInt(newM_Product_ID);
            int M_Product_ID = Util.GetValueOfInt(newM_Product_ID);

            base.SetM_Product_ID(M_Product_ID);
            if (M_Product_ID == 0)
            {
                return;
            }

            //	Employee
            MTimeExpense    hdr           = new MTimeExpense(GetCtx(), GetS_TimeExpense_ID(), null);
            int             C_BPartner_ID = hdr.GetC_BPartner_ID();
            Decimal         Qty           = GetQty();
            Boolean         IsSOTrx       = true;
            MProductPricing pp            = new MProductPricing(GetAD_Client_ID(), GetAD_Org_ID(),
                                                                M_Product_ID, C_BPartner_ID, Qty, IsSOTrx);
            //
            int M_PriceList_ID = hdr.GetM_PriceList_ID();

            pp.SetM_PriceList_ID(M_PriceList_ID);
            DateTime?orderDate = GetDateExpense();

            pp.SetPriceDate(orderDate);
            //
            SetExpenseAmt(pp.GetPriceStd());
            SetC_Currency_ID(pp.GetC_Currency_ID());
            SetAmt(windowNo, "M_Product_ID");
        }       //	setM_Product_ID
示例#4
0
        /// <summary>
        /// Get Limit Price if exists
        /// </summary>
        /// <returns>limit</returns>
        public Decimal GetLimitPrice()
        {
            Decimal limitPrice = GetPlannedPrice();

            if (GetM_Product_ID() == 0)
            {
                return(limitPrice);
            }
            if (GetProject() == null)
            {
                return(limitPrice);
            }
            bool            isSOTrx = true;
            MProduct        prd     = new MProduct(GetCtx(), GetM_Product_ID(), null);
            MProductPricing pp      = new MProductPricing(GetAD_Client_ID(), GetAD_Org_ID(),
                                                          GetM_Product_ID(), _parent.GetC_BPartner_ID(), GetPlannedQty(), isSOTrx);

            pp.SetM_PriceList_ID(_parent.GetM_PriceList_ID());
            pp.SetM_PriceList_Version_ID(_parent.GetM_PriceList_Version_ID());
            pp.SetC_UOM_ID(prd.GetC_UOM_ID());
            if (pp.CalculatePrice())
            {
                limitPrice = pp.GetPriceLimit();
            }
            return(limitPrice);
        }
        /// <summary>
        /// Set Product - Callout
        /// </summary>
        /// <param name="oldM_Product_ID">old value</param>
        /// <param name="newM_Product_ID">new value</param>
        /// <param name="windowNo">window</param>
        //@UICallout
        public void SetM_Product_ID(String oldM_Product_ID, String newM_Product_ID, int windowNo)
        {
            if (newM_Product_ID == null || newM_Product_ID.Length == 0)
            {
                return;
            }
            int M_Product_ID = int.Parse(newM_Product_ID);

            base.SetM_Product_ID(M_Product_ID);
            if (M_Product_ID == 0)
            {
                return;
            }
            //
            int M_PriceList_Version_ID = GetCtx().GetContextAsInt(windowNo, "M_PriceList_Version_ID");

            if (M_PriceList_Version_ID == 0)
            {
                return;
            }

            int             C_BPartner_ID = GetCtx().GetContextAsInt(windowNo, "C_BPartner_ID");
            Decimal         Qty           = GetPlannedQty();
            bool            IsSOTrx       = true;
            MProductPricing pp            = new MProductPricing(GetAD_Client_ID(), GetAD_Org_ID(),
                                                                M_Product_ID, C_BPartner_ID, Qty, IsSOTrx);

            pp.SetM_PriceList_Version_ID(M_PriceList_Version_ID);
            DateTime?date = GetPlannedDate();

            if (date == null)
            {
                date = new DateTime(GetCtx().GetContextAsTime(windowNo, "DateContract"));
            }
            pp.SetPriceDate(date);
            //
            Decimal PriceList = pp.GetPriceList();

            SetPriceList(PriceList);
            Decimal plannedPrice = pp.GetPriceStd();

            SetPlannedPrice(plannedPrice);
            Decimal Discount = pp.GetDiscount();

            SetDiscount(Discount);
            //
            Decimal plannedAmt = pp.GetLineAmt(GetCurPrecision());

            SetPlannedAmt(plannedAmt);
            //
            //p_changeVO.setContext(GetCtx(), windowNo, "StdPrecision", pp.GetPrecision());
            log.Fine("PlannedQty=" + Qty + " * PlannedPrice=" + plannedPrice + " -> PlannedAmt=" + plannedAmt);
        }
        /// <summary>
        /// Get Purchase Price if exists
        /// </summary>
        /// <returns>limit</returns>
        public Decimal GetPurchasePrice()
        {
            //VA077_PurchasePrice
            Decimal purchasePrice = 0;

            if (GetM_Product_ID() == 0)
            {
                return(purchasePrice);
            }
            bool            isSOTrx = false;
            MProduct        prd     = new MProduct(GetCtx(), GetM_Product_ID(), null);
            MProductPricing pp      = new MProductPricing(GetAD_Client_ID(), GetAD_Org_ID(),
                                                          GetM_Product_ID(), _parent.GetC_BPartner_ID(), GetPlannedQty(), isSOTrx);

            pp.SetM_PriceList_ID(Util.GetValueOfInt(_parent.Get_Value("PO_PriceList_ID")));

            DateTime?validFrom = null;      // _parent.GetDateContract();

            if (validFrom == null)
            {
                validFrom = DateTime.Now.Date;
            }

            int M_PriceList_Version_ID = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT M_PriceList_Version_ID FROM M_PriceList_Version WHERE IsActive = 'Y' 
                        AND M_PriceList_ID = " + Util.GetValueOfInt(_parent.Get_Value("PO_PriceList_ID")) + @" AND ValidFrom <= "
                                                                             + DB.TO_DATE(validFrom, true) + " ORDER BY ValidFrom DESC"));

            pp.SetM_PriceList_Version_ID(M_PriceList_Version_ID);

            // Get Price according to Attribute set instance if selected on Project line
            if (Get_ColumnIndex("M_AttributeSetInstance_ID") >= 0)
            {
                pp.SetM_AttributeSetInstance_ID(GetM_AttributeSetInstance_ID());
            }

            // Get Price according to UOM if selected on Project line
            if (Get_ColumnIndex("C_UOM_ID") >= 0)
            {
                pp.SetC_UOM_ID(Util.GetValueOfInt(Get_Value("C_UOM_ID")));
            }
            else
            {
                pp.SetC_UOM_ID(prd.GetC_UOM_ID());
            }
            if (pp.CalculatePrice())
            {
                purchasePrice = pp.GetPriceStd();
            }
            return(purchasePrice);
        }
示例#7
0
        /**
         *  Set Product - Callout
         *	@param oldM_Product_ID old value
         *	@param newM_Product_ID new value
         *	@param windowNo window
         *	@throws Exception
         */
        //@UICallout
        public void SetM_Product_ID(String oldM_Product_ID, String newM_Product_ID, int windowNo)
        {
            try
            {
                if (newM_Product_ID == null || newM_Product_ID.Length == 0)
                {
                    return;
                }
                int M_Product_ID = int.Parse(newM_Product_ID);
                base.SetM_Product_ID(M_Product_ID);
                if (M_Product_ID == 0)
                {
                    SetM_AttributeSetInstance_ID(0);
                    return;
                }
                //	Set Attribute
                int M_AttributeSetInstance_ID = GetCtx().GetContextAsInt(Env.WINDOW_INFO, Env.TAB_INFO, "M_AttributeSetInstance_ID");
                if (GetCtx().GetContextAsInt(Env.WINDOW_INFO, Env.TAB_INFO, "M_Product_ID") == M_Product_ID &&
                    M_AttributeSetInstance_ID != 0)
                {
                    SetM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
                }
                else
                {
                    SetM_AttributeSetInstance_ID(0);
                }

                int             C_BPartner_ID = GetC_BPartner_ID();
                Decimal         Qty           = GetQty();
                bool            isSOTrx       = false;
                MProductPricing pp            = new MProductPricing(GetAD_Client_ID(), GetAD_Org_ID(),
                                                                    M_Product_ID, C_BPartner_ID, Qty, isSOTrx);
                //
                int M_PriceList_ID = GetCtx().GetContextAsInt(windowNo, "M_PriceList_ID");
                pp.SetM_PriceList_ID(M_PriceList_ID);
                int M_PriceList_Version_ID = GetCtx().GetContextAsInt(windowNo, "M_PriceList_Version_ID");
                pp.SetM_PriceList_Version_ID(M_PriceList_Version_ID);
                //DateTime orderDate = new DateTime(GetCtx().GetContextAsTime(windowNo, "DateRequired"));
                DateTime orderDate = Convert.ToDateTime(GetCtx().GetContextAsTime(windowNo, "DateRequired"));
                pp.SetPriceDate(orderDate);
                //
                SetPriceActual(pp.GetPriceStd());
                //p_changeVO.setContext(getContext(), windowNo, "EnforcePriceLimit", pp.isEnforcePriceLimit());	//	not used
                //p_changeVO.setContext(getContext(), windowNo, "DiscountSchema", pp.isDiscountSchema());
            }
            catch
            {
            }
        }
示例#8
0
        /**
         *  Set Amount (Callout)
         *	@param windowNo window
         *	@param columnName changed column
         */
        private void SetAmt(int windowNo, String columnName)
        {
            try
            {
                Decimal qty = GetQty();
                //	Qty changed - recalc price
                if (columnName.Equals("Qty") &&
                    "Y".Equals(GetCtx().GetContext(windowNo, "DiscountSchema")))
                {
                    int             M_Product_ID  = GetM_Product_ID();
                    int             C_BPartner_ID = GetC_BPartner_ID();
                    bool            isSOTrx       = false;
                    MProductPricing pp            = new MProductPricing(GetAD_Client_ID(), GetAD_Org_ID(),
                                                                        M_Product_ID, C_BPartner_ID, qty, isSOTrx);
                    //
                    int M_PriceList_ID = GetCtx().GetContextAsInt(windowNo, "M_PriceList_ID");
                    pp.SetM_PriceList_ID(M_PriceList_ID);
                    int M_PriceList_Version_ID = GetCtx().GetContextAsInt(windowNo, "M_PriceList_Version_ID");
                    pp.SetM_PriceList_Version_ID(M_PriceList_Version_ID);
                    //DateTime orderDate = new DateTime(getContext().getContextAsTime(windowNo, "DateInvoiced"));
                    DateTime orderDate = Convert.ToDateTime(GetCtx().GetContextAsTime(windowNo, "DateInvoiced"));
                    pp.SetPriceDate(orderDate);
                    //
                    SetPriceActual(pp.GetPriceStd());
                }

                int     stdPrecision = GetCtx().GetStdPrecision();
                Decimal priceActual  = GetPriceActual();

                //	get values
                log.Fine("Qty=" + qty + ", Price=" + priceActual + ", Precision=" + stdPrecision);

                //	Multiply
                Decimal lineNetAmt = Decimal.Multiply(qty, priceActual);
                if (Env.Scale(lineNetAmt) > stdPrecision)
                {
                    lineNetAmt = Decimal.Round(lineNetAmt, stdPrecision, MidpointRounding.AwayFromZero);
                }
                SetLineNetAmt(lineNetAmt);
                log.Info("LineNetAmt=" + lineNetAmt);
            }
            catch
            {
            }
        }
示例#9
0
 /**
  *  Set Price for Product and PriceList
  *  @param M_PriceList_ID price list
  */
 public void SetPrice(int M_PriceList_ID)
 {
     try
     {
         if (GetM_Product_ID() == 0)
         {
             return;
         }
         //
         log.Fine("M_PriceList_ID=" + M_PriceList_ID);
         bool            isSOTrx = false;
         MProductPricing pp      = new MProductPricing(GetAD_Client_ID(), GetAD_Org_ID(),
                                                       GetM_Product_ID(), GetC_BPartner_ID(), GetQty(), isSOTrx);
         pp.SetM_PriceList_ID(M_PriceList_ID);
         //	pp.setPriceDate(getDateOrdered());
         //
         SetPriceActual(pp.GetPriceStd());
     }
     catch
     {
         MessageBox.Show("MRequisitionLine--SetPrice(int M_PriceList_ID)");
     }
 }