示例#1
0
 /**
  *  Get Verification Class
  *	@return verification class
  */
 public BankVerificationInterface GetVerificationClass()
 {
     if (_verify == null && !_verifySearched)
     {
         String className = GetBankVerificationClass();
         if (className == null || className.Length == 0)
         {
             className = MClientInfo.Get(GetCtx(), GetAD_Client_ID()).GetBankVerificationClass();
         }
         if (className != null && className.Length > 0)
         {
             try
             {
                 //Class clazz = Class.forName(className);
                 Type clazz = Type.GetType(className);
                 _verify = (BankVerificationInterface)Activator.CreateInstance(clazz);
             }
             catch (Exception e)
             {
                 log.Log(Level.SEVERE, className, e);
             }
         }
         _verifySearched = true;
     }
     return(_verify);
 }
示例#2
0
        protected override bool BeforeSave(bool newRecord)
        {
            if (GetAD_Org_ID() != 0)
            {
                SetAD_Org_ID(0);
            }
            if (base.GetTaxCorrectionType() == null)
            {
                SetTaxCorrectionType(IsDiscountCorrectsTax() ? TAXCORRECTIONTYPE_Write_OffAndDiscount : TAXCORRECTIONTYPE_None);
            }

            // Applied check for Table to enable support with Framework database.
            if (PO.Get_Table_ID("M_CostType") > 0)
            {
                CheckCosting();
            }
            //	Check Primary
            if (GetAD_OrgOnly_ID() != 0)
            {
                MClientInfo info = MClientInfo.Get(GetCtx(), GetAD_Client_ID());
                if (info.GetC_AcctSchema1_ID() == GetC_AcctSchema_ID())
                {
                    SetAD_OrgOnly_ID(0);
                }
            }
            return(true);
        }
示例#3
0
        }       //	get

        /// <summary>
        /// Get Client Info
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="AD_Client_ID">id</param>
        /// <param name="trxName">optional trx</param>
        /// <returns>Client Info</returns>
        public static MClientInfo Get(Ctx ctx, int AD_Client_ID, Trx trxName)
        {
            int         key  = AD_Client_ID;
            MClientInfo info = (MClientInfo)s_cache[key];

            if (info != null)
            {
                return(info);
            }
            //
            String  sql = "SELECT * FROM AD_ClientInfo WHERE AD_Client_ID=" + AD_Client_ID;
            DataSet ds  = null;

            try
            {
                VConnection vcon = VConnection.Get();
                ds = DataBase.DB.ExecuteDataset(sql, null, trxName);
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = ds.Tables[0].Rows[i];
                    info = new MClientInfo(ctx, dr, null);
                    if (trxName == null)
                    {
                        s_cache.Add(key, info);
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Log(Level.SEVERE, sql, ex);
            }
            ds = null;
            return(info);
        }
示例#4
0
 /// <summary>
 ///Get Client Info
 /// </summary>
 /// <returns>Client Info</returns>
 public MClientInfo GetInfo()
 {
     if (_info == null)
     {
         _info = MClientInfo.Get(GetCtx(), GetAD_Client_ID(), Get_Trx());
     }
     return(_info);
 }
示例#5
0
        /// <summary>
        /// Is used to check costing method belongs to PO costing method  like (Average PO, Weighted Average PO or Last PO)
        /// Firts we check costing method on Product category, if not found then we will check on Primary Accounting Schema
        /// </summary>
        /// <param name="ctx">current context</param>
        /// <param name="AD_Client_ID">Client reference</param>
        /// <param name="M_Product_ID">Product whom costing method is to be determine</param>
        /// <param name="trxName">Transaction</param>
        /// <returns>True/False</returns>
        public static bool IsPOCostingmethod(Ctx ctx, int AD_Client_ID, int M_Product_ID, Trx trxName)
        {
            MProductCategory pc = null;
            bool             isPOcostingMethod = false;
            string           costingMethod     = null;
            MClient          client            = MClient.Get(ctx, AD_Client_ID);
            MProduct         product           = MProduct.Get(ctx, M_Product_ID);

            if (product != null)
            {
                pc = MProductCategory.Get(product.GetCtx(), product.GetM_Product_Category_ID());
                if (pc != null)
                {
                    // check costing method from product category
                    costingMethod = pc.GetCostingMethod();
                    if (costingMethod == "C")
                    {
                        costingMethod = Util.GetValueOfString(DB.ExecuteScalar(@"SELECT costingmethod FROM M_CostElement WHERE M_CostElement_ID IN 
                                        (SELECT CAST(M_Ref_CostElement AS INTEGER) FROM M_CostElementLine WHERE M_CostElement_ID=" + pc.GetM_CostElement_ID() + @" )
                                        AND CostingMethod IS NOT NULL", null, trxName));
                    }
                }
                if (String.IsNullOrEmpty(costingMethod))
                {
                    // check costing method against primary accounting schema
                    MClientInfo clientInfo = MClientInfo.Get(ctx, AD_Client_ID);
                    MAcctSchema actSchema  = MAcctSchema.Get(ctx, clientInfo.GetC_AcctSchema1_ID());
                    if (actSchema != null)
                    {
                        costingMethod = actSchema.GetCostingMethod();
                        if (costingMethod == "C")
                        {
                            costingMethod = Util.GetValueOfString(DB.ExecuteScalar(@"SELECT costingmethod FROM M_CostElement WHERE M_CostElement_ID IN 
                                        (SELECT CAST(M_Ref_CostElement AS INTEGER) FROM M_CostElementLine WHERE M_CostElement_ID=" + actSchema.GetM_CostElement_ID() + @" )
                                        AND CostingMethod IS NOT NULL", null, trxName));
                        }
                    }
                }
            }
            if (costingMethod.Equals(COSTINGMETHOD_WeightedAveragePO) ||
                costingMethod.Equals(COSTINGMETHOD_AveragePO) ||
                costingMethod.Equals(COSTINGMETHOD_LastPOPrice))
            {
                isPOcostingMethod = true;
            }
            else
            {
                isPOcostingMethod = false;
            }

            return(isPOcostingMethod);
        }
示例#6
0
 /// <summary>
 /// Get Primary Accounting Schema ID
 /// </summary>
 /// <returns></returns>
 public int GetAcctSchemaID()
 {
     if (_info == null)
     {
         _info = MClientInfo.Get(GetCtx(), GetAD_Client_ID(), Get_TrxName());
     }
     if (_info != null)
     {
         int C_AcctSchema_ID = _info.GetC_AcctSchema1_ID();
         if (C_AcctSchema_ID != 0)
         {
             return(C_AcctSchema_ID);
         }
     }
     return(0);
 }
示例#7
0
 /// <summary>
 /// Get Primary Accounting Schema
 /// </summary>
 /// <returns>Acct Schema or null</returns>
 internal MAcctSchema GetAcctSchema()
 {
     if (_info == null)
     {
         _info = MClientInfo.Get(GetCtx(), GetAD_Client_ID(), Get_TrxName());
     }
     if (_info != null)
     {
         int C_AcctSchema_ID = _info.GetC_AcctSchema1_ID();
         if (C_AcctSchema_ID != 0)
         {
             return(MAcctSchema.Get(GetCtx(), C_AcctSchema_ID));
         }
     }
     return(null);
 }
 protected override bool BeforeSave(bool newRecord)
 {
     if (GetAD_Org_ID() != 0)
     {
         SetAD_Org_ID(0);
     }
     if (base.GetTaxCorrectionType() == null)
     {
         SetTaxCorrectionType(IsDiscountCorrectsTax() ? TAXCORRECTIONTYPE_Write_OffAndDiscount : TAXCORRECTIONTYPE_None);
     }
     CheckCosting();
     //	Check Primary
     if (GetAD_OrgOnly_ID() != 0)
     {
         MClientInfo info = MClientInfo.Get(GetCtx(), GetAD_Client_ID());
         if (info.GetC_AcctSchema1_ID() == GetC_AcctSchema_ID())
         {
             SetAD_OrgOnly_ID(0);
         }
     }
     return(true);
 }
示例#9
0
        /**
         *  Get R_RequestType_ID
         *	@return Request Type
         */
        private int GetR_RequestType_ID()
        {
            MClientInfo ci = MClientInfo.Get(GetCtx(), GetAD_Client_ID());
            int         R_RequestType_ID = ci.GetR_RequestType_ID();

            if (R_RequestType_ID != 0)
            {
                return(R_RequestType_ID);
            }
            log.Warning("Set Request Type in Window Client Info");

            //	Default
            MRequestType rt = MRequestType.GetDefault(GetCtx());

            if (rt != null)
            {
                R_RequestType_ID = rt.GetR_RequestType_ID();
                ci.SetR_RequestType_ID(R_RequestType_ID);
                ci.Save();
                return(R_RequestType_ID);
            }
            //
            return(0);
        }
示例#10
0
        /// <summary>
        /// Calculate User Price
        /// </summary>
        /// <returns>true if calculated</returns>
        private bool CalculateUser()
        {
            if (_userPricing == null)
            {
                MClientInfo client    = MClientInfo.Get(Env.GetContext(), _AD_Client_ID);
                String      userClass = client.GetPricingEngineClass();
                try
                {
                    // class<?> clazz = null;
                    Type clazz = null;
                    if (userClass != null)
                    {
                        //clazz = Class.forName(userClass);
                        clazz = Type.GetType(userClass);
                    }
                    if (clazz != null)
                    {
                        _api = (UserPricingInterface)Activator.CreateInstance(clazz);
                    }
                }
                catch (Exception ex)
                {
                    log.Warning("No User Pricing Engine (" + userClass + ") " + ex.ToString());
                    _userPricing = false;
                    return(false);
                }
                _userPricing = _api != null;
            }
            if (!(Boolean)_userPricing)
            {
                return(false);
            }

            UserPricingVO vo = null;

            if (_api != null)
            {
                try
                {
                    vo = _api.Price(_AD_Org_ID, _isSOTrx, _M_PriceList_ID,
                                    _C_BPartner_ID, _M_Product_ID, _qty, _PriceDate);
                }
                catch (Exception ex)
                {
                    log.Warning("Error User Pricing - " + ex.ToString());
                    return(false);
                }
            }

            if (vo != null && vo.IsValid())
            {
                _PriceList  = vo.GetPriceList();
                _PriceStd   = vo.GetPriceStd();
                _PriceLimit = vo.GetPriceLimit();
                _found      = true;
                //	Optional
                _C_UOM_ID          = vo.GetC_UOM_ID();
                _C_Currency_ID     = vo.GetC_Currency_ID();
                _enforcePriceLimit = vo.IsEnforcePriceLimit();
                if (_C_UOM_ID == 0 || _C_Currency_ID == 0)
                {
                    SetBaseInfo();
                }
            }
            return(false);
        }
        }   //  getClientAcctSchema

        // by amit 23-12-2015
        public static MAcctSchema[] GetClientAcctSchemas(Ctx ctx, int AD_Client_ID, Trx trxName)
        {
            //  Check Cache
            int key = AD_Client_ID;

            if (_schema.ContainsKey(key))
            {
                return((MAcctSchema[])_schema[key]);
            }

            //  Create New
            List <MAcctSchema> list = new List <MAcctSchema>();
            MClientInfo        info = MClientInfo.Get(ctx, AD_Client_ID, trxName);
            MAcctSchema        ass  = MAcctSchema.Get(ctx, info.GetC_AcctSchema1_ID(), trxName);

            if (ass.Get_ID() != 0 && trxName == null)
            {
                list.Add(ass);
            }

            //	Other
            String sql = "SELECT C_AcctSchema_ID FROM C_AcctSchema acs "
                         + "WHERE IsActive='Y'";

            if (AD_Client_ID != 0)
            {
                sql += " AND AD_Client_ID=" + AD_Client_ID;
            }
            sql += " ORDER BY C_AcctSchema_ID";

            IDataReader dr = null;

            try
            {
                dr = DataBase.DB.ExecuteReader(sql, null, trxName);
                while (dr.Read())
                {
                    int id = Utility.Util.GetValueOfInt(dr[0].ToString());
                    if (id != info.GetC_AcctSchema1_ID())       //	already in list
                    {
                        ass = MAcctSchema.Get(ctx, id, trxName);
                        if (ass.Get_ID() != 0 && trxName == null)
                        {
                            list.Add(ass);
                        }
                    }
                }
                dr.Close();
                dr = null;
            }
            catch (System.Data.Common.DbException e)
            {
                if (dr != null)
                {
                    dr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                    dr = null;
                }
            }
            //  Save
            MAcctSchema[] retValue = new MAcctSchema[list.Count];
            retValue = list.ToArray();
            if (trxName == null)
            {
                _schema.Add(key, retValue);
            }
            return(retValue);
        }   //  getClientAcctSchema
示例#12
0
        /// <summary>
        /// Is standard Period Open for specified orgs for the client. For best
        /// performance, ensure that the list of orgs does not contain duplicates.
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="AD_Client_ID"></param>
        /// <param name="orgs"></param>
        /// <param name="DateAcct">accounting date</param>
        /// <param name="DocBaseType">document base type</param>
        /// <returns>error message or null</returns>
        /// <date>07-March-2011</date>
        /// <writer>raghu</writer>
        public static String IsOpen(Ctx ctx, int AD_Client_ID, List <int> orgs, DateTime?DateAcct,
                                    String DocBaseType)
        {
            if (DateAcct == null)
            {
                return("@NotFound@ @DateAcct@");
            }
            if (DocBaseType == null)
            {
                return("@NotFound@ @DocBaseType@");
            }

            MAcctSchema as1 = MClient.Get(ctx, AD_Client_ID).GetAcctSchema();

            if (as1 == null)
            {
                return("@NotFound@ @C_AcctSchema_ID@ for AD_Client_ID=" + AD_Client_ID);
            }
            if (as1.IsAutoPeriodControl())
            {
                if (as1.IsAutoPeriodControlOpen(DateAcct))
                {
                    return(null);
                }
                else
                {
                    return("@PeriodClosed@ - @AutoPeriodControl@");
                }
            }

            //	Get all Calendars in line with Organizations
            MClientInfo clientInfo   = MClientInfo.Get(ctx, AD_Client_ID, null);
            List <int>  orgCalendars = new List <int>();
            List <int>  calendars    = new List <int>();

            foreach (int org in orgs)
            {
                MOrgInfo orgInfo = MOrgInfo.Get(ctx, org, null);

                int C_Calendar_ID = orgInfo.GetC_Calendar_ID();
                if (C_Calendar_ID == 0)
                {
                    C_Calendar_ID = clientInfo.GetC_Calendar_ID();
                }
                orgCalendars.Add(C_Calendar_ID);
                if (!calendars.Contains(C_Calendar_ID))
                {
                    calendars.Add(C_Calendar_ID);
                }
            }
            //	Should not happen
            if (calendars.Count == 0)
            {
                return("@NotFound@ @C_Calendar_ID@");
            }

            //	For all Calendars get Periods
            for (int i = 0; i < calendars.Count; i++)
            {
                int     C_Calendar_ID = calendars[i];
                MPeriod period        = MPeriod.GetOfCalendar(ctx, C_Calendar_ID, DateAcct);
                //	First Org for Calendar
                int AD_Org_ID = 0;
                for (int j = 0; j < orgCalendars.Count; j++)
                {
                    if (orgCalendars[j] == C_Calendar_ID)
                    {
                        AD_Org_ID = orgs[j];
                        break;
                    }
                }
                if (period == null)
                {
                    MCalendar cal  = MCalendar.Get(ctx, C_Calendar_ID);
                    String    date = DisplayType.GetDateFormat(DisplayType.Date).Format(DateAcct);
                    if (cal != null)
                    {
                        return("@NotFound@ @C_Period_ID@: " + date
                               + " - " + MOrg.Get(ctx, AD_Org_ID).GetName()
                               + " -> " + cal.GetName());
                    }
                    else
                    {
                        return("@NotFound@ @C_Period_ID@: " + date
                               + " - " + MOrg.Get(ctx, AD_Org_ID).GetName()
                               + " -> C_Calendar_ID=" + C_Calendar_ID);
                    }
                }
                String error = period.IsOpen(DocBaseType, DateAcct);
                if (error != null)
                {
                    return(error
                           + " - " + MOrg.Get(ctx, AD_Org_ID).GetName()
                           + " -> " + MCalendar.Get(ctx, C_Calendar_ID).GetName());
                }
            }
            return(null);        //	open
        }
示例#13
0
        }       //	testEMail

        public bool SetupClientInfo(String language)
        {
            //	Create Trees
            String sql = null;

            if (Env.IsBaseLanguage(language, "AD_Ref_List"))    //	Get TreeTypes & Name
            {
                sql = "SELECT Value, Name FROM AD_Ref_List WHERE AD_Reference_ID=120 AND IsActive='Y'";
            }
            else
            {
                sql = "SELECT l.Value, t.Name FROM AD_Ref_List l, AD_Ref_List_Trl t "
                      + "WHERE l.AD_Reference_ID=120 AND l.AD_Ref_List_ID=t.AD_Ref_List_ID AND l.IsActive='Y'";
            }

            //  Tree IDs
            int AD_Tree_Org_ID = 0, AD_Tree_BPartner_ID = 0, AD_Tree_Project_ID = 0,
                AD_Tree_SalesRegion_ID = 0, AD_Tree_Product_ID = 0,
                AD_Tree_Campaign_ID = 0, AD_Tree_Activity_ID = 0;

            bool success = false;

            try
            {
                //IDataReader dr = DataBase.DB.ExecuteReader(sql, null, Get_TrxName());
                DataSet dr   = DataBase.DB.ExecuteDataset(sql, null, Get_TrxName());
                MTree   tree = null;
                for (int i = 0; i <= dr.Tables[0].Rows.Count - 1; i++)
                {
                    try
                    {
                        String treeType = dr.Tables[0].Rows[i]["Value"].ToString();
                        if (treeType.Equals(X_AD_Tree.TREETYPE_Other) ||
                            treeType.StartsWith("U"))
                        {
                            continue;
                        }
                        String name = GetName() + " " + dr.Tables[0].Rows[i]["Name"].ToString();
                        //
                        if (treeType.Equals(X_AD_Tree.TREETYPE_Organization))
                        {
                            tree           = new MTree(this, name, treeType);
                            success        = tree.Save();
                            AD_Tree_Org_ID = tree.GetAD_Tree_ID();
                        }
                        else if (treeType.Equals(X_AD_Tree.TREETYPE_BPartner))
                        {
                            tree                = new MTree(this, name, treeType);
                            success             = tree.Save();
                            AD_Tree_BPartner_ID = tree.GetAD_Tree_ID();
                        }
                        else if (treeType.Equals(X_AD_Tree.TREETYPE_Project))
                        {
                            tree               = new MTree(this, name, treeType);
                            success            = tree.Save();
                            AD_Tree_Project_ID = tree.GetAD_Tree_ID();
                        }
                        else if (treeType.Equals(X_AD_Tree.TREETYPE_SalesRegion))
                        {
                            tree    = new MTree(this, name, treeType);
                            success = tree.Save();
                            AD_Tree_SalesRegion_ID = tree.GetAD_Tree_ID();
                        }
                        else if (treeType.Equals(X_AD_Tree.TREETYPE_Product))
                        {
                            tree               = new MTree(this, name, treeType);
                            success            = tree.Save();
                            AD_Tree_Product_ID = tree.GetAD_Tree_ID();
                        }
                        else if (treeType.Equals(X_AD_Tree.TREETYPE_ElementValue))
                        {
                            tree    = new MTree(this, name, treeType);
                            success = tree.Save();
                            m_AD_Tree_Account_ID = tree.GetAD_Tree_ID();
                        }
                        else if (treeType.Equals(X_AD_Tree.TREETYPE_Campaign))
                        {
                            tree                = new MTree(this, name, treeType);
                            success             = tree.Save();
                            AD_Tree_Campaign_ID = tree.GetAD_Tree_ID();
                        }
                        else if (treeType.Equals(X_AD_Tree.TREETYPE_Activity))
                        {
                            tree                = new MTree(this, name, treeType);
                            success             = tree.Save();
                            AD_Tree_Activity_ID = tree.GetAD_Tree_ID();
                        }
                        else if (treeType.Equals(X_AD_Tree.TREETYPE_Menu))      //	No Menu
                        {
                            success = true;
                        }
                        else    //	PC (Product Category), BB (BOM)
                        {
                            tree    = new MTree(this, name, treeType);
                            success = tree.Save();
                        }
                        if (!success)
                        {
                            log.Log(VAdvantage.Logging.Level.SEVERE, "Tree NOT created: " + name);
                            break;
                        }
                    }
                    catch { }
                }

                dr.Dispose();
            }
            catch (Exception e1)
            {
                log.Log(VAdvantage.Logging.Level.SEVERE, "Trees", e1);
                success = false;
            }

            if (!success)
            {
                return(false);
            }

            //	Create ClientInfo
            MClientInfo clientInfo = new MClientInfo(this,
                                                     AD_Tree_Org_ID, AD_Tree_BPartner_ID, AD_Tree_Project_ID,
                                                     AD_Tree_SalesRegion_ID, AD_Tree_Product_ID,
                                                     AD_Tree_Campaign_ID, AD_Tree_Activity_ID, Get_TrxName());

            success = clientInfo.Save();
            return(success);
        }       //	createTrees
示例#14
0
        /// <summary>
        /// Get Default Calendar for Client
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="AD_Client_ID">id</param>
        /// <returns>MCalendar</returns>
        public static MCalendar GetDefault(Context ctx, int AD_Client_ID)
        {
            MClientInfo info = MClientInfo.Get(ctx, AD_Client_ID);

            return(Get(ctx, info.GetC_Calendar_ID()));
        }