private DataTable GetAccountListTable(TDBTransaction AReadTransaction, System.Int32 ALedgerNumber, string ATableName) { StringCollection FieldList = new StringCollection(); FieldList.Add(AAccountTable.GetLedgerNumberDBName()); FieldList.Add(AAccountTable.GetAccountCodeDBName()); FieldList.Add(AAccountTable.GetAccountCodeShortDescDBName()); FieldList.Add(AAccountTable.GetAccountActiveFlagDBName()); FieldList.Add(AAccountTable.GetPostingStatusDBName()); FieldList.Add(AAccountTable.GetForeignCurrencyFlagDBName()); FieldList.Add(AAccountTable.GetForeignCurrencyCodeDBName()); GLSetupTDS TempDS = new GLSetupTDS(); AAccountAccess.LoadViaALedger(TempDS, ALedgerNumber, FieldList, AReadTransaction); // load AAccountProperty and set the BankAccountFlag AAccountPropertyAccess.LoadViaALedger(TempDS, ALedgerNumber, AReadTransaction); foreach (AAccountPropertyRow accProp in TempDS.AAccountProperty.Rows) { if ((accProp.PropertyCode == MFinanceConstants.ACCOUNT_PROPERTY_BANK_ACCOUNT) && (accProp.PropertyValue == "true")) { TempDS.AAccount.DefaultView.RowFilter = String.Format("{0}='{1}'", AAccountTable.GetAccountCodeDBName(), accProp.AccountCode); GLSetupTDSAAccountRow acc = (GLSetupTDSAAccountRow)TempDS.AAccount.DefaultView[0].Row; acc.BankAccountFlag = true; TempDS.AAccount.DefaultView.RowFilter = ""; } } // load AAccountHierarchyDetails and check if this account reports to the CASH account AAccountHierarchyDetailAccess.LoadViaAAccountHierarchy(TempDS, ALedgerNumber, MFinanceConstants.ACCOUNT_HIERARCHY_STANDARD, AReadTransaction); TLedgerInfo ledgerInfo = new TLedgerInfo(ALedgerNumber); TGetAccountHierarchyDetailInfo accountHierarchyTools = new TGetAccountHierarchyDetailInfo(ledgerInfo); List <string> children = accountHierarchyTools.GetChildren(MFinanceConstants.CASH_ACCT); foreach (GLSetupTDSAAccountRow account in TempDS.AAccount.Rows) { if (children.Contains(account.AccountCode)) { account.CashAccountFlag = true; } } return(TempDS.AAccount); }
public void Test_08_TGetAccountHierarchyDetailInfo() { TGetAccountHierarchyDetailInfo gahdi = new TGetAccountHierarchyDetailInfo(FLedgerNumber); Assert.IsTrue(gahdi.HasNoChildren("6800"), "Base Account without children"); Assert.IsFalse(gahdi.HasNoChildren("6800S"), "Root Account"); List <String> list = gahdi.GetChildren("7000S"); Assert.AreEqual(2, list.Count, "Two entries ..."); Assert.AreEqual("7000", list[0], "7000 is the first account"); Assert.AreEqual("7010", list[1], "7010 is the second account"); Assert.AreEqual("7000S", gahdi.GetParentAccount("7010")); List <String> list2 = gahdi.GetChildren("ASSETS"); Assert.AreEqual(41, list2.Count, "Currently 41 child entries"); }