Esempio n. 1
0
        /**
         *  Set Value, Name, Description
         *	@param invoice
         *	@param deliveryCount count
         *	@param product product
         *	@param partner partner
         */
        public void SetValueNameDescription(MInvoice invoice,
                                            int deliveryCount, MProduct product, MBPartner partner)
        {
            String documentNo = "_" + invoice.GetDocumentNo();

            if (deliveryCount > 1)
            {
                documentNo += "_" + deliveryCount;
            }
            //	Value
            String value = partner.GetValue() + "_" + product.GetValue();

            if (value.Length > 40 - documentNo.Length)
            {
                value = value.Substring(0, 40 - documentNo.Length) + documentNo;
            }
            // Change to set Value from Document Sequence
            // SetValue(value);

            // Change to set only name of product as value in Asset
            //	Name		MProduct.afterSave
            // String name = partner.GetName() + " - " + product.GetName();

            String name = product.GetName();

            if (name.Length > 60)
            {
                name = name.Substring(0, 60);
            }
            SetName(name);
            //	Description
            String description = product.GetDescription();

            SetDescription(description);
        }
Esempio n. 2
0
        /**
         *  Create Trial Asset
         *	@param ctx context
         *	@param user user
         *	@param entityType entity type
         *	@return asset or null if no product found
         */
        public static MAsset GetTrial(Ctx ctx, MUser user, String entityType)
        {
            if (user == null)
            {
                _log.Warning("Cannot create Trial - No User");
                return(null);
            }
            if (Utility.Util.IsEmpty(entityType))
            {
                _log.Warning("Cannot create Trial - No Entity Type");
                return(null);
            }
            MProduct product = MProduct.GetTrial(ctx, entityType);

            if (product == null)
            {
                _log.Warning("No Trial for Entity Type=" + entityType);
                return(null);
            }
            //
            DateTime now = Convert.ToDateTime(CommonFunctions.CurrentTimeMillis());
            //
            MAsset asset = new MAsset(ctx, 0, null);

            asset.SetClientOrg(user);
            asset.SetAssetServiceDate(now);
            asset.SetIsOwned(false);
            asset.SetIsTrialPhase(true);
            //
            MBPartner partner    = new MBPartner(ctx, user.GetC_BPartner_ID(), null);
            String    documentNo = "Trial";
            //	Value
            String value = partner.GetValue() + "_" + product.GetValue();

            if (value.Length > 40 - documentNo.Length)
            {
                value = value.Substring(0, 40 - documentNo.Length) + documentNo;
            }
            asset.SetValue(value);
            //	Name		MProduct.afterSave
            String name = "Trial " + partner.GetName() + " - " + product.GetName();

            if (name.Length > 60)
            {
                name = name.Substring(0, 60);
            }
            asset.SetName(name);
            //	Description
            String description = product.GetDescription();

            asset.SetDescription(description);

            //	User
            asset.SetAD_User_ID(user.GetAD_User_ID());
            asset.SetC_BPartner_ID(user.GetC_BPartner_ID());
            //	Product
            asset.SetM_Product_ID(product.GetM_Product_ID());
            asset.SetA_Asset_Group_ID(product.GetA_Asset_Group_ID());
            asset.SetQty(new Decimal(product.GetSupportUnits()));
            //	Guarantee & Version
            asset.SetGuaranteeDate(TimeUtil.AddDays(now, product.GetTrialPhaseDays()));
            asset.SetVersionNo(product.GetVersionNo());
            //
            return(asset);
        }
Esempio n. 3
0
        /**
         *  Create BP, Contact, Location from Lead
         *	@return error message
         */
        public String CreateBP()
        {
            if (GetC_BPartner_ID() != 0 && GetAD_User_ID() != 0 && GetC_BPartner_Location_ID() == 0)
            {
                return("@AlreadyExists@: @C_BPartner_ID@ (ID=" + GetC_BPartner_ID() + ")");
            }

            //	BPartner
            if (GetC_BPartner_ID() == 0 &&
                (GetBPName() != null && GetBPName().Length > 0))
            {
                //	Existing User
                _user = GetUser();
                if (_user != null)
                {
                    if (_user.GetC_BPartner_ID() != 0)
                    {
                        SetRef_BPartner_ID(_user.GetC_BPartner_ID());
                        log.Info("Set to BPartner of User - " + _user);
                        return(CreateBPLocation());
                    }
                }
                //
                _bp = new MBPartner(GetCtx(), Get_TrxName());   //	Template
                _bp.SetAD_Org_ID(GetAD_Org_ID());
                //_bp.SetValue(GetBPName());
                _bp.SetName(GetBPName());
                _bp.SetIsCustomer(false);
                _bp.SetIsProspect(true);
                _bp.SetSOCreditStatus("O");
                // Check Removed as per Surya Sir's Decision BY Lokesh

                //_bp.SetC_Campaign_ID(GetC_Campaign_ID());
                //
                if (GetC_BP_Group_ID() == 0)
                {
                    // ShowMessage.Info("First Select Customer Group Then process again", true, null, null);
                    return(null);
                }
                else
                {
                    _bp.SetC_BP_Group_ID(GetC_BP_Group_ID());
                }
                MBPGroup gp = new MBPGroup(GetCtx(), GetC_BP_Group_ID(), Get_TrxName());
                _bp.SetM_PriceList_ID(gp.GetM_PriceList_ID());
                if (GetC_BP_Size_ID() != 0)
                {
                    _bp.SetC_BP_Size_ID(GetC_BP_Size_ID());
                }
                if (GetURL() != null)
                {
                    _bp.SetURL(GetURL());
                }
                if (GetC_BP_Status_ID() != 0)
                {
                    _bp.SetC_BP_Status_ID(GetC_BP_Status_ID());
                }
                if (GetC_IndustryCode_ID() != 0)
                {
                    _bp.SetC_IndustryCode_ID(GetC_IndustryCode_ID());
                }
                if (GetNAICS() != null)
                {
                    _bp.SetNAICS(GetNAICS());
                }
                if (GetDUNS() != null)
                {
                    _bp.SetDUNS(GetDUNS());
                }
                if (GetNumberEmployees() != 0)
                {
                    _bp.SetNumberEmployees(GetNumberEmployees());
                }
                if (GetSalesVolume() != 0)
                {
                    _bp.SetSalesVolume(GetSalesVolume());
                }
                if (GetSalesRep_ID() != 0)
                {
                    _bp.SetSalesRep_ID(GetSalesRep_ID());
                }
                if (GetC_Campaign_ID() != 0)
                {
                    _bp.SetC_Campaign_ID(GetC_Campaign_ID());
                }
                if (!_bp.Save())
                {
                    return("@SaveError@");
                }
                //	Update User
                if (_user != null && _user.GetC_BPartner_ID() == 0)
                {
                    _user.SetC_BPartner_ID(_bp.GetC_BPartner_ID());
                    _user.Save();
                }
                //	Save BP
                SetRef_BPartner_ID(_bp.GetC_BPartner_ID());
            }

            String error = CreateBPContact();

            if (error != null && error.Length > 0)
            {
                return(error);
            }
            CreateBPLocation();

            try
            {
                int    id    = _bp.GetC_BPartner_ID();
                string qry   = "Update c_bpartner set Description='' where c_bpartner_id=" + id;
                int    check = DB.ExecuteQuery(qry, null, Get_TrxName());
                string val   = _bp.GetValue();
                qry   = "Update c_bpartner set Value='" + val + GetBPName() + "' where c_bpartner_id=" + id;
                check = DB.ExecuteQuery(qry, null, Get_TrxName());

                if (GetR_InterestArea_ID() != 0)
                {
                    string      sql = "Select R_InterestArea_ID from vss_lead_interestarea where C_Lead_ID=" + GetC_Lead_ID();
                    IDataReader dr  = DB.ExecuteReader(sql, null, Get_TrxName());
                    while (dr.Read())
                    {
                        X_R_ContactInterest Prospect = new X_R_ContactInterest(GetCtx(), 0, Get_TrxName());
                        Prospect.SetR_InterestArea_ID(Util.GetValueOfInt(dr[0]));
                        Prospect.SetC_BPartner_ID(GetRef_BPartner_ID());
                        String query  = "Select ad_user_id from ad_user where c_bpartner_id= " + GetRef_BPartner_ID();
                        int    UserId = Util.GetValueOfInt(DB.ExecuteScalar(query, null, Get_TrxName()));
                        Prospect.SetAD_User_ID(UserId);
                        query = "Select C_BPartner_Location_id from C_BPartner_Location where c_bpartner_id= " + GetRef_BPartner_ID();

                        int Id = Util.GetValueOfInt(DB.ExecuteScalar(query, null, Get_TrxName()));
                        X_C_BPartner_Location loc = new X_C_BPartner_Location(GetCtx(), Id, Get_TrxName());
                        Prospect.SetC_BPartner_Location_ID(Id);
                        Prospect.SetPhone(loc.GetPhone());
                        Prospect.SetFax(loc.GetFax());

                        X_AD_User us = new X_AD_User(GetCtx(), UserId, Get_TrxName());
                        Prospect.SetC_Job_ID(us.GetC_Job_ID());
                        Prospect.SetSubscribeDate(DateTime.Today);
                        query = "Select Email from ad_user where ad_user_id= " + UserId;
                        String mail = Util.GetValueOfString(DB.ExecuteScalar(query, null, Get_TrxName()));
                        Prospect.SetEMail(mail);
                        if (Prospect.Save())
                        {
                        }
                    }
                    dr.Close();
                }
            }
            catch
            {
            }

            return(null);
        }