Ejemplo n.º 1
0
 /// <summary>
 /// Creates a journal.
 /// </summary>
 /// <param name="new_journal_info">The new_journal_info is the Journal object with journal_date,amount,debit_or_credit as mandatory attributes.</param>
 /// <returns>Journal object.</returns>
 public Journal Create(Journal new_journal_info)
 {
     string url = baseAddress;
     var json = JsonConvert.SerializeObject(new_journal_info);
     var jsonstring = new Dictionary<object, object>();
     jsonstring.Add("JSONString", json);
     var responce = ZohoHttpClient.post(url, getQueryParameters(jsonstring));
     return JournalParser.getJournal(responce);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Updates the journal with given information.
 /// </summary>
 /// <param name="journal_id">The journal_id is the identifier of the journal.</param>
 /// <param name="update_info">The update_info is the Journal object which contains the updation information of specifed journal.</param>
 /// <returns>Journal object.</returns>
 public Journal Update(string journal_id, Journal update_info)
 {
     string url = baseAddress + "/" + journal_id;
     var json = JsonConvert.SerializeObject(update_info);
     var jsonstring = new Dictionary<object, object>();
     jsonstring.Add("JSONString", json);
     var responce = ZohoHttpClient.put(url, getQueryParameters(jsonstring));
     return JournalParser.getJournal(responce);
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                var journalsApi = service.GetJournalsApi();
                var parameters = new Dictionary<object, object>();
                parameters.Add("filter_by", "JournalDate.All");
                Console.WriteLine("---------------Journals List--------------------");
                var journalsList = journalsApi.GetJournals(parameters);
                var journals = journalsList;

                foreach(var journal in journals)
                {
                    Console.WriteLine("{0},{1},{2}",journal.journal_id,journal.notes,journal.total);
                }
                var journalId = journals[0].journal_id;
                var accountsApi = service.GetChartOfAccountsApi();
                var accountId = accountsApi.GetChartOfAcounts(null)[0].account_id;
                Console.WriteLine("---------------Specified Journal--------------------");
                var journal1 = journalsApi.Get(journalId);
                Console.WriteLine("{0},{1},{2}", journal1.journal_id, journal1.notes, journal1.total);
                var lineitems = journal1.line_items;
                foreach(var lineitem in lineitems)
                {
                    Console.WriteLine("{0},{1},{2}",lineitem.account_id,lineitem.amount,lineitem.line_id);
                }
                var newJournalInfo = new Journal()
                {
                    journal_date="2014-02-10",
                    line_items = new List<LineItem>()
                    {
                        new LineItem(){
                            account_id=accountId,
                            debit_or_credit="credit",
                            amount=150
                        },
                        new LineItem(){
                            account_id=accountId,
                            debit_or_credit="debit",
                            amount=150
                        }
                    }
                };

                Console.WriteLine("---------------New Journal--------------------");
                var newJournal = journalsApi.Create(newJournalInfo);
                Console.WriteLine("{0},{1},{2}", newJournal.journal_id, newJournal.notes, newJournal.total);
                var lineitems1 = newJournal.line_items;
                foreach (var lineitem in lineitems1)
                {
                    Console.WriteLine("{0},{1},{2}", lineitem.account_id, lineitem.amount, lineitem.line_id);
                }
                var updateInfo = new Journal()
                {
                    journal_date = "2014-11-10",
                    line_items = new List<LineItem>()
                    {
                        new LineItem(){
                            account_id=accountId,
                            debit_or_credit="debit",
                            amount=130
                        },
                        new LineItem(){
                            account_id=accountId,
                            debit_or_credit="credit",
                            amount=130
                        }
                    },
                   notes="hari"
                };
                Console.WriteLine("---------------Updated Journal--------------------");
                var updatedJournal = journalsApi.Update(newJournal.journal_id, updateInfo);
                Console.WriteLine("{0},{1},{2}", updatedJournal.journal_id, updatedJournal.notes, updatedJournal.total);
                Console.WriteLine("---------------Delete Journal--------------------");
                var deljournal = journalsApi.Delete(updatedJournal.journal_id);
                Console.WriteLine(deljournal);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }