示例#1
0
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organizationId}");
                var transactionApi = service.GetBankTransactionsApi();
                var accounts = service.GetBankAccountsApi().GetBankAccounts(null);
                var parameters = new Dictionary<object, object>();
                 parameters.Add("filter_by", "Status.All");
                 parameters.Add("account_id", accounts[0].account_id);
                 Console.WriteLine("---------------------- All Transactions ----------------------");
                 var transactionList = transactionApi.GetTransactions(parameters);
                 var transactions = transactionList;
                 foreach (var trans in transactions)
                     Console.WriteLine("{0},{1},{2}", trans.transaction_id, trans.status, trans.amount);

                Console.WriteLine("---------------------- Specified Transaction ----------------------");
                var transaction = transactionApi.Get(transactions[2].transaction_id);
                 Console.WriteLine("{0},{1},{2}", transaction.transaction_id, transaction.transaction_type, transaction.amount);

                 Console.WriteLine("---------------------- New Transaction ----------------------");
                 var newTransactionInfo = new Transaction()
                 {
                     transaction_type = "transfer_fund",
                     from_account_id = accounts[0].account_id,
                     to_account_id = accounts[2].account_id,
                     amount=10
                 };
                 var newTransaction = transactionApi.Create(newTransactionInfo);
                 Console.WriteLine("{0},{1},{2}", newTransaction.transaction_id, newTransaction.transaction_type, newTransaction.amount);

                 Console.WriteLine("---------------------- Updated Transaction ----------------------");
                 var updateInfo = new Transaction()
                  {
                         amount=50,
                         currency_id=transactionList[0].currency_id,
                         date="2014-02-06",
                         description="",
                         exchange_rate=1,
                         from_account_id = accounts[0].account_id,
                         reference_number= "",
                         to_account_id = accounts[2].account_id,
                         transaction_type = "transfer_fund"
                 };
                 var updatedTrans = transactionApi.Update(newTransaction.transaction_id, updateInfo);
                 Console.WriteLine("{0},{1},{2}", updatedTrans.transaction_id, updatedTrans.transaction_type, updatedTrans.amount);

                 Console.WriteLine("---------------------- Delete Transaction ----------------------");
                 var deltrans = transactionApi.Delete(updatedTrans.transaction_id);
                 Console.WriteLine(deltrans);
                var parameters1 = new Dictionary<object, object>();
                 parameters1.Add("amount_start", "1");
                 parameters1.Add("amount_end", "4000");
                 parameters1.Add("date_start", "2014-02-01");
                 parameters1.Add("date_end", "2014-02-07");

                 var matchingtrans = transactionApi.GetMatchingTransactions(transactions[1].transaction_id, parameters1);

                 foreach(var matchingTran in matchingtrans)
                     Console.WriteLine("{0},{1},{2}", matchingTran.transaction_id, matchingTran.transaction_type, matchingTran.amount);
                var parameters3=new Dictionary<object,object>();
                 parameters3.Add("account_id", accounts[1].account_id);
                 TransactionsToBeMatched transtomatch = new TransactionsToBeMatched()
                 {
                     transactions_to_be_matched = new List<Transaction>(){
                         new Transaction()
                         {
                             transaction_id=transactions[2].transaction_id,
                             transaction_type="vendor_payment"
                         },
                         new Transaction()
                         {
                             transaction_id=transactions[3].transaction_id,
                             transaction_type="transfer_fund"
                         },
                         new Transaction()
                         {
                             transaction_id=transactions[1].transaction_id,
                             transaction_type="expense"
                         }
                     }
                 };
                 var matchtransaction = transactionApi.MatchATransaction(transactions[0].transaction_id, transtomatch);
                 Console.WriteLine(matchtransaction);
                 var unmatch = transactionApi.UnmatchTransaction(transactions[0].transaction_id);
                 Console.WriteLine(unmatch);
                 parameters.Add("sort_column", "statement_date");
                 var associatedTransObj = transactionApi.GetAssociatedTransactions(transactions[0].transaction_id, null);
                 var associatedTrans = associatedTransObj.associated_transactions;
                 Console.WriteLine(associatedTransObj.imported_transaction_id);
                 foreach (var asociatedTran in associatedTrans)
                     Console.WriteLine("{0},{1},{2}", asociatedTran.transaction_id, asociatedTran.transaction_type, asociatedTran.amount);
                 var exclude = transactionApi.ExcludeATransaction(transactions[0].transaction_id);
                 Console.WriteLine(exclude);
                 var restore = transactionApi.RestoreATransaction(transactions[0].transaction_id);
                 Console.WriteLine(restore);
                 var transacInfo=new Transaction()
                 {
                         amount=4000,
                         date="2013-01-29",
                         description="Insurance payment",
                         exchange_rate=1,
                         from_account_id = accounts[1].account_id,
                         reference_number="Ref-9872",
                         to_account_id = accounts[3].account_id,
                         transaction_type = "expense"
                 };
                 var catogarise = transactionApi.CategorizeAnUncategorizedTransaction(transactions[0].transaction_id, transacInfo);
                 Console.WriteLine(catogarise);
                 var creditrefundInfo = new CreditNote()
                 {
                     creditnote_id = "{credit note id}",
                     date="2014-02-07",
                     from_account_id = "{account id from which account the transaction is going to be done}",
                     amount=4000
                 };
                 var catogasCred = transactionApi.CategorizeAsCreditNoteRefunds(transactions[0].transaction_id, creditrefundInfo);
                 Console.WriteLine(catogasCred);
                 var vendordetails = new VendorPayment()
                 {
                     vendor_id = "{vendor id}",
                     amount=4000,
                     paid_through_account_id = "{account id}"
                 };
                 var vendorcat = transactionApi.CategorizeAsVendorpayment(transactions[0].transaction_id, vendordetails);
                 Console.WriteLine(vendorcat);
                 var customerinfo = new CustomerPayment()
                 {
                     customer_id = "{customer id}",
                     date="2014-02-08",
                     invoices = new List<Invoice>()
                     {
                         new Invoice(){
                             invoice_id="{invoice id}",
                             amount_applied=4000
                            }
                     },
                     amount=4000
                 };
                 var custpaycat = transactionApi.CategorizeAsCustomerPayments(transactions[0].transaction_id, customerinfo, parameters);
                 Console.WriteLine(custpaycat);
                 var expenseInfo=new Expense()
                 {
                     account_id=accounts[3].account_id,
                     date="2013-01-29",
                     paid_through_account_id = accounts[4].account_id,
                     project_id= "",
                     amount=4000,
                     tax_id="",
                     is_inclusive_tax=false,
                     is_billable=false,
                     reference_number="Ref-123",
                     description="Insurance payment",
                 };
                 var catAsExpens = transactionApi.CategorizeAsExpense(transactions[0].transaction_id, expenseInfo, @"F:\error.png");
                 Console.WriteLine(catAsExpens);
                 var uncatogorise = transactionApi.UncategorizeACategorizedTransaction(transactions[0].transaction_id);
                 Console.WriteLine(uncatogorise);
                 var vendorCreditsApi = service.GetVendorCreditsApi();
                 var vendorCredits = vendorCreditsApi.GetVendorCredits(null);
                 var refundInfo = new VendorCreditRefund()
                 {
                     vendor_credit_id=vendorCredits[0].vendor_credit_id,
                     date="2014-11-25",

                 };
                 var catAsVendorRefund = transactionApi.CategorizeAsVendorCreditRefund(transactions[0].transaction_id, refundInfo);
                 Console.WriteLine(catAsVendorRefund);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
示例#2
0
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organizationId}");
                var transactionApi = service.GetBankTransactionsApi();
                var accounts       = service.GetBankAccountsApi().GetBankAccounts(null);
                var parameters     = new Dictionary <object, object>();
                parameters.Add("filter_by", "Status.All");
                parameters.Add("account_id", accounts[0].account_id);
                Console.WriteLine("---------------------- All Transactions ----------------------");
                var transactionList = transactionApi.GetTransactions(parameters);
                var transactions    = transactionList;
                foreach (var trans in transactions)
                {
                    Console.WriteLine("{0},{1},{2}", trans.transaction_id, trans.status, trans.amount);
                }

                Console.WriteLine("---------------------- Specified Transaction ----------------------");
                var transaction = transactionApi.Get(transactions[2].transaction_id);
                Console.WriteLine("{0},{1},{2}", transaction.transaction_id, transaction.transaction_type, transaction.amount);

                Console.WriteLine("---------------------- New Transaction ----------------------");
                var newTransactionInfo = new Transaction()
                {
                    transaction_type = "transfer_fund",
                    from_account_id  = accounts[0].account_id,
                    to_account_id    = accounts[2].account_id,
                    amount           = 10
                };
                var newTransaction = transactionApi.Create(newTransactionInfo);
                Console.WriteLine("{0},{1},{2}", newTransaction.transaction_id, newTransaction.transaction_type, newTransaction.amount);

                Console.WriteLine("---------------------- Updated Transaction ----------------------");
                var updateInfo = new Transaction()
                {
                    amount           = 50,
                    currency_id      = transactionList[0].currency_id,
                    date             = "2014-02-06",
                    description      = "",
                    exchange_rate    = 1,
                    from_account_id  = accounts[0].account_id,
                    reference_number = "",
                    to_account_id    = accounts[2].account_id,
                    transaction_type = "transfer_fund"
                };
                var updatedTrans = transactionApi.Update(newTransaction.transaction_id, updateInfo);
                Console.WriteLine("{0},{1},{2}", updatedTrans.transaction_id, updatedTrans.transaction_type, updatedTrans.amount);

                Console.WriteLine("---------------------- Delete Transaction ----------------------");
                var deltrans = transactionApi.Delete(updatedTrans.transaction_id);
                Console.WriteLine(deltrans);
                var parameters1 = new Dictionary <object, object>();
                parameters1.Add("amount_start", "1");
                parameters1.Add("amount_end", "4000");
                parameters1.Add("date_start", "2014-02-01");
                parameters1.Add("date_end", "2014-02-07");

                var matchingtrans = transactionApi.GetMatchingTransactions(transactions[1].transaction_id, parameters1);

                foreach (var matchingTran in matchingtrans)
                {
                    Console.WriteLine("{0},{1},{2}", matchingTran.transaction_id, matchingTran.transaction_type, matchingTran.amount);
                }
                var parameters3 = new Dictionary <object, object>();
                parameters3.Add("account_id", accounts[1].account_id);
                TransactionsToBeMatched transtomatch = new TransactionsToBeMatched()
                {
                    transactions_to_be_matched = new List <Transaction>()
                    {
                        new Transaction()
                        {
                            transaction_id   = transactions[2].transaction_id,
                            transaction_type = "vendor_payment"
                        },
                        new Transaction()
                        {
                            transaction_id   = transactions[3].transaction_id,
                            transaction_type = "transfer_fund"
                        },
                        new Transaction()
                        {
                            transaction_id   = transactions[1].transaction_id,
                            transaction_type = "expense"
                        }
                    }
                };
                var matchtransaction = transactionApi.MatchATransaction(transactions[0].transaction_id, transtomatch);
                Console.WriteLine(matchtransaction);
                var unmatch = transactionApi.UnmatchTransaction(transactions[0].transaction_id);
                Console.WriteLine(unmatch);
                parameters.Add("sort_column", "statement_date");
                var associatedTransObj = transactionApi.GetAssociatedTransactions(transactions[0].transaction_id, null);
                var associatedTrans    = associatedTransObj.associated_transactions;
                Console.WriteLine(associatedTransObj.imported_transaction_id);
                foreach (var asociatedTran in associatedTrans)
                {
                    Console.WriteLine("{0},{1},{2}", asociatedTran.transaction_id, asociatedTran.transaction_type, asociatedTran.amount);
                }
                var exclude = transactionApi.ExcludeATransaction(transactions[0].transaction_id);
                Console.WriteLine(exclude);
                var restore = transactionApi.RestoreATransaction(transactions[0].transaction_id);
                Console.WriteLine(restore);
                var transacInfo = new Transaction()
                {
                    amount           = 4000,
                    date             = "2013-01-29",
                    description      = "Insurance payment",
                    exchange_rate    = 1,
                    from_account_id  = accounts[1].account_id,
                    reference_number = "Ref-9872",
                    to_account_id    = accounts[3].account_id,
                    transaction_type = "expense"
                };
                var catogarise = transactionApi.CategorizeAnUncategorizedTransaction(transactions[0].transaction_id, transacInfo);
                Console.WriteLine(catogarise);
                var creditrefundInfo = new CreditNote()
                {
                    creditnote_id   = "{credit note id}",
                    date            = "2014-02-07",
                    from_account_id = "{account id from which account the transaction is going to be done}",
                    amount          = 4000
                };
                var catogasCred = transactionApi.CategorizeAsCreditNoteRefunds(transactions[0].transaction_id, creditrefundInfo);
                Console.WriteLine(catogasCred);
                var vendordetails = new VendorPayment()
                {
                    vendor_id = "{vendor id}",
                    amount    = 4000,
                    paid_through_account_id = "{account id}"
                };
                var vendorcat = transactionApi.CategorizeAsVendorpayment(transactions[0].transaction_id, vendordetails);
                Console.WriteLine(vendorcat);
                var customerinfo = new CustomerPayment()
                {
                    customer_id = "{customer id}",
                    date        = "2014-02-08",
                    invoices    = new List <Invoice>()
                    {
                        new Invoice()
                        {
                            invoice_id     = "{invoice id}",
                            amount_applied = 4000
                        }
                    },
                    amount = 4000
                };
                var custpaycat = transactionApi.CategorizeAsCustomerPayments(transactions[0].transaction_id, customerinfo, parameters);
                Console.WriteLine(custpaycat);
                var expenseInfo = new Expense()
                {
                    account_id = accounts[3].account_id,
                    date       = "2013-01-29",
                    paid_through_account_id = accounts[4].account_id,
                    project_id       = "",
                    amount           = 4000,
                    tax_id           = "",
                    is_inclusive_tax = false,
                    is_billable      = false,
                    reference_number = "Ref-123",
                    description      = "Insurance payment",
                };
                var catAsExpens = transactionApi.CategorizeAsExpense(transactions[0].transaction_id, expenseInfo, @"F:\error.png");
                Console.WriteLine(catAsExpens);
                var uncatogorise = transactionApi.UncategorizeACategorizedTransaction(transactions[0].transaction_id);
                Console.WriteLine(uncatogorise);
                var vendorCreditsApi = service.GetVendorCreditsApi();
                var vendorCredits    = vendorCreditsApi.GetVendorCredits(null);
                var refundInfo       = new VendorCreditRefund()
                {
                    vendor_credit_id = vendorCredits[0].vendor_credit_id,
                    date             = "2014-11-25",
                };
                var catAsVendorRefund = transactionApi.CategorizeAsVendorCreditRefund(transactions[0].transaction_id, refundInfo);
                Console.WriteLine(catAsVendorRefund);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
示例#3
0
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var vendorCreditsApi = service.GetVendorCreditsApi();
         Console.WriteLine("--------------------VendorCreditList--------------");
         var vendorCredits = vendorCreditsApi.GetVendorCredits(null);
         foreach (var tempVendorCredit in vendorCredits)
             Console.WriteLine("Id:{0},Vendor name:{1},Status:{2}",tempVendorCredit.vendor_credit_id,tempVendorCredit.vendor_name,tempVendorCredit.status);
         Console.WriteLine("----------------------------------Specified Vendor Credit-----------------------");
         var vendorCredit = vendorCreditsApi.Get(vendorCredits[0].vendor_credit_id,null);
         Console.WriteLine("Id:{0},Vendor name:{1},Status:{2}", vendorCredit.vendor_credit_id, vendorCredit.vendor_name, vendorCredit.status);
         Console.WriteLine("Line items:");
         var lineitems = vendorCredit.line_items;
         foreach (var tempLineItem in lineitems)
             Console.WriteLine("name:{0},desc:{1},rate:{2}", tempLineItem.name, tempLineItem.description, tempLineItem.rate);
         Console.WriteLine("------------------New Vendor Credit---------");
         var newCreditInfo = new VendorCredit()
         {
             vendor_id=vendorCredit.vendor_id,
             line_items = new List<LineItem>()
             {
                 new LineItem(){
                     item_id=lineitems[0].item_id,
                     rate=360,
                 },
             },
         };
         var newVendorCredit = vendorCreditsApi.Create(newCreditInfo, null);
         Console.WriteLine("Id:{0},Vendor name:{1},Status:{2},amount:{3}", newVendorCredit.vendor_credit_id, newVendorCredit.vendor_name, newVendorCredit.status,newVendorCredit.total);
         Console.WriteLine("-------------------------Update Vendor Credit------------");
         var creditUpdateInfo = new VendorCredit()
         {
             
             line_items = new List<LineItem>()
             {
                 new LineItem(){
                     item_id=lineitems[0].item_id,
                     rate=560,
                 },
             },
         };
         var updatedVendorCredit = vendorCreditsApi.Update(newVendorCredit.vendor_credit_id, creditUpdateInfo);
         Console.WriteLine("Id:{0},Vendor name:{1},Status:{2},amount:{3}", updatedVendorCredit.vendor_credit_id, updatedVendorCredit.vendor_name, updatedVendorCredit.status, updatedVendorCredit.total);
         Console.WriteLine("-----------------------Delete Vendor Credit----------------");
         var deleteVendorcredit = vendorCreditsApi.Delete(updatedVendorCredit.vendor_credit_id);
         Console.WriteLine(deleteVendorcredit);
         Console.WriteLine("------------------Statuses----------------");
         var convertToOpen = vendorCreditsApi.ConvertToOpen(vendorCredits[0].vendor_credit_id);
         Console.WriteLine(convertToOpen);
         var markAsVoid = vendorCreditsApi.MarkAsVoid(vendorCredits[1].vendor_credit_id);
         Console.WriteLine(markAsVoid);
         Console.WriteLine("---------------------------------Bills credited-------------------------------");
         var bills = vendorCreditsApi.GetBillsCredited(vendorCredits[0].vendor_credit_id);
         foreach (var tempBill in bills)
             Console.WriteLine("Bill id:{0},vendor credit bill id:{1},amount:{2}",tempBill.bill_id,tempBill.vendor_credit_bill_id,tempBill.amount);
         var billsToApply = new ApplyToBills()
         {
             bills = new List<Bill>()
             {
                 new Bill(){
                     bill_id=bills[0].bill_id,
                     amount_applied=100
                  },
             }
         };
         var applyCredits = vendorCreditsApi.ApplyCreditsToBill(vendorCredits[0].vendor_credit_id, billsToApply);
         Console.WriteLine(applyCredits);
         var deleteBillsCredited = vendorCreditsApi.DeleteBillsCredited(vendorCredits[0].vendor_credit_id, bills[0].vendor_credit_bill_id);
         Console.WriteLine(deleteBillsCredited);
         Console.WriteLine("------------------------------------Refunds------------------------");
         var allRefunds = vendorCreditsApi.GetRefunds(null);
         foreach (var tempRefund in allRefunds)
             Console.WriteLine("Refund id:{0},vendor name:{1},amount:{2}",tempRefund.vendor_credit_refund_id,tempRefund.vendor_name,tempRefund.amount_fcy);
         var refundsOfCredit = vendorCreditsApi.GetRefundsOfVendorCredit(vendorCredits[0].vendor_credit_id);
         foreach (var tempRefund in refundsOfCredit)
             Console.WriteLine("Refund id:{0},vendor name:{1},amount:{2}", tempRefund.vendor_credit_refund_id, tempRefund.vendor_name, tempRefund.amount_fcy);
         var refund = vendorCreditsApi.GetVendorCreditRefund(vendorCredits[0].vendor_credit_id, refundsOfCredit[0].vendor_credit_refund_id);
         Console.WriteLine("Specified Refund \n Refund id:{0},vendor name:{1},amount:{2}", refund.vendor_credit_refund_id, refund.vendor_name, refund.amount);
         var newRefundInfo = new VendorCreditRefund()
         {
             date="2014-11-25",
             account_id=refund.account_id,
             amount=20
         };
         var newRefund = vendorCreditsApi.AddRefund(vendorCredits[0].vendor_credit_id, newRefundInfo);
         Console.WriteLine("New Refund \n Refund id:{0},vendor name:{1},amount:{2}", newRefund.vendor_credit_refund_id, newRefund.vendor_name, newRefund.amount);
         var updateInfo = new VendorCreditRefund()
         {
             amount = 25
         };
         var updatedRefund = vendorCreditsApi.UpdateRefund(vendorCredits[0].vendor_credit_id, newRefund.vendor_credit_refund_id, updateInfo);
         Console.WriteLine("Updated Refund \n Refund id:{0},vendor name:{1},amount:{2}", updatedRefund.vendor_credit_refund_id, updatedRefund.vendor_name, updatedRefund.amount);
         var deleteRefund = vendorCreditsApi.DeleteRefund(vendorCredits[0].vendor_credit_id, updatedRefund.vendor_credit_refund_id);
         Console.WriteLine(deleteRefund);
         Console.WriteLine("--------------------------Comments-------------------");
         var comments = vendorCreditsApi.GetComments(vendorCredits[0].vendor_credit_id);
         foreach (var comment in comments)
             Console.WriteLine("id:{0},description:{1},commented by:{2}", comment.comment_id, comment.description, comment.commented_by);
         var newCommentInfo = new Comment()
         {
             description="test comment",
         };
         var newComment = vendorCreditsApi.AddComment(vendorCredits[0].vendor_credit_id, newCommentInfo);
         Console.WriteLine("New comment \nid:{0},description:{1},commented by:{2}", newComment.comment_id, newComment.description, newComment.commented_by);
         var deleteComment = vendorCreditsApi.DeleteComment(newComment.vendor_credit_id, newComment.comment_id);
         Console.WriteLine(deleteComment);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }