Skip to content
Closed
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
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ buildscript {
[
'fineract-api',
'fineract-core',
'fineract-validation',
'fineract-command',
'fineract-accounting',
'fineract-provider',
Expand Down Expand Up @@ -426,6 +427,9 @@ configure(project.fineractJavaProjects) {
tasks.withType(Copy) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.withType(Jar) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.withType(JavaCompile) {
options.compilerArgs += [
"-Xlint:cast",
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import static org.slf4j.LoggerFactory.*

plugins {
id 'io.spring.dependency-management' version '1.1.6'
id 'io.spring.dependency-management' version '1.1.7'
id 'groovy'
id 'java-gradle-plugin'
id 'groovy-gradle-plugin'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencyManagement {
mavenBom 'software.amazon.awssdk:bom:2.29.9'
mavenBom 'io.github.resilience4j:resilience4j-bom:2.2.0'
mavenBom 'org.testcontainers:testcontainers-bom:1.20.4'
mavenBom 'org.glassfish.jersey:jersey-bom:3.1.10'
}

dependencies {
Expand Down Expand Up @@ -117,7 +118,6 @@ dependencyManagement {
dependency 'jakarta.management.j2ee:jakarta.management.j2ee-api:1.1.4'
dependency 'jakarta.jms:jakarta.jms-api:3.1.0'
dependency 'jakarta.ws.rs:jakarta.ws.rs-api:3.1.0'
dependency 'org.glassfish.jersey.media:jersey-media-multipart:3.1.10'
dependency 'org.glassfish.jaxb:jaxb-runtime:2.3.6' // Swagger needs exactly this version
dependency 'org.apache.bval:org.apache.bval.bundle:3.0.2'
dependency 'joda-time:joda-time:2.13.1'
Expand Down Expand Up @@ -195,6 +195,8 @@ dependencyManagement {
dependency ('jakarta.xml.bind:jakarta.xml.bind-api:4.0.2') {
exclude 'jakarta.activation:jakarta.activation-api'
}
dependency 'jakarta.validation:jakarta.validation-api:3.1.1'
dependency 'org.hibernate.validator:hibernate-validator:8.0.2.Final'

dependency ('org.liquibase:liquibase-core:4.31.1') {
exclude 'javax.xml.bind:jaxb-api'
Expand Down Expand Up @@ -243,6 +245,7 @@ dependencyManagement {
dependency 'org.assertj:assertj-core:3.26.3'

dependency 'org.apache.commons:commons-math3:3.6.1'
dependency 'commons-beanutils:commons-beanutils:1.11.0'

dependency 'org.mockito:mockito-inline:5.2.0'

Expand Down
1 change: 1 addition & 0 deletions fineract-accounting/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dependencies {
'org.springframework.batch:spring-batch-integration',
'jakarta.ws.rs:jakarta.ws.rs-api',
'org.glassfish.jersey.media:jersey-media-multipart',
'org.glassfish.jersey.ext:jersey-bean-validation',

'com.google.guava:guava',
'com.google.code.gson:gson',
Expand Down
1 change: 1 addition & 0 deletions fineract-branch/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
'org.springframework.boot:spring-boot-starter-security',
'jakarta.ws.rs:jakarta.ws.rs-api',
'org.glassfish.jersey.media:jersey-media-multipart',
'org.glassfish.jersey.ext:jersey-bean-validation',

'com.google.guava:guava',
'com.google.code.gson:gson',
Expand Down
1 change: 1 addition & 0 deletions fineract-charge/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
'org.springframework.boot:spring-boot-starter-security',
'jakarta.ws.rs:jakarta.ws.rs-api',
'org.glassfish.jersey.media:jersey-media-multipart',
'org.glassfish.jersey.ext:jersey-bean-validation',

'com.google.guava:guava',
'com.google.code.gson:gson',
Expand Down
2 changes: 1 addition & 1 deletion fineract-command/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ dependencies {
'org.mapstruct:mapstruct',
'com.lmax:disruptor',
'com.ibm.icu:icu4j',
'org.yakworks:spring-icu4j',
'org.yakworks:spring-icu4j'
)
implementation('org.eclipse.persistence:org.eclipse.persistence.jpa') {
exclude group: 'org.eclipse.persistence', module: 'jakarta.persistence'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class Command<T> implements Serializable {

private UUID id;

private String idempotencyKey;

private OffsetDateTime createdAt;

private String tenantId;
Expand Down
8 changes: 5 additions & 3 deletions fineract-core/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ dependencies {
// Note that we never use 'api', because Fineract at least currently is a simple monolithic application ("WAR"), not a library.
// We also (normally should have) no need to ever use 'compileOnly'.

implementation(
project(path: ':fineract-avro-schemas')
)
implementation(project(path: ':fineract-avro-schemas'))
implementation(project(path: ':fineract-command'))
implementation(project(path: ':fineract-validation'))


// implementation dependencies are directly used (compiled against) in src/main (and src/test)
implementation(
Expand All @@ -36,6 +37,7 @@ dependencies {
'org.springframework.batch:spring-batch-integration',
'jakarta.ws.rs:jakarta.ws.rs-api',
'org.glassfish.jersey.media:jersey-media-multipart',
'org.glassfish.jersey.ext:jersey-bean-validation',
'org.apache.avro:avro',

'com.google.guava:guava',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,26 @@

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import java.util.List;
import java.util.UUID;
import java.util.function.Supplier;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.commands.service.CommandWrapperBuilder;
import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
import org.apache.fineract.infrastructure.businessdate.data.BusinessDateData;
import org.apache.fineract.infrastructure.businessdate.data.request.BusinessDateRequest;
import org.apache.fineract.command.core.CommandPipeline;
import org.apache.fineract.infrastructure.businessdate.command.BusinessDateCommand;
import org.apache.fineract.infrastructure.businessdate.data.BusinessDateResponse;
import org.apache.fineract.infrastructure.businessdate.data.BusinessDateUpdateRequest;
import org.apache.fineract.infrastructure.businessdate.service.BusinessDateReadPlatformService;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.springframework.stereotype.Component;

@RequiredArgsConstructor
Expand All @@ -52,19 +48,14 @@
@Tag(name = "Business Date Management", description = "Business date management enables you to set up, fetch and adjust organisation business dates")
public class BusinessDateApiResource {

private static final String BUSINESS_DATE = "BUSINESS_DATE";

private final PlatformSecurityContext securityContext;
private final DefaultToApiJsonSerializer<BusinessDateData> jsonSerializer;
private final BusinessDateReadPlatformService readPlatformService;
private final PortfolioCommandSourceWritePlatformService commandWritePlatformService;
private final CommandPipeline commandPipeline;

@GET
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "List all business dates", description = "")
public List<BusinessDateData> getBusinessDates() {
securityContext.authenticatedUser().validateHasReadPermission(BUSINESS_DATE);
public List<BusinessDateResponse> getBusinessDates() {
return this.readPlatformService.findAll();
}

Expand All @@ -73,23 +64,27 @@ public List<BusinessDateData> getBusinessDates() {
@Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Retrieve a specific Business date", description = "")
public BusinessDateData getBusinessDate(@PathParam("type") @Parameter(description = "type") final String type) {
securityContext.authenticatedUser().validateHasReadPermission(BUSINESS_DATE);
public BusinessDateResponse getBusinessDate(@PathParam("type") @Parameter(description = "type") final String type) {
return this.readPlatformService.findByType(type);
}

@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Update Business Date", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = BusinessDateRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = BusinessDateApiResourceSwagger.BusinessDateResponse.class))) })
public CommandProcessingResult updateBusinessDate(BusinessDateRequest businessDateRequest) {
securityContext.authenticatedUser().validateHasUpdatePermission(BUSINESS_DATE);
final CommandWrapper commandRequest = new CommandWrapperBuilder().updateBusinessDate()
.withJson(jsonSerializer.serialize(businessDateRequest)).build();
return commandWritePlatformService.logCommandSource(commandRequest);
public BusinessDateResponse updateBusinessDate(@HeaderParam("Idempotency-Key") String idempotencyKey,
@Valid BusinessDateUpdateRequest request) {

final var command = new BusinessDateCommand();

command.setId(UUID.randomUUID());
command.setIdempotencyKey(idempotencyKey);
command.setCreatedAt(DateUtils.getAuditOffsetDateTime());
command.setPayload(request);

final Supplier<BusinessDateResponse> response = commandPipeline.send(command);

return response.get();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.jobs.service.increasedateby1day;
package org.apache.fineract.infrastructure.businessdate.command;

import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.fineract.command.core.Command;
import org.apache.fineract.infrastructure.businessdate.data.BusinessDateUpdateRequest;

public interface IncreaseDateBy1DayService {

void increaseDateByTypeByOneDay(BusinessDateType businessDateType);
}
@Data
@EqualsAndHashCode(callSuper = true)
public class BusinessDateCommand extends Command<BusinessDateUpdateRequest> {}
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,43 @@
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;

@Builder
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class BusinessDateData implements Serializable {
@AllArgsConstructor
public class BusinessDateResponse implements Serializable {

@Serial
private static final long serialVersionUID = 1L;

private String description;
private String type;
private BusinessDateType type;
private LocalDate date;
private Map<BusinessDateType, LocalDate> changes;

public void addChange(final BusinessDateType businessDateType, final LocalDate date) {
if (this.changes == null) {
this.changes = new HashMap<>();
}

public static BusinessDateData instance(BusinessDateType businessDateType, LocalDate value) {
return new BusinessDateData().setType(businessDateType.getName()).setDescription(businessDateType.getDescription()).setDate(value);
changes.put(businessDateType, date);
}

public void addAllChanges(final Map<BusinessDateType, LocalDate> changes) {
if (changes == null || changes.isEmpty()) {
return;
}

for (final Map.Entry<BusinessDateType, LocalDate> entry : changes.entrySet()) {
addChange(entry.getKey(), entry.getValue());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.businessdate.data;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.io.Serial;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.fineract.infrastructure.businessdate.domain.BusinessDateType;
import org.apache.fineract.validation.constraints.LocalDate;
import org.apache.fineract.validation.constraints.Locale;

@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@LocalDate(dateField = "date", formatField = "dateFormat", localeField = "locale")
public class BusinessDateUpdateRequest implements Serializable {

@Serial
private static final long serialVersionUID = 1L;

@NotBlank(message = "{org.apache.fineract.businessdate.date-format.not-blank}")
private String dateFormat;
@NotNull(message = "{org.apache.fineract.businessdate.type.not-null}")
private BusinessDateType type;
@NotBlank(message = "{org.apache.fineract.businessdate.date.not-blank}")
private String date;
@NotBlank(message = "{org.apache.fineract.businessdate.locale.not-blank}")
@Locale
private String locale;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@
*/
package org.apache.fineract.infrastructure.businessdate.handler;

import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.command.core.Command;
import org.apache.fineract.command.core.CommandHandler;
import org.apache.fineract.infrastructure.businessdate.data.BusinessDateResponse;
import org.apache.fineract.infrastructure.businessdate.data.BusinessDateUpdateRequest;
import org.apache.fineract.infrastructure.businessdate.service.BusinessDateWritePlatformService;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Component
@RequiredArgsConstructor
@Service
@CommandType(entity = "BUSINESS_DATE", action = "UPDATE")
public class BusinessDateUpdateHandler implements NewCommandSourceHandler {
public class BusinessDateUpdateHandler implements CommandHandler<BusinessDateUpdateRequest, BusinessDateResponse> {

private final BusinessDateWritePlatformService businessDateWritePlatformService;

@Transactional
@Override
public CommandProcessingResult processCommand(@NotNull final JsonCommand command) {
return businessDateWritePlatformService.updateBusinessDate(command);
public BusinessDateResponse handle(Command<BusinessDateUpdateRequest> command) {
return businessDateWritePlatformService.updateBusinessDate(command.getPayload());
}
}
Loading
Loading