Esempio n. 1
0
        }       //	prepare

        /// <summary>
        /// Perform Process.
        /// </summary>
        /// <returns>Message (clear text)</returns>
        protected override String DoIt()
        {
            if (m_C_ProjectLine_ID == 0)
            {
                throw new ArgumentException("No Project Line");
            }
            MProjectLine projectLine = new MProjectLine(GetCtx(), m_C_ProjectLine_ID, Get_TrxName());

            log.Info("doIt - " + projectLine);
            if (projectLine.GetM_Product_ID() == 0)
            {
                throw new ArgumentException("No Product");
            }
            //
            MProject project = new MProject(GetCtx(), projectLine.GetC_Project_ID(), Get_TrxName());

            if (project.GetM_PriceList_ID() == 0)
            {
                throw new ArgumentException("No PriceList");
            }
            //
            Boolean         isSOTrx = true;
            MProductPricing pp      = new MProductPricing(projectLine.GetAD_Client_ID(), projectLine.GetAD_Org_ID(),
                                                          projectLine.GetM_Product_ID(), project.GetC_BPartner_ID(),
                                                          projectLine.GetPlannedQty(), isSOTrx);

            pp.SetM_PriceList_ID(project.GetM_PriceList_ID());
            //vikas  mantis Issue ( 0000517)
            pp.SetM_PriceList_Version_ID(project.GetM_PriceList_Version_ID());
            //End
            pp.SetPriceDate(project.GetDateContract());
            //
            projectLine.SetPlannedPrice(pp.GetPriceStd());
            //projectLine.SetPlannedMarginAmt(pp.GetPriceStd().subtract(pp.GetPriceLimit()));
            projectLine.SetPlannedMarginAmt(Decimal.Subtract(pp.GetPriceStd(), pp.GetPriceLimit()));
            projectLine.Save();
            //
            String retValue = Msg.GetElement(GetCtx(), "PriceList") + pp.GetPriceList() + " - "
                              + Msg.GetElement(GetCtx(), "PriceStd") + pp.GetPriceStd() + " - "
                              + Msg.GetElement(GetCtx(), "PriceLimit") + pp.GetPriceLimit();

            return(retValue);
        }       //	doIt
        /// <summary>
        /// GetProductPricing
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="fields"></param>
        /// <returns></returns>
        public ProductDataOut GetProductPricing(Ctx ctx, string fields)
        {
            string[] paramValue = fields.Split(',');
            int      M_Product_ID, C_BPartner_ID, M_PriceList_ID, M_PriceList_Version_ID, M_AttributeSetInstance_ID = 0, countED011 = 0, C_UOM_ID = 0;
            decimal  Qty;
            bool     isSOTrx;

            //Assign parameter value
            M_Product_ID           = Util.GetValueOfInt(paramValue[0].ToString());
            C_BPartner_ID          = Util.GetValueOfInt(paramValue[1].ToString());
            Qty                    = Util.GetValueOfDecimal(paramValue[2].ToString());
            isSOTrx                = Convert.ToBoolean(paramValue[3]);
            M_PriceList_ID         = Util.GetValueOfInt(paramValue[4].ToString());
            M_PriceList_Version_ID = Util.GetValueOfInt(paramValue[5].ToString());
            DateTime?orderDate  = Util.GetValueOfDateTime(paramValue[6]);
            DateTime?orderDate1 = Util.GetValueOfDateTime(paramValue[7]);

            //if (paramValue.Length > 8)
            if (paramValue.Length == 9 || paramValue.Length == 11)
            {
                M_AttributeSetInstance_ID = Util.GetValueOfInt(paramValue[8].ToString());
            }

            if (paramValue.Length > 9)
            {
                if (paramValue.Length == 11)
                {
                    C_UOM_ID   = Util.GetValueOfInt(paramValue[9].ToString());
                    countED011 = Util.GetValueOfInt(paramValue[10].ToString());
                }
                else if (paramValue.Length == 10)
                {
                    C_UOM_ID   = Util.GetValueOfInt(paramValue[8].ToString());
                    countED011 = Util.GetValueOfInt(paramValue[9].ToString());
                }
            }

            /** Price List - ValidFrom date validation ** Dt:01/02/2021 ** Modified By: Kumar **/
            if (!string.IsNullOrEmpty(Util.GetValueOfString(orderDate)))
            {
                StringBuilder sbparams = new StringBuilder();
                sbparams.Append(Util.GetValueOfInt(M_PriceList_ID));
                sbparams.Append(",").Append(Convert.ToDateTime(orderDate).ToString("MM-dd-yyyy"));
                sbparams.Append(",").Append(Util.GetValueOfInt(M_Product_ID));
                sbparams.Append(",").Append(Util.GetValueOfInt(C_UOM_ID));
                sbparams.Append(",").Append(Util.GetValueOfInt(M_AttributeSetInstance_ID));
                MPriceListVersionModel objPriceList = new MPriceListVersionModel();
                M_PriceList_Version_ID = objPriceList.GetM_PriceList_Version_ID_On_Transaction_Date(ctx, sbparams.ToString());
            }

            //End Assign parameter value

            MProductPricing pp = new MProductPricing(ctx.GetAD_Client_ID(), ctx.GetAD_Org_ID(),
                                                     M_Product_ID, C_BPartner_ID, Qty, isSOTrx);

            //var M_PriceList_ID = ctx.GetContextAsInt(WindowNo, "M_PriceList_ID");
            pp.SetM_PriceList_ID(M_PriceList_ID);
            /** PLV is only accurate if PL selected in header */
            //var M_PriceList_Version_ID = ctx.GetContextAsInt(WindowNo, "M_PriceList_Version_ID");
            pp.SetM_PriceList_Version_ID(M_PriceList_Version_ID);

            //if (paramValue.Length > 8)
            if (paramValue.Length == 9 || paramValue.Length == 11)
            {
                pp.SetM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
            }
            //var orderDate = System.Convert.ToDateTime(mTab.getValue("DateOrdered"));
            pp.SetPriceDate(orderDate);
            pp.SetPriceDate1(orderDate1);

            if (countED011 > 0)
            {
                pp.SetC_UOM_ID(C_UOM_ID);
            }

            //Get product stock
            MProduct product = MProduct.Get(ctx, M_Product_ID);


            ProductDataOut objInfo = new ProductDataOut
            {
                //** Price List - ValidFrom date : return 0 when plv is not available ** Dt:03/26/2021 ** Modified By: Kumar **//

                PriceList     = (M_PriceList_Version_ID == 0 ? 0: pp.GetPriceList()),
                PriceLimit    = (M_PriceList_Version_ID == 0 ? 0 : pp.GetPriceLimit()),
                PriceActual   = (M_PriceList_Version_ID == 0 ? 0 : pp.GetPriceStd()),
                PriceEntered  = (M_PriceList_Version_ID == 0 ? 0 : pp.GetPriceStd()),
                PriceStd      = (M_PriceList_Version_ID == 0 ? 0 : pp.GetPriceStd()),
                LineAmt       = pp.GetLineAmt(2),
                C_Currency_ID = System.Convert.ToInt32(pp.GetC_Currency_ID()),
                Discount      = pp.GetDiscount(),
                C_UOM_ID      = System.Convert.ToInt32(pp.GetC_UOM_ID()),
                //QtyOrdered= mTab.GetValue("QtyEntered"));
                EnforcePriceLimit = pp.IsEnforcePriceLimit(),
                DiscountSchema    = pp.IsDiscountSchema(),
                IsStocked         = product.IsStocked()
            };

            product = null;
            pp      = null;
            return(objInfo);
        }
        /// <summary>
        /// GetProductPricing
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="fields"></param>
        /// <returns></returns>
        public ProductDataOut GetProductPricing(Ctx ctx, string fields)
        {
            string[] paramValue = fields.Split(',');
            int      M_Product_ID, C_BPartner_ID, M_PriceList_ID, M_PriceList_Version_ID, M_AttributeSetInstance_ID = 0;
            decimal  Qty;
            bool     isSOTrx;

            //Assign parameter value
            M_Product_ID           = Util.GetValueOfInt(paramValue[0].ToString());
            C_BPartner_ID          = Util.GetValueOfInt(paramValue[1].ToString());
            Qty                    = Util.GetValueOfDecimal(paramValue[2].ToString());
            isSOTrx                = Convert.ToBoolean(paramValue[3]);
            M_PriceList_ID         = Util.GetValueOfInt(paramValue[4].ToString());
            M_PriceList_Version_ID = Util.GetValueOfInt(paramValue[5].ToString());
            DateTime?orderDate  = Util.GetValueOfDateTime(paramValue[6]);
            DateTime?orderDate1 = Util.GetValueOfDateTime(paramValue[7]);

            if (paramValue.Length > 8)
            {
                M_AttributeSetInstance_ID = Util.GetValueOfInt(paramValue[8].ToString());
            }
            //End Assign parameter value

            MProductPricing pp = new MProductPricing(ctx.GetAD_Client_ID(), ctx.GetAD_Org_ID(),
                                                     M_Product_ID, C_BPartner_ID, Qty, isSOTrx);

            //var M_PriceList_ID = ctx.GetContextAsInt(WindowNo, "M_PriceList_ID");
            pp.SetM_PriceList_ID(M_PriceList_ID);
            /** PLV is only accurate if PL selected in header */
            //var M_PriceList_Version_ID = ctx.GetContextAsInt(WindowNo, "M_PriceList_Version_ID");
            pp.SetM_PriceList_Version_ID(M_PriceList_Version_ID);
            if (paramValue.Length > 8)
            {
                pp.SetM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
            }
            //var orderDate = System.Convert.ToDateTime(mTab.getValue("DateOrdered"));
            pp.SetPriceDate(orderDate);
            pp.SetPriceDate1(orderDate1);

            //Get product stock
            MProduct product = MProduct.Get(ctx, M_Product_ID);


            ProductDataOut objInfo = new ProductDataOut
            {
                PriceList     = pp.GetPriceList(),
                PriceLimit    = pp.GetPriceLimit(),
                PriceActual   = pp.GetPriceStd(),
                PriceEntered  = pp.GetPriceStd(),
                PriceStd      = pp.GetPriceStd(),
                LineAmt       = pp.GetLineAmt(2),
                C_Currency_ID = System.Convert.ToInt32(pp.GetC_Currency_ID()),
                Discount      = pp.GetDiscount(),
                C_UOM_ID      = System.Convert.ToInt32(pp.GetC_UOM_ID()),
                //QtyOrdered= mTab.GetValue("QtyEntered"));
                EnforcePriceLimit = pp.IsEnforcePriceLimit(),
                DiscountSchema    = pp.IsDiscountSchema(),
                IsStocked         = product.IsStocked()
            };

            product = null;
            pp      = null;
            return(objInfo);
        }
Esempio n. 4
0
        public JsonResult GetProductPricing(string fields)
        {
            string retError = "";
            string retJSON  = "";

            if (Session["ctx"] != null)
            {
                VAdvantage.Utility.Ctx ctx = Session["ctx"] as Ctx;
                string[] paramValue = fields.Split(',');
                int      M_Product_ID, C_BPartner_ID, M_PriceList_ID, M_PriceList_Version_ID;
                decimal  Qty;
                bool     isSOTrx;

                //Assign parameter value
                M_Product_ID           = Util.GetValueOfInt(paramValue[0].ToString());
                C_BPartner_ID          = Util.GetValueOfInt(paramValue[1].ToString());
                Qty                    = Util.GetValueOfDecimal(paramValue[2].ToString());
                isSOTrx                = Util.GetValueOfBool(paramValue[3].ToString());
                M_PriceList_ID         = Util.GetValueOfInt(paramValue[4].ToString());
                M_PriceList_Version_ID = Util.GetValueOfInt(paramValue[5].ToString());
                DateTime orderDate = System.Convert.ToDateTime(paramValue[6].ToString());

                //End Assign parameter value

                MProductPricing pp = new MProductPricing(ctx.GetAD_Client_ID(), ctx.GetAD_Org_ID(),
                                                         M_Product_ID, C_BPartner_ID, Qty, isSOTrx);

                //var M_PriceList_ID = ctx.GetContextAsInt(WindowNo, "M_PriceList_ID");
                pp.SetM_PriceList_ID(M_PriceList_ID);
                /** PLV is only accurate if PL selected in header */
                //var M_PriceList_Version_ID = ctx.GetContextAsInt(WindowNo, "M_PriceList_Version_ID");
                pp.SetM_PriceList_Version_ID(M_PriceList_Version_ID);

                //var orderDate = System.Convert.ToDateTime(mTab.getValue("DateOrdered"));
                pp.SetPriceDate(orderDate);

                //Get product stock
                MProduct product = MProduct.Get(ctx, M_Product_ID);


                VIS.DataContracts.ProductDataOut objInfo = new VIS.DataContracts.ProductDataOut
                {
                    PriceList     = pp.GetPriceList(),
                    PriceLimit    = pp.GetPriceLimit(),
                    PriceActual   = pp.GetPriceStd(),
                    PriceEntered  = pp.GetPriceStd(),
                    PriceStd      = pp.GetPriceStd(),
                    C_Currency_ID = System.Convert.ToInt32(pp.GetC_Currency_ID()),
                    Discount      = pp.GetDiscount(),

                    C_UOM_ID = System.Convert.ToInt32(pp.GetC_UOM_ID()),
                    //QtyOrdered= mTab.GetValue("QtyEntered"));
                    EnforcePriceLimit = pp.IsEnforcePriceLimit(),
                    DiscountSchema    = pp.IsDiscountSchema(),
                    IsStocked         = product.IsStocked()
                };
                product = null;
                pp      = null;
                retJSON = JsonConvert.SerializeObject(objInfo);
            }
            else
            {
                retError = "Session Expired";
            }
            return(Json(new { result = retJSON, error = retError }, JsonRequestBehavior.AllowGet));
        }