In this article, we will learn how to get a balance sheet from Quickbooks online in .NET MVC web application using SDK.

Before using any Quickbooks online API we need access token, if you don’t know how to get access token then you can find it here.

We have to query the Balance Sheet report from the QuickBooks Online Report Service for getting a balance sheet in our application.

We need to specify query parameters with the query according to our needs. some query parameters available for this report are as below.

ATTRIBUTESDESCRIPTION
customerFilters report contents to include information for specified customers. Supported Values: One or more comma-separated customer IDs as returned in the attribute, Customer.Id, of the Customer object response code.
vendorFilters report contents to include information for specified vendors. Supported Values: One or more comma-separated vendor IDs as returned in the attribute, Vendor.Id, of the Vendor object response code.
start_dateThe start date of the report, in the format YYYY-MM-DD. start_date must be less than end_date. Use if you want the report to cover an explicit date range; otherwise, use date_macro to cover a standard report date range. If a not specified value of date_macro is used
end_dateThe end date of the report, in the format YYYY-MM-DD. start_date must be less than end_date. Use if you want the report to cover an explicit date range; otherwise, use date_macro to cover a standard report date range. If a not specified value of date_macro is used
qzurlSpecifies whether Quick Zoom URL information should be generated for rows in the report. Quick Zoom URL is a hyperlink to another report containing further details about the particular column of data. Supported Values: true, false
accounting_methodThe accounting method used in the report. Supported Values: Cash, Accrual
date_macroPredefined date range. Use if you want the report to cover a standard report date range; otherwise, use the start_date and end_date to cover an explicit report date range. Supported Values: Today, Yesterday, This Week, Last Week, This Week-to-date, Last Week-to-date, Next Week, Next 4 Weeks, This Month, Last Month, This Month-to-date, Last Month-to-date, Next Month, This Fiscal Quarter, Last Fiscal Quarter, This Fiscal Quarter-to-date, Last Fiscal Quarter-to-date, Next Fiscal Quarter, This Fiscal Year, Last Fiscal Year, This Fiscal Year-to-date, Last Fiscal Year-to-date, Next Fiscal Year
adjusted_gain_lossSpecifies whether unrealized gain and losses are included in the report. Supported Values: true, false
classFilters report contents to include information for specified classes if so configured in the company file. Supported Values: One or more comma-separated class IDs as returned in the attribute, Class.Id, of the Class entity response code.
itemFilters report contents to include information for specified items. Supported Values: One or more comma-separated item IDs as returned in the attribute, Item.Id, of the Item entity response code.
sort_orderThe sort order. Supported Values: ascend, descend
summarize_column_byThe criteria by which to group the report results. Supported Values: Total, Month, Week, Days, Quarter, Year, Customers, Vendors, Classes, Departments, Employees, ProductsAndServices
departmentFilters report contents to include information for specified departments if so configured in the company file. Supported Values: One or more comma-separated department IDs as returned in the attribute, Department.Id of the Department object response code.

 

We are going to get a balance sheet report of customer and vendor by its Quickbooks customer/vendor ID. and we will show(print) it in text formatted string and also we will add download it as a text file.

Below are the few steps for getting a balance sheet report,

  1. Create a ServiceContext with Auth tokens and realmId.For that, we need access token and realmId.
    OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(Access_token);
    // Create a ServiceContext with Auth tokens and realmId
    ServiceContext serviceContext = new ServiceContext(RealmId, IntuitServicesType.QBO, oauthValidator);
    serviceContext.IppConfiguration.MinorVersion.Qbo = "23";
    serviceContext.IppConfiguration.BaseUrl.Qbo = QboBaseUrl;
    
    //JSON required for QBO Reports API
    serviceContext.IppConfiguration.Message.Response.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;
  2. Create an instance of ReportService by passing the serviceContext object created in the previous step.
    //Instantiate ReportService
    ReportService reportsService = new ReportService(serviceContext);
  3. Add all the desired query parameters for the report to the service object created in the previous step. like Customer.ID or Vendor.ID.
    //For getting Customer By ID
    reportsService.customer = 58;
    //OR
    //For getting Vendor By ID
    //reportsService.vendor = 55;
  4. Execute the report by passing the report name as a string as the attribute.we will pass “BalanceSheet” for the balance sheet report. review this Quickbooks link for a list of the attribute.
    //Execute Report API call
    Report report = reportsService.ExecuteReport("BalanceSheet");
  • The above code will return the balance sheet report of a customer which id we provided.

in this part, we learn how to get a balance sheet report for customer/vendor from Quickbooks. I have covered how to show(print) it in text formatted string and also we will add download it as a text file in Part-2.

Footer Logo

Subscribe

Select Categories