コード例 #1
0
        private void ProcessAccount(LedgerAccount account, ExcelWorkbook book)
        {
            //get all transactions for this account in the given date range
            var hqlParams = new Dictionary<string, object>(3);
            hqlParams.Add("account", account);
            hqlParams.Add("fromDate", _rcFromThruForAccount.FromDate);
            hqlParams.Add("thruDate", _rcFromThruForAccount.ThruDate);

            IList<LedgerTransactionSplit> transactions = Core.Data.Find.FindListByHql<LedgerTransactionSplit>(-1,
                "from LedgerTransactionSplit a where a.Account = :account and a.ParentTransaction.DatePosted between :fromDate and :thruDate order by a.ParentTransaction.DatePosted", hqlParams);


            foreach (LedgerTransactionSplit split in transactions)
            {
                if (_currentRow >= 7)
                {
                    book.Range("A" + _currentRow, "J" + (_currentRow + 1)).FillDown();
                }

                book.Cell("A" + _currentRow).Value2 = split.ParentTransaction.DatePosted;
                //book.Cell("B" + _row).Value2 = split.ParentTransaction.
                book.Cell("C" + _currentRow).Value2 = split.ParentTransaction.Description;
                book.Cell("D" + _currentRow).Value2 = split.Account.FullName;
                book.Cell("E" + _currentRow).Value2 = split.Amount;
                _currentRow++;

            }


            int i = 1;
        }
コード例 #2
0
ファイル: LedgerAccount.cs プロジェクト: vsukhoml/gcdashboard
 private void AddChildAccount(LedgerAccount acct)
 {
     _childAccounts.Add(acct);
 }
コード例 #3
0
ファイル: LedgerAccount.cs プロジェクト: vsukhoml/gcdashboard
        /// <summary>
        /// Indicates whether this account is a parent, either directly or indirectly
        /// of the given account.
        /// </summary>
        /// <param name="account">The account to search for.</param>
        /// <returns>True, if the account exists in the child structure; otherwise false.</returns>
        public virtual bool IsParent(LedgerAccount account)
        {
            LedgerAccount current = account;

            while (current != null)
            {
                if (current.Equals(this))
                    return true;

                if (current.ParentAccount != null)
                {
                    current = current.ParentAccount;
                }
                else
                {
                    return false;
                }
            }

            return false;
        }
コード例 #4
0
ファイル: LedgerAccount.cs プロジェクト: vsukhoml/gcdashboard
 private string CalculateFullName(LedgerAccount a)
 {
     if (a.ParentAccount != null &&
         a.ParentAccount.ParentAccount != null)
         return CalculateFullName(a.ParentAccount) + Configuration.General.AccountSeperator + a.Name;
     else
         return a.Name;
 }
コード例 #5
0
        public override void RunHandler()
        {
            _accountCache = new Dictionary<Guid, LedgerAccount>(50);

            Core.Data.Connection.RunNativeSQL("delete from ledger_account");

            string sourceFilename = ConsoleFunctions.Prompt("Source Filename", "..\\..\\..\\resources\\gc\\sample.gnucash");
            string workFilename = sourceFilename + ".work";

            Helper.DataLoadHelper.Extract(sourceFilename);
            Helper.DataLoadHelper.ReadXml(workFilename);

            XmlNodeList listOfAccounts = Helper.DataLoadHelper.GetAccountNodes();
            List<LedgerAccount> accounts = new List<GcDashboard.Core.Entities.LedgerAccount>(50);

            foreach (XmlNode node in listOfAccounts)
            {
                LedgerAccount a = new LedgerAccount();

                foreach (XmlNode innerNode in node.ChildNodes)
                {
                    switch (innerNode.LocalName)
                    {
                        case "name":
                            a.Name = innerNode.InnerText;
                            break;

                        case "id":
                            a.GnuCashIdentifier = new Guid(innerNode.InnerText);
                            break;

                        case "type":
                            a.AccountType = (LedgerAccountType)Enum.Parse(typeof(LedgerAccountType), innerNode.InnerText, true);
                            break;

                        case "description":
                            a.Description = innerNode.InnerText;
                            break;

                        case "parent":
                            Guid parentGuid = new Guid(innerNode.InnerText);

                            try
                            {
                                a.ParentAccount = LookupAccountByGuid(parentGuid);
                            }
                            catch (Exception)
                            { }
                            break;

                        default:
                            int i = 1;
                            break;
                    }
                }

                accounts.Add(a);
                _accountCache.Add(a.GnuCashIdentifier, a);
            }

            foreach (LedgerAccount account in accounts)
            {
                Core.Data.Connection.Save(-1, account);
            }

            Console.WriteLine("Loaded {0} accounts", accounts.Count);
        }