You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by ar...@apache.org on 2022/07/11 09:22:53 UTC
[fineract] branch develop updated: Date to LocalDate - part 1
This is an automated email from the ASF dual-hosted git repository.
arnold pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new ef96d5cc5 Date to LocalDate - part 1
ef96d5cc5 is described below
commit ef96d5cc50266155ff4de4981c47268b4c79f314
Author: Adam Saghy <ad...@gmail.com>
AuthorDate: Mon Jul 11 10:48:44 2022 +0200
Date to LocalDate - part 1
---
.../data/GlobalConfigurationPropertyData.java | 10 +-
.../domain/ConfigurationDomainService.java | 4 +-
.../domain/ConfigurationDomainServiceJpa.java | 4 +-
.../domain/GlobalConfigurationProperty.java | 10 +-
.../ConfigurationReadPlatformServiceImpl.java | 6 +-
.../infrastructure/core/api/JsonCommand.java | 9 +-
.../infrastructure/core/domain/JdbcSupport.java | 16 +-
.../domain/FineractEntityToEntityMapping.java | 26 +-
.../service/FineractEntityAccessUtil.java | 6 +-
.../FineractEntityAccessWriteServiceImpl.java | 8 +-
.../organisation/holiday/domain/Holiday.java | 47 +-
.../holiday/domain/HolidayRepository.java | 4 +-
.../holiday/domain/HolidayRepositoryWrapper.java | 7 +-
.../fineract/organisation/staff/domain/Staff.java | 14 +-
.../domain/AccountTransferStandingInstruction.java | 40 +-
...etailsReadPlatformServiceJpaRepositoryImpl.java | 4 +-
...lientWritePlatformServiceJpaRepositoryImpl.java | 3 +-
.../floatingrates/data/InterestRatePeriodData.java | 14 +-
.../FloatingRatesReadPlatformServiceImpl.java | 7 +-
...TypesWritePlatformServiceJpaRepositoryImpl.java | 5 +-
.../loanaccount/data/LoanScheduleAccrualData.java | 6 +-
.../portfolio/loanaccount/domain/Loan.java | 498 +++++++++------------
.../domain/LoanAccountDomainServiceJpa.java | 19 +-
.../portfolio/loanaccount/domain/LoanCharge.java | 28 +-
.../domain/LoanDisbursementDetails.java | 40 +-
...LoanInterestRecalcualtionAdditionalDetails.java | 12 +-
.../domain/LoanOfficerAssignmentHistory.java | 28 +-
.../domain/LoanRepaymentScheduleInstallment.java | 51 +--
.../LoanRepaymentScheduleProcessingWrapper.java | 2 +-
.../loanaccount/domain/LoanRepository.java | 8 +-
.../loanaccount/domain/LoanRepositoryWrapper.java | 8 +-
.../loanaccount/domain/LoanTermVariations.java | 42 +-
.../guarantor/command/GuarantorCommand.java | 6 +-
.../loanaccount/guarantor/domain/Guarantor.java | 19 +-
.../loanschedule/domain/LoanApplicationTerms.java | 18 +-
.../domain/LoanRepaymentScheduleHistory.java | 30 +-
.../service/LoanScheduleAssembler.java | 30 +-
...oanScheduleHistoryWritePlatformServiceImpl.java | 22 +-
.../domain/LoanRescheduleRequest.java | 66 +--
.../LoanReschedulePreviewPlatformServiceImpl.java | 5 +-
...nRescheduleRequestWritePlatformServiceImpl.java | 48 +-
.../LoanAccrualWritePlatformServiceImpl.java | 9 +-
.../loanaccount/service/LoanAssembler.java | 8 +-
.../service/LoanReadPlatformService.java | 3 +-
.../service/LoanReadPlatformServiceImpl.java | 30 +-
.../loanaccount/service/LoanUtilService.java | 16 +-
.../LoanWritePlatformServiceJpaRepositoryImpl.java | 27 +-
47 files changed, 495 insertions(+), 828 deletions(-)
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/data/GlobalConfigurationPropertyData.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/data/GlobalConfigurationPropertyData.java
index 7e54b01b2..7f3f6d786 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/data/GlobalConfigurationPropertyData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/data/GlobalConfigurationPropertyData.java
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.configuration.data;
-import java.util.Date;
+import java.time.LocalDate;
/**
* Immutable data object for global configuration property.
@@ -32,7 +32,7 @@ public class GlobalConfigurationPropertyData {
@SuppressWarnings("unused")
private final Long value;
@SuppressWarnings("unused")
- private final Date dateValue;
+ private final LocalDate dateValue;
private String stringValue;
@SuppressWarnings("unused")
private final Long id;
@@ -41,7 +41,7 @@ public class GlobalConfigurationPropertyData {
@SuppressWarnings("unused")
private final boolean trapDoor;
- public GlobalConfigurationPropertyData(final String name, final boolean enabled, final Long value, final Date dateValue,
+ public GlobalConfigurationPropertyData(final String name, final boolean enabled, final Long value, final LocalDate dateValue,
final String stringValue, final String description, final boolean trapDoor) {
this.name = name;
this.enabled = enabled;
@@ -53,7 +53,7 @@ public class GlobalConfigurationPropertyData {
this.trapDoor = trapDoor;
}
- public GlobalConfigurationPropertyData(final String name, final boolean enabled, final Long value, Date dateValue,
+ public GlobalConfigurationPropertyData(final String name, final boolean enabled, final Long value, LocalDate dateValue,
final String stringValue, final Long id, final String description, final boolean isTrapDoor) {
this.name = name;
this.enabled = enabled;
@@ -81,7 +81,7 @@ public class GlobalConfigurationPropertyData {
return this.stringValue;
}
- public Date getDateValue() {
+ public LocalDate getDateValue() {
return this.dateValue;
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainService.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainService.java
index e7839ed34..73761fbcc 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainService.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainService.java
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.configuration.domain;
-import java.util.Date;
+import java.time.LocalDate;
import org.apache.fineract.infrastructure.cache.domain.CacheType;
public interface ConfigurationDomainService {
@@ -67,7 +67,7 @@ public interface ConfigurationDomainService {
boolean isOrganisationstartDateEnabled();
- Date retrieveOrganisationStartDate();
+ LocalDate retrieveOrganisationStartDate();
boolean isPaymnetypeApplicableforDisbursementCharge();
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java
index 43bca44d7..6dd1a1ab8 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/ConfigurationDomainServiceJpa.java
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.configuration.domain;
-import java.util.Date;
+import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
@@ -238,7 +238,7 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
}
@Override
- public Date retrieveOrganisationStartDate() {
+ public LocalDate retrieveOrganisationStartDate() {
final String propertyName = "organisation-start-date";
final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName);
return property.getDateValue();
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/GlobalConfigurationProperty.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/GlobalConfigurationProperty.java
index 84e0283a4..d066c542c 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/GlobalConfigurationProperty.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/domain/GlobalConfigurationProperty.java
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.configuration.domain;
-import java.util.Date;
+import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.persistence.Column;
@@ -44,7 +44,7 @@ public class GlobalConfigurationProperty extends AbstractPersistableCustom {
private Long value;
@Column(name = "date_value", nullable = true)
- private Date dateValue;
+ private LocalDate dateValue;
@Column(name = "string_value", nullable = true)
private String stringValue;
@@ -65,7 +65,7 @@ public class GlobalConfigurationProperty extends AbstractPersistableCustom {
this.isTrapDoor = false;
}
- public GlobalConfigurationProperty(final String name, final boolean enabled, final Long value, final Date dateValue,
+ public GlobalConfigurationProperty(final String name, final boolean enabled, final Long value, final LocalDate dateValue,
final String stringValue, final String description, final boolean isTrapDoor) {
this.name = name;
this.enabled = enabled;
@@ -84,7 +84,7 @@ public class GlobalConfigurationProperty extends AbstractPersistableCustom {
return this.value;
}
- public Date getDateValue() {
+ public LocalDate getDateValue() {
return this.dateValue;
}
@@ -117,7 +117,7 @@ public class GlobalConfigurationProperty extends AbstractPersistableCustom {
final String dateValueParamName = "dateValue";
if (command.isChangeInDateParameterNamed(dateValueParamName, this.dateValue)) {
- final Date newDateValue = command.dateValueOfParameterNamed(dateValueParamName);
+ final LocalDate newDateValue = command.localDateValueOfParameterNamed(dateValueParamName);
actualChanges.put(dateValueParamName, newDateValue);
this.dateValue = newDateValue;
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/service/ConfigurationReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/service/ConfigurationReadPlatformServiceImpl.java
index 29d933769..20ee233e9 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/service/ConfigurationReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/configuration/service/ConfigurationReadPlatformServiceImpl.java
@@ -18,9 +18,10 @@
*/
package org.apache.fineract.infrastructure.configuration.service;
+import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.util.Date;
+import java.time.LocalDate;
import java.util.List;
import org.apache.fineract.infrastructure.configuration.data.GlobalConfigurationData;
import org.apache.fineract.infrastructure.configuration.data.GlobalConfigurationPropertyData;
@@ -105,7 +106,8 @@ public class ConfigurationReadPlatformServiceImpl implements ConfigurationReadPl
final String description = rs.getString("description");
final Long id = rs.getLong("id");
final boolean isTrapDoor = rs.getBoolean("is_trap_door");
- return new GlobalConfigurationPropertyData(name, enabled, value, dateValue, stringValue, id, description, isTrapDoor);
+ final LocalDate localDate = dateValue != null ? dateValue.toLocalDate() : null;
+ return new GlobalConfigurationPropertyData(name, enabled, value, localDate, stringValue, id, description, isTrapDoor);
}
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/api/JsonCommand.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/api/JsonCommand.java
index 595ae95d3..d4efbbb95 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/api/JsonCommand.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/api/JsonCommand.java
@@ -36,7 +36,6 @@ import java.util.Set;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
-import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.security.domain.BasicPasswordEncodablePlatformUser;
import org.apache.fineract.infrastructure.security.domain.PlatformUser;
import org.apache.fineract.infrastructure.security.service.PlatformPasswordEncoder;
@@ -371,12 +370,8 @@ public final class JsonCommand {
return this.fromApiJsonHelper.extractLongNamed(parameterName, this.parsedCommand);
}
- public boolean isChangeInDateParameterNamed(final String parameterName, final Date existingValue) {
- LocalDate localDate = null;
- if (existingValue != null) {
- localDate = LocalDate.ofInstant(existingValue.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
- return isChangeInLocalDateParameterNamed(parameterName, localDate);
+ public boolean isChangeInDateParameterNamed(final String parameterName, final LocalDate existingValue) {
+ return isChangeInLocalDateParameterNamed(parameterName, existingValue);
}
public boolean isChangeInTimeParameterNamed(final String parameterName, final Date existingValue, final String timeFormat) {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/domain/JdbcSupport.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/domain/JdbcSupport.java
index 2d42ef9a7..74728c2c3 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/domain/JdbcSupport.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/domain/JdbcSupport.java
@@ -18,9 +18,8 @@
*/
package org.apache.fineract.infrastructure.core.domain;
-import static org.apache.fineract.infrastructure.core.service.DateUtils.getDateTimeZoneOfTenant;
-
import java.math.BigDecimal;
+import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
@@ -28,7 +27,6 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZonedDateTime;
-import java.util.Date;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.springframework.jdbc.support.JdbcUtils;
@@ -44,7 +42,7 @@ public final class JdbcSupport {
ZonedDateTime dateTime = null;
final Timestamp dateValue = rs.getTimestamp(columnName);
if (dateValue != null) {
- dateTime = ZonedDateTime.ofInstant(new Date(dateValue.getTime()).toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ dateTime = ZonedDateTime.ofInstant(dateValue.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return dateTime;
}
@@ -53,25 +51,25 @@ public final class JdbcSupport {
LocalDateTime dateTime = null;
final Timestamp dateValue = rs.getTimestamp(columnName);
if (dateValue != null) {
- dateTime = LocalDateTime.ofInstant(new Date(dateValue.getTime()).toInstant(), getDateTimeZoneOfTenant());
+ dateTime = dateValue.toLocalDateTime();
}
return dateTime;
}
public static LocalDate getLocalDate(final ResultSet rs, final String columnName) throws SQLException {
LocalDate localDate = null;
- final Date dateValue = rs.getTimestamp(columnName);
+ final Date dateValue = rs.getDate(columnName);
if (dateValue != null) {
- localDate = LocalDate.ofInstant(dateValue.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ localDate = dateValue.toLocalDate();
}
return localDate;
}
public static LocalTime getLocalTime(final ResultSet rs, final String columnName) throws SQLException {
LocalTime localTime = null;
- final Date timeValue = rs.getTimestamp(columnName);
+ final Timestamp timeValue = rs.getTimestamp(columnName);
if (timeValue != null) {
- localTime = LocalTime.ofInstant(timeValue.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ localTime = timeValue.toLocalDateTime().toLocalTime();
}
return localTime;
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/domain/FineractEntityToEntityMapping.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/domain/FineractEntityToEntityMapping.java
index 396fbf008..6d018120f 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/domain/FineractEntityToEntityMapping.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/domain/FineractEntityToEntityMapping.java
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.entityaccess.domain;
-import java.util.Date;
+import java.time.LocalDate;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.persistence.Column;
@@ -26,8 +26,6 @@ import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@@ -49,15 +47,13 @@ public class FineractEntityToEntityMapping extends AbstractPersistableCustom {
private Long toId;
@Column(name = "start_date", nullable = true)
- @Temporal(TemporalType.DATE)
- private Date startDate;
+ private LocalDate startDate;
@Column(name = "end_date", nullable = true)
- @Temporal(TemporalType.DATE)
- private Date endDate;
+ private LocalDate endDate;
- private FineractEntityToEntityMapping(final FineractEntityRelation relationId, final Long fromId, final Long toId, final Date startDate,
- final Date endDate) {
+ private FineractEntityToEntityMapping(final FineractEntityRelation relationId, final Long fromId, final Long toId,
+ final LocalDate startDate, final LocalDate endDate) {
this.relationId = relationId;
this.fromId = fromId;
this.toId = toId;
@@ -70,8 +66,8 @@ public class FineractEntityToEntityMapping extends AbstractPersistableCustom {
//
}
- public static FineractEntityToEntityMapping newMap(FineractEntityRelation relationId, Long fromId, Long toId, Date startDate,
- Date endDate) {
+ public static FineractEntityToEntityMapping newMap(FineractEntityRelation relationId, Long fromId, Long toId, LocalDate startDate,
+ LocalDate endDate) {
return new FineractEntityToEntityMapping(relationId, fromId, toId, startDate, endDate);
@@ -96,18 +92,16 @@ public class FineractEntityToEntityMapping extends AbstractPersistableCustom {
if (command.isChangeInDateParameterNamed(FineractEntityApiResourceConstants.startDate, this.startDate)) {
final String valueAsInput = command.stringValueOfParameterNamed(FineractEntityApiResourceConstants.startDate);
actualChanges.put(FineractEntityApiResourceConstants.startDate, valueAsInput);
- final Date startDate = command.dateValueOfParameterNamed(FineractEntityApiResourceConstants.startDate);
- this.startDate = startDate;
+ this.startDate = command.localDateValueOfParameterNamed(FineractEntityApiResourceConstants.startDate);
}
if (command.isChangeInDateParameterNamed(FineractEntityApiResourceConstants.endDate, this.endDate)) {
final String valueAsInput = command.stringValueOfParameterNamed(FineractEntityApiResourceConstants.endDate);
actualChanges.put(FineractEntityApiResourceConstants.endDate, valueAsInput);
- final Date endDate = command.dateValueOfParameterNamed(FineractEntityApiResourceConstants.endDate);
- this.endDate = endDate;
+ this.endDate = command.localDateValueOfParameterNamed(FineractEntityApiResourceConstants.endDate);
}
if (startDate != null && endDate != null) {
- if (endDate.before(startDate)) {
+ if (endDate.isBefore(startDate)) {
throw new FineractEntityToEntityMappingDateException(startDate.toString(), endDate.toString());
}
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/service/FineractEntityAccessUtil.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/service/FineractEntityAccessUtil.java
index 42201a42a..efb456e13 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/service/FineractEntityAccessUtil.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/service/FineractEntityAccessUtil.java
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.entityaccess.service;
-import java.util.Date;
+import java.time.LocalDate;
import org.apache.fineract.infrastructure.codes.domain.CodeValueRepositoryWrapper;
import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService;
import org.apache.fineract.infrastructure.configuration.domain.GlobalConfigurationProperty;
@@ -87,8 +87,8 @@ public class FineractEntityAccessUtil {
if (restrictToUserOfficeProperty.isEnabled()) {
final Long officeId = thisUser.getOffice().getId();
- Date startDateFormapping = null;
- Date endDateFormapping = null;
+ LocalDate startDateFormapping = null;
+ LocalDate endDateFormapping = null;
FineractEntityRelation fineractEntityRelation = fineractEntityRelationRepositoryWrapper
.findOneByCodeName(fineractEntityAccessType.toStr());
Long relId = fineractEntityRelation.getId();
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/service/FineractEntityAccessWriteServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/service/FineractEntityAccessWriteServiceImpl.java
index e7807135d..70f04846b 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/service/FineractEntityAccessWriteServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/entityaccess/service/FineractEntityAccessWriteServiceImpl.java
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.infrastructure.entityaccess.service;
-import java.util.Date;
+import java.time.LocalDate;
import java.util.Map;
import javax.persistence.PersistenceException;
import org.apache.commons.lang3.exception.ExceptionUtils;
@@ -95,12 +95,12 @@ public class FineractEntityAccessWriteServiceImpl implements FineractEntityAcces
final Long fromId = command.longValueOfParameterNamed(FineractEntityApiResourceConstants.fromEnityType);
final Long toId = command.longValueOfParameterNamed(FineractEntityApiResourceConstants.toEntityType);
- final Date startDate = command.dateValueOfParameterNamed(FineractEntityApiResourceConstants.startDate);
- final Date endDate = command.dateValueOfParameterNamed(FineractEntityApiResourceConstants.endDate);
+ final LocalDate startDate = command.localDateValueOfParameterNamed(FineractEntityApiResourceConstants.startDate);
+ final LocalDate endDate = command.localDateValueOfParameterNamed(FineractEntityApiResourceConstants.endDate);
fromApiJsonDeserializer.checkForEntity(relId.toString(), fromId, toId);
if (startDate != null && endDate != null) {
- if (endDate.before(startDate)) {
+ if (endDate.isBefore(startDate)) {
throw new FineractEntityToEntityMappingDateException(startDate.toString(), endDate.toString());
}
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/holiday/domain/Holiday.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/holiday/domain/Holiday.java
index 5495ba9b3..7a752ad01 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/organisation/holiday/domain/Holiday.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/holiday/domain/Holiday.java
@@ -29,9 +29,7 @@ import static org.apache.fineract.portfolio.savings.SavingsApiConstants.localePa
import com.google.gson.JsonArray;
import java.time.LocalDate;
-import java.time.ZoneId;
import java.util.ArrayList;
-import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@@ -44,8 +42,6 @@ import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -53,7 +49,6 @@ import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
-import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.holiday.api.HolidayApiConstants;
import org.apache.fineract.organisation.office.domain.Office;
@@ -65,16 +60,13 @@ public class Holiday extends AbstractPersistableCustom {
private String name;
@Column(name = "from_date", nullable = false)
- @Temporal(TemporalType.DATE)
- private Date fromDate;
+ private LocalDate fromDate;
@Column(name = "to_date", nullable = false)
- @Temporal(TemporalType.DATE)
- private Date toDate;
+ private LocalDate toDate;
@Column(name = "repayments_rescheduled_to", nullable = true)
- @Temporal(TemporalType.DATE)
- private Date repaymentsRescheduledTo;
+ private LocalDate repaymentsRescheduledTo;
@Column(name = "rescheduling_type", nullable = false)
private int reschedulingType;
@@ -150,8 +142,7 @@ public class Holiday extends AbstractPersistableCustom {
actualChanges.put(fromDateParamName, valueAsInput);
actualChanges.put(dateFormatParamName, dateFormatAsInput);
actualChanges.put(localeParamName, localeAsInput);
- final LocalDate newValue = command.localDateValueOfParameterNamed(fromDateParamName);
- this.fromDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.fromDate = command.localDateValueOfParameterNamed(fromDateParamName);
}
if (command.isChangeInLocalDateParameterNamed(toDateParamName, getToDateLocalDate())) {
@@ -160,8 +151,7 @@ public class Holiday extends AbstractPersistableCustom {
actualChanges.put(dateFormatParamName, dateFormatAsInput);
actualChanges.put(localeParamName, localeAsInput);
- final LocalDate newValue = command.localDateValueOfParameterNamed(toDateParamName);
- this.toDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.toDate = command.localDateValueOfParameterNamed(toDateParamName);
}
if (command.isChangeInLocalDateParameterNamed(repaymentsRescheduledToParamName, getRepaymentsRescheduledToLocalDate())) {
@@ -170,8 +160,7 @@ public class Holiday extends AbstractPersistableCustom {
actualChanges.put(dateFormatParamName, dateFormatAsInput);
actualChanges.put(localeParamName, localeAsInput);
- final LocalDate newValue = command.localDateValueOfParameterNamed(repaymentsRescheduledToParamName);
- this.repaymentsRescheduledTo = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.repaymentsRescheduledTo = command.localDateValueOfParameterNamed(repaymentsRescheduledToParamName);
}
if (command.hasParameter(officesParamName)) {
@@ -234,15 +223,15 @@ public class Holiday extends AbstractPersistableCustom {
}
if (fromDate != null) {
- this.fromDate = Date.from(fromDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.fromDate = fromDate;
}
if (toDate != null) {
- this.toDate = Date.from(toDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.toDate = toDate;
}
if (repaymentsRescheduledTo != null) {
- this.repaymentsRescheduledTo = Date.from(repaymentsRescheduledTo.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.repaymentsRescheduledTo = repaymentsRescheduledTo;
}
this.status = status;
@@ -263,11 +252,7 @@ public class Holiday extends AbstractPersistableCustom {
protected Holiday() {}
public LocalDate getRepaymentsRescheduledToLocalDate() {
- LocalDate repaymentsRescheduledTo = null;
- if (this.repaymentsRescheduledTo != null) {
- repaymentsRescheduledTo = LocalDate.ofInstant(this.repaymentsRescheduledTo.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
- return repaymentsRescheduledTo;
+ return this.repaymentsRescheduledTo;
}
public boolean isProcessed() {
@@ -279,19 +264,11 @@ public class Holiday extends AbstractPersistableCustom {
}
public LocalDate getFromDateLocalDate() {
- LocalDate fromDate = null;
- if (this.fromDate != null) {
- fromDate = LocalDate.ofInstant(this.fromDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
- return fromDate;
+ return this.fromDate;
}
public LocalDate getToDateLocalDate() {
- LocalDate toDate = null;
- if (this.toDate != null) {
- toDate = LocalDate.ofInstant(this.toDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
- return toDate;
+ return this.toDate;
}
public void processed() {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/holiday/domain/HolidayRepository.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/holiday/domain/HolidayRepository.java
index 651662c24..04bda3706 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/organisation/holiday/domain/HolidayRepository.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/holiday/domain/HolidayRepository.java
@@ -18,7 +18,7 @@
*/
package org.apache.fineract.organisation.holiday.domain;
-import java.util.Date;
+import java.time.LocalDate;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
@@ -28,7 +28,7 @@ import org.springframework.data.repository.query.Param;
public interface HolidayRepository extends JpaRepository<Holiday, Long>, JpaSpecificationExecutor<Holiday> {
@Query("select holiday from Holiday holiday, IN(holiday.offices) office where (holiday.fromDate >= :date OR :date <= holiday.toDate) and holiday.status = :status and office.id = :officeId")
- List<Holiday> findByOfficeIdAndGreaterThanDate(@Param("officeId") Long officeId, @Param("date") Date date,
+ List<Holiday> findByOfficeIdAndGreaterThanDate(@Param("officeId") Long officeId, @Param("date") LocalDate date,
@Param("status") Integer status);
@Query("select holiday from Holiday holiday where holiday.processed = false and holiday.status = :status")
diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/holiday/domain/HolidayRepositoryWrapper.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/holiday/domain/HolidayRepositoryWrapper.java
index 0a9e00d69..ec1956c28 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/organisation/holiday/domain/HolidayRepositoryWrapper.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/holiday/domain/HolidayRepositoryWrapper.java
@@ -19,8 +19,6 @@
package org.apache.fineract.organisation.holiday.domain;
import java.time.LocalDate;
-import java.time.ZoneId;
-import java.util.Date;
import java.util.List;
import org.apache.fineract.organisation.holiday.exception.HolidayNotFoundException;
import org.apache.fineract.organisation.holiday.service.HolidayUtil;
@@ -62,7 +60,7 @@ public class HolidayRepositoryWrapper {
this.repository.delete(holiday);
}
- public List<Holiday> findByOfficeIdAndGreaterThanDate(final Long officeId, final Date date) {
+ public List<Holiday> findByOfficeIdAndGreaterThanDate(final Long officeId, final LocalDate date) {
return this.repository.findByOfficeIdAndGreaterThanDate(officeId, date, HolidayStatusType.ACTIVE.getValue());
}
@@ -71,8 +69,7 @@ public class HolidayRepositoryWrapper {
}
public boolean isHoliday(Long officeId, LocalDate transactionDate) {
- final List<Holiday> holidays = findByOfficeIdAndGreaterThanDate(officeId,
- Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ final List<Holiday> holidays = findByOfficeIdAndGreaterThanDate(officeId, transactionDate);
return HolidayUtil.isHoliday(transactionDate, holidays);
}
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/domain/Staff.java b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/domain/Staff.java
index f4b0d75de..261d885e3 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/domain/Staff.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/organisation/staff/domain/Staff.java
@@ -19,8 +19,6 @@
package org.apache.fineract.organisation.staff.domain;
import java.time.LocalDate;
-import java.time.ZoneId;
-import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.persistence.Column;
@@ -29,8 +27,6 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -77,8 +73,7 @@ public class Staff extends AbstractPersistableCustom {
private boolean active;
@Column(name = "joining_date", nullable = true)
- @Temporal(TemporalType.DATE)
- private Date joiningDate;
+ private LocalDate joiningDate;
@ManyToOne
@JoinColumn(name = "organisational_role_parent_staff_id", nullable = true)
@@ -132,9 +127,7 @@ public class Staff extends AbstractPersistableCustom {
this.loanOfficer = isLoanOfficer;
this.active = isActive == null ? true : isActive;
deriveDisplayName(firstname);
- if (joiningDate != null) {
- this.joiningDate = Date.from(joiningDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
- }
+ this.joiningDate = joiningDate;
}
public EnumOptionData organisationalRoleData() {
@@ -213,8 +206,7 @@ public class Staff extends AbstractPersistableCustom {
if (command.isChangeInDateParameterNamed(joiningDateParamName, this.joiningDate)) {
final String valueAsInput = command.stringValueOfParameterNamed(joiningDateParamName);
actualChanges.put(joiningDateParamName, valueAsInput);
- final LocalDate newValue = command.localDateValueOfParameterNamed(joiningDateParamName);
- this.joiningDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.joiningDate = command.localDateValueOfParameterNamed(joiningDateParamName);
}
return actualChanges;
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/domain/AccountTransferStandingInstruction.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/domain/AccountTransferStandingInstruction.java
index 4a96ebb67..cb1aab2d3 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/domain/AccountTransferStandingInstruction.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/domain/AccountTransferStandingInstruction.java
@@ -34,9 +34,7 @@ import static org.apache.fineract.portfolio.account.api.StandingInstructionApiCo
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.MonthDay;
-import java.time.ZoneId;
import java.util.ArrayList;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -45,15 +43,12 @@ import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
-import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
@Entity
@@ -80,13 +75,11 @@ public class AccountTransferStandingInstruction extends AbstractPersistableCusto
@Column(name = "amount", scale = 6, precision = 19, nullable = true)
private BigDecimal amount;
- @Temporal(TemporalType.DATE)
@Column(name = "valid_from")
- private Date validFrom;
+ private LocalDate validFrom;
- @Temporal(TemporalType.DATE)
@Column(name = "valid_till")
- private Date validTill;
+ private LocalDate validTill;
@Column(name = "recurrence_type")
private Integer recurrenceType;
@@ -103,9 +96,8 @@ public class AccountTransferStandingInstruction extends AbstractPersistableCusto
@Column(name = "recurrence_on_month")
private Integer recurrenceOnMonth;
- @Temporal(TemporalType.DATE)
@Column(name = "last_run_date")
- private Date latsRunDate;
+ private LocalDate latsRunDate;
protected AccountTransferStandingInstruction() {
@@ -135,14 +127,8 @@ public class AccountTransferStandingInstruction extends AbstractPersistableCusto
this.instructionType = instructionType;
this.status = status;
this.amount = amount;
- if (validFrom != null) {
- this.validFrom = Date.from(validFrom.atStartOfDay(ZoneId.systemDefault()).toInstant());
- }
- if (validTill == null) {
- this.validTill = null;
- } else {
- this.validTill = Date.from(validTill.atStartOfDay(ZoneId.systemDefault()).toInstant());
- }
+ this.validFrom = validFrom;
+ this.validTill = validTill;
this.recurrenceType = recurrenceType;
this.recurrenceFrequency = recurrenceFrequency;
this.recurrenceInterval = recurrenceInterval;
@@ -170,15 +156,13 @@ public class AccountTransferStandingInstruction extends AbstractPersistableCusto
}
if (command.isChangeInDateParameterNamed(validFromParamName, this.validFrom)) {
- final LocalDate newValue = command.localDateValueOfParameterNamed(validFromParamName);
- actualChanges.put(validFromParamName, newValue);
- this.validFrom = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.validFrom = command.localDateValueOfParameterNamed(validFromParamName);
+ actualChanges.put(validFromParamName, this.validFrom);
}
if (command.isChangeInDateParameterNamed(validTillParamName, this.validTill)) {
- final LocalDate newValue = command.localDateValueOfParameterNamed(validTillParamName);
- actualChanges.put(validTillParamName, newValue);
- this.validTill = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.validTill = command.localDateValueOfParameterNamed(validTillParamName);
+ actualChanges.put(validTillParamName, this.validTill);
}
if (command.isChangeInBigDecimalParameterNamed(amountParamName, this.amount)) {
@@ -248,9 +232,7 @@ public class AccountTransferStandingInstruction extends AbstractPersistableCusto
private void validateDependencies(final DataValidatorBuilder baseDataValidator) {
if (this.validTill != null && this.validFrom != null) {
- baseDataValidator.reset().parameter(validTillParamName)
- .value(LocalDate.ofInstant(this.validTill.toInstant(), DateUtils.getDateTimeZoneOfTenant()))
- .validateDateAfter(LocalDate.ofInstant(this.validFrom.toInstant(), DateUtils.getDateTimeZoneOfTenant()));
+ baseDataValidator.reset().parameter(validTillParamName).value(this.validTill).validateDateAfter(this.validFrom);
}
if (AccountTransferRecurrenceType.fromInt(recurrenceType).isPeriodicRecurrence()) {
@@ -290,7 +272,7 @@ public class AccountTransferStandingInstruction extends AbstractPersistableCusto
}
- public void updateLatsRunDate(Date latsRunDate) {
+ public void updateLatsRunDate(LocalDate latsRunDate) {
this.latsRunDate = latsRunDate;
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accountdetails/service/AccountDetailsReadPlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accountdetails/service/AccountDetailsReadPlatformServiceJpaRepositoryImpl.java
index 29a41af58..158ef8021 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accountdetails/service/AccountDetailsReadPlatformServiceJpaRepositoryImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accountdetails/service/AccountDetailsReadPlatformServiceJpaRepositoryImpl.java
@@ -593,9 +593,7 @@ public class AccountDetailsReadPlatformServiceJpaRepositoryImpl implements Accou
.append(" join m_client as c on c.id = g.entity_id ").append(" LEFT JOIN m_product_loan AS lp ON lp.id = l.product_id")
.append(" left join m_loan_arrears_aging la on la.loan_id = l.id")
.append(" left join m_code_value cv ON cv.id = g.client_reln_cv_id")
- .append(" left join m_savings_account sa on sa.client_id = c.id")
-
- ;
+ .append(" left join m_savings_account sa on sa.client_id = c.id");
return accountsSummary.toString();
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
index 978943f89..c02f4d033 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
@@ -730,8 +730,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
if (loanStatus.isOpen() || loanStatus.isPendingApproval() || loanStatus.isAwaitingDisbursal()) {
final String errorMessage = "Client cannot be closed because of non-closed loans.";
throw new InvalidClientStateTransitionException("close", "loan.non-closed", errorMessage);
- } else if (loanStatus.isClosed()
- && loan.getClosedOnDate().after(Date.from(closureDate.atStartOfDay(ZoneId.systemDefault()).toInstant()))) {
+ } else if (loanStatus.isClosed() && loan.getClosedOnDate().isAfter(closureDate)) {
final String errorMessage = "The client closureDate cannot be before the loan closedOnDate.";
throw new InvalidClientStateTransitionException("close", "date.cannot.before.loan.closed.date", errorMessage,
closureDate, loan.getClosedOnDate());
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/data/InterestRatePeriodData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/data/InterestRatePeriodData.java
index d52d28fa9..5e50ecdb4 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/data/InterestRatePeriodData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/data/InterestRatePeriodData.java
@@ -19,20 +19,20 @@
package org.apache.fineract.portfolio.floatingrates.data;
import java.math.BigDecimal;
-import java.util.Date;
+import java.time.LocalDate;
public class InterestRatePeriodData {
- private Date fromDate;
+ private LocalDate fromDate;
private final BigDecimal interestRate;
private final boolean isDifferentialToBLR;
- private final Date blrFromDate;
+ private final LocalDate blrFromDate;
private final BigDecimal blrInterestRate;
private BigDecimal loanDifferentialInterestRate;
private BigDecimal loanProductDifferentialInterestRate;
private BigDecimal effectiveInterestRate;
- public InterestRatePeriodData(Date fromDate, BigDecimal interestRate, boolean isDifferentialToBLR, Date blrFromDate,
+ public InterestRatePeriodData(LocalDate fromDate, BigDecimal interestRate, boolean isDifferentialToBLR, LocalDate blrFromDate,
BigDecimal blrInterestRate) {
this.fromDate = fromDate;
this.interestRate = interestRate;
@@ -41,11 +41,11 @@ public class InterestRatePeriodData {
this.blrInterestRate = blrInterestRate;
}
- public Date getFromDate() {
+ public LocalDate getFromDate() {
return this.fromDate;
}
- public void setFromDate(Date fromDate) {
+ public void setFromDate(LocalDate fromDate) {
this.fromDate = fromDate;
}
@@ -57,7 +57,7 @@ public class InterestRatePeriodData {
return this.isDifferentialToBLR;
}
- public Date getBlrFromDate() {
+ public LocalDate getBlrFromDate() {
return this.blrFromDate;
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/service/FloatingRatesReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/service/FloatingRatesReadPlatformServiceImpl.java
index 0cca700df..ea55d7300 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/service/FloatingRatesReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/service/FloatingRatesReadPlatformServiceImpl.java
@@ -19,10 +19,10 @@
package org.apache.fineract.portfolio.floatingrates.service;
import java.math.BigDecimal;
+import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDate;
-import java.util.Date;
import java.util.List;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.portfolio.floatingrates.data.FloatingRateData;
@@ -221,8 +221,9 @@ public class FloatingRatesReadPlatformServiceImpl implements FloatingRatesReadPl
final boolean isDifferentialToBLR = rs.getBoolean("linkedrateperiods_is_differential_to_base_lending_rate");
final Date blrFromDate = rs.getDate("baserate_from_date");
final BigDecimal blrInterestRate = rs.getBigDecimal("baserate_interest_rate");
-
- return new InterestRatePeriodData(fromDate, interestRate, isDifferentialToBLR, blrFromDate, blrInterestRate);
+ final LocalDate fromLocalDate = fromDate != null ? fromDate.toLocalDate() : null;
+ final LocalDate blrFromLocalDate = blrFromDate != null ? blrFromDate.toLocalDate() : null;
+ return new InterestRatePeriodData(fromLocalDate, interestRate, isDifferentialToBLR, blrFromLocalDate, blrInterestRate);
}
public String schema() {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java
index 07796811d..2cd0ef5ff 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java
@@ -19,9 +19,7 @@
package org.apache.fineract.portfolio.group.service;
import java.time.LocalDate;
-import java.time.ZoneId;
import java.util.Collection;
-import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -618,8 +616,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
final String errorMessage = groupOrCenter.getGroupLevel().getLevelName() + " cannot be closed because of non-closed loans.";
throw new InvalidGroupStateTransitionException(groupOrCenter.getGroupLevel().getLevelName(), "close", "loan.not.closed",
errorMessage);
- } else if (loanStatus.isClosed()
- && loan.getClosedOnDate().after(Date.from(closureDate.atStartOfDay(ZoneId.systemDefault()).toInstant()))) {
+ } else if (loanStatus.isClosed() && loan.getClosedOnDate().isAfter(closureDate)) {
final String errorMessage = groupOrCenter.getGroupLevel().getLevelName()
+ "closureDate cannot be before the loan closedOnDate.";
throw new InvalidGroupStateTransitionException(groupOrCenter.getGroupLevel().getLevelName(), "close",
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanScheduleAccrualData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanScheduleAccrualData.java
index 75fb07a3d..6fcb359ca 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanScheduleAccrualData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanScheduleAccrualData.java
@@ -20,8 +20,6 @@ package org.apache.fineract.portfolio.loanaccount.data;
import java.math.BigDecimal;
import java.time.LocalDate;
-import java.time.ZoneId;
-import java.util.Date;
import java.util.Map;
import org.apache.fineract.organisation.monetary.data.CurrencyData;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
@@ -88,8 +86,8 @@ public class LoanScheduleAccrualData {
return this.officeId;
}
- public Date getDueDate() {
- return Date.from(this.dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ public LocalDate getDueDate() {
+ return this.dueDate;
}
public LocalDate getDueDateAsLocaldate() {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
index 642b69b1e..d94290148 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/Loan.java
@@ -28,14 +28,12 @@ import java.math.MathContext;
import java.math.RoundingMode;
import java.time.LocalDate;
import java.time.LocalDateTime;
-import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -59,12 +57,9 @@ import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
-import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -221,85 +216,72 @@ public class Loan extends AbstractPersistableCustom {
private Boolean syncDisbursementWithMeeting;
// loan application states
- @Temporal(TemporalType.DATE)
@Column(name = "submittedon_date")
- private Date submittedOnDate;
+ private LocalDate submittedOnDate;
@ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "submittedon_userid", nullable = true)
private AppUser submittedBy;
- @Temporal(TemporalType.DATE)
@Column(name = "rejectedon_date")
- private Date rejectedOnDate;
+ private LocalDate rejectedOnDate;
@ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "rejectedon_userid", nullable = true)
private AppUser rejectedBy;
- @Temporal(TemporalType.DATE)
@Column(name = "withdrawnon_date")
- private Date withdrawnOnDate;
+ private LocalDate withdrawnOnDate;
@ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "withdrawnon_userid", nullable = true)
private AppUser withdrawnBy;
- @Temporal(TemporalType.DATE)
@Column(name = "approvedon_date")
- private Date approvedOnDate;
+ private LocalDate approvedOnDate;
@ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "approvedon_userid", nullable = true)
private AppUser approvedBy;
- @Temporal(TemporalType.DATE)
@Column(name = "expected_disbursedon_date")
- private Date expectedDisbursementDate;
+ private LocalDate expectedDisbursementDate;
- @Temporal(TemporalType.DATE)
@Column(name = "disbursedon_date")
- private Date actualDisbursementDate;
+ private LocalDate actualDisbursementDate;
@ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "disbursedon_userid", nullable = true)
private AppUser disbursedBy;
- @Temporal(TemporalType.DATE)
@Column(name = "closedon_date")
- private Date closedOnDate;
+ private LocalDate closedOnDate;
@ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "closedon_userid", nullable = true)
private AppUser closedBy;
- @Temporal(TemporalType.DATE)
@Column(name = "writtenoffon_date")
- private Date writtenOffOnDate;
+ private LocalDate writtenOffOnDate;
- @Temporal(TemporalType.DATE)
@Column(name = "rescheduledon_date")
- private Date rescheduledOnDate;
+ private LocalDate rescheduledOnDate;
@ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "rescheduledon_userid", nullable = true)
private AppUser rescheduledByUser;
- @Temporal(TemporalType.DATE)
@Column(name = "expected_maturedon_date")
- private Date expectedMaturityDate;
+ private LocalDate expectedMaturityDate;
- @Temporal(TemporalType.DATE)
@Column(name = "maturedon_date")
- private Date actualMaturityDate;
+ private LocalDate actualMaturityDate;
- @Temporal(TemporalType.DATE)
@Column(name = "expected_firstrepaymenton_date")
- private Date expectedFirstRepaymentOnDate;
+ private LocalDate expectedFirstRepaymentOnDate;
- @Temporal(TemporalType.DATE)
@Column(name = "interest_calculated_from_date")
- private Date interestChargedFromDate;
+ private LocalDate interestChargedFromDate;
@Column(name = "total_overpaid_derived", scale = 6, precision = 19)
private BigDecimal totalOverpaid;
@@ -381,9 +363,8 @@ public class Loan extends AbstractPersistableCustom {
@Column(name = "is_npa", nullable = false)
private boolean isNpa;
- @Temporal(TemporalType.DATE)
@Column(name = "accrued_till")
- private Date accruedTill;
+ private LocalDate accruedTill;
@Column(name = "create_standing_instruction_at_disbursement", nullable = true)
private Boolean createStandingInstructionAtDisbursement;
@@ -391,9 +372,8 @@ public class Loan extends AbstractPersistableCustom {
@Column(name = "guarantee_amount_derived", scale = 6, precision = 19, nullable = true)
private BigDecimal guaranteeAmountDerived;
- @Temporal(TemporalType.DATE)
@Column(name = "interest_recalcualated_on")
- private Date interestRecalculatedOn;
+ private LocalDate interestRecalculatedOn;
@Column(name = "is_floating_interest_rate", nullable = true)
private Boolean isFloatingInterestRate;
@@ -678,11 +658,11 @@ public class Loan extends AbstractPersistableCustom {
}
/**
- * Creates a loanTransaction for "Apply Charge Event" with transaction date set to "suppliedTransactionDate". The
- * newly created transaction is also added to the Loan on which this method is called.
+ * Creates a loanTransaction for "Apply Charge Event" with transaction LocalDate set to "suppliedTransactionDate".
+ * The newly created transaction is also added to the Loan on which this method is called.
*
- * If "suppliedTransactionDate" is not passed Id, the transaction date is set to the loans due date if the due date
- * is lesser than todays date. If not, the transaction date is set to todays date
+ * If "suppliedTransactionDate" is not passed Id, the transaction LocalDate is set to the loans due LocalDate if the
+ * due date is lesser than todays date. If not, the transaction LocalDate is set to todays date
*
* @param loanCharge
* @param suppliedTransactionDate
@@ -706,7 +686,7 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate currentDate = DateUtils.getBusinessLocalDate();
// if loan charge is to be applied on a future date, the loan
- // transaction would show todays date as applied date
+ // transaction would show todays LocalDate as applied date
if (transactionDate == null || currentDate.isBefore(transactionDate)) {
transactionDate = currentDate;
}
@@ -779,7 +759,7 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate lastRepaymentPeriodDueDate) {
if (loanCharge.isSpecifiedDueDate()
&& !loanCharge.isDueForCollectionFromAndUpToAndIncluding(disbursementDate, lastRepaymentPeriodDueDate)) {
- final String defaultUserMessage = "This charge with specified due date cannot be added as the it is not in schedule range.";
+ final String defaultUserMessage = "This charge with specified due LocalDate cannot be added as the it is not in schedule range.";
throw new LoanChargeCannotBeAddedException("loanCharge", "specified.due.date.outside.range", defaultUserMessage,
getDisbursementDate(), lastRepaymentPeriodDueDate, loanCharge.name());
}
@@ -1069,7 +1049,7 @@ public class Loan extends AbstractPersistableCustom {
&& (loanCharge.getDueLocalDate() == null || DateUtils.getBusinessLocalDate().isAfter(loanCharge.getDueLocalDate()))) {
regenerateRepaymentScheduleWithInterestRecalculation(scheduleGeneratorDTO);
}
- // Waive of charges whose due date falls after latest 'repayment'
+ // Waive of charges whose due LocalDate falls after latest 'repayment'
// transaction dont require entire loan schedule to be reprocessed.
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
.determineProcessor(this.transactionProcessingStrategy);
@@ -1353,8 +1333,8 @@ public class Loan extends AbstractPersistableCustom {
public void updateLoanScheduleDependentDerivedFields() {
if (this.getLoanRepaymentScheduleInstallmentsSize() > 0) {
- this.expectedMaturityDate = Date.from(determineExpectedMaturityDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
- this.actualMaturityDate = Date.from(determineExpectedMaturityDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.expectedMaturityDate = determineExpectedMaturityDate();
+ this.actualMaturityDate = determineExpectedMaturityDate();
}
}
@@ -1503,8 +1483,7 @@ public class Loan extends AbstractPersistableCustom {
actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput);
- final LocalDate newValue = command.localDateValueOfParameterNamed(submittedOnDateParamName);
- this.submittedOnDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.submittedOnDate = command.localDateValueOfParameterNamed(submittedOnDateParamName);
}
final String expectedDisbursementDateParamName = "expectedDisbursementDate";
@@ -1515,8 +1494,7 @@ public class Loan extends AbstractPersistableCustom {
actualChanges.put("locale", localeAsInput);
actualChanges.put("recalculateLoanSchedule", true);
- final LocalDate newValue = command.localDateValueOfParameterNamed(expectedDisbursementDateParamName);
- this.expectedDisbursementDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.expectedDisbursementDate = command.localDateValueOfParameterNamed(expectedDisbursementDateParamName);
removeFirstDisbursementTransaction();
}
@@ -1528,12 +1506,7 @@ public class Loan extends AbstractPersistableCustom {
actualChanges.put("locale", localeAsInput);
actualChanges.put("recalculateLoanSchedule", true);
- final LocalDate newValue = command.localDateValueOfParameterNamed(repaymentsStartingFromDateParamName);
- if (newValue != null) {
- this.expectedFirstRepaymentOnDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
- } else {
- this.expectedFirstRepaymentOnDate = null;
- }
+ this.expectedFirstRepaymentOnDate = command.localDateValueOfParameterNamed(repaymentsStartingFromDateParamName);
}
final String syncDisbursementParameterName = "syncDisbursementWithMeeting";
@@ -1551,38 +1524,33 @@ public class Loan extends AbstractPersistableCustom {
actualChanges.put("locale", localeAsInput);
actualChanges.put("recalculateLoanSchedule", true);
- final LocalDate newValue = command.localDateValueOfParameterNamed(interestChargedFromDateParamName);
- if (newValue != null) {
- this.interestChargedFromDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
- } else {
- this.interestChargedFromDate = null;
- }
+ this.interestChargedFromDate = command.localDateValueOfParameterNamed(interestChargedFromDateParamName);
}
// the comparison should be done with the tenant date
- // (DateUtils.getBusinessDate()) and not the server date (new
+ // (DateUtils.getBusinessDate()) and not the server LocalDate (new
// LocalDate())
if (getSubmittedOnDate().isAfter(DateUtils.getBusinessLocalDate())) {
- final String errorMessage = "The date on which a loan is submitted cannot be in the future.";
+ final String errorMessage = "The LocalDate on which a loan is submitted cannot be in the future.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.a.future.date", errorMessage, getSubmittedOnDate());
}
if (!(this.client == null)) {
if (getSubmittedOnDate().isBefore(this.client.getActivationLocalDate())) {
- final String errorMessage = "The date on which a loan is submitted cannot be earlier than client's activation date.";
+ final String errorMessage = "The LocalDate on which a loan is submitted cannot be earlier than client's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.client.activation.date", errorMessage,
getSubmittedOnDate());
}
} else if (!(this.group == null)) {
if (getSubmittedOnDate().isBefore(this.group.getActivationLocalDate())) {
- final String errorMessage = "The date on which a loan is submitted cannot be earlier than groups's activation date.";
+ final String errorMessage = "The LocalDate on which a loan is submitted cannot be earlier than groups's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.group.activation.date", errorMessage,
getSubmittedOnDate());
}
}
if (getSubmittedOnDate().isAfter(getExpectedDisbursedOnLocalDate())) {
- final String errorMessage = "The date on which a loan is submitted cannot be after its expected disbursement date: "
+ final String errorMessage = "The LocalDate on which a loan is submitted cannot be after its expected disbursement date: "
+ getExpectedDisbursedOnLocalDate().toString();
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.after.expected.disbursement.date", errorMessage,
getSubmittedOnDate(), getExpectedDisbursedOnLocalDate());
@@ -1804,7 +1772,7 @@ public class Loan extends AbstractPersistableCustom {
return amount;
}
- // This method returns date format and locale if present in the JsonCommand
+ // This method returns LocalDate format and locale if present in the JsonCommand
private Map<String, String> getDateFormatAndLocale(final JsonCommand jsonCommand) {
Map<String, String> returnObject = new HashMap<>();
JsonElement jsonElement = jsonCommand.parsedJson();
@@ -1835,8 +1803,7 @@ public class Loan extends AbstractPersistableCustom {
LocalDate date = JsonParserHelper.convertFrom(valueAsString, LoanApiConstants.disbursementDateParameterName, dateFormat,
locale);
if (date != null) {
- returnObject.put(LoanApiConstants.disbursementDateParameterName,
- Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ returnObject.put(LoanApiConstants.disbursementDateParameterName, date);
}
}
}
@@ -1885,7 +1852,7 @@ public class Loan extends AbstractPersistableCustom {
if (disbursementDataArray != null && disbursementDataArray.size() > 0) {
String dateFormat = null;
Locale locale = null;
- // Gets date format and locate
+ // Gets LocalDate format and locate
Map<String, String> dateAndLocale = getDateFormatAndLocale(jsonCommand);
dateFormat = dateAndLocale.get(LoanApiConstants.dateFormatParameterName);
if (dateAndLocale.containsKey(LoanApiConstants.localeParameterName)) {
@@ -1894,7 +1861,8 @@ public class Loan extends AbstractPersistableCustom {
for (JsonElement jsonElement : disbursementDataArray) {
final JsonObject jsonObject = jsonElement.getAsJsonObject();
Map<String, Object> parsedDisbursementData = parseDisbursementDetails(jsonObject, dateFormat, locale);
- Date expectedDisbursementDate = (Date) parsedDisbursementData.get(LoanApiConstants.disbursementDateParameterName);
+ LocalDate expectedDisbursementDate = (LocalDate) parsedDisbursementData
+ .get(LoanApiConstants.disbursementDateParameterName);
BigDecimal principal = (BigDecimal) parsedDisbursementData.get(LoanApiConstants.disbursementPrincipalParameterName);
Long disbursementID = (Long) parsedDisbursementData.get(LoanApiConstants.disbursementIdParameterName);
chargeIds = (String) parsedDisbursementData.get(LoanApiConstants.loanChargeIdParameterName);
@@ -1942,13 +1910,13 @@ public class Loan extends AbstractPersistableCustom {
}
private void createOrUpdateDisbursementDetails(Long disbursementID, final Map<String, Object> actualChanges,
- Date expectedDisbursementDate, BigDecimal principal, List<Long> existingDisbursementList) {
+ LocalDate expectedDisbursementDate, BigDecimal principal, List<Long> existingDisbursementList) {
if (disbursementID != null) {
LoanDisbursementDetails loanDisbursementDetail = fetchLoanDisbursementsById(disbursementID);
existingDisbursementList.remove(disbursementID);
if (loanDisbursementDetail.actualDisbursementDate() == null) {
- Date actualDisbursementDate = null;
+ LocalDate actualDisbursementDate = null;
LoanDisbursementDetails disbursementDetails = new LoanDisbursementDetails(expectedDisbursementDate, actualDisbursementDate,
principal, this.netDisbursalAmount);
disbursementDetails.updateLoan(this);
@@ -1959,7 +1927,7 @@ public class Loan extends AbstractPersistableCustom {
}
}
} else {
- Date actualDisbursementDate = null;
+ LocalDate actualDisbursementDate = null;
LoanDisbursementDetails disbursementDetails = new LoanDisbursementDetails(expectedDisbursementDate, actualDisbursementDate,
principal, this.netDisbursalAmount);
disbursementDetails.updateLoan(this);
@@ -1967,7 +1935,7 @@ public class Loan extends AbstractPersistableCustom {
for (LoanTrancheCharge trancheCharge : trancheCharges) {
Charge chargeDefinition = trancheCharge.getCharge();
final LoanCharge loanCharge = LoanCharge.createNewWithoutLoan(chargeDefinition, principal, null, null, null,
- LocalDate.ofInstant(expectedDisbursementDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), null, null);
+ expectedDisbursementDate, null, null);
loanCharge.update(this);
LoanTrancheDisbursementCharge loanTrancheDisbursementCharge = new LoanTrancheDisbursementCharge(loanCharge,
disbursementDetails);
@@ -2079,22 +2047,21 @@ public class Loan extends AbstractPersistableCustom {
this.externalId = externalId;
this.termFrequency = loanApplicationTerms.getLoanTermFrequency();
this.termPeriodFrequencyType = loanApplicationTerms.getLoanTermPeriodFrequencyType().getValue();
- this.submittedOnDate = Date.from(submittedOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.submittedOnDate = submittedOn;
this.submittedBy = currentUser;
- this.expectedDisbursementDate = Date
- .from(loanApplicationTerms.getExpectedDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.expectedDisbursementDate = loanApplicationTerms.getExpectedDisbursementDate();
this.expectedFirstRepaymentOnDate = loanApplicationTerms.getRepaymentStartFromDate();
this.interestChargedFromDate = loanApplicationTerms.getInterestChargedFromDate();
updateLoanScheduleDependentDerivedFields();
if (submittedOn.isAfter(DateUtils.getBusinessLocalDate())) {
- final String errorMessage = "The date on which a loan is submitted cannot be in the future.";
+ final String errorMessage = "The LocalDate on which a loan is submitted cannot be in the future.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.a.future.date", errorMessage, submittedOn);
}
if (this.client != null && this.client.isActivatedAfter(submittedOn)) {
- final String errorMessage = "The date on which a loan is submitted cannot be earlier than client's activation date.";
+ final String errorMessage = "The LocalDate on which a loan is submitted cannot be earlier than client's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.client.activation.date", errorMessage,
submittedOn);
}
@@ -2102,12 +2069,12 @@ public class Loan extends AbstractPersistableCustom {
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_CREATED, submittedOn);
if (this.group != null && this.group.isActivatedAfter(submittedOn)) {
- final String errorMessage = "The date on which a loan is submitted cannot be earlier than groups's activation date.";
+ final String errorMessage = "The LocalDate on which a loan is submitted cannot be earlier than groups's activation date.";
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.group.activation.date", errorMessage, submittedOn);
}
if (submittedOn.isAfter(getExpectedDisbursedOnLocalDate())) {
- final String errorMessage = "The date on which a loan is submitted cannot be after its expected disbursement date: "
+ final String errorMessage = "The LocalDate on which a loan is submitted cannot be after its expected disbursement date: "
+ getExpectedDisbursedOnLocalDate().toString();
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.after.expected.disbursement.date", errorMessage,
submittedOn, getExpectedDisbursedOnLocalDate());
@@ -2121,7 +2088,7 @@ public class Loan extends AbstractPersistableCustom {
updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
- // validate if disbursement date is a holiday or a non-working day
+ // validate if disbursement LocalDate is a holiday or a non-working day
validateDisbursementDateIsOnNonWorkingDay(workingDays, allowTransactionsOnNonWorkingDay);
validateDisbursementDateIsOnHoliday(allowTransactionsOnHoliday, holidays);
@@ -2169,9 +2136,9 @@ public class Loan extends AbstractPersistableCustom {
final Locale locale = new Locale(command.locale());
final DateTimeFormatter fmt = DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(locale);
- this.rejectedOnDate = Date.from(rejectedOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.rejectedOnDate = rejectedOn;
this.rejectedBy = currentUser;
- this.closedOnDate = Date.from(rejectedOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.closedOnDate = rejectedOn;
this.closedBy = currentUser;
actualChanges.put("locale", command.locale());
@@ -2180,7 +2147,7 @@ public class Loan extends AbstractPersistableCustom {
actualChanges.put("closedOnDate", rejectedOn.format(fmt));
if (rejectedOn.isBefore(getSubmittedOnDate())) {
- final String errorMessage = "The date on which a loan is rejected cannot be before its submittal date: "
+ final String errorMessage = "The LocalDate on which a loan is rejected cannot be before its submittal date: "
+ getSubmittedOnDate().toString();
throw new InvalidLoanStateTransitionException("reject", "cannot.be.before.submittal.date", errorMessage, rejectedOn,
getSubmittedOnDate());
@@ -2189,7 +2156,7 @@ public class Loan extends AbstractPersistableCustom {
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_REJECTED, rejectedOn);
if (rejectedOn.isAfter(DateUtils.getBusinessLocalDate())) {
- final String errorMessage = "The date on which a loan is rejected cannot be in the future.";
+ final String errorMessage = "The LocalDate on which a loan is rejected cannot be in the future.";
throw new InvalidLoanStateTransitionException("reject", "cannot.be.a.future.date", errorMessage, rejectedOn);
}
} else {
@@ -2218,9 +2185,9 @@ public class Loan extends AbstractPersistableCustom {
final Locale locale = new Locale(command.locale());
final DateTimeFormatter fmt = DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(locale);
- this.withdrawnOnDate = Date.from(withdrawnOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.withdrawnOnDate = withdrawnOn;
this.withdrawnBy = currentUser;
- this.closedOnDate = Date.from(withdrawnOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.closedOnDate = withdrawnOn;
this.closedBy = currentUser;
actualChanges.put("locale", command.locale());
@@ -2229,7 +2196,7 @@ public class Loan extends AbstractPersistableCustom {
actualChanges.put("closedOnDate", withdrawnOn.format(fmt));
if (withdrawnOn.isBefore(getSubmittedOnDate())) {
- final String errorMessage = "The date on which a loan is withdrawn cannot be before its submittal date: "
+ final String errorMessage = "The LocalDate on which a loan is withdrawn cannot be before its submittal date: "
+ getSubmittedOnDate().toString();
throw new InvalidLoanStateTransitionException("withdraw", "cannot.be.before.submittal.date", errorMessage, command,
getSubmittedOnDate());
@@ -2238,7 +2205,7 @@ public class Loan extends AbstractPersistableCustom {
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_WITHDRAWN, withdrawnOn);
if (withdrawnOn.isAfter(DateUtils.getBusinessLocalDate())) {
- final String errorMessage = "The date on which a loan is withdrawn cannot be in the future.";
+ final String errorMessage = "The LocalDate on which a loan is withdrawn cannot be in the future.";
throw new InvalidLoanStateTransitionException("withdraw", "cannot.be.a.future.date", errorMessage, command);
}
} else {
@@ -2325,26 +2292,26 @@ public class Loan extends AbstractPersistableCustom {
loanProduct.maxTrancheCount(), disbursementDetails.size());
}
}
- this.approvedOnDate = Date.from(approvedOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.approvedOnDate = approvedOn;
this.approvedBy = currentUser;
actualChanges.put("locale", command.locale());
actualChanges.put("dateFormat", command.dateFormat());
actualChanges.put("approvedOnDate", approvedOnDateChange);
- final LocalDate submittalDate = LocalDate.ofInstant(this.submittedOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ final LocalDate submittalDate = this.submittedOnDate;
if (approvedOn.isBefore(submittalDate)) {
- final String errorMessage = "The date on which a loan is approved cannot be before its submittal date: "
+ final String errorMessage = "The LocalDate on which a loan is approved cannot be before its submittal date: "
+ submittalDate.toString();
throw new InvalidLoanStateTransitionException("approval", "cannot.be.before.submittal.date", errorMessage,
getApprovedOnDate(), submittalDate);
}
if (expecteddisbursementDate != null) {
- this.expectedDisbursementDate = Date.from(expecteddisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.expectedDisbursementDate = expecteddisbursementDate;
actualChanges.put("expectedDisbursementDate", expectedDisbursementDate);
if (expecteddisbursementDate.isBefore(approvedOn)) {
- final String errorMessage = "The expected disbursement date should be either on or after the approval date: "
+ final String errorMessage = "The expected disbursement LocalDate should be either on or after the approval date: "
+ approvedOn.toString();
throw new InvalidLoanStateTransitionException("expecteddisbursal", "should.be.on.or.after.approval.date", errorMessage,
getApprovedOnDate(), expecteddisbursementDate);
@@ -2354,7 +2321,7 @@ public class Loan extends AbstractPersistableCustom {
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_APPROVED, approvedOn);
if (approvedOn.isAfter(DateUtils.getBusinessLocalDate())) {
- final String errorMessage = "The date on which a loan is approved cannot be in the future.";
+ final String errorMessage = "The LocalDate on which a loan is approved cannot be in the future.";
throw new InvalidLoanStateTransitionException("approval", "cannot.be.a.future.date", errorMessage, getApprovedOnDate());
}
@@ -2476,7 +2443,7 @@ public class Loan extends AbstractPersistableCustom {
HolidayDetailDTO holidayDetailDTO = scheduleGeneratorDTO.getHolidayDetailDTO();
- // validate if disbursement date is a holiday or a non-working day
+ // validate if disbursement LocalDate is a holiday or a non-working day
validateDisbursementDateIsOnNonWorkingDay(holidayDetailDTO.getWorkingDays(), holidayDetailDTO.isAllowTransactionsOnNonWorkingDay());
validateDisbursementDateIsOnHoliday(holidayDetailDTO.isAllowTransactionsOnHoliday(), holidayDetailDTO.getHolidays());
@@ -2530,18 +2497,18 @@ public class Loan extends AbstractPersistableCustom {
public void regenerateScheduleOnDisbursement(final ScheduleGeneratorDTO scheduleGeneratorDTO, final boolean recalculateSchedule,
final LocalDate actualDisbursementDate, BigDecimal emiAmount, LocalDate nextPossibleRepaymentDate,
- Date rescheduledRepaymentDate) {
+ LocalDate rescheduledRepaymentDate) {
boolean isEmiAmountChanged = false;
if ((this.loanProduct.isMultiDisburseLoan() || this.loanProduct.canDefineInstallmentAmount()) && emiAmount != null
&& emiAmount.compareTo(retriveLastEmiAmount()) != 0) {
if (this.loanProduct.isMultiDisburseLoan()) {
- final Date dateValue = null;
+ final LocalDate dateValue = null;
final boolean isSpecificToInstallment = false;
final Boolean isChangeEmiIfRepaymentDateSameAsDisbursementDateEnabled = scheduleGeneratorDTO
.isChangeEmiIfRepaymentDateSameAsDisbursementDateEnabled();
- Date effectiveDateFrom = Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ LocalDate effectiveDateFrom = actualDisbursementDate;
if (!isChangeEmiIfRepaymentDateSameAsDisbursementDateEnabled && actualDisbursementDate.equals(nextPossibleRepaymentDate)) {
- effectiveDateFrom = Date.from(nextPossibleRepaymentDate.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant());
+ effectiveDateFrom = nextPossibleRepaymentDate.plusDays(1);
}
LoanTermVariations loanVariationTerms = new LoanTermVariations(LoanTermVariationType.EMI_AMOUNT.getValue(),
effectiveDateFrom, emiAmount, dateValue, isSpecificToInstallment, this, LoanStatus.ACTIVE.getValue());
@@ -2554,8 +2521,8 @@ public class Loan extends AbstractPersistableCustom {
if (rescheduledRepaymentDate != null && this.loanProduct.isMultiDisburseLoan()) {
final boolean isSpecificToInstallment = false;
LoanTermVariations loanVariationTerms = new LoanTermVariations(LoanTermVariationType.DUE_DATE.getValue(),
- Date.from(nextPossibleRepaymentDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), emiAmount,
- rescheduledRepaymentDate, isSpecificToInstallment, this, LoanStatus.ACTIVE.getValue());
+ nextPossibleRepaymentDate, emiAmount, rescheduledRepaymentDate, isSpecificToInstallment, this,
+ LoanStatus.ACTIVE.getValue());
this.loanTermVariations.add(loanVariationTerms);
}
@@ -2570,7 +2537,7 @@ public class Loan extends AbstractPersistableCustom {
}
public boolean canDisburse(final LocalDate actualDisbursementDate) {
- Date lastDusburseDate = this.actualDisbursementDate;
+ LocalDate lastDisburseDate = this.actualDisbursementDate;
final LoanStatus statusEnum = this.loanLifecycleStateMachine.transition(LoanEvent.LOAN_DISBURSED,
LoanStatus.fromInt(this.loanStatus));
@@ -2579,12 +2546,12 @@ public class Loan extends AbstractPersistableCustom {
LoanDisbursementDetails details = fetchLastDisburseDetail();
if (details != null) {
- lastDusburseDate = details.actualDisbursementDate();
+ lastDisburseDate = details.actualDisbursementDate();
}
- if (Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()).before(lastDusburseDate)) {
- final String errorMsg = "Loan can't be disbursed before " + lastDusburseDate;
- throw new LoanDisbursalException(errorMsg, "actualdisbursementdate.before.lastdusbursedate", lastDusburseDate,
- Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ if (actualDisbursementDate.isBefore(lastDisburseDate)) {
+ final String errorMsg = "Loan can't be disbursed before " + lastDisburseDate;
+ throw new LoanDisbursalException(errorMsg, "actualdisbursementdate.before.lastdusbursedate", lastDisburseDate,
+ actualDisbursementDate);
}
isMultiTrancheDisburse = true;
}
@@ -2595,7 +2562,7 @@ public class Loan extends AbstractPersistableCustom {
Money disburseAmount = this.loanRepaymentScheduleDetail.getPrincipal().zero();
BigDecimal principalDisbursed = command.bigDecimalValueOfParameterNamed(LoanApiConstants.principalDisbursedParameterName);
if (this.actualDisbursementDate == null) {
- this.actualDisbursementDate = Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.actualDisbursementDate = actualDisbursementDate;
}
BigDecimal diff = BigDecimal.ZERO;
Collection<LoanDisbursementDetails> details = fetchUndisbursedDetail();
@@ -2604,8 +2571,7 @@ public class Loan extends AbstractPersistableCustom {
if (!details.isEmpty()) {
disburseAmount = disburseAmount.zero();
for (LoanDisbursementDetails disbursementDetails : details) {
- disbursementDetails.updateActualDisbursementDate(
- Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ disbursementDetails.updateActualDisbursementDate(actualDisbursementDate);
disburseAmount = disburseAmount.plus(disbursementDetails.principal());
}
}
@@ -2620,8 +2586,7 @@ public class Loan extends AbstractPersistableCustom {
diff = this.loanRepaymentScheduleDetail.getPrincipal().minus(principalDisbursed).getAmount();
} else {
for (LoanDisbursementDetails disbursementDetails : details) {
- disbursementDetails.updateActualDisbursementDate(
- Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ disbursementDetails.updateActualDisbursementDate(actualDisbursementDate);
disbursementDetails.updatePrincipal(principalDisbursed);
}
}
@@ -2690,13 +2655,13 @@ public class Loan extends AbstractPersistableCustom {
private Collection<LoanDisbursementDetails> fetchUndisbursedDetail() {
Collection<LoanDisbursementDetails> disbursementDetails = new ArrayList<>();
- Date date = null;
+ LocalDate date = null;
for (LoanDisbursementDetails disbursementDetail : this.disbursementDetails) {
if (disbursementDetail.actualDisbursementDate() == null) {
if (date == null || disbursementDetail.expectedDisbursementDate().compareTo(date) == 0 ? Boolean.TRUE : Boolean.FALSE) {
disbursementDetails.add(disbursementDetail);
date = disbursementDetail.expectedDisbursementDate();
- } else if (disbursementDetail.expectedDisbursementDate().before(date)) {
+ } else if (disbursementDetail.expectedDisbursementDate().isBefore(date)) {
disbursementDetails.clear();
disbursementDetails.add(disbursementDetail);
date = disbursementDetail.expectedDisbursementDate();
@@ -2708,11 +2673,11 @@ public class Loan extends AbstractPersistableCustom {
private LoanDisbursementDetails fetchLastDisburseDetail() {
LoanDisbursementDetails details = null;
- Date date = this.actualDisbursementDate;
+ LocalDate date = this.actualDisbursementDate;
if (date != null) {
for (LoanDisbursementDetails disbursementDetail : this.disbursementDetails) {
if (disbursementDetail.actualDisbursementDate() != null) {
- if (disbursementDetail.actualDisbursementDate().after(date)
+ if (disbursementDetail.actualDisbursementDate().isAfter(date)
|| disbursementDetail.actualDisbursementDate().compareTo(date) == 0 ? Boolean.TRUE : Boolean.FALSE) {
date = disbursementDetail.actualDisbursementDate();
details = disbursementDetail;
@@ -2872,14 +2837,13 @@ public class Loan extends AbstractPersistableCustom {
disbursedOn, null);
final Integer installmentNumber = null;
for (final LoanCharge charge : charges()) {
- Date actualDisbursementDate = getActualDisbursementDate(charge);
+ LocalDate actualDisbursementDate = getActualDisbursementDate(charge);
if ((charge.getCharge().getChargeTimeType().equals(ChargeTimeType.DISBURSEMENT.getValue())
- && disbursedOn.equals(LocalDate.ofInstant(actualDisbursementDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()))
- && (actualDisbursementDate != null) && !charge.isWaived() && !charge.isFullyPaid())
+ && disbursedOn.equals(actualDisbursementDate) && (actualDisbursementDate != null) && !charge.isWaived()
+ && !charge.isFullyPaid())
|| (charge.getCharge().getChargeTimeType().equals(ChargeTimeType.TRANCHE_DISBURSEMENT.getValue())
- && disbursedOn
- .equals(LocalDate.ofInstant(actualDisbursementDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()))
- && (actualDisbursementDate != null) && !charge.isWaived() && !charge.isFullyPaid())) {
+ && disbursedOn.equals(actualDisbursementDate) && (actualDisbursementDate != null) && !charge.isWaived()
+ && !charge.isFullyPaid())) {
if (totalFeeChargesDueAtDisbursement.isGreaterThanZero() && !charge.getChargePaymentMode().isPaymentModeAccountTransfer()) {
charge.markAsFullyPaid();
// Add "Loan Charge Paid By" details to this transaction
@@ -2888,8 +2852,7 @@ public class Loan extends AbstractPersistableCustom {
chargesPayment.getLoanChargesPaid().add(loanChargePaidBy);
disbursentMoney = disbursentMoney.plus(charge.amount());
}
- } else if (disbursedOn
- .equals(LocalDate.ofInstant(this.actualDisbursementDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()))) {
+ } else if (disbursedOn.equals(this.actualDisbursementDate)) {
/**
* create a Charge applied transaction if Up front Accrual, None or Cash based accounting is enabled
**/
@@ -2908,7 +2871,7 @@ public class Loan extends AbstractPersistableCustom {
}
if (getApprovedOnDate() != null && disbursedOn.isBefore(getApprovedOnDate())) {
- final String errorMessage = "The date on which a loan is disbursed cannot be before its approval date: "
+ final String errorMessage = "The LocalDate on which a loan is disbursed cannot be before its approval date: "
+ getApprovedOnDate().toString();
throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.before.approval.date", errorMessage, disbursedOn,
getApprovedOnDate());
@@ -2917,9 +2880,7 @@ public class Loan extends AbstractPersistableCustom {
if (getExpectedFirstRepaymentOnDate() != null
&& (disbursedOn.isAfter(this.fetchRepaymentScheduleInstallment(1).getDueDate())
|| disbursedOn.isAfter(getExpectedFirstRepaymentOnDate()))
- && Date.from(disbursedOn.atStartOfDay(ZoneId.systemDefault()).toInstant()).compareTo(this.actualDisbursementDate) == 0
- ? Boolean.TRUE
- : Boolean.FALSE) {
+ && disbursedOn.compareTo(this.actualDisbursementDate) == 0 ? Boolean.TRUE : Boolean.FALSE) {
final String errorMessage = "submittedOnDate cannot be after the loans expectedFirstRepaymentOnDate: "
+ getExpectedFirstRepaymentOnDate().toString();
throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.after.expected.first.repayment.date", errorMessage,
@@ -2929,7 +2890,7 @@ public class Loan extends AbstractPersistableCustom {
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_DISBURSED, disbursedOn);
if (disbursedOn.isAfter(DateUtils.getBusinessLocalDate())) {
- final String errorMessage = "The date on which a loan with identifier : " + this.accountNumber
+ final String errorMessage = "The LocalDate on which a loan with identifier : " + this.accountNumber
+ " is disbursed cannot be in the future.";
throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.a.future.date", errorMessage, disbursedOn);
}
@@ -2996,7 +2957,7 @@ public class Loan extends AbstractPersistableCustom {
updateLoanToPreDisbursalState();
if (isScheduleRegenerateRequired || isDisbursedAmountChanged || isEmiAmountChanged
|| this.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
- // clear off actual disbusrement date so schedule regeneration
+ // clear off actual disbusrement LocalDate so schedule regeneration
// uses expected date.
regenerateRepaymentSchedule(scheduleGeneratorDTO);
@@ -3147,7 +3108,7 @@ public class Loan extends AbstractPersistableCustom {
holidayDetailDTO.isAllowTransactionsOnNonWorkingDay());
if (paymentTransaction.getTransactionDate().isAfter(DateUtils.getBusinessLocalDate())) {
- final String errorMessage = "The date on which a loan charge paid cannot be in the future.";
+ final String errorMessage = "The LocalDate on which a loan charge paid cannot be in the future.";
throw new InvalidLoanStateTransitionException("charge.payment", "cannot.be.a.future.date", errorMessage,
paymentTransaction.getTransactionDate());
}
@@ -3239,14 +3200,14 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate loanTransactionDate = loanTransaction.getTransactionDate();
if (loanTransactionDate.isBefore(getDisbursementDate())) {
- final String errorMessage = "The transaction date cannot be before the loan disbursement date: "
+ final String errorMessage = "The transaction LocalDate cannot be before the loan disbursement date: "
+ getApprovedOnDate().toString();
throw new InvalidLoanStateTransitionException("transaction", "cannot.be.before.disbursement.date", errorMessage,
loanTransactionDate, getDisbursementDate());
}
if (loanTransactionDate.isAfter(DateUtils.getBusinessLocalDate())) {
- final String errorMessage = "The transaction date cannot be in the future.";
+ final String errorMessage = "The transaction LocalDate cannot be in the future.";
throw new InvalidLoanStateTransitionException("transaction", "cannot.be.a.future.date", errorMessage, loanTransactionDate);
}
@@ -3444,8 +3405,8 @@ public class Loan extends AbstractPersistableCustom {
LoanStatus.fromInt(this.loanStatus));
this.loanStatus = statusEnum.getValue();
- this.closedOnDate = Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
- this.actualMaturityDate = Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.closedOnDate = transactionDate;
+ this.actualMaturityDate = transactionDate;
} else if (LoanStatus.fromInt(this.loanStatus).isOverpaid()) {
final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.LOAN_REPAYMENT_OR_WAIVER,
LoanStatus.fromInt(this.loanStatus));
@@ -3457,8 +3418,7 @@ public class Loan extends AbstractPersistableCustom {
private void processIncomeAccrualTransactionOnLoanClosure() {
if (this.loanInterestRecalculationDetails != null && this.loanInterestRecalculationDetails.isCompoundingToBePostedAsTransaction()
&& this.status().isClosedObligationsMet()) {
- Date closedDate = this.getClosedOnDate();
- LocalDate closedLocalDate = LocalDate.ofInstant(closedDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ LocalDate closedDate = this.getClosedOnDate();
reverseTransactionsOnOrAfter(retreiveListOfIncomePostingTransactions(), closedDate);
reverseTransactionsOnOrAfter(retreiveListOfAccrualTransactions(), closedDate);
HashMap<String, BigDecimal> cumulativeIncomeFromInstallments = new HashMap<>();
@@ -3471,7 +3431,7 @@ public class Loan extends AbstractPersistableCustom {
BigDecimal penaltyToPost = cumulativeIncomeFromInstallments.get("penalty")
.subtract(cumulativeIncomeFromIncomePosting.get("penalty"));
BigDecimal amountToPost = interestToPost.add(feeToPost).add(penaltyToPost);
- LoanTransaction finalIncomeTransaction = LoanTransaction.incomePosting(this, this.getOffice(), closedLocalDate, amountToPost,
+ LoanTransaction finalIncomeTransaction = LoanTransaction.incomePosting(this, this.getOffice(), closedDate, amountToPost,
interestToPost, feeToPost, penaltyToPost);
addLoanTransaction(finalIncomeTransaction);
if (isPeriodicAccrualAccountingEnabledOnLoanProduct()) {
@@ -3481,8 +3441,8 @@ public class Loan extends AbstractPersistableCustom {
lastAccruedDate = updatedAccrualTransactions.get(updatedAccrualTransactions.size() - 1).getTransactionDate();
}
HashMap<String, Object> feeDetails = new HashMap<>();
- determineFeeDetails(lastAccruedDate, closedLocalDate, feeDetails);
- LoanTransaction finalAccrual = LoanTransaction.accrueTransaction(this, this.getOffice(), closedLocalDate, amountToPost,
+ determineFeeDetails(lastAccruedDate, closedDate, feeDetails);
+ LoanTransaction finalAccrual = LoanTransaction.accrueTransaction(this, this.getOffice(), closedDate, amountToPost,
interestToPost, feeToPost, penaltyToPost);
updateLoanChargesPaidBy(finalAccrual, feeDetails, null);
addLoanTransaction(finalAccrual);
@@ -3798,14 +3758,14 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate writtenOffOnLocalDate = command.localDateValueOfParameterNamed("transactionDate");
final String txnExternalId = command.stringValueOfParameterNamedAllowingNull("externalId");
- this.closedOnDate = Date.from(writtenOffOnLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
- this.writtenOffOnDate = Date.from(writtenOffOnLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.closedOnDate = writtenOffOnLocalDate;
+ this.writtenOffOnDate = writtenOffOnLocalDate;
this.closedBy = currentUser;
changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate"));
changes.put("writtenOffOnDate", command.stringValueOfParameterNamed("transactionDate"));
if (writtenOffOnLocalDate.isBefore(getDisbursementDate())) {
- final String errorMessage = "The date on which a loan is written off cannot be before the loan disbursement date: "
+ final String errorMessage = "The LocalDate on which a loan is written off cannot be before the loan disbursement date: "
+ getDisbursementDate().toString();
throw new InvalidLoanStateTransitionException("writeoff", "cannot.be.before.submittal.date", errorMessage,
writtenOffOnLocalDate, getDisbursementDate());
@@ -3814,7 +3774,7 @@ public class Loan extends AbstractPersistableCustom {
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.WRITE_OFF_OUTSTANDING, writtenOffOnLocalDate);
if (writtenOffOnLocalDate.isAfter(DateUtils.getBusinessLocalDate())) {
- final String errorMessage = "The date on which a loan is written off cannot be in the future.";
+ final String errorMessage = "The LocalDate on which a loan is written off cannot be in the future.";
throw new InvalidLoanStateTransitionException("writeoff", "cannot.be.a.future.date", errorMessage, writtenOffOnLocalDate);
}
@@ -3822,7 +3782,7 @@ public class Loan extends AbstractPersistableCustom {
loanTransaction = LoanTransaction.writeoff(this, getOffice(), writtenOffOnLocalDate, txnExternalId);
LocalDate lastTransactionDate = getLastUserTransactionDate();
if (lastTransactionDate.isAfter(writtenOffOnLocalDate)) {
- final String errorMessage = "The date of the writeoff transaction must occur on or before previous transactions.";
+ final String errorMessage = "The LocalDate of the writeoff transaction must occur on or before previous transactions.";
throw new InvalidLoanStateTransitionException("writeoff", "must.occur.on.or.after.other.transaction.dates", errorMessage,
writtenOffOnLocalDate);
}
@@ -3886,19 +3846,19 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate closureDate = command.localDateValueOfParameterNamed("transactionDate");
final String txnExternalId = command.stringValueOfParameterNamedAllowingNull("externalId");
- this.closedOnDate = Date.from(closureDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.closedOnDate = closureDate;
changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate"));
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.REPAID_IN_FULL, closureDate);
if (closureDate.isBefore(getDisbursementDate())) {
- final String errorMessage = "The date on which a loan is closed cannot be before the loan disbursement date: "
+ final String errorMessage = "The LocalDate on which a loan is closed cannot be before the loan disbursement date: "
+ getDisbursementDate().toString();
throw new InvalidLoanStateTransitionException("close", "cannot.be.before.submittal.date", errorMessage, closureDate,
getDisbursementDate());
}
if (closureDate.isAfter(DateUtils.getBusinessLocalDate())) {
- final String errorMessage = "The date on which a loan is closed cannot be in the future.";
+ final String errorMessage = "The LocalDate on which a loan is closed cannot be in the future.";
throw new InvalidLoanStateTransitionException("close", "cannot.be.a.future.date", errorMessage, closureDate);
}
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
@@ -3917,11 +3877,11 @@ public class Loan extends AbstractPersistableCustom {
this.loanStatus = statusEnum.getValue();
changes.put("status", LoanEnumerations.status(this.loanStatus));
}
- this.closedOnDate = Date.from(closureDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.closedOnDate = closureDate;
loanTransaction = LoanTransaction.writeoff(this, getOffice(), closureDate, txnExternalId);
final boolean isLastTransaction = isChronologicallyLatestTransaction(loanTransaction, getLoanTransactions());
if (!isLastTransaction) {
- final String errorMessage = "The closing date of the loan must be on or after latest transaction date.";
+ final String errorMessage = "The closing LocalDate of the loan must be on or after latest transaction date.";
throw new InvalidLoanStateTransitionException("close.loan", "must.occur.on.or.after.latest.transaction.date",
errorMessage, closureDate);
}
@@ -3950,7 +3910,7 @@ public class Loan extends AbstractPersistableCustom {
this.loanStatus = statusEnum.getValue();
changes.put("status", LoanEnumerations.status(this.loanStatus));
}
- this.closedOnDate = Date.from(closureDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.closedOnDate = closureDate;
} else if (totalLoanOverpayment.isGreaterThanZero()) {
final String errorMessage = "The loan is marked as 'Overpaid' and cannot be moved to 'Closed (obligations met).";
throw new InvalidLoanStateTransitionException("close", "loan.is.overpaid", errorMessage, totalLoanOverpayment.toString());
@@ -3979,24 +3939,22 @@ public class Loan extends AbstractPersistableCustom {
changes.put("status", LoanEnumerations.status(this.loanStatus));
}
- this.closedOnDate = Date.from(rescheduledOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
- this.rescheduledOnDate = Date.from(rescheduledOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.closedOnDate = rescheduledOn;
+ this.rescheduledOnDate = rescheduledOn;
changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate"));
changes.put("rescheduledOnDate", command.stringValueOfParameterNamed("transactionDate"));
- final LocalDate rescheduledOnLocalDate = LocalDate.ofInstant(this.rescheduledOnDate.toInstant(),
- DateUtils.getDateTimeZoneOfTenant());
- if (rescheduledOnLocalDate.isBefore(getDisbursementDate())) {
- final String errorMessage = "The date on which a loan is rescheduled cannot be before the loan disbursement date: "
+ if (this.rescheduledOnDate.isBefore(getDisbursementDate())) {
+ final String errorMessage = "The LocalDate on which a loan is rescheduled cannot be before the loan disbursement date: "
+ getDisbursementDate().toString();
throw new InvalidLoanStateTransitionException("close.reschedule", "cannot.be.before.submittal.date", errorMessage,
- rescheduledOnLocalDate, getDisbursementDate());
+ this.rescheduledOnDate, getDisbursementDate());
}
- if (rescheduledOnLocalDate.isAfter(DateUtils.getBusinessLocalDate())) {
- final String errorMessage = "The date on which a loan is rescheduled cannot be in the future.";
+ if (this.rescheduledOnDate.isAfter(DateUtils.getBusinessLocalDate())) {
+ final String errorMessage = "The LocalDate on which a loan is rescheduled cannot be in the future.";
throw new InvalidLoanStateTransitionException("close.reschedule", "cannot.be.a.future.date", errorMessage,
- rescheduledOnLocalDate);
+ this.rescheduledOnDate);
}
}
@@ -4084,62 +4042,47 @@ public class Loan extends AbstractPersistableCustom {
}
public boolean isSubmittedOnDateAfter(final LocalDate compareDate) {
- return this.submittedOnDate == null ? false
- : LocalDate.ofInstant(this.submittedOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()).isAfter(compareDate);
+ return this.submittedOnDate == null ? false : this.submittedOnDate.isAfter(compareDate);
}
public LocalDate getSubmittedOnDate() {
- return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.submittedOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), null);
+ return this.submittedOnDate;
}
public LocalDate getApprovedOnDate() {
- LocalDate date = null;
- if (this.approvedOnDate != null) {
- date = LocalDate.ofInstant(this.approvedOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
- return date;
+ return this.approvedOnDate;
}
public LocalDate getExpectedDisbursedOnLocalDate() {
- LocalDate expectedDisbursementDate = null;
- if (this.expectedDisbursementDate != null) {
- expectedDisbursementDate = LocalDate.ofInstant(this.expectedDisbursementDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
- return expectedDisbursementDate;
+ return this.expectedDisbursementDate;
}
public LocalDate getDisbursementDate() {
LocalDate disbursementDate = getExpectedDisbursedOnLocalDate();
if (this.actualDisbursementDate != null) {
- disbursementDate = LocalDate.ofInstant(this.actualDisbursementDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ disbursementDate = this.actualDisbursementDate;
}
return disbursementDate;
}
- public void setActualDisbursementDate(Date actualDisbursementDate) {
+ public void setActualDisbursementDate(LocalDate actualDisbursementDate) {
this.actualDisbursementDate = actualDisbursementDate;
}
public LocalDate getWrittenOffDate() {
- LocalDate writtenOffDate = null;
- if (this.writtenOffOnDate != null) {
- writtenOffDate = LocalDate.ofInstant(this.writtenOffOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
- return writtenOffDate;
+ return this.writtenOffOnDate;
}
public LocalDate getExpectedDisbursedOnLocalDateForTemplate() {
-
LocalDate expectedDisbursementDate = null;
if (this.expectedDisbursementDate != null) {
- expectedDisbursementDate = LocalDate.ofInstant(this.expectedDisbursementDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ expectedDisbursementDate = this.expectedDisbursementDate;
}
Collection<LoanDisbursementDetails> details = fetchUndisbursedDetail();
if (!details.isEmpty()) {
for (LoanDisbursementDetails disbursementDetails : details) {
- expectedDisbursementDate = LocalDate.ofInstant(disbursementDetails.expectedDisbursementDate().toInstant(),
- DateUtils.getDateTimeZoneOfTenant());
+ expectedDisbursementDate = disbursementDetails.expectedDisbursementDate();
}
}
return expectedDisbursementDate;
@@ -4162,11 +4105,7 @@ public class Loan extends AbstractPersistableCustom {
}
public LocalDate getExpectedFirstRepaymentOnDate() {
- LocalDate firstRepaymentDate = null;
- if (this.expectedFirstRepaymentOnDate != null) {
- firstRepaymentDate = LocalDate.ofInstant(this.expectedFirstRepaymentOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
- return firstRepaymentDate;
+ return this.expectedFirstRepaymentOnDate;
}
private boolean isActualDisbursedOnDateEarlierOrLaterThanExpected(final LocalDate actualDisbursedOnDate) {
@@ -4178,8 +4117,7 @@ public class Loan extends AbstractPersistableCustom {
isRegenerationRequired = true;
}
}
- return !LocalDate.ofInstant(this.expectedDisbursementDate.toInstant(), DateUtils.getDateTimeZoneOfTenant())
- .isEqual(actualDisbursedOnDate) || isRegenerationRequired;
+ return !this.expectedDisbursementDate.isEqual(actualDisbursedOnDate) || isRegenerationRequired;
}
private boolean isRepaymentScheduleRegenerationRequiredForDisbursement(final LocalDate actualDisbursementDate) {
@@ -4256,11 +4194,7 @@ public class Loan extends AbstractPersistableCustom {
}
public LocalDate getInterestChargedFromDate() {
- LocalDate interestChargedFrom = null;
- if (this.interestChargedFromDate != null) {
- interestChargedFrom = LocalDate.ofInstant(this.interestChargedFromDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
- return interestChargedFrom;
+ return this.interestChargedFromDate;
}
public Money getPrincpal() {
@@ -4284,26 +4218,26 @@ public class Loan extends AbstractPersistableCustom {
final LoanOfficerAssignmentHistory latestHistoryRecord = findLatestIncompleteHistoryRecord();
final LoanOfficerAssignmentHistory lastAssignmentRecord = findLastAssignmentHistoryRecord(newLoanOfficer);
- // assignment date should not be less than loan submitted date
+ // assignment LocalDate should not be less than loan submitted date
if (isSubmittedOnDateAfter(assignmentDate)) {
- final String errorMessage = "The Loan Officer assignment date (" + assignmentDate.toString()
- + ") cannot be before loan submitted date (" + getSubmittedOnDate().toString() + ").";
+ final String errorMessage = "The Loan Officer assignment LocalDate (" + assignmentDate.toString()
+ + ") cannot be before loan submitted LocalDate (" + getSubmittedOnDate().toString() + ").";
throw new LoanOfficerAssignmentDateException("cannot.be.before.loan.submittal.date", errorMessage, assignmentDate,
getSubmittedOnDate());
} else if (lastAssignmentRecord != null && lastAssignmentRecord.isEndDateAfter(assignmentDate)) {
- final String errorMessage = "The Loan Officer assignment date (" + assignmentDate
- + ") cannot be before previous Loan Officer unassigned date (" + lastAssignmentRecord.getEndDate() + ").";
+ final String errorMessage = "The Loan Officer assignment LocalDate (" + assignmentDate
+ + ") cannot be before previous Loan Officer unassigned LocalDate (" + lastAssignmentRecord.getEndDate() + ").";
throw new LoanOfficerAssignmentDateException("cannot.be.before.previous.unassignement.date", errorMessage, assignmentDate,
lastAssignmentRecord.getEndDate());
} else if (DateUtils.getBusinessLocalDate().isBefore(assignmentDate)) {
- final String errorMessage = "The Loan Officer assignment date (" + assignmentDate + ") cannot be in the future.";
+ final String errorMessage = "The Loan Officer assignment LocalDate (" + assignmentDate + ") cannot be in the future.";
throw new LoanOfficerAssignmentDateException("cannot.be.a.future.date", errorMessage, assignmentDate);
@@ -4313,7 +4247,7 @@ public class Loan extends AbstractPersistableCustom {
latestHistoryRecord.updateLoanOfficer(newLoanOfficer);
this.loanOfficer = newLoanOfficer;
} else if (latestHistoryRecord != null && latestHistoryRecord.hasStartDateBefore(assignmentDate)) {
- final String errorMessage = "Loan with identifier " + getId() + " was already assigned before date " + assignmentDate;
+ final String errorMessage = "Loan with identifier " + getId() + " was already assigned before LocalDate " + assignmentDate;
throw new LoanOfficerAssignmentDateException("is.before.last.assignment.date", errorMessage, getId(), assignmentDate);
} else {
if (latestHistoryRecord != null) {
@@ -4349,7 +4283,7 @@ public class Loan extends AbstractPersistableCustom {
if (latestHistoryRecord.getStartDate().isAfter(unassignDate)) {
- final String errorMessage = "The Loan officer Unassign date(" + unassignDate + ") cannot be before its assignment date ("
+ final String errorMessage = "The Loan officer Unassign date(" + unassignDate + ") cannot be before its assignment LocalDate ("
+ latestHistoryRecord.getStartDate() + ").";
throw new LoanOfficerUnassignmentDateException("cannot.be.before.assignment.date", errorMessage, getId(),
@@ -4357,7 +4291,7 @@ public class Loan extends AbstractPersistableCustom {
} else if (unassignDate.isAfter(today)) {
- final String errorMessage = "The Loan Officer Unassign date (" + unassignDate + ") cannot be in the future.";
+ final String errorMessage = "The Loan Officer Unassign LocalDate (" + unassignDate + ") cannot be in the future.";
throw new LoanOfficerUnassignmentDateException("cannot.be.a.future.date", errorMessage, unassignDate);
}
@@ -4524,9 +4458,9 @@ public class Loan extends AbstractPersistableCustom {
}
/*
* if (transaction.getTransactionDate().isAfter(tillDate) && transaction.isAccrual()) { final String
- * errorMessage = "The date on which a loan is interest waived cannot be in after accrual transactions." ;
- * throw new InvalidLoanStateTransitionException("waive", "cannot.be.after.accrual.date", errorMessage,
- * tillDate); }
+ * errorMessage =
+ * "The LocalDate on which a loan is interest waived cannot be in after accrual transactions." ; throw new
+ * InvalidLoanStateTransitionException("waive", "cannot.be.after.accrual.date", errorMessage, tillDate); }
*/
}
return receivableInterest;
@@ -4543,7 +4477,7 @@ public class Loan extends AbstractPersistableCustom {
return this.syncDisbursementWithMeeting == null ? false : this.syncDisbursementWithMeeting;
}
- public Date getClosedOnDate() {
+ public LocalDate getClosedOnDate() {
return this.closedOnDate;
}
@@ -4552,7 +4486,7 @@ public class Loan extends AbstractPersistableCustom {
final Boolean reschedulebasedOnMeetingDates, final LocalDate presentMeetingDate, final LocalDate newMeetingDate,
final boolean isSkipRepaymentonfirstdayofmonth, final Integer numberofDays) {
- // first repayment's from date is same as disbursement date.
+ // first repayment's from LocalDate is same as disbursement date.
/*
* meetingStartDate is used as seedDate Capture the seedDate from user and use the seedDate as meetingStart date
*/
@@ -4580,7 +4514,7 @@ public class Loan extends AbstractPersistableCustom {
} else {
// tmpFromDate.plusDays(1) is done to make sure
// getNewRepaymentMeetingDate method returns next meeting
- // date and not the same as tmpFromDate
+ // LocalDate and not the same as tmpFromDate
newRepaymentDate = CalendarUtils.getNewRepaymentMeetingDate(recuringRule, tmpFromDate, tmpFromDate.plusDays(1),
loanRepaymentInterval, frequency, workingDays, isSkipRepaymentonfirstdayofmonth, numberofDays);
}
@@ -4592,7 +4526,7 @@ public class Loan extends AbstractPersistableCustom {
latestRepaymentDate = newRepaymentDate;
}
loanRepaymentScheduleInstallment.updateDueDate(newRepaymentDate);
- // reset from date to get actual daysInPeriod
+ // reset from LocalDate to get actual daysInPeriod
if (!isFirstTime) {
loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate);
@@ -4605,7 +4539,7 @@ public class Loan extends AbstractPersistableCustom {
}
}
if (latestRepaymentDate != null) {
- this.expectedMaturityDate = Date.from(latestRepaymentDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.expectedMaturityDate = latestRepaymentDate;
}
}
@@ -4613,7 +4547,7 @@ public class Loan extends AbstractPersistableCustom {
final boolean isHolidayEnabled, final List<Holiday> holidays, final WorkingDays workingDays,
final boolean isSkipRepaymentonfirstdayofmonth, final Integer numberofDays) {
- // first repayment's from date is same as disbursement date.
+ // first repayment's from LocalDate is same as disbursement date.
LocalDate tmpFromDate = getDisbursementDate();
final PeriodFrequencyType repaymentPeriodFrequencyType = this.loanRepaymentScheduleDetail.getRepaymentPeriodFrequencyType();
final Integer loanRepaymentInterval = this.loanRepaymentScheduleDetail.getRepayEvery();
@@ -4650,7 +4584,7 @@ public class Loan extends AbstractPersistableCustom {
}
loanRepaymentScheduleInstallment.updateDueDate(newRepaymentDate);
- // reset from date to get actual daysInPeriod
+ // reset from LocalDate to get actual daysInPeriod
loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate);
tmpFromDate = newRepaymentDate;// update with new repayment
// date
@@ -4659,7 +4593,7 @@ public class Loan extends AbstractPersistableCustom {
}
}
if (latestRepaymentDate != null) {
- this.expectedMaturityDate = Date.from(latestRepaymentDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.expectedMaturityDate = latestRepaymentDate;
}
}
@@ -4685,7 +4619,7 @@ public class Loan extends AbstractPersistableCustom {
case WHOLE_TERM:
break;
}
- return dueRepaymentPeriodDate.minusDays(1);// get 2n-1 range date from
+ return dueRepaymentPeriodDate.minusDays(1);// get 2n-1 range LocalDate from
// startDate
}
@@ -4733,7 +4667,7 @@ public class Loan extends AbstractPersistableCustom {
adjustedRescheduleToDate = holiday.getRepaymentsRescheduledToLocalDate();
}
- // first repayment's from date is same as disbursement date.
+ // first repayment's from LocalDate is same as disbursement date.
LocalDate tmpFromDate = getDisbursementDate();
// Loop through all loanRepayments
@@ -4746,7 +4680,7 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate();
- // update from date if it's not same as previous installament's due
+ // update from LocalDate if it's not same as previous installament's due
// date.
if (!loanRepaymentScheduleInstallment.getFromDate().isEqual(tmpFromDate)) {
loanRepaymentScheduleInstallment.updateFromDate(tmpFromDate);
@@ -4754,7 +4688,7 @@ public class Loan extends AbstractPersistableCustom {
if (oldDueDate.equals(holiday.getFromDateLocalDate()) || oldDueDate.isAfter(holiday.getFromDateLocalDate())) {
// FIXME: AA do we need to apply non-working days.
- // Assuming holiday's repayment reschedule to date cannot be
+ // Assuming holiday's repayment reschedule to LocalDate cannot be
// created on a non-working day.
adjustedRescheduleToDate = scheduledDateGenerator.generateNextRepaymentDate(adjustedRescheduleToDate, loanApplicationTerms,
@@ -4768,7 +4702,7 @@ public class Loan extends AbstractPersistableCustom {
private void validateDisbursementDateIsOnNonWorkingDay(final WorkingDays workingDays, final boolean allowTransactionsOnNonWorkingDay) {
if (!allowTransactionsOnNonWorkingDay) {
if (!WorkingDaysUtil.isWorkingDay(workingDays, getDisbursementDate())) {
- final String errorMessage = "Expected disbursement date cannot be on a non working day";
+ final String errorMessage = "Expected disbursement LocalDate cannot be on a non working day";
throw new LoanApplicationDateException("disbursement.date.on.non.working.day", errorMessage,
getExpectedDisbursedOnLocalDate());
}
@@ -4778,7 +4712,7 @@ public class Loan extends AbstractPersistableCustom {
private void validateDisbursementDateIsOnHoliday(final boolean allowTransactionsOnHoliday, final List<Holiday> holidays) {
if (!allowTransactionsOnHoliday) {
if (HolidayUtil.isHoliday(getDisbursementDate(), holidays)) {
- final String errorMessage = "Expected disbursement date cannot be on a holiday";
+ final String errorMessage = "Expected disbursement LocalDate cannot be on a holiday";
throw new LoanApplicationDateException("disbursement.date.on.holiday", errorMessage, getExpectedDisbursedOnLocalDate());
}
}
@@ -4788,7 +4722,7 @@ public class Loan extends AbstractPersistableCustom {
final boolean allowTransactionsOnNonWorkingDay) {
if (!allowTransactionsOnNonWorkingDay) {
if (!WorkingDaysUtil.isWorkingDay(workingDays, repaymentDate)) {
- final String errorMessage = "Repayment date cannot be on a non working day";
+ final String errorMessage = "Repayment LocalDate cannot be on a non working day";
throw new LoanApplicationDateException("repayment.date.on.non.working.day", errorMessage, repaymentDate);
}
}
@@ -4798,7 +4732,7 @@ public class Loan extends AbstractPersistableCustom {
final List<Holiday> holidays) {
if (!allowTransactionsOnHoliday) {
if (HolidayUtil.isHoliday(repaymentDate, holidays)) {
- final String errorMessage = "Repayment date cannot be on a holiday";
+ final String errorMessage = "Repayment LocalDate cannot be on a holiday";
throw new LoanApplicationDateException("repayment.date.on.holiday", errorMessage, repaymentDate);
}
}
@@ -4870,7 +4804,7 @@ public class Loan extends AbstractPersistableCustom {
public void validateExpectedDisbursementForHolidayAndNonWorkingDay(final WorkingDays workingDays,
final boolean allowTransactionsOnHoliday, final List<Holiday> holidays, final boolean allowTransactionsOnNonWorkingDay) {
- // validate if disbursement date is a holiday or a non-working day
+ // validate if disbursement LocalDate is a holiday or a non-working day
validateDisbursementDateIsOnNonWorkingDay(workingDays, allowTransactionsOnNonWorkingDay);
validateDisbursementDateIsOnHoliday(allowTransactionsOnHoliday, holidays);
@@ -4885,22 +4819,22 @@ public class Loan extends AbstractPersistableCustom {
String postfix = null;
switch (event) {
case LOAN_CREATED:
- errorMessage = "The date on which a loan is submitted cannot be earlier than client's transfer date to this office";
+ errorMessage = "The LocalDate on which a loan is submitted cannot be earlier than client's transfer LocalDate to this office";
action = "submittal";
postfix = "cannot.be.before.client.transfer.date";
break;
case LOAN_APPROVED:
- errorMessage = "The date on which a loan is approved cannot be earlier than client's transfer date to this office";
+ errorMessage = "The LocalDate on which a loan is approved cannot be earlier than client's transfer LocalDate to this office";
action = "approval";
postfix = "cannot.be.before.client.transfer.date";
break;
case LOAN_APPROVAL_UNDO:
- errorMessage = "The date on which a loan is approved cannot be earlier than client's transfer date to this office";
+ errorMessage = "The LocalDate on which a loan is approved cannot be earlier than client's transfer LocalDate to this office";
action = "approval";
postfix = "cannot.be.undone.before.client.transfer.date";
break;
case LOAN_DISBURSED:
- errorMessage = "The date on which a loan is disbursed cannot be earlier than client's transfer date to this office";
+ errorMessage = "The LocalDate on which a loan is disbursed cannot be earlier than client's transfer LocalDate to this office";
action = "disbursal";
postfix = "cannot.be.before.client.transfer.date";
break;
@@ -4910,37 +4844,37 @@ public class Loan extends AbstractPersistableCustom {
postfix = "cannot.be.undone.before.client.transfer.date";
break;
case LOAN_REPAYMENT_OR_WAIVER:
- errorMessage = "The date on which a repayment or waiver is made cannot be earlier than client's transfer date to this office";
+ errorMessage = "The LocalDate on which a repayment or waiver is made cannot be earlier than client's transfer LocalDate to this office";
action = "repayment.or.waiver";
postfix = "cannot.be.made.before.client.transfer.date";
break;
case LOAN_REJECTED:
- errorMessage = "The date on which a loan is rejected cannot be earlier than client's transfer date to this office";
+ errorMessage = "The LocalDate on which a loan is rejected cannot be earlier than client's transfer LocalDate to this office";
action = "reject";
postfix = "cannot.be.before.client.transfer.date";
break;
case LOAN_WITHDRAWN:
- errorMessage = "The date on which a loan is withdrawn cannot be earlier than client's transfer date to this office";
+ errorMessage = "The LocalDate on which a loan is withdrawn cannot be earlier than client's transfer LocalDate to this office";
action = "withdraw";
postfix = "cannot.be.before.client.transfer.date";
break;
case WRITE_OFF_OUTSTANDING:
- errorMessage = "The date on which a write off is made cannot be earlier than client's transfer date to this office";
+ errorMessage = "The LocalDate on which a write off is made cannot be earlier than client's transfer LocalDate to this office";
action = "writeoff";
postfix = "cannot.be.undone.before.client.transfer.date";
break;
case REPAID_IN_FULL:
- errorMessage = "The date on which the loan is repaid in full cannot be earlier than client's transfer date to this office";
+ errorMessage = "The LocalDate on which the loan is repaid in full cannot be earlier than client's transfer LocalDate to this office";
action = "close";
postfix = "cannot.be.undone.before.client.transfer.date";
break;
case LOAN_CHARGE_PAYMENT:
- errorMessage = "The date on which a charge payment is made cannot be earlier than client's transfer date to this office";
+ errorMessage = "The LocalDate on which a charge payment is made cannot be earlier than client's transfer LocalDate to this office";
action = "charge.payment";
postfix = "cannot.be.made.before.client.transfer.date";
break;
case LOAN_REFUND:
- errorMessage = "The date on which a refund is made cannot be earlier than client's transfer date to this office";
+ errorMessage = "The LocalDate on which a refund is made cannot be earlier than client's transfer LocalDate to this office";
action = "refund";
postfix = "cannot.be.made.before.client.transfer.date";
break;
@@ -4968,17 +4902,17 @@ public class Loan extends AbstractPersistableCustom {
String postfix = null;
switch (event) {
case LOAN_REPAYMENT_OR_WAIVER:
- errorMessage = "The date on which a repayment or waiver is made cannot be earlier than last transaction date";
+ errorMessage = "The LocalDate on which a repayment or waiver is made cannot be earlier than last transaction date";
action = "repayment.or.waiver";
postfix = "cannot.be.made.before.last.transaction.date";
break;
case WRITE_OFF_OUTSTANDING:
- errorMessage = "The date on which a write off is made cannot be earlier than last transaction date";
+ errorMessage = "The LocalDate on which a write off is made cannot be earlier than last transaction date";
action = "writeoff";
postfix = "cannot.be.made.before.last.transaction.date";
break;
case LOAN_CHARGE_PAYMENT:
- errorMessage = "The date on which a charge payment is made cannot be earlier than last transaction date";
+ errorMessage = "The LocalDate on which a charge payment is made cannot be earlier than last transaction date";
action = "charge.payment";
postfix = "cannot.be.made.before.last.transaction.date";
break;
@@ -5259,8 +5193,7 @@ public class Loan extends AbstractPersistableCustom {
locale);
final LocalDate expectedDisbursementDate = command
.localDateValueOfParameterNamed(LoanApiConstants.updatedDisbursementDateParameterName);
- disbursementDetails.updateExpectedDisbursementDateAndAmount(
- Date.from(expectedDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), principal);
+ disbursementDetails.updateExpectedDisbursementDateAndAmount(expectedDisbursementDate, principal);
actualChanges.put(LoanApiConstants.disbursementDateParameterName,
command.stringValueOfParameterNamed(LoanApiConstants.disbursementDateParameterName));
actualChanges.put(LoanApiConstants.disbursementIdParameterName,
@@ -5299,9 +5232,9 @@ public class Loan extends AbstractPersistableCustom {
public BigDecimal retriveLastEmiAmount() {
BigDecimal emiAmount = this.fixedEmiAmount;
- Date startDate = Date.from(this.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
+ LocalDate startDate = this.getDisbursementDate();
for (LoanTermVariations loanTermVariations : this.loanTermVariations) {
- if (loanTermVariations.getTermType().isEMIAmountVariation() && !startDate.after(loanTermVariations.getTermApplicableFrom())) {
+ if (loanTermVariations.getTermType().isEMIAmountVariation() && !startDate.isAfter(loanTermVariations.getTermApplicableFrom())) {
startDate = loanTermVariations.getTermApplicableFrom();
emiAmount = loanTermVariations.getTermValue();
}
@@ -5361,19 +5294,11 @@ public class Loan extends AbstractPersistableCustom {
}
public LocalDate getExpectedMaturityDate() {
- LocalDate expectedMaturityDate = null;
- if (this.expectedMaturityDate != null) {
- expectedMaturityDate = LocalDate.ofInstant(this.expectedMaturityDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
- return expectedMaturityDate;
+ return this.expectedMaturityDate;
}
public LocalDate getMaturityDate() {
- LocalDate maturityDate = getExpectedMaturityDate();
- if (this.actualMaturityDate != null) {
- maturityDate = LocalDate.ofInstant(this.actualMaturityDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
- return maturityDate;
+ return this.actualMaturityDate;
}
public ChangedTransactionDetail recalculateScheduleFromLastTransaction(final ScheduleGeneratorDTO generatorDTO,
@@ -5432,7 +5357,7 @@ public class Loan extends AbstractPersistableCustom {
return;
}
updateLoanSchedule(loanSchedule.getInstallments());
- this.interestRecalculatedOn = DateUtils.getBusinessDate();
+ this.interestRecalculatedOn = DateUtils.getBusinessLocalDate();
LocalDate lastRepaymentDate = this.getLastRepaymentPeriodDueDate(true);
Set<LoanCharge> charges = this.charges();
for (final LoanCharge loanCharge : charges) {
@@ -5501,10 +5426,9 @@ public class Loan extends AbstractPersistableCustom {
}
}
- private void reverseTransactionsOnOrAfter(List<LoanTransaction> transactions, Date date) {
- LocalDate refDate = LocalDate.ofInstant(date.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ private void reverseTransactionsOnOrAfter(List<LoanTransaction> transactions, LocalDate date) {
for (LoanTransaction loanTransaction : transactions) {
- if (!loanTransaction.getTransactionDate().isBefore(refDate)) {
+ if (!loanTransaction.getTransactionDate().isBefore(date)) {
loanTransaction.reverse();
}
}
@@ -5788,11 +5712,7 @@ public class Loan extends AbstractPersistableCustom {
}
public LocalDate getAccruedTill() {
- LocalDate accruedTill = null;
- if (this.accruedTill != null) {
- accruedTill = LocalDate.ofInstant(this.accruedTill.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
- return accruedTill;
+ return this.accruedTill;
}
public LocalDate fetchInterestRecalculateFromDate() {
@@ -5800,7 +5720,7 @@ public class Loan extends AbstractPersistableCustom {
if (this.interestRecalculatedOn == null) {
interestRecalculatedOn = getDisbursementDate();
} else {
- interestRecalculatedOn = LocalDate.ofInstant(this.interestRecalculatedOn.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ interestRecalculatedOn = this.interestRecalculatedOn;
}
return interestRecalculatedOn;
}
@@ -5872,8 +5792,8 @@ public class Loan extends AbstractPersistableCustom {
/**
* @param dueDate
- * the due date of the installment
- * @return a schedule installment with similar due date to the one provided
+ * the due LocalDate of the installment
+ * @return a schedule installment with similar due LocalDate to the one provided
**/
public LoanRepaymentScheduleInstallment getRepaymentScheduleInstallment(LocalDate dueDate) {
LoanRepaymentScheduleInstallment installment = null;
@@ -5907,13 +5827,11 @@ public class Loan extends AbstractPersistableCustom {
LocalDate actualDisbursementDate = null;
if (loanDisbursementDetails.expectedDisbursementDate() != null) {
- expectedDisbursementDate = LocalDate.ofInstant(loanDisbursementDetails.expectedDisbursementDate().toInstant(),
- DateUtils.getDateTimeZoneOfTenant());
+ expectedDisbursementDate = loanDisbursementDetails.expectedDisbursementDate();
}
if (loanDisbursementDetails.actualDisbursementDate() != null) {
- actualDisbursementDate = LocalDate.ofInstant(loanDisbursementDetails.actualDisbursementDate().toInstant(),
- DateUtils.getDateTimeZoneOfTenant());
+ actualDisbursementDate = loanDisbursementDetails.actualDisbursementDate();
}
BigDecimal waivedChargeAmount = null;
disbursementData.add(new DisbursementData(loanDisbursementDetails.getId(), expectedDisbursementDate, actualDisbursementDate,
@@ -6061,7 +5979,7 @@ public class Loan extends AbstractPersistableCustom {
public void updateRescheduledOnDate(LocalDate rescheduledOnDate) {
if (rescheduledOnDate != null) {
- this.rescheduledOnDate = Date.from(rescheduledOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.rescheduledOnDate = rescheduledOnDate;
}
}
@@ -6218,14 +6136,14 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate loanTransactionDate = loanTransaction.getTransactionDate();
if (loanTransactionDate.isBefore(getDisbursementDate())) {
- final String errorMessage = "The transaction date cannot be before the loan disbursement date: "
+ final String errorMessage = "The transaction LocalDate cannot be before the loan disbursement date: "
+ getApprovedOnDate().toString();
throw new InvalidLoanStateTransitionException("transaction", "cannot.be.before.disbursement.date", errorMessage,
loanTransactionDate, getDisbursementDate());
}
if (loanTransactionDate.isAfter(DateUtils.getBusinessLocalDate())) {
- final String errorMessage = "The transaction date cannot be in the future.";
+ final String errorMessage = "The transaction LocalDate cannot be in the future.";
throw new InvalidLoanStateTransitionException("transaction", "cannot.be.a.future.date", errorMessage, loanTransactionDate);
}
@@ -6277,8 +6195,8 @@ public class Loan extends AbstractPersistableCustom {
return lastTransactionDate == null ? now : lastTransactionDate;
}
- private Date getActualDisbursementDate(final LoanCharge loanCharge) {
- Date actualDisbursementDate = this.actualDisbursementDate;
+ private LocalDate getActualDisbursementDate(final LoanCharge loanCharge) {
+ LocalDate actualDisbursementDate = this.actualDisbursementDate;
if (loanCharge.isDueAtDisbursement() && loanCharge.isActive()) {
LoanTrancheDisbursementCharge trancheDisbursementCharge = loanCharge.getTrancheDisbursementCharge();
if (trancheDisbursementCharge != null) {
@@ -6328,12 +6246,10 @@ public class Loan extends AbstractPersistableCustom {
LoanTermVariations loanTermVariations = iterator.next();
if ((loanTermVariations.getTermType().isDueDateVariation()
&& loanTermVariations.fetchDateValue().isAfter(actualDisbursementDate))
- || (loanTermVariations.getTermType().isEMIAmountVariation() && loanTermVariations.getTermApplicableFrom()
- .compareTo(Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant())) == 0
- ? Boolean.TRUE
+ || (loanTermVariations.getTermType().isEMIAmountVariation()
+ && loanTermVariations.getTermApplicableFrom().compareTo(actualDisbursementDate) == 0 ? Boolean.TRUE
: Boolean.FALSE)
- || loanTermVariations.getTermApplicableFrom()
- .after(Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()))) {
+ || loanTermVariations.getTermApplicableFrom().isAfter(actualDisbursementDate)) {
iterator.remove();
}
}
@@ -6370,15 +6286,13 @@ public class Loan extends AbstractPersistableCustom {
for (final LoanCharge charge : charges()) {
if (charge.isOverdueInstallmentCharge()) {
charge.setActive(false);
- } else if (charge.isTrancheDisbursementCharge() && actualDisbursementDate.equals(LocalDate.ofInstant(
- charge.getTrancheDisbursementCharge().getloanDisbursementDetails().actualDisbursementDate().toInstant(),
- DateUtils.getDateTimeZoneOfTenant()))) {
+ } else if (charge.isTrancheDisbursementCharge() && actualDisbursementDate
+ .equals(charge.getTrancheDisbursementCharge().getloanDisbursementDetails().actualDisbursementDate())) {
charge.resetToOriginal(loanCurrency());
}
}
for (final LoanDisbursementDetails details : this.disbursementDetails) {
- if (actualDisbursementDate
- .equals(LocalDate.ofInstant(details.actualDisbursementDate().toInstant(), DateUtils.getDateTimeZoneOfTenant()))) {
+ if (actualDisbursementDate.equals(details.actualDisbursementDate())) {
this.loanRepaymentScheduleDetail.setPrincipal(getDisbursedAmount().subtract(details.principal()));
details.updateActualDisbursementDate(null);
}
@@ -6432,12 +6346,12 @@ public class Loan extends AbstractPersistableCustom {
return this.repaymentScheduleDetail().getNumberOfRepayments() + adjustNumberOfRepayments();
}
- public void setExpectedFirstRepaymentOnDate(Date expectedFirstRepaymentOnDate) {
+ public void setExpectedFirstRepaymentOnDate(LocalDate expectedFirstRepaymentOnDate) {
this.expectedFirstRepaymentOnDate = expectedFirstRepaymentOnDate;
}
/*
- * get the next repayment date for rescheduling at the time of disbursement
+ * get the next repayment LocalDate for rescheduling at the time of disbursement
*/
public LocalDate getNextPossibleRepaymentDateForRescheduling() {
List<LoanDisbursementDetails> loanDisbursementDetails = this.disbursementDetails;
@@ -6464,13 +6378,13 @@ public class Loan extends AbstractPersistableCustom {
if (isMultiDisburmentLoan() && loanCharge.getCharge().getChargeTimeType().equals(ChargeTimeType.DISBURSEMENT.getValue())) {
amount = getApprovedPrincipal();
} else {
- // If charge type is specified due date and loan is multi disburment
+ // If charge type is specified due LocalDate and loan is multi disburment
// loan.
- // Then we need to get as of this loan charge due date how much
+ // Then we need to get as of this loan charge due LocalDate how much
// amount disbursed.
if (loanCharge.isSpecifiedDueDate() && this.isMultiDisburmentLoan()) {
for (final LoanDisbursementDetails loanDisbursementDetails : this.getDisbursementDetails()) {
- if (!loanDisbursementDetails.expectedDisbursementDate().after(loanCharge.getDueDate())) {
+ if (!loanDisbursementDetails.expectedDisbursementDate().isAfter(loanCharge.getDueDate())) {
amount = amount.add(loanDisbursementDetails.principal());
}
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java
index 20b4ae39b..8f727c635 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanAccountDomainServiceJpa.java
@@ -21,11 +21,9 @@ package org.apache.fineract.portfolio.loanaccount.domain;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
-import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -377,8 +375,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
loan.handlePayDisbursementTransaction(chargeId, newPaymentTransaction, existingTransactionIds, existingReversedTransactionIds);
} else {
final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled();
- final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
- Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), HolidayStatusType.ACTIVE.getValue());
+ final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), transactionDate,
+ HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled();
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
@@ -454,8 +452,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
final LoanTransaction newRefundTransaction = LoanTransaction.refund(loan.getOffice(), refundAmount, paymentDetail, transactionDate,
txnExternalId);
final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled();
- final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
- Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), HolidayStatusType.ACTIVE.getValue());
+ final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), transactionDate,
+ HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled();
@@ -542,7 +540,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
}
boolean isOrganisationDateEnabled = this.configurationDomainService.isOrganisationstartDateEnabled();
- Date organisationStartDate = DateUtils.getBusinessDate();
+ LocalDate organisationStartDate = DateUtils.getBusinessLocalDate();
if (isOrganisationDateEnabled) {
organisationStartDate = this.configurationDomainService.retrieveOrganisationStartDate();
}
@@ -564,8 +562,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
if (installment.getDueDate().isAfter(loan.getMaturityDate())) {
accruedTill = DateUtils.getBusinessLocalDate();
}
- if (!isOrganisationDateEnabled || LocalDate.ofInstant(organisationStartDate.toInstant(), DateUtils.getDateTimeZoneOfTenant())
- .isBefore(installment.getDueDate())) {
+ if (!isOrganisationDateEnabled || organisationStartDate.isBefore(installment.getDueDate())) {
generateLoanScheduleAccrualData(accruedTill, loanScheduleAccrualDatas, loanId, officeId, accrualStartDate,
repaymentFrequency, repayEvery, interestCalculatedFrom, loanProductId, currency, currencyData, loanCharges,
installment);
@@ -681,8 +678,8 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
final LoanTransaction newRefundTransaction = LoanTransaction.refundForActiveLoan(loan.getOffice(), refundAmount, paymentDetail,
transactionDate, txnExternalId);
final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled();
- final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
- Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), HolidayStatusType.ACTIVE.getValue());
+ final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), transactionDate,
+ HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled();
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java
index c5e23a595..22e5410ef 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanCharge.java
@@ -21,11 +21,9 @@ package org.apache.fineract.portfolio.loanaccount.domain;
import java.math.BigDecimal;
import java.math.MathContext;
import java.time.LocalDate;
-import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
@@ -40,12 +38,9 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
-import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.organisation.monetary.domain.Money;
import org.apache.fineract.organisation.monetary.domain.MoneyHelper;
@@ -72,9 +67,8 @@ public class LoanCharge extends AbstractPersistableCustom {
@Column(name = "charge_time_enum", nullable = false)
private Integer chargeTime;
- @Temporal(TemporalType.DATE)
@Column(name = "due_for_collection_as_of_date")
- private Date dueDate;
+ private LocalDate dueDate;
@Column(name = "charge_calculation_enum")
private Integer chargeCalculation;
@@ -201,8 +195,7 @@ public class LoanCharge extends AbstractPersistableCustom {
if (chargeDefinition.getChargeTimeType().equals(ChargeTimeType.SPECIFIED_DUE_DATE.getValue()) && loan.isMultiDisburmentLoan()) {
amountPercentageAppliedTo = BigDecimal.ZERO;
for (final LoanDisbursementDetails loanDisbursementDetails : loan.getDisbursementDetails()) {
- if (!loanDisbursementDetails.expectedDisbursementDate()
- .after(Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant()))) {
+ if (!loanDisbursementDetails.expectedDisbursementDate().isAfter(dueDate)) {
amountPercentageAppliedTo = amountPercentageAppliedTo.add(loanDisbursementDetails.principal());
}
}
@@ -252,7 +245,7 @@ public class LoanCharge extends AbstractPersistableCustom {
chargeDefinition.getName());
}
- this.dueDate = Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.dueDate = dueDate;
} else {
this.dueDate = null;
}
@@ -400,7 +393,7 @@ public class LoanCharge extends AbstractPersistableCustom {
public void update(final BigDecimal amount, final LocalDate dueDate, final BigDecimal loanPrincipal, Integer numberOfRepayments,
BigDecimal loanCharge) {
if (dueDate != null) {
- this.dueDate = Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.dueDate = dueDate;
}
if (amount != null) {
@@ -448,7 +441,7 @@ public class LoanCharge extends AbstractPersistableCustom {
// much amount disbursed.
if (this.loan.isMultiDisburmentLoan() && this.isSpecifiedDueDate()) {
for (final LoanDisbursementDetails loanDisbursementDetails : this.loan.getDisbursementDetails()) {
- if (!loanDisbursementDetails.expectedDisbursementDate().after(this.getDueDate())) {
+ if (!loanDisbursementDetails.expectedDisbursementDate().isAfter(this.getDueDate())) {
amountPercentageAppliedTo = amountPercentageAppliedTo.add(loanDisbursementDetails.principal());
}
}
@@ -487,8 +480,7 @@ public class LoanCharge extends AbstractPersistableCustom {
actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput);
- final LocalDate newValue = command.localDateValueOfParameterNamed(dueDateParamName);
- this.dueDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.dueDate = command.localDateValueOfParameterNamed(dueDateParamName);
}
final String amountParamName = "amount";
@@ -596,14 +588,10 @@ public class LoanCharge extends AbstractPersistableCustom {
}
public LocalDate getDueLocalDate() {
- LocalDate dueDate = null;
- if (this.dueDate != null) {
- dueDate = LocalDate.ofInstant(this.dueDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
- return dueDate;
+ return this.dueDate;
}
- public Date getDueDate() {
+ public LocalDate getDueDate() {
return this.dueDate;
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java
index 6399c36b4..8dca91eed 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanDisbursementDetails.java
@@ -20,17 +20,13 @@ package org.apache.fineract.portfolio.loanaccount.domain;
import java.math.BigDecimal;
import java.time.LocalDate;
-import java.util.Date;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
-import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.loanaccount.data.DisbursementData;
@Entity
@@ -41,13 +37,11 @@ public class LoanDisbursementDetails extends AbstractPersistableCustom {
@JoinColumn(name = "loan_id", nullable = false)
private Loan loan;
- @Temporal(TemporalType.DATE)
@Column(name = "expected_disburse_date")
- private Date expectedDisbursementDate;
+ private LocalDate expectedDisbursementDate;
- @Temporal(TemporalType.DATE)
@Column(name = "disbursedon_date")
- private Date actualDisbursementDate;
+ private LocalDate actualDisbursementDate;
@Column(name = "principal", scale = 6, precision = 19, nullable = false)
private BigDecimal principal;
@@ -59,8 +53,8 @@ public class LoanDisbursementDetails extends AbstractPersistableCustom {
}
- public LoanDisbursementDetails(final Date expectedDisbursementDate, final Date actualDisbursementDate, final BigDecimal principal,
- final BigDecimal netDisbursalAmount) {
+ public LoanDisbursementDetails(final LocalDate expectedDisbursementDate, final LocalDate actualDisbursementDate,
+ final BigDecimal principal, final BigDecimal netDisbursalAmount) {
this.expectedDisbursementDate = expectedDisbursementDate;
this.actualDisbursementDate = actualDisbursementDate;
this.principal = principal;
@@ -96,19 +90,19 @@ public class LoanDisbursementDetails extends AbstractPersistableCustom {
this.actualDisbursementDate = disbursementDetails.actualDisbursementDate;
}
- public Date expectedDisbursementDate() {
+ public LocalDate expectedDisbursementDate() {
return this.expectedDisbursementDate;
}
public LocalDate expectedDisbursementDateAsLocalDate() {
LocalDate expectedDisburseDate = null;
if (this.expectedDisbursementDate != null) {
- expectedDisburseDate = LocalDate.ofInstant(this.expectedDisbursementDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ expectedDisburseDate = this.expectedDisbursementDate;
}
return expectedDisburseDate;
}
- public Date actualDisbursementDate() {
+ public LocalDate actualDisbursementDate() {
return this.actualDisbursementDate;
}
@@ -120,26 +114,18 @@ public class LoanDisbursementDetails extends AbstractPersistableCustom {
this.principal = principal;
}
- public Date getDisbursementDate() {
- Date disbursementDate = this.expectedDisbursementDate;
- if (this.actualDisbursementDate != null) {
- disbursementDate = this.actualDisbursementDate;
- }
- return disbursementDate;
+ public LocalDate getDisbursementDate() {
+ return this.actualDisbursementDate;
}
public DisbursementData toData() {
LocalDate expectedDisburseDate = expectedDisbursementDateAsLocalDate();
- LocalDate actualDisburseDate = null;
- if (this.actualDisbursementDate != null) {
- actualDisburseDate = LocalDate.ofInstant(this.actualDisbursementDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
BigDecimal waivedChargeAmount = null;
- return new DisbursementData(getId(), expectedDisburseDate, actualDisburseDate, this.principal, this.netDisbursalAmount, null, null,
- waivedChargeAmount);
+ return new DisbursementData(getId(), expectedDisburseDate, this.actualDisbursementDate, this.principal, this.netDisbursalAmount,
+ null, null, waivedChargeAmount);
}
- public void updateActualDisbursementDate(Date actualDisbursementDate) {
+ public void updateActualDisbursementDate(LocalDate actualDisbursementDate) {
this.actualDisbursementDate = actualDisbursementDate;
}
@@ -151,7 +137,7 @@ public class LoanDisbursementDetails extends AbstractPersistableCustom {
this.netDisbursalAmount = netDisbursalAmount;
}
- public void updateExpectedDisbursementDateAndAmount(Date expectedDisbursementDate, BigDecimal principal) {
+ public void updateExpectedDisbursementDateAndAmount(LocalDate expectedDisbursementDate, BigDecimal principal) {
this.expectedDisbursementDate = expectedDisbursementDate;
this.principal = principal;
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalcualtionAdditionalDetails.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalcualtionAdditionalDetails.java
index a2b5f4d2c..f07eca1fa 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalcualtionAdditionalDetails.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalcualtionAdditionalDetails.java
@@ -20,17 +20,12 @@ package org.apache.fineract.portfolio.loanaccount.domain;
import java.math.BigDecimal;
import java.time.LocalDate;
-import java.time.ZoneId;
-import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
-import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity
@Table(name = "m_loan_interest_recalculation_additional_details")
@@ -40,9 +35,8 @@ public class LoanInterestRecalcualtionAdditionalDetails extends AbstractPersista
@JoinColumn(name = "loan_repayment_schedule_id", nullable = false)
private LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment;
- @Temporal(TemporalType.DATE)
@Column(name = "effective_date")
- private Date effectiveDate;
+ private LocalDate effectiveDate;
@Column(name = "amount", scale = 6, precision = 19, nullable = false)
private BigDecimal amount;
@@ -53,13 +47,13 @@ public class LoanInterestRecalcualtionAdditionalDetails extends AbstractPersista
public LoanInterestRecalcualtionAdditionalDetails(final LocalDate effectiveDate, final BigDecimal amount) {
if (effectiveDate != null) {
- this.effectiveDate = Date.from(effectiveDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.effectiveDate = effectiveDate;
}
this.amount = amount;
}
public LocalDate getEffectiveDate() {
- return LocalDate.ofInstant(this.effectiveDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ return this.effectiveDate;
}
public BigDecimal getAmount() {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanOfficerAssignmentHistory.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanOfficerAssignmentHistory.java
index fe038f834..783ae40ed 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanOfficerAssignmentHistory.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanOfficerAssignmentHistory.java
@@ -19,18 +19,12 @@
package org.apache.fineract.portfolio.loanaccount.domain;
import java.time.LocalDate;
-import java.time.ZoneId;
-import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import org.apache.commons.lang3.ObjectUtils;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
-import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.staff.domain.Staff;
@Entity
@@ -45,24 +39,21 @@ public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom {
@JoinColumn(name = "loan_officer_id", nullable = true)
private Staff loanOfficer;
- @Temporal(TemporalType.DATE)
@Column(name = "start_date")
- private Date startDate;
+ private LocalDate startDate;
- @Temporal(TemporalType.DATE)
@Column(name = "end_date")
- private Date endDate;
+ private LocalDate endDate;
public static LoanOfficerAssignmentHistory createNew(final Loan loan, final Staff loanOfficer, final LocalDate startDate) {
- return new LoanOfficerAssignmentHistory(loan, loanOfficer, Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant()),
- null);
+ return new LoanOfficerAssignmentHistory(loan, loanOfficer, startDate, null);
}
protected LoanOfficerAssignmentHistory() {
//
}
- private LoanOfficerAssignmentHistory(final Loan loan, final Staff loanOfficer, final Date startDate, final Date endDate) {
+ private LoanOfficerAssignmentHistory(final Loan loan, final Staff loanOfficer, final LocalDate startDate, final LocalDate endDate) {
this.loan = loan;
this.loanOfficer = loanOfficer;
this.startDate = startDate;
@@ -74,11 +65,11 @@ public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom {
}
public void updateStartDate(final LocalDate startDate) {
- this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.startDate = startDate;
}
public void updateEndDate(final LocalDate endDate) {
- this.endDate = Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.endDate = endDate;
}
public boolean matchesStartDateOf(final LocalDate matchingDate) {
@@ -86,7 +77,7 @@ public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom {
}
public LocalDate getStartDate() {
- return LocalDate.ofInstant(this.startDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ return this.startDate;
}
public boolean hasStartDateBefore(final LocalDate matchingDate) {
@@ -104,12 +95,11 @@ public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom {
* @return
*/
public boolean isEndDateAfter(final LocalDate compareDate) {
- return this.endDate == null ? false
- : LocalDate.ofInstant(this.endDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()).isAfter(compareDate);
+ return this.endDate.isAfter(compareDate);
}
public LocalDate getEndDate() {
- return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.endDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), null);
+ return this.endDate;
}
public boolean isSameLoanOfficer(final Staff staff) {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java
index 911abd484..5430c4b6a 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleInstallment.java
@@ -20,9 +20,7 @@ package org.apache.fineract.portfolio.loanaccount.domain;
import java.math.BigDecimal;
import java.time.LocalDate;
-import java.time.ZoneId;
import java.util.Comparator;
-import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
@@ -33,10 +31,7 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
-import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.organisation.monetary.domain.Money;
import org.apache.fineract.portfolio.repaymentwithpostdatedchecks.domain.PostDatedChecks;
@@ -53,13 +48,11 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
@Column(name = "installment", nullable = false)
private Integer installmentNumber;
- @Temporal(TemporalType.DATE)
@Column(name = "fromdate", nullable = true)
- private Date fromDate;
+ private LocalDate fromDate;
- @Temporal(TemporalType.DATE)
@Column(name = "duedate", nullable = false)
- private Date dueDate;
+ private LocalDate dueDate;
@Column(name = "principal_amount", scale = 6, precision = 19, nullable = true)
private BigDecimal principal;
@@ -127,9 +120,8 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
@Column(name = "completed_derived", nullable = false)
private boolean obligationsMet;
- @Temporal(TemporalType.DATE)
@Column(name = "obligations_met_on_date")
- private Date obligationsMetOnDate;
+ private LocalDate obligationsMetOnDate;
@Column(name = "recalculated_interest_component", nullable = false)
private boolean recalculatedInterestComponent;
@@ -156,8 +148,8 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
final Set<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails, final BigDecimal rescheduleInterestPortion) {
this.loan = loan;
this.installmentNumber = installmentNumber;
- this.fromDate = Date.from(fromDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
- this.dueDate = Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.fromDate = fromDate;
+ this.dueDate = dueDate;
this.principal = defaultToNullIfZero(principal);
this.interestCharged = defaultToNullIfZero(interest);
this.feeChargesCharged = defaultToNullIfZero(feeCharges);
@@ -177,8 +169,8 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
final Set<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails) {
this.loan = loan;
this.installmentNumber = installmentNumber;
- this.fromDate = Date.from(fromDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
- this.dueDate = Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.fromDate = fromDate;
+ this.dueDate = dueDate;
this.principal = defaultToNullIfZero(principal);
this.interestCharged = defaultToNullIfZero(interest);
this.feeChargesCharged = defaultToNullIfZero(feeCharges);
@@ -216,12 +208,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
}
public LocalDate getFromDate() {
- LocalDate fromLocalDate = null;
- if (this.fromDate != null) {
- fromLocalDate = LocalDate.ofInstant(this.fromDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
-
- return fromLocalDate;
+ return this.fromDate;
}
public void setPostDatedChecksToNull() {
@@ -233,7 +220,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
}
public LocalDate getDueDate() {
- return LocalDate.ofInstant(this.dueDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ return this.dueDate;
}
public Money getPrincipal(final MonetaryCurrency currency) {
@@ -613,7 +600,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
public void updateDerivedFields(final MonetaryCurrency currency, final LocalDate actualDisbursementDate) {
if (!this.obligationsMet && getTotalOutstanding(currency).isZero()) {
this.obligationsMet = true;
- this.obligationsMetOnDate = Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.obligationsMetOnDate = actualDisbursementDate;
}
}
@@ -641,7 +628,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
private void checkIfRepaymentPeriodObligationsAreMet(final LocalDate transactionDate, final MonetaryCurrency currency) {
this.obligationsMet = getTotalOutstanding(currency).isZero();
if (this.obligationsMet) {
- this.obligationsMetOnDate = Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.obligationsMetOnDate = transactionDate;
} else {
this.obligationsMetOnDate = null;
}
@@ -649,13 +636,13 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
public void updateDueDate(final LocalDate newDueDate) {
if (newDueDate != null) {
- this.dueDate = Date.from(newDueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.dueDate = newDueDate;
}
}
public void updateFromDate(final LocalDate newFromDate) {
if (newFromDate != null) {
- this.fromDate = Date.from(newFromDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.fromDate = newFromDate;
}
}
@@ -690,9 +677,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
}
public void updateObligationMetOnDate(final LocalDate obligationsMetOnDate) {
- this.obligationsMetOnDate = (obligationsMetOnDate != null)
- ? Date.from(obligationsMetOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant())
- : null;
+ this.obligationsMetOnDate = obligationsMetOnDate;
}
public void updateInterestWrittenOff(final BigDecimal interestWrittenOff) {
@@ -721,13 +706,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
}
public LocalDate getObligationsMetOnDate() {
- LocalDate obligationsMetOnDate = null;
-
- if (this.obligationsMetOnDate != null) {
- obligationsMetOnDate = LocalDate.ofInstant(this.obligationsMetOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
-
- return obligationsMetOnDate;
+ return this.obligationsMetOnDate;
}
/********** UNPAY COMPONENTS ****/
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleProcessingWrapper.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleProcessingWrapper.java
index 775052446..8a0fb8d10 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleProcessingWrapper.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepaymentScheduleProcessingWrapper.java
@@ -106,7 +106,7 @@ public class LoanRepaymentScheduleProcessingWrapper {
if (loanCharge.getLoan() != null && loanCharge.isSpecifiedDueDate()
&& loanCharge.getLoan().isMultiDisburmentLoan()) {
for (final LoanDisbursementDetails loanDisbursementDetails : loanCharge.getLoan().getDisbursementDetails()) {
- if (!loanDisbursementDetails.expectedDisbursementDate().after(loanCharge.getDueDate())) {
+ if (!loanDisbursementDetails.expectedDisbursementDate().isAfter(loanCharge.getDueDate())) {
amount = amount.add(loanDisbursementDetails.principal());
}
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepository.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepository.java
index 44dd7e756..3ec053973 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepository.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepository.java
@@ -18,8 +18,8 @@
*/
package org.apache.fineract.portfolio.loanaccount.domain;
+import java.time.LocalDate;
import java.util.Collection;
-import java.util.Date;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
@@ -74,11 +74,11 @@ public interface LoanRepository extends JpaRepository<Loan, Long>, JpaSpecificat
String FIND_BY_ACCOUNT_NUMBER = "select loan from Loan loan where loan.accountNumber = :accountNumber";
@Query(FIND_GROUP_LOANS_DISBURSED_AFTER)
- List<Loan> getGroupLoansDisbursedAfter(@Param("disbursementDate") Date disbursementDate, @Param("groupId") Long groupId,
+ List<Loan> getGroupLoansDisbursedAfter(@Param("disbursementDate") LocalDate disbursementDate, @Param("groupId") Long groupId,
@Param("loanType") Integer loanType);
@Query(FIND_CLIENT_OR_JLG_LOANS_DISBURSED_AFTER)
- List<Loan> getClientOrJLGLoansDisbursedAfter(@Param("disbursementDate") Date disbursementDate, @Param("clientId") Long clientId);
+ List<Loan> getClientOrJLGLoansDisbursedAfter(@Param("disbursementDate") LocalDate disbursementDate, @Param("clientId") Long clientId);
@Query(FIND_MAX_GROUP_LOAN_COUNTER_QUERY)
Integer getMaxGroupLoanCounter(@Param("groupId") Long groupId, @Param("loanType") Integer loanType);
@@ -129,7 +129,7 @@ public interface LoanRepository extends JpaRepository<Loan, Long>, JpaSpecificat
@Param("loanStatuses") Collection<Integer> loanStatuses, @Param("loanTypes") Collection<Integer> loanTypes);
@Query("select loan.id from Loan loan where loan.actualDisbursementDate > :disbursalDate order by loan.actualDisbursementDate")
- List<Long> getLoansDisbursedAfter(@Param("disbursalDate") Date disbursalDate);
+ List<Long> getLoansDisbursedAfter(@Param("disbursalDate") LocalDate disbursalDate);
@Query("select loan from Loan loan where loan.client.office.id IN :officeIds and loan.loanStatus IN :loanStatuses")
List<Loan> findByClientOfficeIdsAndLoanStatus(@Param("officeIds") Collection<Long> officeIds,
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepositoryWrapper.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepositoryWrapper.java
index 5ad13c870..83ae69a41 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepositoryWrapper.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepositoryWrapper.java
@@ -18,10 +18,10 @@
*/
package org.apache.fineract.portfolio.loanaccount.domain;
+import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Date;
import java.util.List;
import org.apache.fineract.portfolio.loanaccount.exception.LoanNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -88,13 +88,13 @@ public class LoanRepositoryWrapper {
}
// Only root entities is enough
- public List<Loan> getGroupLoansDisbursedAfter(@Param("disbursementDate") Date disbursementDate, @Param("groupId") Long groupId,
+ public List<Loan> getGroupLoansDisbursedAfter(@Param("disbursementDate") LocalDate disbursementDate, @Param("groupId") Long groupId,
@Param("loanType") Integer loanType) {
return this.repository.getGroupLoansDisbursedAfter(disbursementDate, groupId, loanType);
}
// Only root entities enough
- public List<Loan> getClientOrJLGLoansDisbursedAfter(@Param("disbursementDate") Date disbursementDate,
+ public List<Loan> getClientOrJLGLoansDisbursedAfter(@Param("disbursementDate") LocalDate disbursementDate,
@Param("clientId") Long clientId) {
return this.repository.getClientOrJLGLoansDisbursedAfter(disbursementDate, clientId);
}
@@ -192,7 +192,7 @@ public class LoanRepositoryWrapper {
}
// This method is not used
- public List<Long> getLoansDisbursedAfter(@Param("disbursalDate") Date disbursalDate) {
+ public List<Long> getLoansDisbursedAfter(@Param("disbursalDate") LocalDate disbursalDate) {
return this.repository.getLoansDisbursedAfter(disbursalDate);
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTermVariations.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTermVariations.java
index 7e68aa124..330f3621c 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTermVariations.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanTermVariations.java
@@ -20,7 +20,6 @@ package org.apache.fineract.portfolio.loanaccount.domain;
import java.math.BigDecimal;
import java.time.LocalDate;
-import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
@@ -28,11 +27,8 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
-import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.loanaccount.data.LoanTermVariationsData;
import org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations;
@@ -47,16 +43,14 @@ public class LoanTermVariations extends AbstractPersistableCustom {
@Column(name = "term_type", nullable = false)
private Integer termType;
- @Temporal(TemporalType.DATE)
@Column(name = "applicable_date", nullable = false)
- private Date termApplicableFrom;
+ private LocalDate termApplicableFrom;
@Column(name = "decimal_value", scale = 6, precision = 19)
private BigDecimal decimalValue;
- @Temporal(TemporalType.DATE)
@Column(name = "date_value")
- private Date dateValue;
+ private LocalDate dateValue;
@Column(name = "is_specific_to_installment", nullable = false)
private boolean isSpecificToInstallment;
@@ -71,8 +65,8 @@ public class LoanTermVariations extends AbstractPersistableCustom {
@JoinColumn(name = "parent_id")
private LoanTermVariations parent;
- public LoanTermVariations(final Integer termType, final Date termApplicableFrom, final BigDecimal decimalValue, final Date dateValue,
- final boolean isSpecificToInstallment, final Loan loan) {
+ public LoanTermVariations(final Integer termType, final LocalDate termApplicableFrom, final BigDecimal decimalValue,
+ final LocalDate dateValue, final boolean isSpecificToInstallment, final Loan loan) {
this.loan = loan;
this.termApplicableFrom = termApplicableFrom;
this.termType = termType;
@@ -84,8 +78,8 @@ public class LoanTermVariations extends AbstractPersistableCustom {
this.parent = null;
}
- public LoanTermVariations(final Integer termType, final Date termApplicableFrom, final BigDecimal decimalValue, final Date dateValue,
- final boolean isSpecificToInstallment, final Loan loan, final Integer loanStatus) {
+ public LoanTermVariations(final Integer termType, final LocalDate termApplicableFrom, final BigDecimal decimalValue,
+ final LocalDate dateValue, final boolean isSpecificToInstallment, final Loan loan, final Integer loanStatus) {
this.loan = loan;
this.termApplicableFrom = termApplicableFrom;
this.termType = termType;
@@ -97,9 +91,9 @@ public class LoanTermVariations extends AbstractPersistableCustom {
this.parent = null;
}
- public LoanTermVariations(final Integer termType, final Date termApplicableFrom, final BigDecimal decimalValue, final Date dateValue,
- final boolean isSpecificToInstallment, final Loan loan, final Integer loanStatus, final Boolean isActive,
- final LoanTermVariations parent) {
+ public LoanTermVariations(final Integer termType, final LocalDate termApplicableFrom, final BigDecimal decimalValue,
+ final LocalDate dateValue, final boolean isSpecificToInstallment, final Loan loan, final Integer loanStatus,
+ final Boolean isActive, final LoanTermVariations parent) {
this.loan = loan;
this.termApplicableFrom = termApplicableFrom;
this.termType = termType;
@@ -120,36 +114,32 @@ public class LoanTermVariations extends AbstractPersistableCustom {
}
public LoanTermVariationsData toData() {
- LocalDate termStartDate = LocalDate.ofInstant(this.termApplicableFrom.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- LocalDate dateValue = null;
- if (this.dateValue != null) {
- dateValue = LocalDate.ofInstant(this.dateValue.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
EnumOptionData type = LoanEnumerations.loanvariationType(this.termType);
- return new LoanTermVariationsData(getId(), type, termStartDate, this.decimalValue, dateValue, this.isSpecificToInstallment);
+ return new LoanTermVariationsData(getId(), type, this.termApplicableFrom, this.decimalValue, this.dateValue,
+ this.isSpecificToInstallment);
}
- public Date getTermApplicableFrom() {
+ public LocalDate getTermApplicableFrom() {
return this.termApplicableFrom;
}
public LocalDate fetchTermApplicaDate() {
- return LocalDate.ofInstant(this.termApplicableFrom.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ return this.termApplicableFrom;
}
public BigDecimal getTermValue() {
return this.decimalValue;
}
- public Date getDateValue() {
+ public LocalDate getDateValue() {
return this.dateValue;
}
public LocalDate fetchDateValue() {
- return this.dateValue == null ? null : LocalDate.ofInstant(this.dateValue.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ return this.dateValue;
}
- public void setTermApplicableFrom(Date termApplicableFrom) {
+ public void setTermApplicableFrom(LocalDate termApplicableFrom) {
this.termApplicableFrom = termApplicableFrom;
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/guarantor/command/GuarantorCommand.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/guarantor/command/GuarantorCommand.java
index 1ef242061..462ae9e33 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/guarantor/command/GuarantorCommand.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/guarantor/command/GuarantorCommand.java
@@ -20,9 +20,7 @@ package org.apache.fineract.portfolio.loanaccount.guarantor.command;
import java.math.BigDecimal;
import java.time.LocalDate;
-import java.time.ZoneId;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
@@ -90,8 +88,8 @@ public class GuarantorCommand {
return GuarantorType.EXTERNAL.getValue().equals(this.guarantorTypeId);
}
- public Date getDobAsDate() {
- return Date.from(this.dob.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ public LocalDate getDobAsDate() {
+ return this.dob;
}
public void validateForCreate() {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/guarantor/domain/Guarantor.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/guarantor/domain/Guarantor.java
index ddd5713dc..a6c0fe915 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/guarantor/domain/Guarantor.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/guarantor/domain/Guarantor.java
@@ -18,8 +18,8 @@
*/
package org.apache.fineract.portfolio.loanaccount.guarantor.domain;
+import java.time.LocalDate;
import java.util.ArrayList;
-import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -31,8 +31,6 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -65,8 +63,7 @@ public class Guarantor extends AbstractPersistableCustom {
private String lastname;
@Column(name = "dob")
- @Temporal(TemporalType.DATE)
- private Date dateOfBirth;
+ private LocalDate dateOfBirth;
@Column(name = "address_line_1", length = 500)
private String addressLine1;
@@ -106,9 +103,9 @@ public class Guarantor extends AbstractPersistableCustom {
}
private Guarantor(final Loan loan, final CodeValue clientRelationshipType, final Integer gurantorType, final Long entityId,
- final String firstname, final String lastname, final Date dateOfBirth, final String addressLine1, final String addressLine2,
- final String city, final String state, final String country, final String zip, final String housePhoneNumber,
- final String mobilePhoneNumber, final String comment, final boolean active,
+ final String firstname, final String lastname, final LocalDate dateOfBirth, final String addressLine1,
+ final String addressLine2, final String city, final String state, final String country, final String zip,
+ final String housePhoneNumber, final String mobilePhoneNumber, final String comment, final boolean active,
final List<GuarantorFundingDetails> guarantorFundDetails) {
this.loan = loan;
this.clientRelationshipType = clientRelationshipType;
@@ -138,7 +135,7 @@ public class Guarantor extends AbstractPersistableCustom {
if (GuarantorType.EXTERNAL.getValue().equals(gurantorType)) {
final String firstname = command.stringValueOfParameterNamed(GuarantorJSONinputParams.FIRSTNAME.getValue());
final String lastname = command.stringValueOfParameterNamed(GuarantorJSONinputParams.LASTNAME.getValue());
- final Date dateOfBirth = command.dateValueOfParameterNamed(GuarantorJSONinputParams.DATE_OF_BIRTH.getValue());
+ final LocalDate dateOfBirth = command.localDateValueOfParameterNamed(GuarantorJSONinputParams.DATE_OF_BIRTH.getValue());
final String addressLine1 = command.stringValueOfParameterNamed(GuarantorJSONinputParams.ADDRESS_LINE_1.getValue());
final String addressLine2 = command.stringValueOfParameterNamed(GuarantorJSONinputParams.ADDRESS_LINE_2.getValue());
final String city = command.stringValueOfParameterNamed(GuarantorJSONinputParams.CITY.getValue());
@@ -249,9 +246,9 @@ public class Guarantor extends AbstractPersistableCustom {
}
private void handlePropertyUpdate(final JsonCommand command, final Map<String, Object> actualChanges, final String paramName,
- Date propertyToBeUpdated) {
+ LocalDate propertyToBeUpdated) {
if (command.isChangeInDateParameterNamed(paramName, propertyToBeUpdated)) {
- final Date newValue = command.dateValueOfParameterNamed(paramName);
+ final LocalDate newValue = command.localDateValueOfParameterNamed(paramName);
actualChanges.put(paramName, newValue);
// propertyToBeUpdated = newValue;
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java
index 1d1429f14..03cef56c4 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java
@@ -21,9 +21,7 @@ package org.apache.fineract.portfolio.loanaccount.loanschedule.domain;
import java.math.BigDecimal;
import java.math.MathContext;
import java.time.LocalDate;
-import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
-import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -1388,20 +1386,12 @@ public final class LoanApplicationTerms {
return this.repaymentPeriodFrequencyType;
}
- public Date getRepaymentStartFromDate() {
- Date dateValue = null;
- if (this.repaymentsStartingFromDate != null) {
- dateValue = Date.from(this.repaymentsStartingFromDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
- }
- return dateValue;
+ public LocalDate getRepaymentStartFromDate() {
+ return this.repaymentsStartingFromDate;
}
- public Date getInterestChargedFromDate() {
- Date dateValue = null;
- if (this.interestChargedFromDate != null) {
- dateValue = Date.from(this.interestChargedFromDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
- }
- return dateValue;
+ public LocalDate getInterestChargedFromDate() {
+ return this.interestChargedFromDate;
}
public void setPrincipal(Money principal) {
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanRepaymentScheduleHistory.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanRepaymentScheduleHistory.java
index 34fc4befe..77e754549 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanRepaymentScheduleHistory.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanRepaymentScheduleHistory.java
@@ -19,15 +19,13 @@
package org.apache.fineract.portfolio.loanaccount.loanschedule.domain;
import java.math.BigDecimal;
-import java.util.Date;
+import java.time.LocalDate;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.rescheduleloan.domain.LoanRescheduleRequest;
@@ -47,13 +45,11 @@ public class LoanRepaymentScheduleHistory extends AbstractPersistableCustom {
@Column(name = "installment", nullable = false)
private Integer installmentNumber;
- @Temporal(TemporalType.DATE)
@Column(name = "fromdate", nullable = true)
- private Date fromDate;
+ private LocalDate fromDate;
- @Temporal(TemporalType.DATE)
@Column(name = "duedate", nullable = false)
- private Date dueDate;
+ private LocalDate dueDate;
@Column(name = "principal_amount", scale = 6, precision = 19, nullable = true)
private BigDecimal principal;
@@ -67,9 +63,8 @@ public class LoanRepaymentScheduleHistory extends AbstractPersistableCustom {
@Column(name = "penalty_charges_amount", scale = 6, precision = 19, nullable = true)
private BigDecimal penaltyCharges;
- @Temporal(TemporalType.DATE)
@Column(name = "created_date")
- private Date createdOnDate;
+ private LocalDate createdOnDate;
@Column(name = "createdby_id")
private Long createdByUser;
@@ -77,9 +72,8 @@ public class LoanRepaymentScheduleHistory extends AbstractPersistableCustom {
@Column(name = "lastmodifiedby_id")
private Long lastModifiedByUser;
- @Temporal(TemporalType.DATE)
@Column(name = "lastmodified_date")
- private Date lastModifiedOnDate;
+ private LocalDate lastModifiedOnDate;
@Column(name = "version")
private Integer version;
@@ -93,9 +87,10 @@ public class LoanRepaymentScheduleHistory extends AbstractPersistableCustom {
* LoanRepaymentScheduleHistory constructor
**/
private LoanRepaymentScheduleHistory(final Loan loan, final LoanRescheduleRequest loanRescheduleRequest,
- final Integer installmentNumber, final Date fromDate, final Date dueDate, final BigDecimal principal,
- final BigDecimal interestCharged, final BigDecimal feeChargesCharged, final BigDecimal penaltyCharges, final Date createdOnDate,
- final Long createdByUser, final Long lastModifiedByUser, final Date lastModifiedOnDate, final Integer version) {
+ final Integer installmentNumber, final LocalDate fromDate, final LocalDate dueDate, final BigDecimal principal,
+ final BigDecimal interestCharged, final BigDecimal feeChargesCharged, final BigDecimal penaltyCharges,
+ final LocalDate createdOnDate, final Long createdByUser, final Long lastModifiedByUser, final LocalDate lastModifiedOnDate,
+ final Integer version) {
this.loan = loan;
this.loanRescheduleRequest = loanRescheduleRequest;
@@ -117,9 +112,10 @@ public class LoanRepaymentScheduleHistory extends AbstractPersistableCustom {
* @return an instance of the LoanRepaymentScheduleHistory class
**/
public static LoanRepaymentScheduleHistory instance(final Loan loan, final LoanRescheduleRequest loanRescheduleRequest,
- final Integer installmentNumber, final Date fromDate, final Date dueDate, final BigDecimal principal,
- final BigDecimal interestCharged, final BigDecimal feeChargesCharged, final BigDecimal penaltyCharges, final Date createdOnDate,
- final Long createdByUser, final Long lastModifiedByUser, final Date lastModifiedOnDate, final Integer version) {
+ final Integer installmentNumber, final LocalDate fromDate, final LocalDate dueDate, final BigDecimal principal,
+ final BigDecimal interestCharged, final BigDecimal feeChargesCharged, final BigDecimal penaltyCharges,
+ final LocalDate createdOnDate, final Long createdByUser, final Long lastModifiedByUser, final LocalDate lastModifiedOnDate,
+ final Integer version) {
return new LoanRepaymentScheduleHistory(loan, loanRescheduleRequest, installmentNumber, fromDate, dueDate, principal,
interestCharged, feeChargesCharged, penaltyCharges, createdOnDate, createdByUser, lastModifiedByUser, lastModifiedOnDate,
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java
index afd727050..2b6ff390b 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java
@@ -25,12 +25,10 @@ import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.time.LocalDate;
-import java.time.ZoneId;
import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -443,8 +441,8 @@ public class LoanScheduleAssembler {
officeId = group.getOffice().getId();
}
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
- final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId,
- Date.from(expectedDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), HolidayStatusType.ACTIVE.getValue());
+ final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId, expectedDisbursementDate,
+ HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne();
HolidayDetailDTO detailDTO = new HolidayDetailDTO(isHolidayEnabled, holidays, workingDays);
final boolean isInterestToBeRecoveredFirstWhenGreaterThanEMI = this.configurationDomainService
@@ -622,8 +620,8 @@ public class LoanScheduleAssembler {
}
final LocalDate expectedDisbursementDate = this.fromApiJsonHelper.extractLocalDateNamed("expectedDisbursementDate", element);
- final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId,
- Date.from(expectedDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), HolidayStatusType.ACTIVE.getValue());
+ final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId, expectedDisbursementDate,
+ HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne();
validateDisbursementDateIsOnNonWorkingDay(loanApplicationTerms.getExpectedDisbursementDate(), workingDays);
@@ -671,8 +669,7 @@ public class LoanScheduleAssembler {
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId,
- Date.from(loanApplicationTerms.getExpectedDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
- HolidayStatusType.ACTIVE.getValue());
+ loanApplicationTerms.getExpectedDisbursementDate(), HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne();
final LoanScheduleGenerator loanScheduleGenerator = this.loanScheduleFactory.create(loanApplicationTerms.getInterestMethod());
@@ -690,8 +687,7 @@ public class LoanScheduleAssembler {
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId,
- Date.from(loanApplicationTerms.getExpectedDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
- HolidayStatusType.ACTIVE.getValue());
+ loanApplicationTerms.getExpectedDisbursementDate(), HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne();
HolidayDetailDTO holidayDetailDTO = new HolidayDetailDTO(isHolidayEnabled, holidays, workingDays);
@@ -872,8 +868,7 @@ public class LoanScheduleAssembler {
throw new PlatformApiDataValidationException(dataValidationErrors);
}
if (loan.getExpectedFirstRepaymentOnDate() == null) {
- loan.setExpectedFirstRepaymentOnDate(
- Date.from(loan.fetchRepaymentScheduleInstallment(1).getDueDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ loan.setExpectedFirstRepaymentOnDate(loan.fetchRepaymentScheduleInstallment(1).getDueDate());
}
final LocalDate recalculateFrom = null;
ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom);
@@ -1007,15 +1002,14 @@ public class LoanScheduleAssembler {
decimalValueVariationType = LoanTermVariationType.PRINCIPAL_AMOUNT;
}
- LocalDate duedateLocalDate = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.dueDateParamName, arrayElement,
- dateFormat, locale);
- Date dueDate = Date.from(duedateLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ LocalDate dueDate = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.dueDateParamName, arrayElement, dateFormat,
+ locale);
LocalDate modifiedDuedateLocalDate = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.modifiedDueDateParamName,
arrayElement, dateFormat, locale);
- Date modifiedDuedate = null;
+ LocalDate modifiedDuedate = null;
if (modifiedDuedateLocalDate != null) {
- modifiedDuedate = Date.from(modifiedDuedateLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ modifiedDuedate = modifiedDuedateLocalDate;
}
boolean isSpecificToInstallment = true;
if (isInsertInstallment) {
@@ -1037,7 +1031,7 @@ public class LoanScheduleAssembler {
if (modifiedDuedate == null) {
modifiedDuedate = dueDate;
}
- Date date = null;
+ LocalDate date = null;
LoanTermVariations data = new LoanTermVariations(decimalValueVariationType.getValue(), modifiedDuedate, decimalValue,
date, isSpecificToInstallment, loan);
loanTermVariations.add(data);
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleHistoryWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleHistoryWritePlatformServiceImpl.java
index 70d94c251..a84f67798 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleHistoryWritePlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleHistoryWritePlatformServiceImpl.java
@@ -19,10 +19,10 @@
package org.apache.fineract.portfolio.loanaccount.loanschedule.service;
import java.math.BigDecimal;
-import java.time.ZoneId;
+import java.time.LocalDate;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
+import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
@@ -57,15 +57,15 @@ public class LoanScheduleHistoryWritePlatformServiceImpl implements LoanSchedule
for (LoanRepaymentScheduleInstallment repaymentScheduleInstallment : repaymentScheduleInstallments) {
final Integer installmentNumber = repaymentScheduleInstallment.getInstallmentNumber();
- Date fromDate = null;
- Date dueDate = null;
+ LocalDate fromDate = null;
+ LocalDate dueDate = null;
if (repaymentScheduleInstallment.getFromDate() != null) {
- fromDate = Date.from(repaymentScheduleInstallment.getFromDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
+ fromDate = repaymentScheduleInstallment.getFromDate();
}
if (repaymentScheduleInstallment.getDueDate() != null) {
- dueDate = Date.from(repaymentScheduleInstallment.getDueDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
+ dueDate = repaymentScheduleInstallment.getDueDate();
}
final BigDecimal principal = repaymentScheduleInstallment.getPrincipal(currency).getAmount();
@@ -73,18 +73,20 @@ public class LoanScheduleHistoryWritePlatformServiceImpl implements LoanSchedule
final BigDecimal feeChargesCharged = repaymentScheduleInstallment.getFeeChargesCharged(currency).getAmount();
final BigDecimal penaltyCharges = repaymentScheduleInstallment.getPenaltyChargesCharged(currency).getAmount();
- Date createdOnDate = null;
+ LocalDate createdOnDate = null;
if (repaymentScheduleInstallment.getCreatedDate().isPresent()) {
- createdOnDate = Date.from(repaymentScheduleInstallment.getCreatedDate().get()); // NOSONAR
+ createdOnDate = LocalDate.ofInstant(repaymentScheduleInstallment.getCreatedDate().get(),
+ DateUtils.getDateTimeZoneOfTenant()); // NOSONAR
}
final Long createdByUser = repaymentScheduleInstallment.getCreatedBy().orElse(null);
final Long lastModifiedByUser = repaymentScheduleInstallment.getLastModifiedBy().orElse(null);
- Date lastModifiedOnDate = null;
+ LocalDate lastModifiedOnDate = null;
if (repaymentScheduleInstallment.getLastModifiedDate().isPresent()) {
- lastModifiedOnDate = Date.from(repaymentScheduleInstallment.getLastModifiedDate().get()); // NOSONAR
+ lastModifiedOnDate = LocalDate.ofInstant(repaymentScheduleInstallment.getLastModifiedDate().get(),
+ DateUtils.getDateTimeZoneOfTenant()); // NOSONAR
}
LoanRepaymentScheduleHistory loanRepaymentScheduleHistory = LoanRepaymentScheduleHistory.instance(loan, loanRescheduleRequest,
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/domain/LoanRescheduleRequest.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/domain/LoanRescheduleRequest.java
index 32425bd40..e081e92db 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/domain/LoanRescheduleRequest.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/domain/LoanRescheduleRequest.java
@@ -19,8 +19,6 @@
package org.apache.fineract.portfolio.loanaccount.rescheduleloan.domain;
import java.time.LocalDate;
-import java.time.ZoneId;
-import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -32,11 +30,8 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
-import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRescheduleRequestToTermVariationMapping;
import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
@@ -57,9 +52,8 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom {
@Column(name = "reschedule_from_installment")
private Integer rescheduleFromInstallment;
- @Temporal(TemporalType.DATE)
@Column(name = "reschedule_from_date")
- private Date rescheduleFromDate;
+ private LocalDate rescheduleFromDate;
@Column(name = "recalculate_interest")
private Boolean recalculateInterest;
@@ -71,25 +65,22 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom {
@Column(name = "reschedule_reason_comment")
private String rescheduleReasonComment;
- @Temporal(TemporalType.DATE)
@Column(name = "submitted_on_date")
- private Date submittedOnDate;
+ private LocalDate submittedOnDate;
@ManyToOne
@JoinColumn(name = "submitted_by_user_id")
private AppUser submittedByUser;
- @Temporal(TemporalType.DATE)
@Column(name = "approved_on_date")
- private Date approvedOnDate;
+ private LocalDate approvedOnDate;
@ManyToOne
@JoinColumn(name = "approved_by_user_id")
private AppUser approvedByUser;
- @Temporal(TemporalType.DATE)
@Column(name = "rejected_on_date")
- private Date rejectedOnDate;
+ private LocalDate rejectedOnDate;
@ManyToOne
@JoinColumn(name = "rejected_by_user_id")
@@ -107,9 +98,9 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom {
* LoanRescheduleRequest constructor
**/
private LoanRescheduleRequest(final Loan loan, final Integer statusEnum, final Integer rescheduleFromInstallment,
- final Date rescheduleFromDate, final Boolean recalculateInterest, final CodeValue rescheduleReasonCodeValue,
- final String rescheduleReasonComment, final Date submittedOnDate, final AppUser submittedByUser, final Date approvedOnDate,
- final AppUser approvedByUser, final Date rejectedOnDate, AppUser rejectedByUser) {
+ final LocalDate rescheduleFromDate, final Boolean recalculateInterest, final CodeValue rescheduleReasonCodeValue,
+ final String rescheduleReasonComment, final LocalDate submittedOnDate, final AppUser submittedByUser,
+ final LocalDate approvedOnDate, final AppUser approvedByUser, final LocalDate rejectedOnDate, AppUser rejectedByUser) {
this.loan = loan;
this.statusEnum = statusEnum;
this.rescheduleFromInstallment = rescheduleFromInstallment;
@@ -129,9 +120,9 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom {
* @return a new instance of the LoanRescheduleRequest class
**/
public static LoanRescheduleRequest instance(final Loan loan, final Integer statusEnum, final Integer rescheduleFromInstallment,
- final Date rescheduleFromDate, final Boolean recalculateInterest, final CodeValue rescheduleReasonCodeValue,
- final String rescheduleReasonComment, final Date submittedOnDate, final AppUser submittedByUser, final Date approvedOnDate,
- final AppUser approvedByUser, final Date rejectedOnDate, AppUser rejectedByUser) {
+ final LocalDate rescheduleFromDate, final Boolean recalculateInterest, final CodeValue rescheduleReasonCodeValue,
+ final String rescheduleReasonComment, final LocalDate submittedOnDate, final AppUser submittedByUser,
+ final LocalDate approvedOnDate, final AppUser approvedByUser, final LocalDate rejectedOnDate, AppUser rejectedByUser) {
return new LoanRescheduleRequest(loan, statusEnum, rescheduleFromInstallment, rescheduleFromDate, recalculateInterest,
rescheduleReasonCodeValue, rescheduleReasonComment, submittedOnDate, submittedByUser, approvedOnDate, approvedByUser,
@@ -163,14 +154,7 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom {
* @return due date of the rescheduling start point
**/
public LocalDate getRescheduleFromDate() {
-
- LocalDate localDate = null;
-
- if (this.rescheduleFromDate != null) {
- localDate = LocalDate.ofInstant(this.rescheduleFromDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
-
- return localDate;
+ return this.rescheduleFromDate;
}
/**
@@ -191,13 +175,7 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom {
* @return the date the request was submitted
**/
public LocalDate getSubmittedOnDate() {
- LocalDate localDate = null;
-
- if (this.submittedOnDate != null) {
- localDate = LocalDate.ofInstant(this.submittedOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
-
- return localDate;
+ return this.submittedOnDate;
}
/**
@@ -211,13 +189,7 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom {
* @return the date the request was approved
**/
public LocalDate getApprovedOnDate() {
- LocalDate localDate = null;
-
- if (this.approvedOnDate != null) {
- localDate = LocalDate.ofInstant(this.approvedOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
-
- return localDate;
+ return this.approvedOnDate;
}
/**
@@ -231,13 +203,7 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom {
* @return the date the request was rejected
**/
public LocalDate getRejectedOnDate() {
- LocalDate localDate = null;
-
- if (this.rejectedOnDate != null) {
- localDate = LocalDate.ofInstant(this.rejectedOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- }
-
- return localDate;
+ return this.rejectedOnDate;
}
/**
@@ -274,7 +240,7 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom {
if (approvedOnDate != null) {
this.approvedByUser = approvedByUser;
- this.approvedOnDate = Date.from(approvedOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.approvedOnDate = approvedOnDate;
this.statusEnum = LoanStatus.APPROVED.getValue();
}
}
@@ -293,7 +259,7 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom {
if (approvedOnDate != null) {
this.rejectedByUser = approvedByUser;
- this.rejectedOnDate = Date.from(approvedOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ this.rejectedOnDate = approvedOnDate;
this.statusEnum = LoanStatus.REJECTED.getValue();
}
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanReschedulePreviewPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanReschedulePreviewPlatformServiceImpl.java
index 924ab0ae7..1b4feeb69 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanReschedulePreviewPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanReschedulePreviewPlatformServiceImpl.java
@@ -21,9 +21,7 @@ package org.apache.fineract.portfolio.loanaccount.rescheduleloan.service;
import java.math.MathContext;
import java.math.RoundingMode;
import java.time.LocalDate;
-import java.time.ZoneId;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import java.util.Set;
import org.apache.fineract.organisation.monetary.domain.MoneyHelper;
@@ -109,8 +107,7 @@ public class LoanReschedulePreviewPlatformServiceImpl implements LoanRescheduleP
if (loanRescheduleRequestToTermVariationMapping.getLoanTermVariations().getTermType().isDueDateVariation()
&& rescheduleFromDate != null) {
adjustedApplicableDate = loanRescheduleRequestToTermVariationMapping.getLoanTermVariations().fetchDateValue();
- loanRescheduleRequestToTermVariationMapping.getLoanTermVariations()
- .setTermApplicableFrom(Date.from(rescheduleFromDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ loanRescheduleRequestToTermVariationMapping.getLoanTermVariations().setTermApplicableFrom(rescheduleFromDate);
}
loanTermVariationsData.add(loanRescheduleRequestToTermVariationMapping.getLoanTermVariations().toData());
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanRescheduleRequestWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanRescheduleRequestWritePlatformServiceImpl.java
index 5fae22ab5..976b19ab2 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanRescheduleRequestWritePlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/rescheduleloan/service/LoanRescheduleRequestWritePlatformServiceImpl.java
@@ -22,11 +22,9 @@ import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.time.LocalDate;
-import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -213,32 +211,27 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
final Boolean recalculateInterest = jsonCommand
.booleanObjectValueOfParameterNamed(RescheduleLoansApiConstants.recalculateInterestParamName);
- final Date endDate = jsonCommand.dateValueOfParameterNamed(RescheduleLoansApiConstants.endDateParamName);
+ final LocalDate endDate = jsonCommand.localDateValueOfParameterNamed(RescheduleLoansApiConstants.endDateParamName);
final BigDecimal emi = jsonCommand.bigDecimalValueOfParameterNamed(RescheduleLoansApiConstants.emiParamName);
// initialize set the value to null
- Date submittedOnDate = null;
+ LocalDate submittedOnDate = null;
// check if the parameter is in the JsonCommand object
if (jsonCommand.hasParameter(RescheduleLoansApiConstants.submittedOnDateParamName)) {
// create a LocalDate object from the "submittedOnDate" Date
// string
- LocalDate localDate = jsonCommand.localDateValueOfParameterNamed(RescheduleLoansApiConstants.submittedOnDateParamName);
-
- if (localDate != null) {
- // update the value of the "submittedOnDate" variable
- submittedOnDate = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
- }
+ submittedOnDate = jsonCommand.localDateValueOfParameterNamed(RescheduleLoansApiConstants.submittedOnDateParamName);
}
// initially set the value to null
- Date rescheduleFromDate = null;
+ LocalDate rescheduleFromDate = null;
// start point of the rescheduling exercise
Integer rescheduleFromInstallment = null;
// initially set the value to null
- Date adjustedDueDate = null;
+ LocalDate adjustedDueDate = null;
// check if the parameter is in the JsonCommand object
if (jsonCommand.hasParameter(RescheduleLoansApiConstants.rescheduleFromDateParamName)) {
@@ -252,19 +245,14 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
rescheduleFromInstallment = installment.getInstallmentNumber();
// update the value of the "rescheduleFromDate" variable
- rescheduleFromDate = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
+ rescheduleFromDate = localDate;
}
}
if (jsonCommand.hasParameter(RescheduleLoansApiConstants.adjustedDueDateParamName)) {
// create a LocalDate object from the "adjustedDueDate" Date
// string
- LocalDate localDate = jsonCommand.localDateValueOfParameterNamed(RescheduleLoansApiConstants.adjustedDueDateParamName);
-
- if (localDate != null) {
- // update the value of the "adjustedDueDate"variable
- adjustedDueDate = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
- }
+ adjustedDueDate = jsonCommand.localDateValueOfParameterNamed(RescheduleLoansApiConstants.adjustedDueDateParamName);
}
final LoanRescheduleRequest loanRescheduleRequest = LoanRescheduleRequest.instance(loan,
@@ -277,7 +265,7 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
final Boolean isActive = false;
final boolean isSpecificToInstallment = false;
BigDecimal decimalValue = null;
- Date dueDate = null;
+ LocalDate dueDate = null;
// create term variations for flat and declining balance loans
createLoanTermVariationsForRegularLoans(loan, graceOnPrincipal, graceOnInterest, extraTerms, interestRate, rescheduleFromDate,
adjustedDueDate, loanRescheduleRequest, loanRescheduleRequestToTermVariationMappings, isActive, isSpecificToInstallment,
@@ -302,23 +290,21 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
}
private void createLoanTermVariationsForRegularLoans(final Loan loan, final Integer graceOnPrincipal, final Integer graceOnInterest,
- final Integer extraTerms, final BigDecimal interestRate, Date rescheduleFromDate, Date adjustedDueDate,
+ final Integer extraTerms, final BigDecimal interestRate, LocalDate rescheduleFromDate, LocalDate adjustedDueDate,
final LoanRescheduleRequest loanRescheduleRequest,
List<LoanRescheduleRequestToTermVariationMapping> loanRescheduleRequestToTermVariationMappings, final Boolean isActive,
- final boolean isSpecificToInstallment, BigDecimal decimalValue, Date dueDate, Date endDate, BigDecimal emi) {
+ final boolean isSpecificToInstallment, BigDecimal decimalValue, LocalDate dueDate, LocalDate endDate, BigDecimal emi) {
if (rescheduleFromDate != null && endDate != null && emi != null) {
LoanTermVariations parent = null;
- LocalDate rescheduleFromLocDate = LocalDate.ofInstant(rescheduleFromDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
- LocalDate endDateLocDate = LocalDate.ofInstant(endDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
+ LocalDate rescheduleFromLocDate = rescheduleFromDate;
+ LocalDate endDateLocDate = endDate;
final Integer termType = LoanTermVariationType.EMI_AMOUNT.getValue();
List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments();
for (LoanRepaymentScheduleInstallment installment : installments) {
if (installment.getDueDate().isEqual(rescheduleFromLocDate) || installment.getDueDate().isEqual(endDateLocDate)
|| (installment.getDueDate().isAfter(rescheduleFromLocDate) && installment.getDueDate().isBefore(endDateLocDate))) {
- createLoanTermVariations(loanRescheduleRequest, termType, loan,
- Date.from(installment.getDueDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
- Date.from(installment.getDueDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
+ createLoanTermVariations(loanRescheduleRequest, termType, loan, installment.getDueDate(), installment.getDueDate(),
loanRescheduleRequestToTermVariationMappings, isActive, true, emi, parent);
}
if (installment.getDueDate().isAfter(endDateLocDate)) {
@@ -374,7 +360,7 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
}
private LoanTermVariations createLoanTermVariations(LoanRescheduleRequest loanRescheduleRequest, final Integer termType,
- final Loan loan, Date rescheduleFromDate, Date adjustedDueDate,
+ final Loan loan, LocalDate rescheduleFromDate, LocalDate adjustedDueDate,
List<LoanRescheduleRequestToTermVariationMapping> loanRescheduleRequestToTermVariationMappings, final Boolean isActive,
final boolean isSpecificToInstallment, final BigDecimal decimalValue, LoanTermVariations parent) {
LoanTermVariations loanTermVariation = new LoanTermVariations(termType, rescheduleFromDate, decimalValue, adjustedDueDate,
@@ -436,8 +422,7 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
&& activeLoanTermVariation.fetchDateValue().equals(dueDateVariationInCurrentRequest.fetchTermApplicaDate())) {
activeLoanTermVariation.markAsInactive();
rescheduleFromDate = activeLoanTermVariation.fetchTermApplicaDate();
- dueDateVariationInCurrentRequest
- .setTermApplicableFrom(Date.from(rescheduleFromDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ dueDateVariationInCurrentRequest.setTermApplicableFrom(rescheduleFromDate);
} else if (!activeLoanTermVariation.fetchTermApplicaDate().isBefore(fromScheduleDate)) {
while (currentScheduleDate.isBefore(activeLoanTermVariation.fetchTermApplicaDate())) {
currentScheduleDate = this.scheduledDateGenerator.generateNextRepaymentDate(currentScheduleDate,
@@ -447,8 +432,7 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
changeMap.put(currentScheduleDate, modifiedScheduleDate);
}
if (changeMap.containsKey(activeLoanTermVariation.fetchTermApplicaDate())) {
- activeLoanTermVariation.setTermApplicableFrom(Date.from(changeMap
- .get(activeLoanTermVariation.fetchTermApplicaDate()).atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ activeLoanTermVariation.setTermApplicableFrom(changeMap.get(activeLoanTermVariation.fetchTermApplicaDate()));
}
}
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAccrualWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAccrualWritePlatformServiceImpl.java
index ec91520d8..408555669 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAccrualWritePlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAccrualWritePlatformServiceImpl.java
@@ -20,11 +20,9 @@ package org.apache.fineract.portfolio.loanaccount.service;
import java.math.BigDecimal;
import java.time.LocalDate;
-import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -271,8 +269,8 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
String transactionSql = "INSERT INTO m_loan_transaction (loan_id,office_id,is_reversed,transaction_type_enum,transaction_date,amount,interest_portion_derived,"
+ "fee_charges_portion_derived,penalty_charges_portion_derived, submitted_on_date) VALUES (?, ?, false, ?, ?, ?, ?, ?, ?, ?)";
this.jdbcTemplate.update(transactionSql, scheduleAccrualData.getLoanId(), scheduleAccrualData.getOfficeId(),
- LoanTransactionType.ACCRUAL.getValue(), Date.from(accruedTill.atStartOfDay(ZoneId.systemDefault()).toInstant()), amount,
- interestportion, feeportion, penaltyportion, DateUtils.getBusinessDate());
+ LoanTransactionType.ACCRUAL.getValue(), accruedTill, amount, interestportion, feeportion, penaltyportion,
+ DateUtils.getBusinessDate());
@SuppressWarnings("deprecation")
final Long transactonId = this.jdbcTemplate.queryForObject("SELECT " + sqlGenerator.lastInsertId(), Long.class); // NOSONAR
@@ -293,8 +291,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
scheduleAccrualData.getRepaymentScheduleId());
String updateLoan = "UPDATE m_loan SET accrued_till=? WHERE id=?";
- this.jdbcTemplate.update(updateLoan, Date.from(accruedTill.atStartOfDay(ZoneId.systemDefault()).toInstant()),
- scheduleAccrualData.getLoanId());
+ this.jdbcTemplate.update(updateLoan, accruedTill, scheduleAccrualData.getLoanId());
final Map<String, Object> accountingBridgeData = deriveAccountingBridgeData(scheduleAccrualData, transactionMap);
this.journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData);
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAssembler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAssembler.java
index 60f31d118..41b49b026 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAssembler.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAssembler.java
@@ -21,10 +21,8 @@ package org.apache.fineract.portfolio.loanaccount.service;
import com.google.gson.JsonElement;
import java.math.BigDecimal;
import java.time.LocalDate;
-import java.time.ZoneId;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
@@ -344,8 +342,7 @@ public class LoanAssembler {
final LoanApplicationTerms loanApplicationTerms = this.loanScheduleAssembler.assembleLoanTerms(element);
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loanApplication.getOfficeId(),
- Date.from(loanApplicationTerms.getExpectedDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
- HolidayStatusType.ACTIVE.getValue());
+ loanApplicationTerms.getExpectedDisbursementDate(), HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled();
final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled();
@@ -402,8 +399,7 @@ public class LoanAssembler {
final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loanApplication.getOfficeId(),
- Date.from(loanApplication.getExpectedDisbursedOnLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
- HolidayStatusType.ACTIVE.getValue());
+ loanApplication.getExpectedDisbursedOnLocalDate(), HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled();
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformService.java
index 3d81a76a1..549ffee28 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformService.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformService.java
@@ -21,7 +21,6 @@ package org.apache.fineract.portfolio.loanaccount.service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Collection;
-import java.util.Date;
import java.util.List;
import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.core.service.SearchParameters;
@@ -123,7 +122,7 @@ public interface LoanReadPlatformService {
boolean isGuaranteeRequired(Long loanId);
- Date retrieveMinimumDateOfRepaymentTransaction(Long loanId);
+ LocalDate retrieveMinimumDateOfRepaymentTransaction(Long loanId);
PaidInAdvanceData retrieveTotalPaidInAdvance(Long loanId);
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
index cf791792f..90ba8a5a8 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
@@ -24,13 +24,11 @@ import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDate;
-import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -1656,7 +1654,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
public Collection<LoanScheduleAccrualData> retriveScheduleAccrualData() {
LoanScheduleAccrualMapper mapper = new LoanScheduleAccrualMapper();
- Date organisationStartDate = this.configurationDomainService.retrieveOrganisationStartDate();
+ LocalDate organisationStartDate = this.configurationDomainService.retrieveOrganisationStartDate();
final StringBuilder sqlBuilder = new StringBuilder(400);
sqlBuilder.append("select ").append(mapper.schema()).append(
" where (recaldet.is_compounding_to_be_posted_as_transaction is null or recaldet.is_compounding_to_be_posted_as_transaction = false) ")
@@ -1671,8 +1669,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
Map<String, Object> paramMap = new HashMap<>(3);
paramMap.put("active", LoanStatus.ACTIVE.getValue());
paramMap.put("type", AccountingRuleType.ACCRUAL_PERIODIC.getValue());
- paramMap.put("organisationStartDate", (organisationStartDate == null) ? DateUtils.getBusinessLocalDate()
- : LocalDate.ofInstant(organisationStartDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()));
+ paramMap.put("organisationStartDate", (organisationStartDate == null) ? DateUtils.getBusinessLocalDate() : organisationStartDate);
paramMap.put("currentDate", DateUtils.getBusinessLocalDate());
return this.namedParameterJdbcTemplate.query(sqlBuilder.toString(), paramMap, mapper);
@@ -1682,7 +1679,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
public Collection<LoanScheduleAccrualData> retrivePeriodicAccrualData(final LocalDate tillDate) {
LoanSchedulePeriodicAccrualMapper mapper = new LoanSchedulePeriodicAccrualMapper();
- Date organisationStartDate = this.configurationDomainService.retrieveOrganisationStartDate();
+ LocalDate organisationStartDate = this.configurationDomainService.retrieveOrganisationStartDate();
final StringBuilder sqlBuilder = new StringBuilder(400);
sqlBuilder.append("select ").append(mapper.schema()).append(
" where (recaldet.is_compounding_to_be_posted_as_transaction is null or recaldet.is_compounding_to_be_posted_as_transaction = false) ")
@@ -1694,8 +1691,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
Map<String, Object> paramMap = new HashMap<>(4);
if (organisationStartDate != null) {
sqlBuilder.append(" and ls.duedate > :organisationStartDate ");
- paramMap.put("organisationStartDate",
- LocalDate.ofInstant(organisationStartDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()));
+ paramMap.put("organisationStartDate", organisationStartDate);
}
sqlBuilder.append(" order by loan.id,ls.duedate ");
paramMap.put("active", LoanStatus.ACTIVE.getValue());
@@ -2084,10 +2080,11 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
}
@Override
- public Date retrieveMinimumDateOfRepaymentTransaction(Long loanId) {
+ public LocalDate retrieveMinimumDateOfRepaymentTransaction(Long loanId) {
// TODO Auto-generated method stub
- Date date = this.jdbcTemplate.queryForObject(
- "select min(transaction_date) from m_loan_transaction where loan_id=? and transaction_type_enum=2", Date.class, loanId);
+ LocalDate date = this.jdbcTemplate.queryForObject(
+ "select min(transaction_date) from m_loan_transaction where loan_id=? and transaction_type_enum=2", LocalDate.class,
+ loanId);
return date;
}
@@ -2155,13 +2152,10 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final Collection<InterestRatePeriodData> intRates = this.floatingRatesReadPlatformService
.retrieveInterestRatePeriods(loanData.loanProductId());
for (final InterestRatePeriodData rate : intRates) {
- if (rate.getFromDate()
- .compareTo(Date.from(loanData.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant())) > 0
- && loanData.isFloatingInterestRate()) {
+ if (rate.getFromDate().compareTo(loanData.getDisbursementDate()) > 0 && loanData.isFloatingInterestRate()) {
updateInterestRatePeriodData(rate, loanData);
intRatePeriodData.add(rate);
- } else if (rate.getFromDate()
- .compareTo(Date.from(loanData.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant())) <= 0) {
+ } else if (rate.getFromDate().compareTo(loanData.getDisbursementDate()) <= 0) {
updateInterestRatePeriodData(rate, loanData);
intRatePeriodData.add(rate);
break;
@@ -2187,8 +2181,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
}
rate.setEffectiveInterestRate(effectiveInterestRate);
- if (rate.getFromDate().compareTo(Date.from(loan.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant())) < 0) {
- rate.setFromDate(Date.from(loan.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ if (rate.getFromDate().compareTo(loan.getDisbursementDate()) < 0) {
+ rate.setFromDate(loan.getDisbursementDate());
}
}
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java
index 8c810548f..55a24f4b6 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java
@@ -22,9 +22,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.math.BigDecimal;
import java.time.LocalDate;
-import java.time.ZoneId;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Set;
@@ -194,8 +192,7 @@ public class LoanUtilService {
private HolidayDetailDTO constructHolidayDTO(final Loan loan) {
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
- Date.from(loan.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
- HolidayStatusType.ACTIVE.getValue());
+ loan.getDisbursementDate(), HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled();
final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled();
@@ -319,17 +316,14 @@ public class LoanUtilService {
int i = 0;
do {
final JsonObject jsonObject = disbursementDataArray.get(i).getAsJsonObject();
- Date expectedDisbursementDate = null;
- Date actualDisbursementDate = null;
+ LocalDate expectedDisbursementDate = null;
+ LocalDate actualDisbursementDate = null;
BigDecimal principal = null;
BigDecimal netDisbursalAmount = null;
if (jsonObject.has(LoanApiConstants.disbursementDateParameterName)) {
- LocalDate date = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.disbursementDateParameterName,
- jsonObject, dateFormat, locale);
- if (date != null) {
- expectedDisbursementDate = Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant());
- }
+ expectedDisbursementDate = this.fromApiJsonHelper
+ .extractLocalDateNamed(LoanApiConstants.disbursementDateParameterName, jsonObject, dateFormat, locale);
}
if (jsonObject.has(LoanApiConstants.disbursementPrincipalParameterName)
&& jsonObject.get(LoanApiConstants.disbursementPrincipalParameterName).isJsonPrimitive()
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
index 6b6b5373f..a9cfa8787 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
@@ -29,7 +29,6 @@ import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -318,8 +317,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
if (loan.loanProduct().isDisallowExpectedDisbursements()) {
// create artificial 'tranche/expected disbursal' as current disburse code expects it for multi-disbursal
// products
- final Date artificialExpectedDate = Date
- .from(loan.getExpectedDisbursedOnLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
+ final LocalDate artificialExpectedDate = loan.getExpectedDisbursedOnLocalDate();
LoanDisbursementDetails disbursementDetail = new LoanDisbursementDetails(artificialExpectedDate, null,
loan.getDisbursedAmount(), null);
disbursementDetail.updateLoan(loan);
@@ -359,14 +357,14 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
checkClientOrGroupActive(loan);
final LocalDate nextPossibleRepaymentDate = loan.getNextPossibleRepaymentDateForRescheduling();
- final Date rescheduledRepaymentDate = command.dateValueOfParameterNamed("adjustRepaymentDate");
+ final LocalDate rescheduledRepaymentDate = command.localDateValueOfParameterNamed("adjustRepaymentDate");
entityDatatableChecksWritePlatformService.runTheCheckForProduct(loanId, EntityTables.LOAN.getName(),
StatusEnum.DISBURSE.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId());
LocalDate recalculateFrom = null;
if (!loan.isMultiDisburmentLoan()) {
- loan.setActualDisbursementDate(Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ loan.setActualDisbursementDate(actualDisbursementDate);
}
ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom);
@@ -669,7 +667,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
}
final LocalDate nextPossibleRepaymentDate = null;
- final Date rescheduledRepaymentDate = null;
+ final LocalDate rescheduledRepaymentDate = null;
for (final SingleDisbursalCommand singleLoanDisbursalCommand : disbursalCommand) {
final Loan loan = this.loanAssembler.assembleFrom(singleLoanDisbursalCommand.getLoanId());
@@ -970,7 +968,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
if (singleLoanRepaymentCommand != null) {
Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(singleLoanRepaymentCommand.getLoanId());
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
- Date.from(singleLoanRepaymentCommand.getTransactionDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ singleLoanRepaymentCommand.getTransactionDate());
final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled();
boolean isHolidayEnabled = false;
@@ -2360,8 +2358,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
}
}
- holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
- Date.from(loan.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
+ holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), loan.getDisbursementDate());
if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
ScheduleGeneratorDTO scheduleGeneratorDTO = loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom);
loan.setHelpers(null, this.loanSummaryWrapper, this.transactionProcessingStrategy);
@@ -2414,15 +2411,14 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
private void updateLoanCounters(final Loan loan, final LocalDate actualDisbursementDate) {
if (loan.isGroupLoan()) {
- final List<Loan> loansToUpdateForLoanCounter = this.loanRepositoryWrapper.getGroupLoansDisbursedAfter(
- Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), loan.getGroupId(),
- AccountType.GROUP.getValue());
+ final List<Loan> loansToUpdateForLoanCounter = this.loanRepositoryWrapper.getGroupLoansDisbursedAfter(actualDisbursementDate,
+ loan.getGroupId(), AccountType.GROUP.getValue());
final Integer newLoanCounter = getNewGroupLoanCounter(loan);
final Integer newLoanProductCounter = getNewGroupLoanProductCounter(loan);
updateLoanCounter(loan, loansToUpdateForLoanCounter, newLoanCounter, newLoanProductCounter);
} else {
- final List<Loan> loansToUpdateForLoanCounter = this.loanRepositoryWrapper.getClientOrJLGLoansDisbursedAfter(
- Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), loan.getClientId());
+ final List<Loan> loansToUpdateForLoanCounter = this.loanRepositoryWrapper
+ .getClientOrJLGLoansDisbursedAfter(actualDisbursementDate, loan.getClientId());
final Integer newLoanCounter = getNewClientOrJLGLoanCounter(loan);
final Integer newLoanProductCounter = getNewClientOrJLGLoanProductCounter(loan);
updateLoanCounter(loan, loansToUpdateForLoanCounter, newLoanCounter, newLoanProductCounter);
@@ -3087,8 +3083,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
private void regenerateScheduleOnDisbursement(final JsonCommand command, final Loan loan, final boolean recalculateSchedule,
final ScheduleGeneratorDTO scheduleGeneratorDTO, final LocalDate nextPossibleRepaymentDate,
- final Date rescheduledRepaymentDate) {
- AppUser currentUser = getAppUserIfPresent();
+ final LocalDate rescheduledRepaymentDate) {
final LocalDate actualDisbursementDate = command.localDateValueOfParameterNamed("actualDisbursementDate");
BigDecimal emiAmount = command.bigDecimalValueOfParameterNamed(LoanApiConstants.emiAmountParameterName);
loan.regenerateScheduleOnDisbursement(scheduleGeneratorDTO, recalculateSchedule, actualDisbursementDate, emiAmount,