Date to LocalDate - part 1

This commit is contained in:
Adam Saghy
2022-07-11 11:22:47 +02:00
committed by Arnold Gálovics
parent adaac89583
commit ef96d5cc50
47 changed files with 495 additions and 828 deletions
@@ -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;
}
@@ -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();
@@ -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();
@@ -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;
}
@@ -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);
}
}
@@ -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) {
@@ -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;
}
@@ -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());
}
}
@@ -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();
@@ -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());
}
}
@@ -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() {
@@ -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")
@@ -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);
}
}
@@ -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;
@@ -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;
}
@@ -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();
}
@@ -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());
@@ -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;
}
@@ -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() {
@@ -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",
@@ -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() {
@@ -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();
@@ -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;
}
@@ -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;
}
@@ -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() {
@@ -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) {
@@ -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 ****/
@@ -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());
}
}
@@ -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,
@@ -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);
}
@@ -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;
}
@@ -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() {
@@ -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;
@@ -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) {
@@ -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,
@@ -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);
@@ -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,
@@ -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();
}
}
@@ -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());
}
@@ -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()));
}
}
}
@@ -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);
}
@@ -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();
@@ -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);
@@ -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());
}
}
@@ -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()
@@ -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,