/// <summary> /// Refund credit note amount. /// </summary> /// <param name="creditnote_id">The creditnote_id is the identifier of the crditnote.</param> /// <param name="refund_details">The refund_details is the Creditnote object which is having the refund details with date and amount parameters as mandatory.</param> /// <returns>Creditnote object.</returns> public CreditNote AddRefund(string creditnote_id, CreditNote refund_details) { string url = baseAddress + creditnote_id + "/refunds"; var json = JsonConvert.SerializeObject(refund_details); var jsonstring = new Dictionary<object, object>(); jsonstring.Add("JSONString", json); var responce = ZohoHttpClient.post(url, getQueryParameters(jsonstring)); return CreditNoteParser.getCreditnoteRefund(responce); }
/// <summary> /// Categorizes an uncategorized transaction as credit note refunds. /// </summary> /// <param name="transaction_id">The transaction_id is the identifier of the uncategorized transaction .</param> /// <param name="refund_details">The refund_details is the Creditnote object which is having the details of the refund.</param> /// <returns>System.String.<br></br>The success message is "The transaction is now categorized."</returns> public string CategorizeAsCreditNoteRefunds(string transaction_id, CreditNote refund_details) { string url = baseAddress + "/uncategorized/" + transaction_id + "/categorize/creditnoterefunds"; var json = JsonConvert.SerializeObject(refund_details); var jsonstring = new Dictionary<object, object>(); jsonstring.Add("JSONString", json); var responce = ZohoHttpClient.post(url, getQueryParameters(jsonstring)); return BankTransactionParser.getMessage(responce); }
internal static CreditNote getCreditnote(HttpResponseMessage responce) { var creditnote = new CreditNote(); var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(responce.Content.ReadAsStringAsync().Result); if (jsonObj.ContainsKey("creditnote")) { creditnote = JsonConvert.DeserializeObject<CreditNote>(jsonObj["creditnote"].ToString()); } return creditnote; }
internal static CreditNoteList getCredits(HttpResponseMessage responce) { var creditList = new CreditNoteList(); var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(responce.Content.ReadAsStringAsync().Result); if (jsonObj.ContainsKey("credits")) { var paymentsArray = JsonConvert.DeserializeObject<List<object>>(jsonObj["credits"].ToString()); foreach (var paymentObj in paymentsArray) { var credit = new CreditNote(); credit = JsonConvert.DeserializeObject<CreditNote>(paymentObj.ToString()); creditList.Add(credit); } } return creditList; }
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(); }
internal static CreditNoteList getCreditnoteList(HttpResponseMessage responce) { var creditNoteList = new CreditNoteList(); var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(responce.Content.ReadAsStringAsync().Result); if (jsonObj.ContainsKey("creditnotes")) { var creditnotesArray = JsonConvert.DeserializeObject<List<object>>(jsonObj["creditnotes"].ToString()); foreach(var creditnoteObj in creditnotesArray) { var creditnote = new CreditNote(); creditnote = JsonConvert.DeserializeObject<CreditNote>(creditnoteObj.ToString()); creditNoteList.Add(creditnote); } } if (jsonObj.ContainsKey("page_context")) { var pageContext = new PageContext(); pageContext = JsonConvert.DeserializeObject<PageContext>(jsonObj["page_context"].ToString()); creditNoteList.page_context = pageContext; } return creditNoteList; }
/// <summary> /// Updates an existing credit note. /// </summary> /// <param name="creditnote_id">The creditnote_id is the identifier of the creditnote.</param> /// <param name="update_info">The update_info is the Creditnote object which is having the updation details.</param> /// <param name="parameters">The parameters is the dictionary object which is having the optional parameters.<br></br>Those are<br></br> /// <table> /// <tr><td>ignore_auto_number_generation</td><td>Ignore auto number generation for this credit note only. On enabling this option credit note number is mandatory.</td></tr> /// </table> /// </param> /// <returns>Creditnote object.</returns> public CreditNote Update(string creditnote_id, CreditNote update_info, Dictionary<object, object> parameters) { string url = baseAddress + "/" + creditnote_id; var json = JsonConvert.SerializeObject(update_info); parameters.Add("JSONString", json); var responce = ZohoHttpClient.put(url, getQueryParameters(parameters)); return CreditNoteParser.getCreditnote(responce); }
static void Main(string[] args) { try { var service = new ZohoBooks(); service.initialize("{authtoken}", "{organization id}"); CreditNotesApi creditnoteApi = service.GetCreditNoteApi(); var parameters = new Dictionary<object, object>(); parameters.Add("creditnote_number_startswith", "CN"); parameters.Add("status", "open"); parameters.Add("total_less_than", "5000"); var creditnotesList = creditnoteApi.GetCreditnotes(parameters); var creditnotes = creditnotesList; var creditnoteId = creditnotes[0].creditnote_id; if (creditnotes != null) { foreach (var creditnote in creditnotes) Console.WriteLine("{0},{1},{2}", creditnote.creditnote_number, creditnote.total_credits_used, creditnote.total); } var parameters1 = new Dictionary<object, object>(); parameters1.Add("print", "false"); var creditnote1 = creditnoteApi.Get(creditnoteId, parameters1); if (creditnote1 != null) Console.WriteLine("{0},{1},{2}", creditnote1.creditnote_number, creditnote1.total_credits_used, creditnote1.total); var newCreditnote = new CreditNote() { customer_id = "{customer id}", creditnote_number = "CN-0008", line_items = new List<LineItem>(){ new LineItem(){ item_id="{item id}", name="Hard Drive", description="500GB, USB 2.0 interface 1400 rpm, protective hard case.", unit="", rate=120.00, quantity= 1.00, }, } }; var parameters2 = new Dictionary<object, object>(); parameters2.Add("ignore_auto_number_generation", "true"); var createdCreditnote = creditnoteApi.Create(newCreditnote, parameters2); if (createdCreditnote != null) Console.WriteLine("{0},{1},{2}", createdCreditnote.creditnote_number, createdCreditnote.total_credits_used, createdCreditnote.total); CreditNote updateInf = new CreditNote() { customer_id = "{customer id}", creditnote_number = "CN-00000", }; var parameters3 = new Dictionary<object, object>(); parameters3.Add("ignore_auto_number_generation", "true"); var updatedCreditnote = creditnoteApi.Update(creditnoteId, updateInf, parameters3); if (updatedCreditnote != null) Console.WriteLine("{0},{1},{2}", updatedCreditnote.creditnote_number, updatedCreditnote.total_credits_used, updatedCreditnote.total); var delstr = creditnoteApi.Delete(creditnotes[2].creditnote_id); Console.WriteLine(delstr); var convToOpen = creditnoteApi.ConvertToOpen(creditnoteId); Console.WriteLine(convToOpen); var voidstr = creditnoteApi.ConvertToVoid(creditnoteId); Console.WriteLine(voidstr); var parameters4 = new Dictionary<object, object>(); var emaildata = new EmailNotification() { send_from_org_email_id = false, to_mail_ids = new List<string>(){ "*****@*****.**" }, subject = "Credit Note from Zillium Inc ", body = "Dear Customer, <br><br><br><br>The credit note is attached with this email. <br><br><br><br>Credit Note Overview: \n" }; var emailstr = creditnoteApi.SendEmail(creditnoteId, emaildata, parameters4); Console.WriteLine(emailstr); var emailhstrs = creditnoteApi.GetEmailHistory(creditnoteId); if (emailhstrs != null) foreach (var emailhstr in emailhstrs) Console.WriteLine("{0},{1},{2}", emailhstr.from, emailhstr.mailhistory_id, emailhstr.to_mail_ids); var parameters5 = new Dictionary<object, object>(); var emailstmt = creditnoteApi.GetEmailContent(creditnoteId, parameters5); if (emailstmt != null) { Console.WriteLine("{0},{1},{2}", emailstmt.body, emailstmt.subject, emailstmt.file_name); } var addr = new Address() { city = "guntur", state = "AP" }; var upbilladdrstr = creditnoteApi.UpdateBillingAddress(creditnoteId, addr); Console.WriteLine(upbilladdrstr); var address = new Address() { city = "guntur", state = "AP" }; var upshipp = creditnoteApi.UpdateShippingAddress(creditnoteId, address); Console.WriteLine(upshipp); var templatesList = creditnoteApi.GetTemplates(); var templates = templatesList; if (templates != null) foreach (var template in templates) Console.WriteLine("{0},{1},{2}", template.template_id, template.template_name, template.template_type); var updtemplatestr = creditnoteApi.UpdateTemplate(creditnoteId, templates[0].template_id); Console.WriteLine(updtemplatestr); var invoicescreditedList = creditnoteApi.GetInvoicesCredited(creditnoteId); var invoicescredited = invoicescreditedList; if (invoicescredited != null) foreach (var invoicecredited in invoicescredited) Console.WriteLine("{0},{1},{2}", invoicecredited.creditnote_invoice_id, invoicecredited.credited_amount, invoicecredited.invoice_id); var applytoinvoice = new ApplyToInvoices() { invoices = new List<CreditedInvoice>(){ new CreditedInvoice(){ invoice_id="{invoice id}", amount_applied=55.00, }, } }; var creditedinvoicesInfoList = creditnoteApi.CreditToInvoices(creditnoteId, applytoinvoice); var creditedinvoicesInfo = creditedinvoicesInfoList; if (creditedinvoicesInfo != null) foreach (var creditedinvoiceInfo in creditedinvoicesInfo) Console.WriteLine("{0},{1}", creditedinvoiceInfo.invoice_id, creditedinvoiceInfo.amount_applied); var delcreditinvapplied = creditnoteApi.DeleteInvoiceCredited(creditnoteId, creditedinvoicesInfo[1].creditnote_id); Console.WriteLine(delcreditinvapplied); var parameters6 = new Dictionary<object, object>(); var creditrefunds = creditnoteApi.GetCreditnoteRefunds(parameters6); if (creditrefunds != null) foreach (var creditrefund in creditrefunds) Console.WriteLine("{0},{1},{2}", creditrefund.creditnote_refund_id, creditrefund.creditnote_number, creditrefund.amount_bcy); var creditrefundsofcrednote = creditnoteApi.GetRefundsOfCrreditnote(creditnoteId); foreach (var creditrefund in creditrefundsofcrednote) Console.WriteLine("{0},{1},{2}", creditrefund.creditnote_refund_id, creditrefund.creditnote_number, creditrefund.amount_bcy); var creditnoterefund = creditnoteApi.GetCreditnoteRefund(creditnoteId, creditrefundsofcrednote[0].creditnote_refund_id); if (creditnoterefund != null) Console.WriteLine("{0},{1},{2}", creditnoterefund.creditnote_refund_id, creditnoterefund.from_account_name, creditnoterefund.amount); var refunddetails = new CreditNote() { date = "2014-01-30", from_account_id = "{account id}", amount = 10, }; var refundedcredit = creditnoteApi.AddRefund(creditnoteId, refunddetails); if (refundedcredit != null) Console.WriteLine("{0},{1},{2}", refundedcredit.creditnote_refund_id, refundedcredit.from_account_name, refundedcredit.amount); var creditrefundupdateinfo = new CreditNote() { date = "2014-01-30", from_account_id = "{account id}", amount = 5, }; var updatedCreditrefund = creditnoteApi.UpdateRefund(creditnoteId, creditrefundsofcrednote[0].creditnote_refund_id, creditrefundupdateinfo); if (updatedCreditrefund != null) Console.WriteLine("{0},{1},{2}", updatedCreditrefund.creditnote_refund_id, updatedCreditrefund.from_account_name, updatedCreditrefund.amount); var delcrdrefstr = creditnoteApi.DeleteRefund(creditnoteId, creditrefundsofcrednote[1].creditnote_refund_id); Console.WriteLine(delcrdrefstr); var commentsList = creditnoteApi.GetcreditnoteComments(creditnoteId); var comments = commentsList; if (comments != null) foreach (var comment in comments) Console.WriteLine("{0},{1},{2}", comment.comment_id, comment.description, comment.commented_by); var newcommentinfo = new Comment() { description = "nothing" }; var newcomment = creditnoteApi.AddComment(creditnoteId, newcommentinfo); if (newcomment != null) Console.WriteLine("{0},{1},{2}", newcomment.comment_id, newcomment.description, newcomment.commented_by); var delcommentstr = creditnoteApi.DeleteComment(creditnoteId, comments[1].comment_id); Console.WriteLine(delcommentstr); } catch(Exception e) { Console.WriteLine(e.Message); } Console.ReadKey(); }