}       //	getValidCombination

        /// <summary>
        ///	Get Natural Account Element Value
        /// </summary>
        /// <returns> account</returns>
        public MElementValue GetAccountElementValue()
        {
            if (m_accountElement == null)
            {
                MAccount vc = GetAccount();
                if (vc != null && vc.GetAccount_ID() != 0)
                {
                    m_accountElement = new MElementValue(GetCtx(), vc.GetAccount_ID(), Get_TrxName());
                }
            }
            return(m_accountElement);
        }       //	getAccountElement
 /// <summary>
 ///     Get Distribution for combination
 /// </summary>
 /// <param name="acct">account (ValidCombination)</param>
 /// <param name="PostingType">only posting type</param>
 /// <param name="C_DocType_ID">only document type</param>
 /// <returns>array of distributions</returns>
 public static MDistribution[] Get(MAccount acct,
                                   String PostingType, int C_DocType_ID)
 {
     return(Get(acct.GetCtx(), acct.GetC_AcctSchema_ID(),
                PostingType, C_DocType_ID,
                acct.GetAD_Org_ID(), acct.GetAccount_ID(),
                acct.GetM_Product_ID(), acct.GetC_BPartner_ID(), acct.GetC_Project_ID(),
                acct.GetC_Campaign_ID(), acct.GetC_Activity_ID(), acct.GetAD_OrgTrx_ID(),
                acct.GetC_SalesRegion_ID(), acct.GetC_LocTo_ID(), acct.GetC_LocFrom_ID(),
                acct.GetUser1_ID(), acct.GetUser2_ID()));
 }       //	get
 /** Fill Accounting Dimensions from line combination **/
 private void fillDimensionsFromCombination()
 {
     if (GetC_ValidCombination_ID() > 0)
     {
         MAccount combi = new MAccount(GetCtx(), GetC_ValidCombination_ID(), Get_TrxName());
         if (Get_ColumnIndex("Account_ID") > 0)
         {
             Set_Value("Account_ID", combi.GetAccount_ID() > 0 ? combi.GetAccount_ID() : 0);
         }
         if (Get_ColumnIndex("C_SubAcct_ID") > 0)
         {
             Set_Value("C_SubAcct_ID", combi.GetC_SubAcct_ID() > 0 ? combi.GetC_SubAcct_ID() : 0);
         }
         if (Get_ColumnIndex("M_Product_ID") > 0)
         {
             Set_Value("M_Product_ID", combi.GetM_Product_ID() > 0 ? combi.GetM_Product_ID() : 0);
         }
         if (Get_ColumnIndex("C_BPartner_ID") > 0)
         {
             Set_Value("C_BPartner_ID", combi.GetC_BPartner_ID() > 0 ? combi.GetC_BPartner_ID() : 0);
         }
         if (Get_ColumnIndex("AD_OrgTrx_ID") > 0)
         {
             Set_Value("AD_OrgTrx_ID", combi.GetAD_OrgTrx_ID() > 0 ? combi.GetAD_OrgTrx_ID() : 0);
         }
         if (Get_ColumnIndex("AD_Org_ID") > 0)
         {
             Set_Value("AD_Org_ID", combi.GetAD_Org_ID() > 0 ? combi.GetAD_Org_ID() : 0);
         }
         if (Get_ColumnIndex("C_LocFrom_ID") > 0)
         {
             Set_Value("C_LocFrom_ID", combi.GetC_LocFrom_ID() > 0 ? combi.GetC_LocFrom_ID() : 0);
         }
         if (Get_ColumnIndex("C_LocTo_ID") > 0)
         {
             Set_Value("C_LocTo_ID", combi.GetC_LocTo_ID() > 0 ? combi.GetC_LocTo_ID() : 0);
         }
         if (Get_ColumnIndex("C_SalesRegion_ID") > 0)
         {
             Set_Value("C_SalesRegion_ID", combi.GetC_SalesRegion_ID() > 0 ? combi.GetC_SalesRegion_ID() : 0);
         }
         if (Get_ColumnIndex("C_Project_ID") > 0)
         {
             Set_Value("C_Project_ID", combi.GetC_Project_ID() > 0 ? combi.GetC_Project_ID() : 0);
         }
         if (Get_ColumnIndex("C_Campaign_ID") > 0)
         {
             Set_Value("C_Campaign_ID", combi.GetC_Campaign_ID() > 0 ? combi.GetC_Campaign_ID() : 0);
         }
         if (Get_ColumnIndex("C_Activity_ID") > 0)
         {
             Set_Value("C_Activity_ID", combi.GetC_Activity_ID() > 0 ? combi.GetC_Activity_ID() : 0);
         }
         if (Get_ColumnIndex("User1_ID") > 0)
         {
             Set_Value("User1_ID", combi.GetUser1_ID() > 0 ? combi.GetUser1_ID() : 0);
         }
         if (Get_ColumnIndex("User2_ID") > 0)
         {
             Set_Value("User2_ID", combi.GetUser2_ID() > 0 ? combi.GetUser2_ID() : 0);
         }
     }
 }
Exemple #4
0
        /// <summary>
        /// Factory: default combination
        /// </summary>
        /// <param name="acctSchema">accounting schema</param>
        /// <param name="optionalNull">if true, the optional values are null</param>
        /// <returns>Account</returns>
        public static MAccount GetDefault(MAcctSchema acctSchema, bool optionalNull)
        {
            MAccount vc = new MAccount(acctSchema);

            //  Active Elements
            MAcctSchemaElement[] elements = acctSchema.GetAcctSchemaElements();
            for (int i = 0; i < elements.Length; i++)
            {
                MAcctSchemaElement ase         = elements[i];
                String             elementType = ase.GetElementType();
                int  defaultValue = ase.GetDefaultValue();
                bool setValue     = ase.IsMandatory() || (!ase.IsMandatory() && !optionalNull);
                //
                if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Organization))
                {
                    vc.SetAD_Org_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Account))
                {
                    vc.SetAccount_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount) && setValue)
                {
                    vc.SetC_SubAcct_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_BPartner) && setValue)
                {
                    vc.SetC_BPartner_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Product) && setValue)
                {
                    vc.SetM_Product_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Activity) && setValue)
                {
                    vc.SetC_Activity_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom) && setValue)
                {
                    vc.SetC_LocFrom_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo) && setValue)
                {
                    vc.SetC_LocTo_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Campaign) && setValue)
                {
                    vc.SetC_Campaign_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx) && setValue)
                {
                    vc.SetAD_OrgTrx_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Project) && setValue)
                {
                    vc.SetC_Project_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion) && setValue)
                {
                    vc.SetC_SalesRegion_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_UserList1) && setValue)
                {
                    vc.SetUser1_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_UserList2) && setValue)
                {
                    vc.SetUser2_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_UserElement1) && setValue)
                {
                    vc.SetUserElement1_ID(defaultValue);
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_UserElement2) && setValue)
                {
                    vc.SetUserElement2_ID(defaultValue);
                }
            }
            _log.Fine("Client_ID=" + vc.GetAD_Client_ID() + ", Org_ID=" + vc.GetAD_Org_ID()
                      + " - AcctSchema_ID=" + vc.GetC_AcctSchema_ID() + ", Account_ID=" + vc.GetAccount_ID());
            return(vc);
        }
Exemple #5
0
        }       //	setAccount

        /// <summary>
        ///	Get Account Combination based on Account and Overwrite
        /// </summary>
        /// <returns>account</returns>
        public MAccount GetAccount()
        {
            MAccount acct = MAccount.Get(GetCtx(),
                                         _account.GetAD_Client_ID(),
                                         IsOverwriteOrg() && GetOrg_ID() != 0 ? GetOrg_ID() : _account.GetAD_Org_ID(),
                                         _account.GetC_AcctSchema_ID(),
                                         IsOverwriteAcct() && GetAccount_ID() != 0 ? GetAccount_ID() : _account.GetAccount_ID(),
                                         _account.GetC_SubAcct_ID(),
                                         //
                                         IsOverwriteProduct() ? GetM_Product_ID() : _account.GetM_Product_ID(),
                                         IsOverwriteBPartner() ? GetC_BPartner_ID() : _account.GetC_BPartner_ID(),
                                         IsOverwriteOrgTrx() ? GetAD_OrgTrx_ID() : _account.GetAD_OrgTrx_ID(),
                                         IsOverwriteLocFrom() ? GetC_LocFrom_ID() : _account.GetC_LocFrom_ID(),
                                         IsOverwriteLocTo() ? GetC_LocTo_ID() : _account.GetC_LocTo_ID(),
                                         IsOverwriteSalesRegion() ? GetC_SalesRegion_ID() : _account.GetC_SalesRegion_ID(),
                                         IsOverwriteProject() ? GetC_Project_ID() : _account.GetC_Project_ID(),
                                         IsOverwriteCampaign() ? GetC_Campaign_ID() : _account.GetC_Campaign_ID(),
                                         IsOverwriteActivity() ? GetC_Activity_ID() : _account.GetC_Activity_ID(),
                                         IsOverwriteUser1() ? GetUser1_ID() : _account.GetUser1_ID(),
                                         IsOverwriteUser2() ? GetUser2_ID() : _account.GetUser2_ID(),
                                         _account.GetUserElement1_ID(),
                                         _account.GetUserElement2_ID());

            return(acct);
        }       //	setAccount
Exemple #6
0
 /** Fill Accounting Dimensions from line combination **/
 private void fillDimensionsFromCombination()
 {
     if (GetC_ValidCombination_ID() > 0)
     {
         MAccount combi = new MAccount(GetCtx(), GetC_ValidCombination_ID(), Get_TrxName());
         if (Get_ColumnIndex("Account_ID") > 0)
         {
             Set_Value("Account_ID", combi.GetAccount_ID() > 0 ? combi.GetAccount_ID() : 0);
         }
         if (Get_ColumnIndex("C_SubAcct_ID") > 0)
         {
             Set_Value("C_SubAcct_ID", combi.GetC_SubAcct_ID() > 0 ? combi.GetC_SubAcct_ID() : 0);
         }
         // setting null in business partner and product search control because if set 0 then it shows <0> in controls.-Mohit-11 May 2020
         if (Get_ColumnIndex("M_Product_ID") > 0)
         {
             if (combi.GetM_Product_ID() > 0)
             {
                 Set_Value("M_Product_ID", combi.GetM_Product_ID());
             }
         }
         if (Get_ColumnIndex("C_BPartner_ID") > 0)
         {
             if (combi.GetC_BPartner_ID() > 0)
             {
                 Set_Value("C_BPartner_ID", combi.GetC_BPartner_ID());
             }
         }
         if (Get_ColumnIndex("AD_OrgTrx_ID") > 0)
         {
             Set_Value("AD_OrgTrx_ID", combi.GetAD_OrgTrx_ID() > 0 ? combi.GetAD_OrgTrx_ID() : 0);
         }
         if (Get_ColumnIndex("AD_Org_ID") > 0)
         {
             Set_Value("AD_Org_ID", combi.GetAD_Org_ID() > 0 ? combi.GetAD_Org_ID() : 0);
         }
         if (Get_ColumnIndex("C_LocFrom_ID") > 0)
         {
             Set_Value("C_LocFrom_ID", combi.GetC_LocFrom_ID() > 0 ? combi.GetC_LocFrom_ID() : 0);
         }
         if (Get_ColumnIndex("C_LocTo_ID") > 0)
         {
             Set_Value("C_LocTo_ID", combi.GetC_LocTo_ID() > 0 ? combi.GetC_LocTo_ID() : 0);
         }
         if (Get_ColumnIndex("C_SalesRegion_ID") > 0)
         {
             Set_Value("C_SalesRegion_ID", combi.GetC_SalesRegion_ID() > 0 ? combi.GetC_SalesRegion_ID() : 0);
         }
         if (Get_ColumnIndex("C_Project_ID") > 0)
         {
             Set_Value("C_Project_ID", combi.GetC_Project_ID() > 0 ? combi.GetC_Project_ID() : 0);
         }
         if (Get_ColumnIndex("C_Campaign_ID") > 0)
         {
             Set_Value("C_Campaign_ID", combi.GetC_Campaign_ID() > 0 ? combi.GetC_Campaign_ID() : 0);
         }
         if (Get_ColumnIndex("C_Activity_ID") > 0)
         {
             Set_Value("C_Activity_ID", combi.GetC_Activity_ID() > 0 ? combi.GetC_Activity_ID() : 0);
         }
         if (Get_ColumnIndex("User1_ID") > 0)
         {
             Set_Value("User1_ID", combi.GetUser1_ID() > 0 ? combi.GetUser1_ID() : 0);
         }
         if (Get_ColumnIndex("User2_ID") > 0)
         {
             Set_Value("User2_ID", combi.GetUser2_ID() > 0 ? combi.GetUser2_ID() : 0);
         }
     }
 }