From 779bc1d77c60f4e09d62f92a3d5f9927511ac1eb Mon Sep 17 00:00:00 2001 From: SidneyAllen Date: Thu, 15 Nov 2018 06:24:42 -0800 Subject: [PATCH] Fix Profit and Loss Report param The timeframe is not numeric like other reports, but a string "MONTH, QUARTER or YEAR). --- README.md | 4 ++-- pom.xml | 2 +- src/main/java/com/xero/api/JsonConfig.java | 2 +- .../com/xero/api/client/AccountingApi.java | 2 +- .../xero/example/RequestResourceServlet.java | 20 +++++++++++++------ 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 7f600671..1cda148e 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This is the official Java SDK for Xero's API. It supports accounting, fixed asse ## Migrating from version 1.0 to 2.0 of SDK -We've made some big changes to our Java SDK with version 2.0. +We've made some big changes to our Java SDK with version 2.0. All code examples in this README are for version 2.0. We've archived [code samples for version 1.0 here](https://github.com/XeroAPI/Xero-Java/tree/master/example). 2.0 implements requests and responses for accounting API endpoints using JSON only. Don't worry we won't be removing any of the existing methods for XML, but will mark them as deprecated in favor of JSON. @@ -72,7 +72,7 @@ For those using maven, add the dependency and repository to your pom.xml com.xero xero-java-sdk - 2.0.0 + 2.0.1 diff --git a/pom.xml b/pom.xml index 03f59122..9f72d367 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.xero xero-java-sdk jar - 2.0.0 + 2.0.1 Xero-Java SDK http://maven.apache.org diff --git a/src/main/java/com/xero/api/JsonConfig.java b/src/main/java/com/xero/api/JsonConfig.java index 1ac2652f..556119ca 100644 --- a/src/main/java/com/xero/api/JsonConfig.java +++ b/src/main/java/com/xero/api/JsonConfig.java @@ -131,7 +131,7 @@ public String getAccessTokenUrl() { @Override public String getUserAgent() { - return USER_AGENT + " " + CONSUMER_KEY + " [Xero-Java-2.0.0]"; + return USER_AGENT + " " + CONSUMER_KEY + " [Xero-Java-2.0.1]"; } @Override diff --git a/src/main/java/com/xero/api/client/AccountingApi.java b/src/main/java/com/xero/api/client/AccountingApi.java index 7404f67c..3c1bdbc3 100644 --- a/src/main/java/com/xero/api/client/AccountingApi.java +++ b/src/main/java/com/xero/api/client/AccountingApi.java @@ -6573,7 +6573,7 @@ public ReportWithRows getReportExecutiveSummary(String date) throws IOException * @return ReportWithRows * @throws IOException if an error occurs while attempting to invoke the API **/ - public ReportWithRows getReportProfitAndLoss(String fromDate, String toDate, BigDecimal periods, BigDecimal timeframe, String trackingCategoryID, String trackingCategoryID2, String trackingOptionID, String trackingOptionID2, Boolean standardLayout, Boolean paymentsOnly) throws IOException { + public ReportWithRows getReportProfitAndLoss(String fromDate, String toDate, BigDecimal periods, String timeframe, String trackingCategoryID, String trackingCategoryID2, String trackingOptionID, String trackingOptionID2, Boolean standardLayout, Boolean paymentsOnly) throws IOException { //, Map params try { String strBody = null; diff --git a/src/main/java/com/xero/example/RequestResourceServlet.java b/src/main/java/com/xero/example/RequestResourceServlet.java index fc0b9088..592df5fa 100755 --- a/src/main/java/com/xero/example/RequestResourceServlet.java +++ b/src/main/java/com/xero/example/RequestResourceServlet.java @@ -2215,18 +2215,21 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) System.out.println(e.getMessage()); } } else if (object.equals("Reports")) { + /* REPORTS */ + /* // TenNinetyNine - US Only String reportYear = null; Reports reports = accountingApi.getReportTenNinetyNine(reportYear); System.out.println(reports.toString()); - + */ // AgedPayablesByContact String date = null; String fromDate = null; String toDate = null; BigDecimal periods = null; BigDecimal timeframe = null; + String profitLossTimeframe = null; String trackingOptionID1 = null; String trackingOptionID2 = null; boolean standardLayout = false; @@ -2248,7 +2251,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) ReportWithRows reportBalanceSheet = accountingApi.getReportBalanceSheet(toDate, periods, timeframe, trackingOptionID1, trackingOptionID2, standardLayout, paymentsOnly); messages.add("Get a Reports - Name:" + reportBalanceSheet.getReports().get(0).getReportName()); - // reportBalanceSheet + // reportBankSummary BigDecimal period = null; ReportWithRows reportBankSummary = accountingApi.getReportBankSummary(toDate, period, timeframe); messages.add("Get a Reports - Name:" + reportBankSummary.getReports().get(0).getReportName()); @@ -2262,12 +2265,17 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) messages.add("Get a Reports - Name:" + reportExecutiveSummary.getReports().get(0).getReportName()); // reportProfitandLoss - Map reportParams = new HashMap<>(); - addToMapIfNotNull(reportParams, "fromDate", "2018-07-01"); - addToMapIfNotNull(reportParams, "toDate", "2018-09-01"); + fromDate = "2018-07-01"; + toDate = "2018-11-30"; - ReportWithRows reportProfitLoss = accountingApi.getReportProfitAndLoss(fromDate, toDate, periods, timeframe, trackingCategoryID, trackingCategoryID2, trackingOptionID, trackingOptionID2, standardLayout, paymentsOnly); + profitLossTimeframe = "MONTH"; + ReportWithRows reportProfitLoss = accountingApi.getReportProfitAndLoss(fromDate, toDate, periods, profitLossTimeframe, trackingCategoryID, trackingCategoryID2, trackingOptionID, trackingOptionID2, standardLayout, paymentsOnly); messages.add("Get a Reports - Name:" + reportProfitLoss.getReports().get(0).getReportName()); + fromDate = null; + toDate = null; + + System.out.println(reportProfitLoss.toString()); + // reportTrialBalance ReportWithRows reportTrialBalance = accountingApi.getReportTrialBalance(toDate, paymentsOnly);