Esempio n. 1
0
        /// <summary>
        /// Load controls lookup etc.
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="windowNo"></param>
        /// <param name="C_AcctSchema_ID"></param>
        /// <returns>class lookups</returns>
        public AccountSchema AccountSchemaLoad(Ctx ctx, int windowNo, int C_AcctSchema_ID)
        {
            AccountSchema objSchema = new AccountSchema();

            MAcctSchemaElement[] elements = null;

            var _AcctSchema = new MAcctSchema(ctx, C_AcctSchema_ID, null);

            ctx.GetCtx(windowNo).SetContext(windowNo, "C_AcctSchema_ID", C_AcctSchema_ID);
            elements = _AcctSchema.GetAcctSchemaElements();

            objSchema.IsHasAlies = _AcctSchema.IsHasAlias();
            objSchema.Elements   = new List <AccountingElements>();
            for (int i = 0; i < elements.Length; i++)
            {
                AccountingElements obj = new AccountingElements();
                MAcctSchemaElement ase = elements[i];
                obj.Type         = ase.GetElementType();
                obj.IsMandatory  = ase.IsMandatory();
                obj.ID           = ase.Get_ID();
                obj.Name         = ase.GetName();
                obj.DefaultValue = ase.GetDefaultValue();
                obj.SeqNo        = ase.GetSeqNo();
                obj.AD_Column_ID = ase.GetAD_Column_ID();
                obj.IsHeavyData  = Util.GetValueOfBool(ase.Get_Value("IsHeavyData"));
                objSchema.Elements.Add(obj);
            }
            objSchema.Description = _AcctSchema.ToString();
            return(objSchema);
        }
Esempio n. 2
0
 /// <summary>
 /// Balance all segments.
 /// - For all balancing segments
 /// - For all segment values
 /// - If balance <> 0 create dueTo/dueFrom line
 /// overwriting the segment value
 /// </summary>
 public void BalanceSegments()
 {
     MAcctSchemaElement[] elements = _acctSchema.GetAcctSchemaElements();
     //  check all balancing segments
     for (int i = 0; i < elements.Length; i++)
     {
         MAcctSchemaElement ase = elements[i];
         if (ase.IsBalanced())
         {
             BalanceSegment(ase.GetElementType());
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Are all segments balanced
        /// </summary>
        /// <returns>true if segments are balanced</returns>
        public bool IsSegmentBalanced()
        {
            if (_lines.Count == 0)
            {
                return(true);
            }

            MAcctSchemaElement[] elements = _acctSchema.GetAcctSchemaElements();
            //  check all balancing segments
            for (int i = 0; i < elements.Length; i++)
            {
                MAcctSchemaElement ase = elements[i];
                if (ase.IsBalanced() && !IsSegmentBalanced(ase.GetElementType()))
                {
                    return(false);
                }
            }
            return(true);
        }
        }       //	copyDefault

        /// <summary>
        /// Create Account
        /// </summary>
        /// <param name="targetAS">target AS</param>
        /// <param name="sourceAcct">source account</param>
        /// <returns>target account</returns>
        private MAccount CreateAccount(MAcctSchema targetAS, MAccount sourceAcct)
        {
            int AD_Client_ID    = targetAS.GetAD_Client_ID();
            int C_AcctSchema_ID = targetAS.GetC_AcctSchema_ID();
            //
            int AD_Org_ID        = 0;
            int Account_ID       = 0;
            int C_SubAcct_ID     = 0;
            int M_Product_ID     = 0;
            int C_BPartner_ID    = 0;
            int AD_OrgTrx_ID     = 0;
            int C_LocFrom_ID     = 0;
            int C_LocTo_ID       = 0;
            int C_SalesRegion_ID = 0;
            int C_Project_ID     = 0;
            int C_Campaign_ID    = 0;
            int C_Activity_ID    = 0;
            int User1_ID         = 0;
            int User2_ID         = 0;
            int UserElement1_ID  = 0;
            int UserElement2_ID  = 0;

            //
            //  Active Elements
            MAcctSchemaElement[] elements = targetAS.GetAcctSchemaElements();
            for (int i = 0; i < elements.Length; i++)
            {
                MAcctSchemaElement ase         = elements[i];
                String             elementType = ase.GetElementType();
                //
                if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Organization))
                {
                    AD_Org_ID = sourceAcct.GetAD_Org_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Account))
                {
                    Account_ID = sourceAcct.GetAccount_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_SubAccount))
                {
                    C_SubAcct_ID = sourceAcct.GetC_SubAcct_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_BPartner))
                {
                    C_BPartner_ID = sourceAcct.GetC_BPartner_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Product))
                {
                    M_Product_ID = sourceAcct.GetM_Product_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Activity))
                {
                    C_Activity_ID = sourceAcct.GetC_Activity_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_LocationFrom))
                {
                    C_LocFrom_ID = sourceAcct.GetC_LocFrom_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_LocationTo))
                {
                    C_LocTo_ID = sourceAcct.GetC_LocTo_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Campaign))
                {
                    C_Campaign_ID = sourceAcct.GetC_Campaign_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_OrgTrx))
                {
                    AD_OrgTrx_ID = sourceAcct.GetAD_OrgTrx_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_Project))
                {
                    C_Project_ID = sourceAcct.GetC_Project_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_SalesRegion))
                {
                    C_SalesRegion_ID = sourceAcct.GetC_SalesRegion_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_UserList1))
                {
                    User1_ID = sourceAcct.GetUser1_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_UserList2))
                {
                    User2_ID = sourceAcct.GetUser2_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_UserElement1))
                {
                    UserElement1_ID = sourceAcct.GetUserElement1_ID();
                }
                else if (elementType.Equals(MAcctSchemaElement.ELEMENTTYPE_UserElement2))
                {
                    UserElement2_ID = sourceAcct.GetUserElement2_ID();
                }
                //	No UserElement
            }
            //
            return(MAccount.Get(GetCtx(), AD_Client_ID, AD_Org_ID,
                                C_AcctSchema_ID, Account_ID, C_SubAcct_ID,
                                M_Product_ID, C_BPartner_ID, AD_OrgTrx_ID,
                                C_LocFrom_ID, C_LocTo_ID, C_SalesRegion_ID,
                                C_Project_ID, C_Campaign_ID, C_Activity_ID,
                                User1_ID, User2_ID, UserElement1_ID, UserElement2_ID));
        } //	createAccount