Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The following Endpoints are implemented based on lexoffice developer documentati
* [ ] Posting Categories Endpoint
* [ ] Profile Endpoint
* [x] Quotations
* [ ] Recurring Templates Endpoint
* [x] Recurring Templates Endpoint
* [x] Voucherlist Endpoint
* [ ] Vouchers Endpoint

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import de.focus_shift.lexoffice.java.sdk.chain.EventSubscriptionChain;
import de.focus_shift.lexoffice.java.sdk.chain.InvoiceChain;
import de.focus_shift.lexoffice.java.sdk.chain.QuotationChain;
import de.focus_shift.lexoffice.java.sdk.chain.RecurringTemplateChain;
import de.focus_shift.lexoffice.java.sdk.chain.VoucherListChain;

import java.text.DateFormat;
Expand Down Expand Up @@ -40,4 +41,8 @@ public EventSubscriptionChain eventSubscriptions() {
return new EventSubscriptionChain(context);
}

public RecurringTemplateChain recurringTemplates() {
return new RecurringTemplateChain(context);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package de.focus_shift.lexoffice.java.sdk.chain;

import de.focus_shift.lexoffice.java.sdk.RequestContext;
import de.focus_shift.lexoffice.java.sdk.model.Page;
import de.focus_shift.lexoffice.java.sdk.model.RecurringTemplate;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;

@RequiredArgsConstructor
public class RecurringTemplateChain {

private final RequestContext context;

/**
* Retrieve a single recurring template by its ID.
*
* @param id the UUID of the recurring template
* @return the RecurringTemplate
*/
public RecurringTemplate get(String id) {
return new Get(context).get(id);
}

/**
* Returns a Fetch chain for retrieving a paginated list of recurring templates.
*
* @return Fetch chain for method chaining
*/
public Fetch fetch() {
return new Fetch(context);
}

protected static class Get extends ExecutableRequestChain {
private static final ParameterizedTypeReference<RecurringTemplate> TYPE_REFERENCE =
new ParameterizedTypeReference<>() {};

public Get(RequestContext context) {
super(context, "/recurring-templates");
}

@SneakyThrows
public RecurringTemplate get(String id) {
getUriBuilder().appendPath("/" + id);
return getContext().execute(getUriBuilder(), HttpMethod.GET, TYPE_REFERENCE);
}
}

public static class Fetch extends ExecutableRequestChain {
private static final ParameterizedTypeReference<Page<RecurringTemplate>> TYPE_REFERENCE =
new ParameterizedTypeReference<>() {};

public Fetch(RequestContext context) {
super(context, "/recurring-templates");
}

/**
* Pages are zero indexed, thus providing 0 for page will return the first page.
*/
public Fetch page(int page) {
super.getUriBuilder()
.addParameter("page", String.valueOf(page));
return this;
}

/**
* Default page size is set to 25 but can be increased up to 250.
*/
public Fetch pageSize(int pageSize) {
super.getUriBuilder()
.addParameter("size", String.valueOf(pageSize));
return this;
}

/**
* Sort by createdDate in ascending or descending order.
*/
public Fetch sortByCreatedDate(boolean asc) {
super.getUriBuilder()
.addParameter("sort", String.format("createdDate,%s", asc ? "ASC" : "DESC"));
return this;
}

/**
* Sort by updatedDate in ascending or descending order.
*/
public Fetch sortByUpdatedDate(boolean asc) {
super.getUriBuilder()
.addParameter("sort", String.format("updatedDate,%s", asc ? "ASC" : "DESC"));
return this;
}

/**
* Sort by lastExecutionDate in ascending or descending order.
*/
public Fetch sortByLastExecutionDate(boolean asc) {
super.getUriBuilder()
.addParameter("sort", String.format("lastExecutionDate,%s", asc ? "ASC" : "DESC"));
return this;
}

/**
* Sort by nextExecutionDate in ascending or descending order.
*/
public Fetch sortByNextExecutionDate(boolean asc) {
super.getUriBuilder()
.addParameter("sort", String.format("nextExecutionDate,%s", asc ? "ASC" : "DESC"));
return this;
}

/**
* Generic sort method for custom sort parameters.
* Format: "property,direction" e.g., "createdDate,ASC"
*/
public Fetch sort(String sort) {
super.getUriBuilder()
.addParameter("sort", sort);
return this;
}

@SneakyThrows
public Page<RecurringTemplate> get() {
return getContext().execute(getUriBuilder(), HttpMethod.GET, TYPE_REFERENCE);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package de.focus_shift.lexoffice.java.sdk.model;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

public enum ExecutionInterval {

WEEKLY("WEEKLY"),
MONTHLY("MONTHLY"),
QUARTERLY("QUARTERLY"),
ANNUALLY("ANNUALLY");

@Getter
@JsonValue
private String value;

ExecutionInterval(String value) {
this.value = value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package de.focus_shift.lexoffice.java.sdk.model;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

public enum ExecutionStatus {

ACTIVE("ACTIVE"),
PAUSED("PAUSED"),
ENDED("ENDED");

@Getter
@JsonValue
private String value;

ExecutionStatus(String value) {
this.value = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public class PaymentConditions {
@JsonProperty("paymentTermLabel")
private String paymentTermLabel;

@JsonProperty("paymentTermLabelTemplate")
private String paymentTermLabelTemplate;

@JsonProperty("paymentTermDuration")
private Integer paymentTermDuration;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package de.focus_shift.lexoffice.java.sdk.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Singular;

import java.util.Date;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class RecurringTemplate {

@JsonProperty("id")
private String id;

@JsonProperty("organizationId")
private String organizationId;

@JsonProperty("createdDate")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
private Date createdDate;

@JsonProperty("updatedDate")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")
private Date updatedDate;

@JsonProperty("version")
private Integer version;

@JsonProperty("language")
private String language;

@JsonProperty("archived")
private boolean archived;

@JsonProperty("address")
private Address address;

@Singular
@JsonProperty("lineItems")
private List<LineItem> lineItems;

@JsonProperty("totalPrice")
private TotalPrice totalPrice;

@Singular
@JsonProperty("taxAmounts")
private List<TaxAmount> taxAmounts;

@JsonProperty("taxConditions")
private TaxConditions taxConditions;

@JsonProperty("paymentConditions")
private PaymentConditions paymentConditions;

@JsonProperty("title")
private String title;

@JsonProperty("introduction")
private String introduction;

@JsonProperty("remark")
private String remark;

@JsonProperty("recurringTemplateSettings")
private RecurringTemplateSettings recurringTemplateSettings;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package de.focus_shift.lexoffice.java.sdk.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class RecurringTemplateSettings {

@JsonProperty("id")
private String id;

@JsonProperty("startDate")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private Date startDate;

@JsonProperty("endDate")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private Date endDate;

@JsonProperty("finalize")
private Boolean finalize;

@JsonProperty("shippingType")
private ShippingType shippingType;

@JsonProperty("retroactiveInvoice")
private Boolean retroactiveInvoice;

@JsonProperty("executionInterval")
private ExecutionInterval executionInterval;

@JsonProperty("lastExecutionFailed")
private Boolean lastExecutionFailed;

@JsonProperty("lastExecutionErrorMessage")
private String lastExecutionErrorMessage;

@JsonProperty("executionStatus")
private ExecutionStatus executionStatus;

@JsonProperty("lastExecutionDate")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private Date lastExecutionDate;

@JsonProperty("nextExecutionDate")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd")
private Date nextExecutionDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ public class TaxConditions {
@JsonProperty("taxTypeNote")
private String taxTypeNote;

@JsonProperty("taxSubType")
private String taxSubType;

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ public enum TaxType {
/**
* Ausfuhrlieferungen an Drittländer
*/
THIRD_PARTY_COUNTRY_DELIVERY("thirdPartyCountryDelivery");
THIRD_PARTY_COUNTRY_DELIVERY("thirdPartyCountryDelivery"),
/**
* Photovoltaikanlagen
*/
PHOTOVOLTAIC_EQUIPMENT("photovoltaicEquipment");

@Getter
@JsonValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void exampleUsage() {
.shippingDate(new Date())
.shippingType(ShippingType.DELIVERY)
.build())
.taxConditions(new TaxConditions(TaxType.NET, ""))
.taxConditions(TaxConditions.builder().taxType(TaxType.NET).build())
.lineItems(Arrays.asList(LineItem.builder()
.type(LineItemType.CUSTOM)
.name("Name")
Expand Down
Loading