FINERACT-2437: Decrease the number of compilation warnings
This commit is contained in:
+50
-44
@@ -166,7 +166,7 @@ allprojects {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations.all {
|
configurations.configureEach {
|
||||||
resolutionStrategy {
|
resolutionStrategy {
|
||||||
dependencySubstitution {
|
dependencySubstitution {
|
||||||
// Substitution is to resolve CVE-2025-12183
|
// Substitution is to resolve CVE-2025-12183
|
||||||
@@ -392,7 +392,7 @@ configure(project.fineractJavaProjects) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add performance optimizations
|
// Add performance optimizations
|
||||||
configurations.all {
|
configurations.configureEach {
|
||||||
resolutionStrategy {
|
resolutionStrategy {
|
||||||
cacheChangingModulesFor 0, 'seconds'
|
cacheChangingModulesFor 0, 'seconds'
|
||||||
cacheDynamicVersionsFor 0, 'seconds'
|
cacheDynamicVersionsFor 0, 'seconds'
|
||||||
@@ -440,40 +440,40 @@ configure(project.fineractJavaProjects) {
|
|||||||
configurations {
|
configurations {
|
||||||
api.setCanBeResolved(true)
|
api.setCanBeResolved(true)
|
||||||
}
|
}
|
||||||
tasks.withType(Copy) {
|
tasks.withType(Copy).configureEach {
|
||||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
}
|
}
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile).configureEach {
|
||||||
options.compilerArgs += [
|
options.compilerArgs += [
|
||||||
"-Xlint:cast",
|
"-Xlint:cast",
|
||||||
"-Xlint:auxiliaryclass",
|
"-Xlint:auxiliaryclass",
|
||||||
"-Xlint:dep-ann",
|
"-Xlint:dep-ann",
|
||||||
"-Xlint:divzero",
|
"-Xlint:divzero",
|
||||||
"-Xlint:empty",
|
"-Xlint:empty",
|
||||||
"-Xlint:exports",
|
"-Xlint:exports",
|
||||||
"-Xlint:fallthrough",
|
"-Xlint:fallthrough",
|
||||||
"-Xlint:finally",
|
"-Xlint:finally",
|
||||||
"-Xlint:module",
|
"-Xlint:module",
|
||||||
"-Xlint:opens",
|
"-Xlint:opens",
|
||||||
"-Xlint:options",
|
"-Xlint:options",
|
||||||
"-Xlint:overloads",
|
"-Xlint:overloads",
|
||||||
"-Xlint:overrides",
|
"-Xlint:overrides",
|
||||||
"-Xlint:path",
|
"-Xlint:path",
|
||||||
"-Xlint:processing",
|
"-Xlint:processing",
|
||||||
"-Xlint:removal",
|
"-Xlint:removal",
|
||||||
"-Xlint:requires-automatic",
|
"-Xlint:requires-automatic",
|
||||||
"-Xlint:requires-transitive-automatic",
|
"-Xlint:requires-transitive-automatic",
|
||||||
"-Xlint:try",
|
"-Xlint:try",
|
||||||
"-Xlint:varargs",
|
"-Xlint:varargs",
|
||||||
"-Xlint:preview",
|
"-Xlint:preview",
|
||||||
"-Xlint:static",
|
"-Xlint:static",
|
||||||
// -Werror needs to be disabled because EclipseLink's static weaving doesn't generate warning-free code
|
// -Werror needs to be disabled because EclipseLink's static weaving doesn't generate warning-free code
|
||||||
// and during an IntelliJ recompilation, it fails
|
// and during an IntelliJ recompilation, it fails
|
||||||
//"-Werror",
|
//"-Werror",
|
||||||
"-Xmaxwarns",
|
"-Xmaxwarns",
|
||||||
"1500",
|
"1500",
|
||||||
"-Xmaxerrs",
|
"-Xmaxerrs",
|
||||||
"1500"
|
"1500"
|
||||||
]
|
]
|
||||||
// TODO FINERACT-959 (gradually) enable -Xlint:all (see "javac -help -X")
|
// TODO FINERACT-959 (gradually) enable -Xlint:all (see "javac -help -X")
|
||||||
|
|
||||||
@@ -759,11 +759,13 @@ configure(project.fineractJavaProjects) {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(Javadoc) {
|
tasks.withType(Javadoc).tap {
|
||||||
options.addStringOption('Xdoclint:none', '-quiet')
|
configureEach {
|
||||||
options.encoding = 'UTF-8'
|
options.addStringOption('Xdoclint:none', '-quiet')
|
||||||
// Ignore any errors during javadoc generation
|
options.encoding = 'UTF-8'
|
||||||
failOnError = false
|
// Ignore any errors during javadoc generation
|
||||||
|
failOnError = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -899,17 +901,21 @@ cyclonedxBom {
|
|||||||
includeLicenseText = true
|
includeLicenseText = true
|
||||||
}
|
}
|
||||||
|
|
||||||
task printSourceSetInformation() {
|
tasks.register('printSourceSetInformation') {
|
||||||
doLast{
|
doLast {
|
||||||
sourceSets.each { srcSet ->
|
sourceSets.each { srcSet ->
|
||||||
println "["+srcSet.name+"]"
|
println "[" + srcSet.name + "]"
|
||||||
print "-->Source directories: "+srcSet.allJava.srcDirs+"\n"
|
print "-->Source directories: " + srcSet.allJava.srcDirs + "\n"
|
||||||
print "-->Output directories: "+srcSet.output.classesDirs.files+"\n"
|
print "-->Output directories: " + srcSet.output.classesDirs.files + "\n"
|
||||||
print "-->Compile classpath:\n"
|
print "-->Compile classpath:\n"
|
||||||
srcSet.compileClasspath.files.each {
|
srcSet.compileClasspath.files.each {
|
||||||
print " "+it.path+"\n"
|
print " " + it.path + "\n"
|
||||||
}
|
}
|
||||||
println ""
|
println ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.withType(Checkstyle).configureEach {
|
||||||
|
exclude("**/*.avsc")
|
||||||
|
}
|
||||||
|
|||||||
+3
-24
@@ -28,8 +28,9 @@ import org.apache.fineract.client.models.PostEntityTypeEntityIdDocumentsResponse
|
|||||||
import org.apache.fineract.client.models.PutEntityTypeEntityIdDocumentsResponse;
|
import org.apache.fineract.client.models.PutEntityTypeEntityIdDocumentsResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class was originally generated by OpenAPI Generator (https://openapi-generator.tech), but then had to be
|
* This class was originally generated by <a href="https://openapi-generator.tech">OpenAPI Generator</a>, but then had
|
||||||
* manually edited to manually fix https://issues.apache.org/jira/browse/FINERACT-1227. If we could fix our OpenAPI /
|
* to be manually edited to manually fix
|
||||||
|
* <a href="https://issues.apache.org/jira/browse/FINERACT-1227">FINERACT-1227</a>. If we could fix our OpenAPI /
|
||||||
* Swagger YAML generation from the JAX RS and OpenAPI annotation to have the correct notation for binary document files
|
* Swagger YAML generation from the JAX RS and OpenAPI annotation to have the correct notation for binary document files
|
||||||
* and images, then this could be removed again.
|
* and images, then this could be removed again.
|
||||||
*/
|
*/
|
||||||
@@ -40,16 +41,6 @@ public interface DocumentsApiFixed {
|
|||||||
* the document description : Description of the document file : The file to be uploaded Mandatory Fields : file and
|
* the document description : Description of the document file : The file to be uploaded Mandatory Fields : file and
|
||||||
* description
|
* description
|
||||||
*
|
*
|
||||||
* @param entityType
|
|
||||||
* entityType (required)
|
|
||||||
* @param entityId
|
|
||||||
* entityId (required)
|
|
||||||
* @param file
|
|
||||||
* (required)
|
|
||||||
* @param name
|
|
||||||
* name (optional)
|
|
||||||
* @param description
|
|
||||||
* description (optional)
|
|
||||||
* @return PostEntityTypeEntityIdDocumentsResponse
|
* @return PostEntityTypeEntityIdDocumentsResponse
|
||||||
*/
|
*/
|
||||||
@RequestLine("POST /v1/{entityType}/{entityId}/documents")
|
@RequestLine("POST /v1/{entityType}/{entityId}/documents")
|
||||||
@@ -120,18 +111,6 @@ public interface DocumentsApiFixed {
|
|||||||
* Update a Document Note: A document is updated using a Multi-part form upload Body Parts name Name or summary of
|
* Update a Document Note: A document is updated using a Multi-part form upload Body Parts name Name or summary of
|
||||||
* the document description Description of the document file The file to be uploaded
|
* the document description Description of the document file The file to be uploaded
|
||||||
*
|
*
|
||||||
* @param entityType
|
|
||||||
* entityType (required)
|
|
||||||
* @param entityId
|
|
||||||
* entityId (required)
|
|
||||||
* @param documentId
|
|
||||||
* documentId (required)
|
|
||||||
* @param file
|
|
||||||
* (optional)
|
|
||||||
* @param name
|
|
||||||
* name (optional)
|
|
||||||
* @param description
|
|
||||||
* description (optional)
|
|
||||||
* @return PutEntityTypeEntityIdDocumentsResponse
|
* @return PutEntityTypeEntityIdDocumentsResponse
|
||||||
*/
|
*/
|
||||||
@RequestLine("PUT /v1/{entityType}/{entityId}/documents/{documentId}")
|
@RequestLine("PUT /v1/{entityType}/{entityId}/documents/{documentId}")
|
||||||
|
|||||||
+1
@@ -34,6 +34,7 @@ final class CommandJsonMapper {
|
|||||||
private static final String CLASS_ATTRIBUTE = "@class";
|
private static final String CLASS_ATTRIBUTE = "@class";
|
||||||
private final ObjectMapper mapper;
|
private final ObjectMapper mapper;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public <T> T map(JsonNode source) {
|
public <T> T map(JsonNode source) {
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
+5
-5
@@ -56,7 +56,7 @@ public class RetryConfigurationAssembler {
|
|||||||
|
|
||||||
public Retry getRetryConfigurationForExecuteCommand() {
|
public Retry getRetryConfigurationForExecuteCommand() {
|
||||||
Class<? extends Throwable>[] exceptionList = fineractProperties.getRetry().getInstances().getExecuteCommand().getRetryExceptions();
|
Class<? extends Throwable>[] exceptionList = fineractProperties.getRetry().getInstances().getExecuteCommand().getRetryExceptions();
|
||||||
RetryConfig.Builder configBuilder = buildCommonExecuteCommandConfiguration();
|
RetryConfig.Builder<Throwable> configBuilder = buildCommonExecuteCommandConfiguration();
|
||||||
|
|
||||||
if (exceptionList != null) {
|
if (exceptionList != null) {
|
||||||
configBuilder.retryOnException(ex -> {
|
configBuilder.retryOnException(ex -> {
|
||||||
@@ -71,7 +71,7 @@ public class RetryConfigurationAssembler {
|
|||||||
|
|
||||||
public Retry getRetryConfigurationForBatchApiWithEnclosingTransaction() {
|
public Retry getRetryConfigurationForBatchApiWithEnclosingTransaction() {
|
||||||
Class<? extends Throwable>[] exceptionList = fineractProperties.getRetry().getInstances().getExecuteCommand().getRetryExceptions();
|
Class<? extends Throwable>[] exceptionList = fineractProperties.getRetry().getInstances().getExecuteCommand().getRetryExceptions();
|
||||||
RetryConfig.Builder configBuilder = buildCommonExecuteCommandConfiguration();
|
RetryConfig.Builder<Throwable> configBuilder = buildCommonExecuteCommandConfiguration();
|
||||||
|
|
||||||
if (exceptionList != null) {
|
if (exceptionList != null) {
|
||||||
configBuilder.retryOnException(ex -> {
|
configBuilder.retryOnException(ex -> {
|
||||||
@@ -89,10 +89,10 @@ public class RetryConfigurationAssembler {
|
|||||||
return registry.retry(BATCH_RETRY, config);
|
return registry.retry(BATCH_RETRY, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RetryConfig.Builder buildCommonExecuteCommandConfiguration() {
|
private RetryConfig.Builder<Throwable> buildCommonExecuteCommandConfiguration() {
|
||||||
var props = fineractProperties.getRetry().getInstances().getExecuteCommand();
|
var props = fineractProperties.getRetry().getInstances().getExecuteCommand();
|
||||||
|
|
||||||
RetryConfig.Builder configBuilder = RetryConfig.custom().maxAttempts(props.getMaxAttempts());
|
RetryConfig.Builder<Throwable> configBuilder = RetryConfig.<Throwable>custom().maxAttempts(props.getMaxAttempts());
|
||||||
|
|
||||||
if (props.getWaitDuration() != null && props.getWaitDuration().toMillis() >= 0) {
|
if (props.getWaitDuration() != null && props.getWaitDuration().toMillis() >= 0) {
|
||||||
if (Boolean.TRUE.equals(props.getEnableExponentialBackoff())) {
|
if (Boolean.TRUE.equals(props.getEnableExponentialBackoff())) {
|
||||||
@@ -111,7 +111,7 @@ public class RetryConfigurationAssembler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Retry getRetryConfigurationForCommandResultPersistence() {
|
public Retry getRetryConfigurationForCommandResultPersistence() {
|
||||||
RetryConfig.Builder configBuilder = buildCommonExecuteCommandConfiguration();
|
RetryConfig.Builder<Throwable> configBuilder = buildCommonExecuteCommandConfiguration();
|
||||||
|
|
||||||
configBuilder.retryOnException(e -> e instanceof RuntimeException && !(e instanceof CommandResultPersistenceException));
|
configBuilder.retryOnException(e -> e instanceof RuntimeException && !(e instanceof CommandResultPersistenceException));
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -34,10 +34,12 @@ public interface ApiFacingEnum<T extends Enum<T> & ApiFacingEnum<T>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default StringEnumOptionData getValueAsStringEnumOptionData() {
|
default StringEnumOptionData getValueAsStringEnumOptionData() {
|
||||||
return new StringEnumOptionData(((Enum<T>) this).name(), getCode(), getHumanReadableName());
|
return new StringEnumOptionData(this.name(), getCode(), getHumanReadableName());
|
||||||
}
|
}
|
||||||
|
|
||||||
String getCode();
|
String getCode();
|
||||||
|
|
||||||
String getHumanReadableName();
|
String getHumanReadableName();
|
||||||
|
|
||||||
|
String name();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -540,7 +540,7 @@ public final class JsonCommand {
|
|||||||
*/
|
*/
|
||||||
public boolean booleanPrimitiveValueOfParameterNamed(final String parameterName) {
|
public boolean booleanPrimitiveValueOfParameterNamed(final String parameterName) {
|
||||||
final Boolean value = this.fromApiJsonHelper.extractBooleanNamed(parameterName, this.parsedCommand);
|
final Boolean value = this.fromApiJsonHelper.extractBooleanNamed(parameterName, this.parsedCommand);
|
||||||
return ObjectUtils.defaultIfNull(value, Boolean.FALSE);
|
return ObjectUtils.getIfNull(value, Boolean.FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isChangeInArrayParameterNamed(final String parameterName, final String[] existingValue) {
|
public boolean isChangeInArrayParameterNamed(final String parameterName, final String[] existingValue) {
|
||||||
|
|||||||
+9
-5
@@ -28,6 +28,7 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import lombok.Getter;
|
||||||
import net.fortuna.ical4j.model.property.RRule;
|
import net.fortuna.ical4j.model.property.RRule;
|
||||||
import net.fortuna.ical4j.validate.ValidationException;
|
import net.fortuna.ical4j.validate.ValidationException;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
@@ -40,6 +41,7 @@ import org.springframework.util.ObjectUtils;
|
|||||||
public class DataValidatorBuilder {
|
public class DataValidatorBuilder {
|
||||||
|
|
||||||
public static final String VALID_INPUT_SEPARATOR = "_";
|
public static final String VALID_INPUT_SEPARATOR = "_";
|
||||||
|
@Getter
|
||||||
private final List<ApiParameterError> dataValidationErrors;
|
private final List<ApiParameterError> dataValidationErrors;
|
||||||
private String resource;
|
private String resource;
|
||||||
private String parameter;
|
private String parameter;
|
||||||
@@ -78,10 +80,6 @@ public class DataValidatorBuilder {
|
|||||||
return !dataValidationErrors.isEmpty();
|
return !dataValidationErrors.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ApiParameterError> getDataValidationErrors() {
|
|
||||||
return dataValidationErrors;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataValidatorBuilder resource(final String resource) {
|
public DataValidatorBuilder resource(final String resource) {
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
return this;
|
return this;
|
||||||
@@ -629,7 +627,13 @@ public class DataValidatorBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<Object> list = (List<Object>) this.value;
|
if (!(this.value instanceof List<?> list)) {
|
||||||
|
String validationErrorCode = "validation.msg." + this.resource + "." + this.parameter + ".is.not.list";
|
||||||
|
String defaultEnglishMessage = "The parameter `" + this.parameter + "` should be a list.";
|
||||||
|
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode, defaultEnglishMessage, this.parameter);
|
||||||
|
this.dataValidationErrors.add(error);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
if (CollectionUtils.isEmpty(list)) {
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
String validationErrorCode = "validation.msg." + this.resource + "." + this.parameter + ".cannot.be.empty";
|
String validationErrorCode = "validation.msg." + this.resource + "." + this.parameter + ".cannot.be.empty";
|
||||||
String defaultEnglishMessage = "The parameter `" + this.parameter + "` cannot be empty. You must select at least one.";
|
String defaultEnglishMessage = "The parameter `" + this.parameter + "` cannot be empty. You must select at least one.";
|
||||||
|
|||||||
+2
-5
@@ -20,6 +20,7 @@ package org.apache.fineract.infrastructure.core.domain;
|
|||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.MappedSuperclass;
|
import jakarta.persistence.MappedSuperclass;
|
||||||
|
import java.io.Serial;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import org.springframework.data.domain.Auditable;
|
import org.springframework.data.domain.Auditable;
|
||||||
@@ -32,15 +33,11 @@ import org.springframework.data.jpa.domain.AbstractAuditable;
|
|||||||
* instead of LocalDateTime for created and modified.
|
* instead of LocalDateTime for created and modified.
|
||||||
*
|
*
|
||||||
* Abstract base class for auditable entities. Stores the audit values in persistent fields.
|
* Abstract base class for auditable entities. Stores the audit values in persistent fields.
|
||||||
*
|
|
||||||
* @param <U>
|
|
||||||
* the auditing type. Typically some kind of user.
|
|
||||||
* @param <PK>
|
|
||||||
* the type of the auditing type's identifier
|
|
||||||
*/
|
*/
|
||||||
@MappedSuperclass
|
@MappedSuperclass
|
||||||
public abstract class AbstractAuditableCustom extends AbstractPersistableCustom<Long> implements Auditable<Long, Long, LocalDateTime> {
|
public abstract class AbstractAuditableCustom extends AbstractPersistableCustom<Long> implements Auditable<Long, Long, LocalDateTime> {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 141481953116476081L;
|
private static final long serialVersionUID = 141481953116476081L;
|
||||||
|
|
||||||
@Column(name = "createdby_id")
|
@Column(name = "createdby_id")
|
||||||
|
|||||||
+1
-4
@@ -116,6 +116,7 @@ public final class ErrorHandler {
|
|||||||
private final DefaultExceptionMapper defaultExceptionMapper;
|
private final DefaultExceptionMapper defaultExceptionMapper;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends RuntimeException> ExceptionMapper<T> findMostSpecificExceptionHandler(T exception) {
|
public <T extends RuntimeException> ExceptionMapper<T> findMostSpecificExceptionHandler(T exception) {
|
||||||
Class<?> clazz = exception.getClass();
|
Class<?> clazz = exception.getClass();
|
||||||
do {
|
do {
|
||||||
@@ -123,23 +124,19 @@ public final class ErrorHandler {
|
|||||||
Set<String> fineractErrorMappers = createSet(ctx.getBeanNamesForType(FineractExceptionMapper.class));
|
Set<String> fineractErrorMappers = createSet(ctx.getBeanNamesForType(FineractExceptionMapper.class));
|
||||||
SetUtils.SetView<String> intersection = SetUtils.intersection(exceptionMappers, fineractErrorMappers);
|
SetUtils.SetView<String> intersection = SetUtils.intersection(exceptionMappers, fineractErrorMappers);
|
||||||
if (!intersection.isEmpty()) {
|
if (!intersection.isEmpty()) {
|
||||||
// noinspection unchecked
|
|
||||||
return (ExceptionMapper<T>) ctx.getBean(intersection.iterator().next());
|
return (ExceptionMapper<T>) ctx.getBean(intersection.iterator().next());
|
||||||
}
|
}
|
||||||
if (!exceptionMappers.isEmpty()) {
|
if (!exceptionMappers.isEmpty()) {
|
||||||
// noinspection unchecked
|
|
||||||
return (ExceptionMapper<T>) ctx.getBean(exceptionMappers.iterator().next());
|
return (ExceptionMapper<T>) ctx.getBean(exceptionMappers.iterator().next());
|
||||||
}
|
}
|
||||||
clazz = clazz.getSuperclass();
|
clazz = clazz.getSuperclass();
|
||||||
} while (!clazz.equals(Exception.class));
|
} while (!clazz.equals(Exception.class));
|
||||||
// noinspection unchecked
|
|
||||||
return (ExceptionMapper<T>) defaultExceptionMapper;
|
return (ExceptionMapper<T>) defaultExceptionMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an object of ErrorInfo type containing the information regarding the raised error.
|
* Returns an object of ErrorInfo type containing the information regarding the raised error.
|
||||||
*
|
*
|
||||||
* @param exception
|
|
||||||
* @return ErrorInfo
|
* @return ErrorInfo
|
||||||
*/
|
*/
|
||||||
public ErrorInfo handle(@NotNull RuntimeException exception) {
|
public ErrorInfo handle(@NotNull RuntimeException exception) {
|
||||||
|
|||||||
+1
-3
@@ -28,9 +28,7 @@ public interface ExternalEventProducer {
|
|||||||
* Sends the created ExternalEvents
|
* Sends the created ExternalEvents
|
||||||
*
|
*
|
||||||
* @param partitions
|
* @param partitions
|
||||||
* is a Map<Long, List<byte[]>> partitions, the key here the id of the aggregated root. The value is list
|
* The value is list of external events belong to the same key, serialized into byte array
|
||||||
* of external events belong to the same key, serialized into byte array
|
|
||||||
* @throws AcknowledgementTimeoutException
|
|
||||||
*/
|
*/
|
||||||
void sendEvents(Map<Long, List<byte[]>> partitions) throws AcknowledgementTimeoutException;
|
void sendEvents(Map<Long, List<byte[]>> partitions) throws AcknowledgementTimeoutException;
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-14
@@ -27,11 +27,9 @@ import java.util.regex.Pattern;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility to assemble the WHERE clause of an SQL query without the risk of SQL injection.
|
* Utility to assemble the WHERE clause of an SQL query without the risk of SQL injection. When using this utility
|
||||||
*
|
* instead of manually assembling SQL queries, then SqlValidator should not be required anymore. (Correctly using this
|
||||||
* <p>
|
* means only ever passing completely fixed String literals to .)
|
||||||
* When using this utility instead of manually assembling SQL queries, then {@link SqlValidator} should not be required
|
|
||||||
* anymore. (Correctly using this means only ever passing completely fixed String literals to .)
|
|
||||||
*
|
*
|
||||||
* @author Michael Vorburger <mike@vorburger.ch>
|
* @author Michael Vorburger <mike@vorburger.ch>
|
||||||
*/
|
*/
|
||||||
@@ -67,9 +65,6 @@ public class SQLBuilder {
|
|||||||
throw new IllegalArgumentException("criteria cannot be null");
|
throw new IllegalArgumentException("criteria cannot be null");
|
||||||
}
|
}
|
||||||
String trimmedCriteria = criteria.trim();
|
String trimmedCriteria = criteria.trim();
|
||||||
if (trimmedCriteria.isEmpty()) {
|
|
||||||
throw new IllegalArgumentException("criteria cannot be null");
|
|
||||||
}
|
|
||||||
if (trimmedCriteria.contains("?")) {
|
if (trimmedCriteria.contains("?")) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"criteria cannot contain a '?' (that is automatically added at the end): " + trimmedCriteria);
|
"criteria cannot contain a '?' (that is automatically added at the end): " + trimmedCriteria);
|
||||||
@@ -89,7 +84,7 @@ public class SQLBuilder {
|
|||||||
"criteria cannot contain more than 1 space (between column name and operator): " + trimmedCriteria);
|
"criteria cannot contain more than 1 space (between column name and operator): " + trimmedCriteria);
|
||||||
}
|
}
|
||||||
if (!operator.equals("=") && !operator.equals("<") && !operator.equals(">") && !operator.equals("<=") && !operator.equals(">=")
|
if (!operator.equals("=") && !operator.equals("<") && !operator.equals(">") && !operator.equals("<=") && !operator.equals(">=")
|
||||||
&& !operator.equals("<>") && !operator.equals("LIKE") && !operator.equals("like") && !operator.toLowerCase().equals("is")) {
|
&& !operator.equals("<>") && !operator.equalsIgnoreCase("like") && !operator.equalsIgnoreCase("is")) {
|
||||||
// add support for SQL's BETWEEN and IN, if/when ever needed.. (it's
|
// add support for SQL's BETWEEN and IN, if/when ever needed.. (it's
|
||||||
// a little more than just adding above, as it can have multiple
|
// a little more than just adding above, as it can have multiple
|
||||||
// arguments)
|
// arguments)
|
||||||
@@ -97,7 +92,7 @@ public class SQLBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Would be better to use SqlOperator functionality to handle
|
// TODO: Would be better to use SqlOperator functionality to handle
|
||||||
if (sb.length() > 0) {
|
if (!sb.isEmpty()) {
|
||||||
sb.append(whereLogicalOperator.getSqlStr());
|
sb.append(whereLogicalOperator.getSqlStr());
|
||||||
}
|
}
|
||||||
sb.append(trimmedCriteria);
|
sb.append(trimmedCriteria);
|
||||||
@@ -124,7 +119,7 @@ public class SQLBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addSubOperation(Consumer<SQLBuilder> subOperation) {
|
public void addSubOperation(Consumer<SQLBuilder> subOperation) {
|
||||||
if (sb.length() > 0) {
|
if (!sb.isEmpty()) {
|
||||||
sb.append(WhereLogicalOperator.AND.getSqlStr());
|
sb.append(WhereLogicalOperator.AND.getSqlStr());
|
||||||
}
|
}
|
||||||
sb.append(" ( ");
|
sb.append(" ( ");
|
||||||
@@ -138,8 +133,8 @@ public class SQLBuilder {
|
|||||||
* @return SQL WHERE clause, almost always starting with " WHERE ..." (unless no criteria, then empty)
|
* @return SQL WHERE clause, almost always starting with " WHERE ..." (unless no criteria, then empty)
|
||||||
*/
|
*/
|
||||||
public String getSQLTemplate() {
|
public String getSQLTemplate() {
|
||||||
if (sb.length() > 0) {
|
if (!sb.isEmpty()) {
|
||||||
return " WHERE " + sb.toString();
|
return " WHERE " + sb;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -178,7 +173,7 @@ public class SQLBuilder {
|
|||||||
} else if (currentArg == null) {
|
} else if (currentArg == null) {
|
||||||
whereClause.append("null");
|
whereClause.append("null");
|
||||||
} else {
|
} else {
|
||||||
whereClause.append(String.valueOf(currentArg));
|
whereClause.append(currentArg);
|
||||||
}
|
}
|
||||||
whereClause.append("]");
|
whereClause.append("]");
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-22
@@ -19,11 +19,12 @@
|
|||||||
package org.apache.fineract.portfolio.savings;
|
package org.apache.fineract.portfolio.savings;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enumeration of different options available on account closure {@link FixedDepositAccount} &
|
* An enumeration of different options available on account closure
|
||||||
* {@link RecurringDepositAccount}.
|
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public enum DepositAccountOnClosureType {
|
public enum DepositAccountOnClosureType {
|
||||||
|
|
||||||
INVALID(0, "depositAccountClosureType.invalid"), //
|
INVALID(0, "depositAccountClosureType.invalid"), //
|
||||||
@@ -40,31 +41,18 @@ public enum DepositAccountOnClosureType {
|
|||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getValue() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCode() {
|
|
||||||
return this.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DepositAccountOnClosureType fromInt(final Integer v) {
|
public static DepositAccountOnClosureType fromInt(final Integer v) {
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
return INVALID;
|
return INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (v) {
|
return switch (v) {
|
||||||
case 100:
|
case 100 -> WITHDRAW_DEPOSIT;
|
||||||
return WITHDRAW_DEPOSIT;
|
case 200 -> TRANSFER_TO_SAVINGS;
|
||||||
case 200:
|
case 300 -> REINVEST_PRINCIPAL_AND_INTEREST;
|
||||||
return TRANSFER_TO_SAVINGS;
|
case 400 -> REINVEST_PRINCIPAL_ONLY;
|
||||||
case 300:
|
default -> INVALID;
|
||||||
return REINVEST_PRINCIPAL_AND_INTEREST;
|
};
|
||||||
case 400:
|
|
||||||
return REINVEST_PRINCIPAL_ONLY;
|
|
||||||
default:
|
|
||||||
return INVALID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: why not just use the enum values... just more boilerplate code here!!
|
// TODO: why not just use the enum values... just more boilerplate code here!!
|
||||||
|
|||||||
+9
-17
@@ -18,9 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.portfolio.savings;
|
package org.apache.fineract.portfolio.savings;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enumeration of on hold transactions that can occur on a {@link SavingsAccount}.
|
* An enumeration of on hold transactions that can occur on SavingsAccount.
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public enum DepositAccountOnHoldTransactionType {
|
public enum DepositAccountOnHoldTransactionType {
|
||||||
|
|
||||||
INVALID(0, "deposutAccountOnHoldTransactionType.invalid"), //
|
INVALID(0, "deposutAccountOnHoldTransactionType.invalid"), //
|
||||||
@@ -35,27 +38,16 @@ public enum DepositAccountOnHoldTransactionType {
|
|||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getValue() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCode() {
|
|
||||||
return this.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DepositAccountOnHoldTransactionType fromInt(final Integer v) {
|
public static DepositAccountOnHoldTransactionType fromInt(final Integer v) {
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
return INVALID;
|
return INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (v) {
|
return switch (v) {
|
||||||
case 1:
|
case 1 -> HOLD;
|
||||||
return HOLD;
|
case 2 -> RELEASE;
|
||||||
case 2:
|
default -> INVALID;
|
||||||
return RELEASE;
|
};
|
||||||
default:
|
|
||||||
return INVALID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: why not just use the enum values... just more boilerplate code here!!
|
// TODO: why not just use the enum values... just more boilerplate code here!!
|
||||||
|
|||||||
+18
-33
@@ -18,11 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.portfolio.savings;
|
package org.apache.fineract.portfolio.savings;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import lombok.Getter;
|
||||||
|
import org.apache.commons.lang3.Strings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enumeration of different transactions that can occur on a {@link SavingsAccount}.
|
* An enumeration of different transactions that can occur on a SavingsAccount.
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public enum DepositAccountType {
|
public enum DepositAccountType {
|
||||||
|
|
||||||
INVALID(0, "depositAccountType.invalid"), //
|
INVALID(0, "depositAccountType.invalid"), //
|
||||||
@@ -40,31 +42,18 @@ public enum DepositAccountType {
|
|||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getValue() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCode() {
|
|
||||||
return this.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DepositAccountType fromInt(final Integer v) {
|
public static DepositAccountType fromInt(final Integer v) {
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
return INVALID;
|
return INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (v) {
|
return switch (v) {
|
||||||
case 100:
|
case 100 -> SAVINGS_DEPOSIT;
|
||||||
return SAVINGS_DEPOSIT;
|
case 200 -> FIXED_DEPOSIT;
|
||||||
case 200:
|
case 300 -> RECURRING_DEPOSIT;
|
||||||
return FIXED_DEPOSIT;
|
case 400 -> CURRENT_DEPOSIT;
|
||||||
case 300:
|
default -> INVALID;
|
||||||
return RECURRING_DEPOSIT;
|
};
|
||||||
case 400:
|
|
||||||
return CURRENT_DEPOSIT;
|
|
||||||
default:
|
|
||||||
return INVALID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: why not just use the enum values... just more boilerplate code here!!
|
// TODO: why not just use the enum values... just more boilerplate code here!!
|
||||||
@@ -94,19 +83,15 @@ public enum DepositAccountType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return StringUtils.replace(code, "_", SPACE);
|
return Strings.CS.replace(code, "_", SPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String resourceName() {
|
public String resourceName() {
|
||||||
switch (this) {
|
return switch (this) {
|
||||||
case FIXED_DEPOSIT:
|
case FIXED_DEPOSIT -> DepositsApiConstants.FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME;
|
||||||
return DepositsApiConstants.FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME;
|
case RECURRING_DEPOSIT -> DepositsApiConstants.RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME;
|
||||||
case RECURRING_DEPOSIT:
|
case SAVINGS_DEPOSIT -> DepositsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME;
|
||||||
return DepositsApiConstants.RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME;
|
default -> "INVALID";
|
||||||
case SAVINGS_DEPOSIT:
|
};
|
||||||
return DepositsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME;
|
|
||||||
default:
|
|
||||||
return "INVALID";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-9
@@ -24,10 +24,11 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import lombok.Getter;
|
||||||
import org.apache.fineract.portfolio.TransactionEntryType;
|
import org.apache.fineract.portfolio.TransactionEntryType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enumeration of different transactions that can occur on a {@link SavingsAccount}.
|
* An enumeration of different transactions that can occur on a SavingsAccount.
|
||||||
*/
|
*/
|
||||||
public enum SavingsAccountTransactionType {
|
public enum SavingsAccountTransactionType {
|
||||||
|
|
||||||
@@ -56,7 +57,9 @@ public enum SavingsAccountTransactionType {
|
|||||||
.collect(Collectors.toMap(SavingsAccountTransactionType::getValue, v -> v));
|
.collect(Collectors.toMap(SavingsAccountTransactionType::getValue, v -> v));
|
||||||
|
|
||||||
private final int value;
|
private final int value;
|
||||||
|
@Getter
|
||||||
private final String code;
|
private final String code;
|
||||||
|
@Getter
|
||||||
private final TransactionEntryType entryType;
|
private final TransactionEntryType entryType;
|
||||||
|
|
||||||
SavingsAccountTransactionType(final Integer value, final String code, TransactionEntryType entryType) {
|
SavingsAccountTransactionType(final Integer value, final String code, TransactionEntryType entryType) {
|
||||||
@@ -77,14 +80,6 @@ public enum SavingsAccountTransactionType {
|
|||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCode() {
|
|
||||||
return this.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TransactionEntryType getEntryType() {
|
|
||||||
return entryType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCreditEntryType() {
|
public boolean isCreditEntryType() {
|
||||||
return entryType != null && entryType.isCredit();
|
return entryType != null && entryType.isCredit();
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-79
@@ -23,6 +23,8 @@ import java.math.BigDecimal;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import org.apache.fineract.accounting.common.AccountingRuleType;
|
import org.apache.fineract.accounting.common.AccountingRuleType;
|
||||||
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
|
import org.apache.fineract.accounting.glaccount.data.GLAccountData;
|
||||||
import org.apache.fineract.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper;
|
import org.apache.fineract.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper;
|
||||||
@@ -38,24 +40,40 @@ import org.apache.fineract.portfolio.tax.data.TaxGroupData;
|
|||||||
*/
|
*/
|
||||||
public final class SavingsProductData implements Serializable {
|
public final class SavingsProductData implements Serializable {
|
||||||
|
|
||||||
|
@Getter
|
||||||
private final Long id;
|
private final Long id;
|
||||||
|
@Getter
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String shortName;
|
private final String shortName;
|
||||||
private final String description;
|
private final String description;
|
||||||
|
@Getter
|
||||||
private final CurrencyData currency;
|
private final CurrencyData currency;
|
||||||
|
@Getter
|
||||||
private final BigDecimal nominalAnnualInterestRate;
|
private final BigDecimal nominalAnnualInterestRate;
|
||||||
|
@Getter
|
||||||
private final EnumOptionData interestCompoundingPeriodType;
|
private final EnumOptionData interestCompoundingPeriodType;
|
||||||
|
@Getter
|
||||||
private final EnumOptionData interestPostingPeriodType;
|
private final EnumOptionData interestPostingPeriodType;
|
||||||
|
@Getter
|
||||||
private final EnumOptionData interestCalculationType;
|
private final EnumOptionData interestCalculationType;
|
||||||
|
@Getter
|
||||||
private final EnumOptionData interestCalculationDaysInYearType;
|
private final EnumOptionData interestCalculationDaysInYearType;
|
||||||
|
@Getter
|
||||||
private final BigDecimal minRequiredOpeningBalance;
|
private final BigDecimal minRequiredOpeningBalance;
|
||||||
|
@Getter
|
||||||
private final Integer lockinPeriodFrequency;
|
private final Integer lockinPeriodFrequency;
|
||||||
|
@Getter
|
||||||
private final EnumOptionData lockinPeriodFrequencyType;
|
private final EnumOptionData lockinPeriodFrequencyType;
|
||||||
|
@Getter
|
||||||
private final boolean withdrawalFeeForTransfers;
|
private final boolean withdrawalFeeForTransfers;
|
||||||
|
@Getter
|
||||||
private final boolean allowOverdraft;
|
private final boolean allowOverdraft;
|
||||||
|
@Getter
|
||||||
private final BigDecimal overdraftLimit;
|
private final BigDecimal overdraftLimit;
|
||||||
|
@Getter
|
||||||
private final BigDecimal minRequiredBalance;
|
private final BigDecimal minRequiredBalance;
|
||||||
private final boolean enforceMinRequiredBalance;
|
private final boolean enforceMinRequiredBalance;
|
||||||
|
@Getter
|
||||||
private final BigDecimal maxAllowedLienLimit;
|
private final BigDecimal maxAllowedLienLimit;
|
||||||
private final boolean lienAllowed;
|
private final boolean lienAllowed;
|
||||||
private final BigDecimal minBalanceForInterestCalculation;
|
private final BigDecimal minBalanceForInterestCalculation;
|
||||||
@@ -63,6 +81,8 @@ public final class SavingsProductData implements Serializable {
|
|||||||
private final BigDecimal minOverdraftForInterestCalculation;
|
private final BigDecimal minOverdraftForInterestCalculation;
|
||||||
private final boolean withHoldTax;
|
private final boolean withHoldTax;
|
||||||
private final TaxGroupData taxGroup;
|
private final TaxGroupData taxGroup;
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
private String depositAccountType = null;
|
private String depositAccountType = null;
|
||||||
private final String accountMappingForPayment;
|
private final String accountMappingForPayment;
|
||||||
|
|
||||||
@@ -171,10 +191,6 @@ public final class SavingsProductData implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Returns a {@link SavingsProductData} that contains and exist {@link SavingsProductData} data with further
|
* Returns a {@link SavingsProductData} that contains and exist {@link SavingsProductData} data with further
|
||||||
* template data for dropdowns.
|
* template data for dropdowns.
|
||||||
*
|
|
||||||
* @param taxGroupOptions
|
|
||||||
* TODO
|
|
||||||
* @param accountMapping
|
|
||||||
*/
|
*/
|
||||||
public static SavingsProductData withTemplate(final SavingsProductData existingProduct, final Collection<CurrencyData> currencyOptions,
|
public static SavingsProductData withTemplate(final SavingsProductData existingProduct, final Collection<CurrencyData> currencyOptions,
|
||||||
final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions,
|
final Collection<EnumOptionData> interestCompoundingPeriodTypeOptions,
|
||||||
@@ -220,7 +236,6 @@ public final class SavingsProductData implements Serializable {
|
|||||||
final Map<String, List<GLAccountData>> accountingMappingOptions = null;
|
final Map<String, List<GLAccountData>> accountingMappingOptions = null;
|
||||||
final Collection<ChargeData> chargeOptions = null;
|
final Collection<ChargeData> chargeOptions = null;
|
||||||
final Collection<ChargeData> penaltyOptions = null;
|
final Collection<ChargeData> penaltyOptions = null;
|
||||||
final String accountMappingForPayment = null;
|
|
||||||
|
|
||||||
return new SavingsProductData(existingProduct.id, existingProduct.name, existingProduct.shortName, existingProduct.description,
|
return new SavingsProductData(existingProduct.id, existingProduct.name, existingProduct.shortName, existingProduct.description,
|
||||||
existingProduct.currency, existingProduct.nominalAnnualInterestRate, existingProduct.interestCompoundingPeriodType,
|
existingProduct.currency, existingProduct.nominalAnnualInterestRate, existingProduct.interestCompoundingPeriodType,
|
||||||
@@ -505,10 +520,9 @@ public final class SavingsProductData implements Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (!(obj instanceof SavingsProductData)) {
|
if (!(obj instanceof SavingsProductData productData)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final SavingsProductData productData = (SavingsProductData) obj;
|
|
||||||
return productData.id.compareTo(this.id) == 0;
|
return productData.id.compareTo(this.id) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,78 +531,6 @@ public final class SavingsProductData implements Serializable {
|
|||||||
return this.id.hashCode();
|
return this.id.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDepositAccountType() {
|
|
||||||
return depositAccountType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDepositAccountType(String depositAccountType) {
|
|
||||||
this.depositAccountType = depositAccountType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getNominalAnnualInterestRate() {
|
|
||||||
return nominalAnnualInterestRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CurrencyData getCurrency() {
|
|
||||||
return currency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getLockinPeriodFrequency() {
|
|
||||||
return lockinPeriodFrequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EnumOptionData getLockinPeriodFrequencyType() {
|
|
||||||
return lockinPeriodFrequencyType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getOverdraftLimit() {
|
|
||||||
return overdraftLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getMinRequiredOpeningBalance() {
|
|
||||||
return minRequiredOpeningBalance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EnumOptionData getInterestCompoundingPeriodType() {
|
|
||||||
return interestCompoundingPeriodType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EnumOptionData getInterestPostingPeriodType() {
|
|
||||||
return interestPostingPeriodType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EnumOptionData getInterestCalculationType() {
|
|
||||||
return interestCalculationType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EnumOptionData getInterestCalculationDaysInYearType() {
|
|
||||||
return interestCalculationDaysInYearType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAllowOverdraft() {
|
|
||||||
return allowOverdraft;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getMinRequiredBalance() {
|
|
||||||
return minRequiredBalance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BigDecimal getMaxAllowedLienLimit() {
|
|
||||||
return maxAllowedLienLimit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isWithdrawalFeeForTransfers() {
|
|
||||||
return withdrawalFeeForTransfers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCashBasedAccountingEnabled() {
|
public boolean isCashBasedAccountingEnabled() {
|
||||||
return AccountingRuleType.CASH_BASED.getValue().toString().equals(this.accountingRule.getValue());
|
return AccountingRuleType.CASH_BASED.getValue().toString().equals(this.accountingRule.getValue());
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-44
@@ -18,9 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.portfolio.savings.domain;
|
package org.apache.fineract.portfolio.savings.domain;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum representation of {@link SavingsAccount} status states.
|
* Enum representation of SavingsAccount status states.
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public enum SavingsAccountStatusType {
|
public enum SavingsAccountStatusType {
|
||||||
|
|
||||||
INVALID(0, "savingsAccountStatusType.invalid"), //
|
INVALID(0, "savingsAccountStatusType.invalid"), //
|
||||||
@@ -39,41 +42,19 @@ public enum SavingsAccountStatusType {
|
|||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
public static SavingsAccountStatusType fromInt(final Integer type) {
|
public static SavingsAccountStatusType fromInt(final Integer type) {
|
||||||
|
return switch (type) {
|
||||||
SavingsAccountStatusType enumeration = SavingsAccountStatusType.INVALID;
|
case 100 -> SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL;
|
||||||
switch (type) {
|
case 200 -> SavingsAccountStatusType.APPROVED;
|
||||||
case 100:
|
case 300 -> SavingsAccountStatusType.ACTIVE;
|
||||||
enumeration = SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL;
|
case 303 -> SavingsAccountStatusType.TRANSFER_IN_PROGRESS;
|
||||||
break;
|
case 304 -> SavingsAccountStatusType.TRANSFER_ON_HOLD;
|
||||||
case 200:
|
case 400 -> SavingsAccountStatusType.WITHDRAWN_BY_APPLICANT;
|
||||||
enumeration = SavingsAccountStatusType.APPROVED;
|
case 500 -> SavingsAccountStatusType.REJECTED;
|
||||||
break;
|
case 600 -> SavingsAccountStatusType.CLOSED;
|
||||||
case 300:
|
case 700 -> SavingsAccountStatusType.PRE_MATURE_CLOSURE;
|
||||||
enumeration = SavingsAccountStatusType.ACTIVE;
|
case 800 -> SavingsAccountStatusType.MATURED;
|
||||||
break;
|
default -> SavingsAccountStatusType.INVALID;
|
||||||
case 303:
|
};
|
||||||
enumeration = SavingsAccountStatusType.TRANSFER_IN_PROGRESS;
|
|
||||||
break;
|
|
||||||
case 304:
|
|
||||||
enumeration = SavingsAccountStatusType.TRANSFER_ON_HOLD;
|
|
||||||
break;
|
|
||||||
case 400:
|
|
||||||
enumeration = SavingsAccountStatusType.WITHDRAWN_BY_APPLICANT;
|
|
||||||
break;
|
|
||||||
case 500:
|
|
||||||
enumeration = SavingsAccountStatusType.REJECTED;
|
|
||||||
break;
|
|
||||||
case 600:
|
|
||||||
enumeration = SavingsAccountStatusType.CLOSED;
|
|
||||||
break;
|
|
||||||
case 700:
|
|
||||||
enumeration = SavingsAccountStatusType.PRE_MATURE_CLOSURE;
|
|
||||||
break;
|
|
||||||
case 800:
|
|
||||||
enumeration = SavingsAccountStatusType.MATURED;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return enumeration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SavingsAccountStatusType(final Integer value, final String code) {
|
SavingsAccountStatusType(final Integer value, final String code) {
|
||||||
@@ -85,14 +66,6 @@ public enum SavingsAccountStatusType {
|
|||||||
return this.value.equals(state.getValue());
|
return this.value.equals(state.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getValue() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCode() {
|
|
||||||
return this.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSubmittedAndPendingApproval() {
|
public boolean isSubmittedAndPendingApproval() {
|
||||||
return this.value.equals(SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL.getValue());
|
return this.value.equals(SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL.getValue());
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-29
@@ -18,9 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.portfolio.savings.domain;
|
package org.apache.fineract.portfolio.savings.domain;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum representation of {@link SavingsAccount} sub-status states.
|
* Enum representation of SavingsAccount sub-status states.
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public enum SavingsAccountSubStatusEnum {
|
public enum SavingsAccountSubStatusEnum {
|
||||||
|
|
||||||
NONE(0, "SavingsAccountSubStatusEnum.none"), //
|
NONE(0, "SavingsAccountSubStatusEnum.none"), //
|
||||||
@@ -38,26 +41,15 @@ public enum SavingsAccountSubStatusEnum {
|
|||||||
|
|
||||||
SavingsAccountSubStatusEnum enumeration = SavingsAccountSubStatusEnum.NONE;
|
SavingsAccountSubStatusEnum enumeration = SavingsAccountSubStatusEnum.NONE;
|
||||||
if (null != type) {
|
if (null != type) {
|
||||||
switch (type) {
|
enumeration = switch (type) {
|
||||||
case 100:
|
case 100 -> SavingsAccountSubStatusEnum.INACTIVE;
|
||||||
enumeration = SavingsAccountSubStatusEnum.INACTIVE;
|
case 200 -> SavingsAccountSubStatusEnum.DORMANT;
|
||||||
break;
|
case 300 -> SavingsAccountSubStatusEnum.ESCHEAT;
|
||||||
case 200:
|
case 400 -> SavingsAccountSubStatusEnum.BLOCK;
|
||||||
enumeration = SavingsAccountSubStatusEnum.DORMANT;
|
case 500 -> SavingsAccountSubStatusEnum.BLOCK_CREDIT;
|
||||||
break;
|
case 600 -> SavingsAccountSubStatusEnum.BLOCK_DEBIT;
|
||||||
case 300:
|
default -> enumeration;
|
||||||
enumeration = SavingsAccountSubStatusEnum.ESCHEAT;
|
};
|
||||||
break;
|
|
||||||
case 400:
|
|
||||||
enumeration = SavingsAccountSubStatusEnum.BLOCK;
|
|
||||||
break;
|
|
||||||
case 500:
|
|
||||||
enumeration = SavingsAccountSubStatusEnum.BLOCK_CREDIT;
|
|
||||||
break;
|
|
||||||
case 600:
|
|
||||||
enumeration = SavingsAccountSubStatusEnum.BLOCK_DEBIT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return enumeration;
|
return enumeration;
|
||||||
}
|
}
|
||||||
@@ -71,14 +63,6 @@ public enum SavingsAccountSubStatusEnum {
|
|||||||
return this.value.equals(state.getValue());
|
return this.value.equals(state.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getValue() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCode() {
|
|
||||||
return this.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSubStatusInactive() {
|
public boolean isSubStatusInactive() {
|
||||||
return this.value.equals(SavingsAccountSubStatusEnum.INACTIVE.getValue());
|
return this.value.equals(SavingsAccountSubStatusEnum.INACTIVE.getValue());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -26,8 +26,7 @@ import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionData;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapper for dealing with side-effect free functionality related to a {@link SavingsAccount}'s
|
* A wrapper for dealing with side-effect free functionality related to a SavingsAccountTransaction.
|
||||||
* {@link SavingsAccountTransaction}'s.
|
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public final class SavingsAccountTransactionDataSummaryWrapper {
|
public final class SavingsAccountTransactionDataSummaryWrapper {
|
||||||
|
|||||||
+13
-10
@@ -21,7 +21,6 @@ package org.apache.fineract.investor.service;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
@@ -42,6 +41,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
|||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.Arguments;
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
import org.mockito.ArgumentMatchers;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
@@ -64,9 +64,9 @@ public class ExternalAssetOwnerLoanProductAttributesReadServiceTest {
|
|||||||
|
|
||||||
private ExternalAssetOwnerLoanProductAttributesReadService underTest;
|
private ExternalAssetOwnerLoanProductAttributesReadService underTest;
|
||||||
|
|
||||||
private int offset = 0;
|
private static final int OFFSET = 0;
|
||||||
|
|
||||||
private int limit = 100;
|
private static final int LIMIT = 100;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -80,11 +80,12 @@ public class ExternalAssetOwnerLoanProductAttributesReadServiceTest {
|
|||||||
// given
|
// given
|
||||||
ExternalAssetOwnerLoanProductAttributes attributes = Mockito.mock(ExternalAssetOwnerLoanProductAttributes.class);
|
ExternalAssetOwnerLoanProductAttributes attributes = Mockito.mock(ExternalAssetOwnerLoanProductAttributes.class);
|
||||||
ExternalTransferLoanProductAttributesData data = Mockito.mock(ExternalTransferLoanProductAttributesData.class);
|
ExternalTransferLoanProductAttributesData data = Mockito.mock(ExternalTransferLoanProductAttributesData.class);
|
||||||
PageRequest pageRequest = PageRequest.of(offset, limit, Sort.by("id").ascending());
|
PageRequest pageRequest = PageRequest.of(OFFSET, LIMIT, Sort.by("id").ascending());
|
||||||
org.springframework.data.domain.Page<ExternalAssetOwnerLoanProductAttributes> attributesPage = new PageImpl<>(List.of(attributes),
|
org.springframework.data.domain.Page<ExternalAssetOwnerLoanProductAttributes> attributesPage = new PageImpl<>(List.of(attributes),
|
||||||
pageRequest, 1);
|
pageRequest, 1);
|
||||||
|
|
||||||
when(externalAssetOwnerLoanProductAttributesRepository.findAll(any(Specification.class), eq(pageRequest)))
|
when(externalAssetOwnerLoanProductAttributesRepository
|
||||||
|
.findAll(ArgumentMatchers.<Specification<ExternalAssetOwnerLoanProductAttributes>>any(), eq(pageRequest)))
|
||||||
.thenReturn(attributesPage);
|
.thenReturn(attributesPage);
|
||||||
when(loanProductRepository.existsById(loanProductId)).thenReturn(true);
|
when(loanProductRepository.existsById(loanProductId)).thenReturn(true);
|
||||||
when(mapper.mapLoanProductAttributes(attributes)).thenReturn(data);
|
when(mapper.mapLoanProductAttributes(attributes)).thenReturn(data);
|
||||||
@@ -95,7 +96,7 @@ public class ExternalAssetOwnerLoanProductAttributesReadServiceTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(1, result.getTotalFilteredRecords());
|
assertEquals(1, result.getTotalFilteredRecords());
|
||||||
assertEquals(data, result.getPageItems().get(0));
|
assertEquals(data, result.getPageItems().getFirst());
|
||||||
verify(loanProductRepository, times(1)).existsById(loanProductId);
|
verify(loanProductRepository, times(1)).existsById(loanProductId);
|
||||||
verify(mapper, times(1)).mapLoanProductAttributes(attributes);
|
verify(mapper, times(1)).mapLoanProductAttributes(attributes);
|
||||||
}
|
}
|
||||||
@@ -105,11 +106,12 @@ public class ExternalAssetOwnerLoanProductAttributesReadServiceTest {
|
|||||||
// given
|
// given
|
||||||
Long loanProductId = 1L;
|
Long loanProductId = 1L;
|
||||||
ExternalAssetOwnerLoanProductAttributes attributes = Mockito.mock(ExternalAssetOwnerLoanProductAttributes.class);
|
ExternalAssetOwnerLoanProductAttributes attributes = Mockito.mock(ExternalAssetOwnerLoanProductAttributes.class);
|
||||||
PageRequest pageRequest = PageRequest.of(offset, limit, Sort.by("id").ascending());
|
PageRequest pageRequest = PageRequest.of(OFFSET, LIMIT, Sort.by("id").ascending());
|
||||||
org.springframework.data.domain.Page<ExternalAssetOwnerLoanProductAttributes> attributesPage = new PageImpl<>(List.of(attributes),
|
org.springframework.data.domain.Page<ExternalAssetOwnerLoanProductAttributes> attributesPage = new PageImpl<>(List.of(attributes),
|
||||||
pageRequest, 0);
|
pageRequest, 0);
|
||||||
|
|
||||||
when(externalAssetOwnerLoanProductAttributesRepository.findAll(any(Specification.class), eq(pageRequest)))
|
when(externalAssetOwnerLoanProductAttributesRepository
|
||||||
|
.findAll(ArgumentMatchers.<Specification<ExternalAssetOwnerLoanProductAttributes>>any(), eq(pageRequest)))
|
||||||
.thenReturn(attributesPage);
|
.thenReturn(attributesPage);
|
||||||
when(loanProductRepository.existsById(loanProductId)).thenReturn(true);
|
when(loanProductRepository.existsById(loanProductId)).thenReturn(true);
|
||||||
when(mapper.mapLoanProductAttributes(attributes)).thenReturn(null);
|
when(mapper.mapLoanProductAttributes(attributes)).thenReturn(null);
|
||||||
@@ -120,8 +122,9 @@ public class ExternalAssetOwnerLoanProductAttributesReadServiceTest {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertEquals(1, result.getTotalFilteredRecords());
|
assertEquals(1, result.getTotalFilteredRecords());
|
||||||
assertNull(result.getPageItems().get(0));
|
assertNull(result.getPageItems().getFirst());
|
||||||
verify(externalAssetOwnerLoanProductAttributesRepository, times(1)).findAll(any(Specification.class), eq(pageRequest));
|
verify(externalAssetOwnerLoanProductAttributesRepository, times(1))
|
||||||
|
.findAll(ArgumentMatchers.<Specification<ExternalAssetOwnerLoanProductAttributes>>any(), eq(pageRequest));
|
||||||
verify(loanProductRepository, times(1)).existsById(loanProductId);
|
verify(loanProductRepository, times(1)).existsById(loanProductId);
|
||||||
verify(mapper, times(1)).mapLoanProductAttributes(attributes);
|
verify(mapper, times(1)).mapLoanProductAttributes(attributes);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user