Skip to content

Commit

Permalink
Fix Profit and Loss Report param
Browse files Browse the repository at this point in the history
The timeframe is not numeric like other reports, but a string "MONTH, QUARTER or YEAR).
  • Loading branch information
SidneyAllen committed Nov 15, 2018
1 parent 4d12441 commit 779bc1d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -72,7 +72,7 @@ For those using maven, add the dependency and repository to your pom.xml
<dependency>
<groupId>com.xero</groupId>
<artifactId>xero-java-sdk</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</dependency>

<repositories>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.xero</groupId>
<artifactId>xero-java-sdk</artifactId>
<packaging>jar</packaging>
<version>2.0.0</version>
<version>2.0.1</version>
<name>Xero-Java SDK</name>
<url>http://maven.apache.org</url>
<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/xero/api/JsonConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/xero/api/client/AccountingApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> params
try {
String strBody = null;
Expand Down
20 changes: 14 additions & 6 deletions src/main/java/com/xero/example/RequestResourceServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand All @@ -2262,12 +2265,17 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
messages.add("Get a Reports - Name:" + reportExecutiveSummary.getReports().get(0).getReportName());

// reportProfitandLoss
Map<String, String> 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);
Expand Down

0 comments on commit 779bc1d

Please sign in to comment.