Exemplo n.º 1
0
        public static string GetGnuCashAccount(List <AccountDictionaryEntry> accountDictionary, string moneyloverBook, string moneyloverCategory)
        // Return a string with GnuCash account name which matches the given "moneyloverBook" and "moneyloverCategory"
        // GNUCash replace for GnuCash
        {
            List <AccountDictionaryEntry> accountDictionaryMatch = accountDictionary.FindAll(x => x.moneyloverBook.Contains(moneyloverBook));

            if (accountDictionaryMatch != null)
            {
                AccountDictionaryEntry accountDictionaryEntryMatch = accountDictionaryMatch.Find(x => x.moneyloverCategory.Contains(moneyloverCategory));
                if (accountDictionaryEntryMatch != null)
                {
                    string gnucashAccountName = accountDictionaryEntryMatch.gnucashAccountName;
                    return(gnucashAccountName);
                }
                else
                {
                    Console.WriteLine("Following book and category not found in supplied dictionary: \"" + moneyloverBook + "\" \"" + moneyloverCategory + "\"");
                    return("unknown");
                }
            }
            else
            {
                Console.WriteLine("\"" + moneyloverBook + " book not found in the supplied dictionary.");
                return("unknown");
            }
            //string gnucashAccountName =
            //    accountDictionary
            //    .FindAll(x => x.moneyloverBook.Contains(moneyloverBook))
            //    .Find(x => x.moneyloverCategory.Contains(moneyloverCategory))
            //    .gnucashAccountName;
            //return gnucashAccountName;
        }
Exemplo n.º 2
0
        public static List <AccountDictionaryEntry> AddDictionaryEntry(List <AccountDictionaryEntry> accountDictionary, XmlNode nod)
        // Add a new element to the provided list and return it
        {
            AccountDictionaryEntry newEntry = new AccountDictionaryEntry();

            newEntry.gnucashAccountName = nod.Attributes["gnucashAccountName"].Value;
            newEntry.moneyloverBook     = nod.Attributes["moneyloverBook"].Value;
            newEntry.moneyloverCategory = nod.Attributes["moneyloverCategory"].Value;

            // add newEntry it to the accountDictionary list
            accountDictionary.Add(newEntry);

            // Clear "newEntry" variable
            newEntry = null;

            return(accountDictionary);
        }