Skip to content

Commit 8eab650

Browse files
grafjomrclrchtr
authored andcommitted
add support for Recurring Templates
(cherry picked from commit 4197b90)
1 parent 44a01bb commit 8eab650

File tree

13 files changed

+593
-3
lines changed

13 files changed

+593
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The following Endpoints are implemented based on Lexware developer documentation
7575
* [ ] Posting Categories Endpoint
7676
* [ ] Profile Endpoint
7777
* [x] Quotations
78-
* [ ] Recurring Templates Endpoint
78+
* [x] Recurring Templates Endpoint
7979
* [x] Voucherlist Endpoint
8080
* [ ] Vouchers Endpoint
8181

src/main/java/de/octalog/lexware/java/sdk/LexwareApi.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import de.octalog.lexware.java.sdk.chain.EventSubscriptionChain;
55
import de.octalog.lexware.java.sdk.chain.InvoiceChain;
66
import de.octalog.lexware.java.sdk.chain.QuotationChain;
7+
import de.octalog.lexware.java.sdk.chain.RecurringTemplateChain;
78
import de.octalog.lexware.java.sdk.chain.VoucherListChain;
89

910
import java.text.DateFormat;
@@ -40,4 +41,8 @@ public EventSubscriptionChain eventSubscriptions() {
4041
return new EventSubscriptionChain(context);
4142
}
4243

44+
public RecurringTemplateChain recurringTemplates() {
45+
return new RecurringTemplateChain(context);
46+
}
47+
4348
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
package de.octalog.lexware.java.sdk.chain;
2+
3+
import de.octalog.lexware.java.sdk.RequestContext;
4+
import de.octalog.lexware.java.sdk.model.Page;
5+
import de.octalog.lexware.java.sdk.model.RecurringTemplate;
6+
import lombok.RequiredArgsConstructor;
7+
import lombok.SneakyThrows;
8+
import org.springframework.core.ParameterizedTypeReference;
9+
import org.springframework.http.HttpMethod;
10+
11+
@RequiredArgsConstructor
12+
public class RecurringTemplateChain {
13+
14+
private final RequestContext context;
15+
16+
/**
17+
* Retrieve a single recurring template by its ID.
18+
*
19+
* @param id the UUID of the recurring template
20+
* @return the RecurringTemplate
21+
*/
22+
public RecurringTemplate get(String id) {
23+
return new Get(context).get(id);
24+
}
25+
26+
/**
27+
* Returns a Fetch chain for retrieving a paginated list of recurring templates.
28+
*
29+
* @return Fetch chain for method chaining
30+
*/
31+
public Fetch fetch() {
32+
return new Fetch(context);
33+
}
34+
35+
protected static class Get extends ExecutableRequestChain {
36+
private static final ParameterizedTypeReference<RecurringTemplate> TYPE_REFERENCE =
37+
new ParameterizedTypeReference<>() {};
38+
39+
public Get(RequestContext context) {
40+
super(context, "/recurring-templates");
41+
}
42+
43+
@SneakyThrows
44+
public RecurringTemplate get(String id) {
45+
getUriBuilder().appendPath("/" + id);
46+
return getContext().execute(getUriBuilder(), HttpMethod.GET, TYPE_REFERENCE);
47+
}
48+
}
49+
50+
public static class Fetch extends ExecutableRequestChain {
51+
private static final ParameterizedTypeReference<Page<RecurringTemplate>> TYPE_REFERENCE =
52+
new ParameterizedTypeReference<>() {};
53+
54+
public Fetch(RequestContext context) {
55+
super(context, "/recurring-templates");
56+
}
57+
58+
/**
59+
* Pages are zero indexed, thus providing 0 for page will return the first page.
60+
*/
61+
public Fetch page(int page) {
62+
super.getUriBuilder()
63+
.addParameter("page", String.valueOf(page));
64+
return this;
65+
}
66+
67+
/**
68+
* Default page size is set to 25 but can be increased up to 250.
69+
*/
70+
public Fetch pageSize(int pageSize) {
71+
super.getUriBuilder()
72+
.addParameter("size", String.valueOf(pageSize));
73+
return this;
74+
}
75+
76+
/**
77+
* Sort by createdDate in ascending or descending order.
78+
*/
79+
public Fetch sortByCreatedDate(boolean asc) {
80+
super.getUriBuilder()
81+
.addParameter("sort", String.format("createdDate,%s", asc ? "ASC" : "DESC"));
82+
return this;
83+
}
84+
85+
/**
86+
* Sort by updatedDate in ascending or descending order.
87+
*/
88+
public Fetch sortByUpdatedDate(boolean asc) {
89+
super.getUriBuilder()
90+
.addParameter("sort", String.format("updatedDate,%s", asc ? "ASC" : "DESC"));
91+
return this;
92+
}
93+
94+
/**
95+
* Sort by lastExecutionDate in ascending or descending order.
96+
*/
97+
public Fetch sortByLastExecutionDate(boolean asc) {
98+
super.getUriBuilder()
99+
.addParameter("sort", String.format("lastExecutionDate,%s", asc ? "ASC" : "DESC"));
100+
return this;
101+
}
102+
103+
/**
104+
* Sort by nextExecutionDate in ascending or descending order.
105+
*/
106+
public Fetch sortByNextExecutionDate(boolean asc) {
107+
super.getUriBuilder()
108+
.addParameter("sort", String.format("nextExecutionDate,%s", asc ? "ASC" : "DESC"));
109+
return this;
110+
}
111+
112+
/**
113+
* Generic sort method for custom sort parameters.
114+
* Format: "property,direction" e.g., "createdDate,ASC"
115+
*/
116+
public Fetch sort(String sort) {
117+
super.getUriBuilder()
118+
.addParameter("sort", sort);
119+
return this;
120+
}
121+
122+
@SneakyThrows
123+
public Page<RecurringTemplate> get() {
124+
return getContext().execute(getUriBuilder(), HttpMethod.GET, TYPE_REFERENCE);
125+
}
126+
}
127+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package de.octalog.lexware.java.sdk.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonValue;
4+
import lombok.Getter;
5+
6+
public enum ExecutionInterval {
7+
8+
WEEKLY("WEEKLY"),
9+
MONTHLY("MONTHLY"),
10+
QUARTERLY("QUARTERLY"),
11+
ANNUALLY("ANNUALLY");
12+
13+
@Getter
14+
@JsonValue
15+
private String value;
16+
17+
ExecutionInterval(String value) {
18+
this.value = value;
19+
}
20+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package de.octalog.lexware.java.sdk.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonValue;
4+
import lombok.Getter;
5+
6+
public enum ExecutionStatus {
7+
8+
ACTIVE("ACTIVE"),
9+
PAUSED("PAUSED"),
10+
ENDED("ENDED");
11+
12+
@Getter
13+
@JsonValue
14+
private String value;
15+
16+
ExecutionStatus(String value) {
17+
this.value = value;
18+
}
19+
}

src/main/java/de/octalog/lexware/java/sdk/model/PaymentConditions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public class PaymentConditions {
1515
@JsonProperty("paymentTermLabel")
1616
private String paymentTermLabel;
1717

18+
@JsonProperty("paymentTermLabelTemplate")
19+
private String paymentTermLabelTemplate;
20+
1821
@JsonProperty("paymentTermDuration")
1922
private Integer paymentTermDuration;
2023

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package de.octalog.lexware.java.sdk.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonFormat;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Builder;
7+
import lombok.Data;
8+
import lombok.NoArgsConstructor;
9+
import lombok.Singular;
10+
11+
import java.util.Date;
12+
import java.util.List;
13+
14+
@Data
15+
@AllArgsConstructor
16+
@NoArgsConstructor
17+
@Builder
18+
public class RecurringTemplate {
19+
20+
@JsonProperty("id")
21+
private String id;
22+
23+
@JsonProperty("organizationId")
24+
private String organizationId;
25+
26+
@JsonProperty("createdDate")
27+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
28+
private Date createdDate;
29+
30+
@JsonProperty("updatedDate")
31+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
32+
private Date updatedDate;
33+
34+
@JsonProperty("version")
35+
private Integer version;
36+
37+
@JsonProperty("language")
38+
private String language;
39+
40+
@JsonProperty("archived")
41+
private boolean archived;
42+
43+
@JsonProperty("address")
44+
private Address address;
45+
46+
@Singular
47+
@JsonProperty("lineItems")
48+
private List<LineItem> lineItems;
49+
50+
@JsonProperty("totalPrice")
51+
private TotalPrice totalPrice;
52+
53+
@Singular
54+
@JsonProperty("taxAmounts")
55+
private List<TaxAmount> taxAmounts;
56+
57+
@JsonProperty("taxConditions")
58+
private TaxConditions taxConditions;
59+
60+
@JsonProperty("paymentConditions")
61+
private PaymentConditions paymentConditions;
62+
63+
@JsonProperty("title")
64+
private String title;
65+
66+
@JsonProperty("introduction")
67+
private String introduction;
68+
69+
@JsonProperty("remark")
70+
private String remark;
71+
72+
@JsonProperty("recurringTemplateSettings")
73+
private RecurringTemplateSettings recurringTemplateSettings;
74+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package de.octalog.lexware.java.sdk.model;
2+
3+
import com.fasterxml.jackson.annotation.JsonFormat;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Builder;
7+
import lombok.Data;
8+
import lombok.NoArgsConstructor;
9+
10+
import java.util.Date;
11+
12+
@Data
13+
@AllArgsConstructor
14+
@NoArgsConstructor
15+
@Builder
16+
public class RecurringTemplateSettings {
17+
18+
@JsonProperty("id")
19+
private String id;
20+
21+
@JsonProperty("startDate")
22+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
23+
private Date startDate;
24+
25+
@JsonProperty("endDate")
26+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
27+
private Date endDate;
28+
29+
@JsonProperty("finalize")
30+
private Boolean finalize;
31+
32+
@JsonProperty("shippingType")
33+
private ShippingType shippingType;
34+
35+
@JsonProperty("retroactiveInvoice")
36+
private Boolean retroactiveInvoice;
37+
38+
@JsonProperty("executionInterval")
39+
private ExecutionInterval executionInterval;
40+
41+
@JsonProperty("lastExecutionFailed")
42+
private Boolean lastExecutionFailed;
43+
44+
@JsonProperty("lastExecutionErrorMessage")
45+
private String lastExecutionErrorMessage;
46+
47+
@JsonProperty("executionStatus")
48+
private ExecutionStatus executionStatus;
49+
50+
@JsonProperty("lastExecutionDate")
51+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
52+
private Date lastExecutionDate;
53+
54+
@JsonProperty("nextExecutionDate")
55+
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
56+
private Date nextExecutionDate;
57+
}

src/main/java/de/octalog/lexware/java/sdk/model/TaxConditions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,7 @@ public class TaxConditions {
1818
@JsonProperty("taxTypeNote")
1919
private String taxTypeNote;
2020

21+
@JsonProperty("taxSubType")
22+
private String taxSubType;
23+
2124
}

src/main/java/de/octalog/lexware/java/sdk/model/TaxType.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ public enum TaxType {
2727
/**
2828
* Ausfuhrlieferungen an Drittländer
2929
*/
30-
THIRD_PARTY_COUNTRY_DELIVERY("thirdPartyCountryDelivery");
30+
THIRD_PARTY_COUNTRY_DELIVERY("thirdPartyCountryDelivery"),
31+
/**
32+
* Photovoltaikanlagen
33+
*/
34+
PHOTOVOLTAIC_EQUIPMENT("photovoltaicEquipment");
3135

3236
@Getter
3337
@JsonValue

0 commit comments

Comments
 (0)