FINERACT-2081: Fix inconsistent transaction processing order
This commit is contained in:
-11
@@ -33,7 +33,6 @@ import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
import org.springframework.data.domain.Auditable;
|
||||
import org.springframework.data.jpa.domain.AbstractAuditable;
|
||||
|
||||
@@ -81,11 +80,6 @@ public abstract class AbstractAuditableWithUTCDateTimeCustom<T extends Serializa
|
||||
return Optional.ofNullable(createdDate);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public OffsetDateTime getCreatedDateTime() {
|
||||
return getCreatedDate().orElseGet(DateUtils::getAuditOffsetDateTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Optional<Long> getLastModifiedBy() {
|
||||
@@ -97,9 +91,4 @@ public abstract class AbstractAuditableWithUTCDateTimeCustom<T extends Serializa
|
||||
public Optional<OffsetDateTime> getLastModifiedDate() {
|
||||
return Optional.ofNullable(lastModifiedDate);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public OffsetDateTime getLastModifiedDateTime() {
|
||||
return getLastModifiedDate().orElseGet(DateUtils::getAuditOffsetDateTime);
|
||||
}
|
||||
}
|
||||
|
||||
+20
@@ -31,6 +31,7 @@ import java.time.format.DateTimeParseException;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
||||
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
||||
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
@@ -425,4 +426,23 @@ public final class DateUtils {
|
||||
}
|
||||
return formatter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Comparing dates. Null will be considered as last elements
|
||||
*
|
||||
* @param first
|
||||
* @param second
|
||||
* @return
|
||||
*/
|
||||
public static int compareWithNullsLast(LocalDate first, LocalDate second) {
|
||||
return first == null ? (second == null ? 0 : 1) : (second == null ? -1 : first.compareTo(second));
|
||||
}
|
||||
|
||||
public static int compareWithNullsLast(@NotNull Optional<OffsetDateTime> first, @NotNull Optional<OffsetDateTime> second) {
|
||||
return DateUtils.compareWithNullsLast(first.orElse(null), second.orElse(null));
|
||||
}
|
||||
|
||||
public static int compareWithNullsLast(OffsetDateTime first, OffsetDateTime second) {
|
||||
return first == null ? (second == null ? 0 : 1) : (second == null ? -1 : first.compareTo(second));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ public class CalendarHistoryDataWrapper {
|
||||
|
||||
@Override
|
||||
public int compare(CalendarHistory calendarHistory1, CalendarHistory calendarHistory2) {
|
||||
return DateUtils.compare(calendarHistory1.getEndDate(), calendarHistory2.getEndDate());
|
||||
return DateUtils.compareWithNullsLast(calendarHistory1.getEndDate(), calendarHistory2.getEndDate());
|
||||
}
|
||||
};
|
||||
this.calendarHistoryList.sort(orderByDate);
|
||||
|
||||
Reference in New Issue
Block a user