Ejemplo n.º 1
0
        }       //	get

        /// <summary>
        /// Get Distributions for combination
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="C_AcctSchema_ID">schema</param>
        /// <param name="PostingType">posting type</param>
        /// <param name="C_DocType_ID">document type</param>
        /// <param name="AD_Org_ID">org</param>
        /// <param name="Account_ID">account</param>
        /// <param name="M_Product_ID">product</param>
        /// <param name="C_BPartner_ID">partner</param>
        /// <param name="C_Project_ID">project</param>
        /// <param name="C_Campaign_ID">campaign</param>
        /// <param name="C_Activity_ID">activity</param>
        /// <param name="AD_OrgTrx_ID">trx org</param>
        /// <param name="C_SalesRegion_ID">C_SalesRegion_ID</param>
        /// <param name="C_LocTo_ID">location to</param>
        /// <param name="C_LocFrom_ID">from</param>
        /// <param name="User1_ID">user 1</param>
        /// <param name="User2_ID">user 2</param>
        /// <returns>array of distributions or null</returns>
        public static MDistribution[] Get(Ctx ctx, int C_AcctSchema_ID,
                                          String PostingType, int C_DocType_ID,
                                          int AD_Org_ID, int Account_ID,
                                          int M_Product_ID, int C_BPartner_ID, int C_Project_ID,
                                          int C_Campaign_ID, int C_Activity_ID, int AD_OrgTrx_ID,
                                          int C_SalesRegion_ID, int C_LocTo_ID, int C_LocFrom_ID,
                                          int User1_ID, int User2_ID)
        {
            MDistribution[] acctList = Get(ctx, Account_ID);
            if (acctList == null || acctList.Length == 0)
            {
                return(null);
            }
            //
            //ArrayList<MDistribution> list = new ArrayList<MDistribution>();
            List <MDistribution> list = new List <MDistribution>();

            for (int i = 0; i < acctList.Length; i++)
            {
                MDistribution distribution = acctList[i];
                if (!distribution.IsActive() || !distribution.IsValid())
                {
                    continue;
                }
                //	Mandatory Acct Schema
                if (distribution.GetC_AcctSchema_ID() != C_AcctSchema_ID)
                {
                    continue;
                }
                //	Only Posting Type / DocType
                if (distribution.GetPostingType() != null && !distribution.GetPostingType().Equals(PostingType))
                {
                    continue;
                }
                if (distribution.GetC_DocType_ID() != 0 && distribution.GetC_DocType_ID() != C_DocType_ID)
                {
                    continue;
                }
                //	Optional Elements - "non-Any"
                if (!distribution.IsAnyOrg() && distribution.GetAD_Org_ID() != AD_Org_ID)
                {
                    continue;
                }
                if (!distribution.IsAnyAcct() && distribution.GetAccount_ID() != Account_ID)
                {
                    continue;
                }
                if (!distribution.IsAnyProduct() && distribution.GetM_Product_ID() != M_Product_ID)
                {
                    continue;
                }
                if (!distribution.IsAnyBPartner() && distribution.GetC_BPartner_ID() != C_BPartner_ID)
                {
                    continue;
                }
                if (!distribution.IsAnyProject() && distribution.GetC_Project_ID() != C_Project_ID)
                {
                    continue;
                }
                if (!distribution.IsAnyCampaign() && distribution.GetC_Campaign_ID() != C_Campaign_ID)
                {
                    continue;
                }
                if (!distribution.IsAnyActivity() && distribution.GetC_Activity_ID() != C_Activity_ID)
                {
                    continue;
                }
                if (!distribution.IsAnyOrgTrx() && distribution.GetAD_OrgTrx_ID() != AD_OrgTrx_ID)
                {
                    continue;
                }
                if (!distribution.IsAnySalesRegion() && distribution.GetC_SalesRegion_ID() != C_SalesRegion_ID)
                {
                    continue;
                }
                if (!distribution.IsAnyLocTo() && distribution.GetC_LocTo_ID() != C_LocTo_ID)
                {
                    continue;
                }
                if (!distribution.IsAnyLocFrom() && distribution.GetC_LocFrom_ID() != C_LocFrom_ID)
                {
                    continue;
                }
                if (!distribution.IsAnyUser1() && distribution.GetUser1_ID() != User1_ID)
                {
                    continue;
                }
                if (!distribution.IsAnyUser2() && distribution.GetUser2_ID() != User2_ID)
                {
                    continue;
                }
                //
                list.Add(distribution);
            }           //	 for all distributions with acct
            //
            MDistribution[] retValue = new MDistribution[list.Count];
            //list.toArray (retValue);
            retValue = list.ToArray();
            return(retValue);
        }       //	get