Skip to content

Commit 2d00ece

Browse files
committed
Create ManualJournalLine to use instead of JournalLine
Create a separate class for ManualJournal Lines as they differ so much from JournalLine (used by Journals)
1 parent bdaf629 commit 2d00ece

6 files changed

Lines changed: 263 additions & 19 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Add the dependency to your pom.xml. Gradle, sbt and other build tools can be fo
7474
<dependency>
7575
<groupId>com.github.xeroapi</groupId>
7676
<artifactId>xero-java</artifactId>
77-
<version>2.2.5</version>
77+
<version>2.2.6</version>
7878
</dependency>
7979

8080

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.github.xeroapi</groupId>
55
<artifactId>xero-java</artifactId>
66
<packaging>jar</packaging>
7-
<version>2.2.5</version>
7+
<version>2.2.6</version>
88
<name>Xero-Java SDK</name>
99
<description>This is the official Java SDK for Xero API</description>
1010
<url>https://github.com/XeroAPI/Xero-Java</url>

src/main/java/com/xero/api/JsonConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public String getAccessTokenUrl() {
132132

133133
@Override
134134
public String getUserAgent() {
135-
return USER_AGENT + " " + CONSUMER_KEY + " [Xero-Java-2.2.5]";
135+
return USER_AGENT + " " + CONSUMER_KEY + " [Xero-Java-2.2.6]";
136136
}
137137

138138
@Override

src/main/java/com/xero/example/RequestResourceServlet.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import com.xero.models.accounting.LinkedTransaction;
7575
import com.xero.models.accounting.LinkedTransactions;
7676
import com.xero.models.accounting.ManualJournal;
77+
import com.xero.models.accounting.ManualJournalLine;
7778
import com.xero.models.accounting.ManualJournals;
7879
import com.xero.models.accounting.OnlineInvoices;
7980
import com.xero.models.accounting.Organisations;
@@ -2015,30 +2016,30 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
20152016
/* MANUAL JOURNAL */
20162017
try {
20172018
// Create Manual Journal
2018-
where = "Type==\"EXPENSE\"";
2019+
where = "Type==\"EXPENSE\" && Status ==\"ACTIVE\"";
20192020
Accounts accounts = accountingApi.getAccounts(ifModifiedSince, where, order);
20202021
String accountCode = accounts.getAccounts().get(0).getCode();
20212022
where = null;
2022-
20232023
ManualJournals manualJournals = new ManualJournals();
20242024
ManualJournal manualJournal = new ManualJournal();
20252025
LocalDate currDate = LocalDate.now();
20262026
manualJournal.setDate(currDate);
20272027
manualJournal.setNarration("Foo bar");
20282028

2029-
JournalLine credit = new JournalLine();
2030-
credit.description("Hello there");
2029+
ManualJournalLine credit = new ManualJournalLine();
2030+
credit.setDescription("Hello there");
20312031
credit.setAccountCode(accountCode);
2032-
credit.setNetAmount(100.00f);
2032+
credit.setLineAmount(100.00f);
20332033
manualJournal.addJournalLinesItem(credit);
20342034

2035-
JournalLine debit = new JournalLine();
2036-
debit.description("Goodbye");
2035+
ManualJournalLine debit = new ManualJournalLine();
2036+
debit.setDescription("Goodbye");
20372037
debit.setAccountCode(accountCode);
2038-
debit.setNetAmount(-100.00f);
2038+
debit.setLineAmount(-100.00f);
20392039
manualJournal.addJournalLinesItem(debit);
20402040
manualJournals.addManualJournalsItem(manualJournal);
20412041
ManualJournals createdManualJournals = accountingApi.createManualJournal(manualJournals);
2042+
UUID newManualJournalId = createdManualJournals.getManualJournals().get(0).getManualJournalID();
20422043
messages.add("Create Manual Journal - Narration : " + createdManualJournals.getManualJournals().get(0).getNarration());
20432044

20442045
// GET all Manual Journal
@@ -2051,13 +2052,15 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
20512052
messages.add("Get one Manual Journal - Narration : " + oneManualJournal.getManualJournals().get(0).getNarration());
20522053

20532054
// Update Manual Journal
2055+
20542056
ManualJournals updateManualJournals = new ManualJournals();
20552057
ManualJournal updateManualJournal = new ManualJournal();
2056-
updateManualJournal.setManualJournalID(manualJournalId);
2058+
updateManualJournal.setManualJournalID(newManualJournalId);
20572059
updateManualJournal.setNarration("Hello Xero");
20582060
updateManualJournals.addManualJournalsItem(updateManualJournal);
2059-
ManualJournals updatedManualJournal = accountingApi.updateManualJournal(manualJournalId,updateManualJournals);
2061+
ManualJournals updatedManualJournal = accountingApi.updateManualJournal(newManualJournalId,updateManualJournals);
20602062
messages.add("Update Manual Journal - Narration : " + updatedManualJournal.getManualJournals().get(0).getNarration());
2063+
20612064
} catch (XeroApiException e) {
20622065
System.out.println(e.getMessage());
20632066
}

src/main/java/com/xero/models/accounting/ManualJournal.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
import com.fasterxml.jackson.annotation.JsonProperty;
1919
import com.fasterxml.jackson.annotation.JsonCreator;
2020
import com.fasterxml.jackson.annotation.JsonValue;
21-
import com.xero.models.accounting.JournalLine;
2221
import com.xero.models.accounting.LineAmountTypes;
22+
import com.xero.models.accounting.ManualJournalLine;
2323
import io.swagger.annotations.ApiModel;
2424
import io.swagger.annotations.ApiModelProperty;
2525
import java.util.ArrayList;
@@ -41,7 +41,7 @@ public class ManualJournal {
4141

4242

4343
@JsonProperty("JournalLines")
44-
private List<JournalLine> journalLines = new ArrayList<JournalLine>();
44+
private List<ManualJournalLine> journalLines = new ArrayList<ManualJournalLine>();
4545

4646
@JsonDeserialize(using = com.xero.api.CustomDateDeserializer.class)
4747
@JsonProperty("Date")
@@ -132,12 +132,12 @@ public void setNarration(String narration) {
132132
this.narration = narration;
133133
}
134134

135-
public ManualJournal journalLines(List<JournalLine> journalLines) {
135+
public ManualJournal journalLines(List<ManualJournalLine> journalLines) {
136136
this.journalLines = journalLines;
137137
return this;
138138
}
139139

140-
public ManualJournal addJournalLinesItem(JournalLine journalLinesItem) {
140+
public ManualJournal addJournalLinesItem(ManualJournalLine journalLinesItem) {
141141
this.journalLines.add(journalLinesItem);
142142
return this;
143143
}
@@ -147,11 +147,11 @@ public ManualJournal addJournalLinesItem(JournalLine journalLinesItem) {
147147
* @return journalLines
148148
**/
149149
@ApiModelProperty(required = true, value = "See JournalLines")
150-
public List<JournalLine> getJournalLines() {
150+
public List<ManualJournalLine> getJournalLines() {
151151
return journalLines;
152152
}
153153

154-
public void setJournalLines(List<JournalLine> journalLines) {
154+
public void setJournalLines(List<ManualJournalLine> journalLines) {
155155
this.journalLines = journalLines;
156156
}
157157

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
/*
2+
* Accounting API
3+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
4+
*
5+
* OpenAPI spec version: 2.0.0
6+
* Contact: api@xero.com
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package com.xero.models.accounting;
15+
16+
import java.util.Objects;
17+
import java.util.Arrays;
18+
import com.fasterxml.jackson.annotation.JsonProperty;
19+
import com.fasterxml.jackson.annotation.JsonCreator;
20+
import com.fasterxml.jackson.annotation.JsonValue;
21+
import com.xero.models.accounting.TaxType;
22+
import com.xero.models.accounting.TrackingCategory;
23+
import io.swagger.annotations.ApiModel;
24+
import io.swagger.annotations.ApiModelProperty;
25+
import java.util.ArrayList;
26+
import java.util.List;
27+
28+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
29+
30+
/**
31+
* ManualJournalLine
32+
*/
33+
34+
public class ManualJournalLine {
35+
36+
@JsonProperty("LineAmount")
37+
private Float lineAmount = null;
38+
39+
40+
@JsonProperty("AccountCode")
41+
private String accountCode = null;
42+
43+
44+
@JsonProperty("Description")
45+
private String description = null;
46+
47+
48+
@JsonProperty("TaxType")
49+
private TaxType taxType = null;
50+
51+
52+
@JsonProperty("Tracking")
53+
private List<TrackingCategory> tracking = null;
54+
55+
56+
@JsonProperty("TaxAmount")
57+
private Float taxAmount = null;
58+
59+
60+
@JsonProperty("IsBlank")
61+
private Boolean isBlank = null;
62+
63+
public ManualJournalLine lineAmount(Float lineAmount) {
64+
this.lineAmount = lineAmount;
65+
return this;
66+
}
67+
68+
/**
69+
* total for line. Debits are positive, credits are negative value
70+
* @return lineAmount
71+
**/
72+
@ApiModelProperty(example = "-2569.0", value = "total for line. Debits are positive, credits are negative value")
73+
public Float getLineAmount() {
74+
return lineAmount;
75+
}
76+
77+
public void setLineAmount(Float lineAmount) {
78+
this.lineAmount = lineAmount;
79+
}
80+
81+
public ManualJournalLine accountCode(String accountCode) {
82+
this.accountCode = accountCode;
83+
return this;
84+
}
85+
86+
/**
87+
* See Accounts
88+
* @return accountCode
89+
**/
90+
@ApiModelProperty(example = "720", value = "See Accounts")
91+
public String getAccountCode() {
92+
return accountCode;
93+
}
94+
95+
public void setAccountCode(String accountCode) {
96+
this.accountCode = accountCode;
97+
}
98+
99+
public ManualJournalLine description(String description) {
100+
this.description = description;
101+
return this;
102+
}
103+
104+
/**
105+
* Description for journal line
106+
* @return description
107+
**/
108+
@ApiModelProperty(example = "Coded incorrectly Office Equipment should be Computer Equipment", value = "Description for journal line")
109+
public String getDescription() {
110+
return description;
111+
}
112+
113+
public void setDescription(String description) {
114+
this.description = description;
115+
}
116+
117+
public ManualJournalLine taxType(TaxType taxType) {
118+
this.taxType = taxType;
119+
return this;
120+
}
121+
122+
/**
123+
* Get taxType
124+
* @return taxType
125+
**/
126+
@ApiModelProperty(value = "")
127+
public TaxType getTaxType() {
128+
return taxType;
129+
}
130+
131+
public void setTaxType(TaxType taxType) {
132+
this.taxType = taxType;
133+
}
134+
135+
public ManualJournalLine tracking(List<TrackingCategory> tracking) {
136+
this.tracking = tracking;
137+
return this;
138+
}
139+
140+
public ManualJournalLine addTrackingItem(TrackingCategory trackingItem) {
141+
if (this.tracking == null) {
142+
this.tracking = new ArrayList<TrackingCategory>();
143+
}
144+
this.tracking.add(trackingItem);
145+
return this;
146+
}
147+
148+
/**
149+
* Optional Tracking Category – see Tracking. Any JournalLine can have a maximum of 2 &lt;TrackingCategory&gt; elements.
150+
* @return tracking
151+
**/
152+
@ApiModelProperty(value = "Optional Tracking Category – see Tracking. Any JournalLine can have a maximum of 2 <TrackingCategory> elements.")
153+
public List<TrackingCategory> getTracking() {
154+
return tracking;
155+
}
156+
157+
public void setTracking(List<TrackingCategory> tracking) {
158+
this.tracking = tracking;
159+
}
160+
161+
/**
162+
* The calculated tax amount based on the TaxType and LineAmount
163+
* @return taxAmount
164+
**/
165+
@ApiModelProperty(example = "0.0", value = "The calculated tax amount based on the TaxType and LineAmount")
166+
public Float getTaxAmount() {
167+
return taxAmount;
168+
}
169+
170+
public ManualJournalLine isBlank(Boolean isBlank) {
171+
this.isBlank = isBlank;
172+
return this;
173+
}
174+
175+
/**
176+
* is the line blank
177+
* @return isBlank
178+
**/
179+
@ApiModelProperty(value = "is the line blank")
180+
public Boolean getIsBlank() {
181+
return isBlank;
182+
}
183+
184+
public void setIsBlank(Boolean isBlank) {
185+
this.isBlank = isBlank;
186+
}
187+
188+
189+
@Override
190+
public boolean equals(java.lang.Object o) {
191+
if (this == o) {
192+
return true;
193+
}
194+
if (o == null || getClass() != o.getClass()) {
195+
return false;
196+
}
197+
ManualJournalLine manualJournalLine = (ManualJournalLine) o;
198+
return Objects.equals(this.lineAmount, manualJournalLine.lineAmount) &&
199+
Objects.equals(this.accountCode, manualJournalLine.accountCode) &&
200+
Objects.equals(this.description, manualJournalLine.description) &&
201+
Objects.equals(this.taxType, manualJournalLine.taxType) &&
202+
Objects.equals(this.tracking, manualJournalLine.tracking) &&
203+
Objects.equals(this.taxAmount, manualJournalLine.taxAmount) &&
204+
Objects.equals(this.isBlank, manualJournalLine.isBlank);
205+
}
206+
207+
@Override
208+
public int hashCode() {
209+
return Objects.hash(lineAmount, accountCode, description, taxType, tracking, taxAmount, isBlank);
210+
}
211+
212+
213+
@Override
214+
public String toString() {
215+
StringBuilder sb = new StringBuilder();
216+
sb.append("class ManualJournalLine {\n");
217+
218+
sb.append(" lineAmount: ").append(toIndentedString(lineAmount)).append("\n");
219+
sb.append(" accountCode: ").append(toIndentedString(accountCode)).append("\n");
220+
sb.append(" description: ").append(toIndentedString(description)).append("\n");
221+
sb.append(" taxType: ").append(toIndentedString(taxType)).append("\n");
222+
sb.append(" tracking: ").append(toIndentedString(tracking)).append("\n");
223+
sb.append(" taxAmount: ").append(toIndentedString(taxAmount)).append("\n");
224+
sb.append(" isBlank: ").append(toIndentedString(isBlank)).append("\n");
225+
sb.append("}");
226+
return sb.toString();
227+
}
228+
229+
/**
230+
* Convert the given object to string with each line indented by 4 spaces
231+
* (except the first line).
232+
*/
233+
private String toIndentedString(java.lang.Object o) {
234+
if (o == null) {
235+
return "null";
236+
}
237+
return o.toString().replace("\n", "\n ");
238+
}
239+
240+
}
241+

0 commit comments

Comments
 (0)