Tenant & Server - Different Timezone fix T-1 (FINERACT-1394) (#1857)

This commit is contained in:
Manoj
2021-09-07 19:10:11 +05:30
committed by GitHub
parent 37b0715206
commit b8c6efa25b
87 changed files with 430 additions and 400 deletions
@@ -19,11 +19,11 @@
package org.apache.fineract.accounting.journalentry.api; package org.apache.fineract.accounting.journalentry.api;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
import javax.ws.rs.WebApplicationException; import javax.ws.rs.WebApplicationException;
import org.apache.fineract.infrastructure.core.serialization.JsonParserHelper; import org.apache.fineract.infrastructure.core.serialization.JsonParserHelper;
import org.apache.fineract.infrastructure.core.service.DateUtils;
/** /**
* Class for parsing dates sent as query parameters * Class for parsing dates sent as query parameters
@@ -41,6 +41,6 @@ public class DateParam {
public Date getDate(final String parameterName, final String dateFormat, final String localeAsString) { public Date getDate(final String parameterName, final String dateFormat, final String localeAsString) {
final Locale locale = JsonParserHelper.localeFromString(localeAsString); final Locale locale = JsonParserHelper.localeFromString(localeAsString);
final LocalDate localDate = JsonParserHelper.convertFrom(this.dateAsString, parameterName, dateFormat, locale); final LocalDate localDate = JsonParserHelper.convertFrom(this.dateAsString, parameterName, dateFormat, locale);
return Date.from(localDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -20,6 +20,7 @@ package org.apache.fineract.accounting.journalentry.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -58,7 +59,6 @@ import org.apache.fineract.accounting.producttoaccountmapping.domain.ProductToGL
import org.apache.fineract.accounting.producttoaccountmapping.exception.ProductToGLAccountMappingNotFoundException; import org.apache.fineract.accounting.producttoaccountmapping.exception.ProductToGLAccountMappingNotFoundException;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException; import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.data.CurrencyData; import org.apache.fineract.organisation.monetary.data.CurrencyData;
import org.apache.fineract.organisation.office.domain.Office; import org.apache.fineract.organisation.office.domain.Office;
import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper; import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper;
@@ -132,8 +132,7 @@ public class AccountingProcessorHelper {
for (final Map<String, Object> map : newTransactionsMap) { for (final Map<String, Object> map : newTransactionsMap) {
final Long transactionOfficeId = (Long) map.get("officeId"); final Long transactionOfficeId = (Long) map.get("officeId");
final String transactionId = ((Long) map.get("id")).toString(); final String transactionId = ((Long) map.get("id")).toString();
final Date transactionDate = Date final Date transactionDate = Date.from(((LocalDate) map.get("date")).atStartOfDay(ZoneId.systemDefault()).toInstant());
.from(((LocalDate) map.get("date")).atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
final LoanTransactionEnumData transactionType = (LoanTransactionEnumData) map.get("type"); final LoanTransactionEnumData transactionType = (LoanTransactionEnumData) map.get("type");
final BigDecimal amount = (BigDecimal) map.get("amount"); final BigDecimal amount = (BigDecimal) map.get("amount");
final BigDecimal principal = (BigDecimal) map.get("principalPortion"); final BigDecimal principal = (BigDecimal) map.get("principalPortion");
@@ -200,8 +199,7 @@ public class AccountingProcessorHelper {
for (final Map<String, Object> map : newTransactionsMap) { for (final Map<String, Object> map : newTransactionsMap) {
final Long transactionOfficeId = (Long) map.get("officeId"); final Long transactionOfficeId = (Long) map.get("officeId");
final String transactionId = ((Long) map.get("id")).toString(); final String transactionId = ((Long) map.get("id")).toString();
final Date transactionDate = Date final Date transactionDate = Date.from(((LocalDate) map.get("date")).atStartOfDay(ZoneId.systemDefault()).toInstant());
.from(((LocalDate) map.get("date")).atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
final SavingsAccountTransactionEnumData transactionType = (SavingsAccountTransactionEnumData) map.get("type"); final SavingsAccountTransactionEnumData transactionType = (SavingsAccountTransactionEnumData) map.get("type");
final BigDecimal amount = (BigDecimal) map.get("amount"); final BigDecimal amount = (BigDecimal) map.get("amount");
final boolean reversed = (Boolean) map.get("reversed"); final boolean reversed = (Boolean) map.get("reversed");
@@ -270,8 +268,7 @@ public class AccountingProcessorHelper {
for (final Map<String, Object> map : newTransactionsMap) { for (final Map<String, Object> map : newTransactionsMap) {
final Long transactionOfficeId = (Long) map.get("officeId"); final Long transactionOfficeId = (Long) map.get("officeId");
final String transactionId = ((Long) map.get("id")).toString(); final String transactionId = ((Long) map.get("id")).toString();
final Date transactionDate = Date final Date transactionDate = Date.from(((LocalDate) map.get("date")).atStartOfDay(ZoneId.systemDefault()).toInstant());
.from(((LocalDate) map.get("date")).atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
final ShareAccountTransactionEnumData transactionType = (ShareAccountTransactionEnumData) map.get("type"); final ShareAccountTransactionEnumData transactionType = (ShareAccountTransactionEnumData) map.get("type");
final ShareAccountTransactionEnumData transactionStatus = (ShareAccountTransactionEnumData) map.get("status"); final ShareAccountTransactionEnumData transactionStatus = (ShareAccountTransactionEnumData) map.get("status");
final BigDecimal amount = (BigDecimal) map.get("amount"); final BigDecimal amount = (BigDecimal) map.get("amount");
@@ -308,7 +305,7 @@ public class AccountingProcessorHelper {
final Long clientId = (Long) accountingBridgeData.get("clientId"); final Long clientId = (Long) accountingBridgeData.get("clientId");
final Long transactionId = (Long) accountingBridgeData.get("id"); final Long transactionId = (Long) accountingBridgeData.get("id");
final Date transactionDate = Date final Date transactionDate = Date
.from(((LocalDate) accountingBridgeData.get("date")).atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); .from(((LocalDate) accountingBridgeData.get("date")).atStartOfDay(ZoneId.systemDefault()).toInstant());
final EnumOptionData transactionType = (EnumOptionData) accountingBridgeData.get("type"); final EnumOptionData transactionType = (EnumOptionData) accountingBridgeData.get("type");
final BigDecimal amount = (BigDecimal) accountingBridgeData.get("amount"); final BigDecimal amount = (BigDecimal) accountingBridgeData.get("amount");
final boolean reversed = (Boolean) accountingBridgeData.get("reversed"); final boolean reversed = (Boolean) accountingBridgeData.get("reversed");
@@ -20,6 +20,7 @@ package org.apache.fineract.accounting.journalentry.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
@@ -69,7 +70,6 @@ import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException; import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException; import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.organisation.office.domain.Office; import org.apache.fineract.organisation.office.domain.Office;
import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper; import org.apache.fineract.organisation.office.domain.OfficeRepositoryWrapper;
@@ -593,7 +593,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
private void validateBusinessRulesForJournalEntries(final JournalEntryCommand command) { private void validateBusinessRulesForJournalEntries(final JournalEntryCommand command) {
/** check if date of Journal entry is valid ***/ /** check if date of Journal entry is valid ***/
final LocalDate entryLocalDate = command.getTransactionDate(); final LocalDate entryLocalDate = command.getTransactionDate();
final Date transactionDate = Date.from(entryLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); final Date transactionDate = Date.from(entryLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
// shouldn't be in the future // shouldn't be in the future
final Date todaysDate = new Date(); final Date todaysDate = new Date();
if (transactionDate.after(todaysDate)) { if (transactionDate.after(todaysDate)) {
@@ -20,6 +20,7 @@ package org.apache.fineract.accounting.provisioning.service;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@@ -150,13 +151,13 @@ public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements
private Date parseDate(JsonCommand command) { private Date parseDate(JsonCommand command) {
LocalDate localDate = this.fromApiJsonHelper.extractLocalDateNamed("date", command.parsedJson()); LocalDate localDate = this.fromApiJsonHelper.extractLocalDateNamed("date", command.parsedJson());
return Date.from(localDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
@Override @Override
@CronTarget(jobName = JobName.GENERATE_LOANLOSS_PROVISIONING) @CronTarget(jobName = JobName.GENERATE_LOANLOSS_PROVISIONING)
public void generateLoanLossProvisioningAmount() { public void generateLoanLossProvisioningAmount() {
Date currentDate = Date.from(DateUtils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); Date currentDate = Date.from(DateUtils.getLocalDateOfTenant().atStartOfDay(ZoneId.systemDefault()).toInstant());
boolean addJournalEntries = true; boolean addJournalEntries = true;
try { try {
Collection<ProvisioningCriteriaData> criteriaCollection = this.provisioningCriteriaReadPlatformService Collection<ProvisioningCriteriaData> criteriaCollection = this.provisioningCriteriaReadPlatformService
@@ -20,6 +20,7 @@ package org.apache.fineract.infrastructure.campaigns.email.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
@@ -152,7 +153,7 @@ public class EmailCampaign extends AbstractPersistableCustom {
this.emailAttachmentFileFormat = emailAttachmentFileFormat.getValue(); this.emailAttachmentFileFormat = emailAttachmentFileFormat.getValue();
this.stretchyReport = stretchyReport; this.stretchyReport = stretchyReport;
this.stretchyReportParamMap = stretchyReportParamMap; this.stretchyReportParamMap = stretchyReportParamMap;
this.submittedOnDate = Date.from(submittedOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.submittedOnDate = Date.from(submittedOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.submittedBy = submittedBy; this.submittedBy = submittedBy;
this.recurrence = recurrence; this.recurrence = recurrence;
LocalDateTime recurrenceStartDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()); LocalDateTime recurrenceStartDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
@@ -274,7 +275,7 @@ public class EmailCampaign extends AbstractPersistableCustom {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
this.approvedOnDate = Date.from(activationLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.approvedOnDate = Date.from(activationLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.approvedBy = currentUser; this.approvedBy = currentUser;
this.status = EmailCampaignStatus.ACTIVE.getValue(); this.status = EmailCampaignStatus.ACTIVE.getValue();
@@ -298,7 +299,7 @@ public class EmailCampaign extends AbstractPersistableCustom {
this.lastTriggerDate = null; this.lastTriggerDate = null;
} }
this.closedBy = currentUser; this.closedBy = currentUser;
this.closureDate = Date.from(closureLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closureDate = Date.from(closureLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.status = EmailCampaignStatus.CLOSED.getValue(); this.status = EmailCampaignStatus.CLOSED.getValue();
validateClosureDate(); validateClosureDate();
} }
@@ -317,7 +318,7 @@ public class EmailCampaign extends AbstractPersistableCustom {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
this.approvedOnDate = Date.from(reactivateLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.approvedOnDate = Date.from(reactivateLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.status = EmailCampaignStatus.ACTIVE.getValue(); this.status = EmailCampaignStatus.ACTIVE.getValue();
this.approvedBy = currentUser; this.approvedBy = currentUser;
this.closureDate = null; this.closureDate = null;
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.campaigns.email.domain; package org.apache.fineract.infrastructure.campaigns.email.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
@@ -109,7 +110,7 @@ public class EmailMessage extends AbstractPersistableCustom {
this.message = message; this.message = message;
this.campaignName = campaignName; this.campaignName = campaignName;
this.submittedOnDate = Date this.submittedOnDate = Date
.from(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); .from(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public Map<String, Object> update(final JsonCommand command) { public Map<String, Object> update(final JsonCommand command) {
@@ -20,6 +20,7 @@ package org.apache.fineract.infrastructure.campaigns.sms.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
@@ -139,7 +140,7 @@ public class SmsCampaign extends AbstractPersistableCustom {
this.paramValue = paramValue; this.paramValue = paramValue;
this.status = SmsCampaignStatus.PENDING.getValue(); this.status = SmsCampaignStatus.PENDING.getValue();
this.message = message; this.message = message;
this.submittedOnDate = Date.from(submittedOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.submittedOnDate = Date.from(submittedOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.submittedBy = submittedBy; this.submittedBy = submittedBy;
this.recurrence = recurrence; this.recurrence = recurrence;
LocalDateTime recurrenceStartDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()); LocalDateTime recurrenceStartDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
@@ -280,7 +281,7 @@ public class SmsCampaign extends AbstractPersistableCustom {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
this.approvedOnDate = Date.from(activationLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.approvedOnDate = Date.from(activationLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.approvedBy = currentUser; this.approvedBy = currentUser;
this.status = SmsCampaignStatus.ACTIVE.getValue(); this.status = SmsCampaignStatus.ACTIVE.getValue();
@@ -304,7 +305,7 @@ public class SmsCampaign extends AbstractPersistableCustom {
this.lastTriggerDate = null; this.lastTriggerDate = null;
} }
this.closedBy = currentUser; this.closedBy = currentUser;
this.closureDate = Date.from(closureLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closureDate = Date.from(closureLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.status = SmsCampaignStatus.CLOSED.getValue(); this.status = SmsCampaignStatus.CLOSED.getValue();
validateClosureDate(); validateClosureDate();
} }
@@ -323,7 +324,7 @@ public class SmsCampaign extends AbstractPersistableCustom {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
this.approvedOnDate = Date.from(reactivateLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.approvedOnDate = Date.from(reactivateLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.status = SmsCampaignStatus.ACTIVE.getValue(); this.status = SmsCampaignStatus.ACTIVE.getValue();
this.approvedBy = currentUser; this.approvedBy = currentUser;
this.closureDate = null; this.closureDate = null;
@@ -26,6 +26,7 @@ import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.MonthDay; import java.time.MonthDay;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
@@ -417,7 +418,7 @@ public final class JsonCommand {
if (localDate == null) { if (localDate == null) {
return null; return null;
} }
return Date.from(localDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public boolean isChangeInStringParameterNamed(final String parameterName, final String existingValue) { public boolean isChangeInStringParameterNamed(final String parameterName, final String existingValue) {
@@ -21,10 +21,10 @@ package org.apache.fineract.infrastructure.gcm.service;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.core.service.RoutingDataSource; import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
import org.apache.fineract.infrastructure.gcm.domain.DeviceRegistrationData; import org.apache.fineract.infrastructure.gcm.domain.DeviceRegistrationData;
import org.apache.fineract.infrastructure.gcm.exception.DeviceRegistrationNotFoundException; import org.apache.fineract.infrastructure.gcm.exception.DeviceRegistrationNotFoundException;
@@ -75,7 +75,7 @@ public class DeviceRegistrationReadPlatformServiceImpl implements DeviceRegistra
final String clientName = rs.getString("clientName"); final String clientName = rs.getString("clientName");
ClientData clientData = ClientData.instance(clientId, clientName); ClientData clientData = ClientData.instance(clientId, clientName);
return DeviceRegistrationData.instance(id, clientData, registrationId, return DeviceRegistrationData.instance(id, clientData, registrationId,
Date.from(updatedOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(updatedOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
} }
} }
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.gcm.service; package org.apache.fineract.infrastructure.gcm.service;
import java.io.IOException; import java.io.IOException;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
@@ -109,7 +110,7 @@ public class NotificationSenderService {
if (res.getSuccess() != null && res.getSuccess() > 0) { if (res.getSuccess() != null && res.getSuccess() > 0) {
smsMessage.setStatusType(SmsMessageStatusType.SENT.getValue()); smsMessage.setStatusType(SmsMessageStatusType.SENT.getValue());
smsMessage.setDeliveredOnDate( smsMessage.setDeliveredOnDate(
Date.from(DateUtils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(DateUtils.getLocalDateOfTenant().atStartOfDay(ZoneId.systemDefault()).toInstant()));
} else if (res.getFailure() != null && res.getFailure() > 0) { } else if (res.getFailure() != null && res.getFailure() > 0) {
smsMessage.setStatusType(SmsMessageStatusType.FAILED.getValue()); smsMessage.setStatusType(SmsMessageStatusType.FAILED.getValue());
} }
@@ -19,6 +19,7 @@
package org.apache.fineract.infrastructure.sms.domain; package org.apache.fineract.infrastructure.sms.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
@@ -122,7 +123,7 @@ public class SmsMessage extends AbstractPersistableCustom {
this.message = message; this.message = message;
this.smsCampaign = smsCampaign; this.smsCampaign = smsCampaign;
this.submittedOnDate = Date this.submittedOnDate = Date
.from(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); .from(LocalDate.now(DateUtils.getDateTimeZoneOfTenant()).atStartOfDay(ZoneId.systemDefault()).toInstant());
this.isNotification = isNotification; this.isNotification = isNotification;
} }
@@ -225,8 +225,7 @@ public class InteropServiceImpl implements InteropService {
return true; return true;
} }
java.time.LocalDateTime transactionDate = t.getTransactionLocalDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()) java.time.LocalDateTime transactionDate = t.getTransactionLocalDate().atStartOfDay(ZoneId.systemDefault()).toLocalDateTime();
.toLocalDateTime();
return (transactionsTo == null || transactionsTo.compareTo(transactionDate) > 0) && (transactionsFrom == null return (transactionsTo == null || transactionsTo.compareTo(transactionDate) > 0) && (transactionsFrom == null
|| transactionsFrom.compareTo(transactionDate.withHour(23).withMinute(59).withSecond(59)) <= 0); || transactionsFrom.compareTo(transactionDate.withHour(23).withMinute(59).withSecond(59)) <= 0);
}; };
@@ -29,6 +29,7 @@ import static org.apache.fineract.portfolio.savings.SavingsApiConstants.localePa
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
@@ -150,7 +151,7 @@ public class Holiday extends AbstractPersistableCustom {
actualChanges.put(dateFormatParamName, dateFormatAsInput); actualChanges.put(dateFormatParamName, dateFormatAsInput);
actualChanges.put(localeParamName, localeAsInput); actualChanges.put(localeParamName, localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(fromDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(fromDateParamName);
this.fromDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.fromDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (command.isChangeInLocalDateParameterNamed(toDateParamName, getToDateLocalDate())) { if (command.isChangeInLocalDateParameterNamed(toDateParamName, getToDateLocalDate())) {
@@ -160,7 +161,7 @@ public class Holiday extends AbstractPersistableCustom {
actualChanges.put(localeParamName, localeAsInput); actualChanges.put(localeParamName, localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(toDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(toDateParamName);
this.toDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.toDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (command.isChangeInLocalDateParameterNamed(repaymentsRescheduledToParamName, getRepaymentsRescheduledToLocalDate())) { if (command.isChangeInLocalDateParameterNamed(repaymentsRescheduledToParamName, getRepaymentsRescheduledToLocalDate())) {
@@ -170,7 +171,7 @@ public class Holiday extends AbstractPersistableCustom {
actualChanges.put(localeParamName, localeAsInput); actualChanges.put(localeParamName, localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(repaymentsRescheduledToParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(repaymentsRescheduledToParamName);
this.repaymentsRescheduledTo = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.repaymentsRescheduledTo = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (command.hasParameter(officesParamName)) { if (command.hasParameter(officesParamName)) {
@@ -233,15 +234,15 @@ public class Holiday extends AbstractPersistableCustom {
} }
if (fromDate != null) { if (fromDate != null) {
this.fromDate = Date.from(fromDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.fromDate = Date.from(fromDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (toDate != null) { if (toDate != null) {
this.toDate = Date.from(toDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.toDate = Date.from(toDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (repaymentsRescheduledTo != null) { if (repaymentsRescheduledTo != null) {
this.repaymentsRescheduledTo = Date.from(repaymentsRescheduledTo.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.repaymentsRescheduledTo = Date.from(repaymentsRescheduledTo.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
this.status = status; this.status = status;
@@ -19,9 +19,9 @@
package org.apache.fineract.organisation.holiday.domain; package org.apache.fineract.organisation.holiday.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.holiday.exception.HolidayNotFoundException; import org.apache.fineract.organisation.holiday.exception.HolidayNotFoundException;
import org.apache.fineract.organisation.holiday.service.HolidayUtil; import org.apache.fineract.organisation.holiday.service.HolidayUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -72,7 +72,7 @@ public class HolidayRepositoryWrapper {
public boolean isHoliday(Long officeId, LocalDate transactionDate) { public boolean isHoliday(Long officeId, LocalDate transactionDate) {
final List<Holiday> holidays = findByOfficeIdAndGreaterThanDate(officeId, final List<Holiday> holidays = findByOfficeIdAndGreaterThanDate(officeId,
Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
return HolidayUtil.isHoliday(transactionDate, holidays); return HolidayUtil.isHoliday(transactionDate, holidays);
} }
} }
@@ -20,6 +20,7 @@ package org.apache.fineract.organisation.office.domain;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -89,7 +90,7 @@ public class Office extends AbstractPersistableCustom implements Serializable {
private Office(final Office parent, final String name, final LocalDate openingDate, final String externalId) { private Office(final Office parent, final String name, final LocalDate openingDate, final String externalId) {
this.parent = parent; this.parent = parent;
this.openingDate = Date.from(openingDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.openingDate = Date.from(openingDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
if (parent != null) { if (parent != null) {
this.parent.addChild(this); this.parent.addChild(this);
} }
@@ -136,7 +137,7 @@ public class Office extends AbstractPersistableCustom implements Serializable {
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(openingDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(openingDateParamName);
this.openingDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.openingDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final String nameParamName = "name"; final String nameParamName = "name";
@@ -20,6 +20,7 @@ package org.apache.fineract.organisation.office.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embedded; import javax.persistence.Embedded;
@@ -32,7 +33,6 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; 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.MonetaryCurrency;
import org.apache.fineract.organisation.monetary.domain.Money; import org.apache.fineract.organisation.monetary.domain.Money;
@@ -79,7 +79,7 @@ public class OfficeTransaction extends AbstractPersistableCustom {
this.from = fromOffice; this.from = fromOffice;
this.to = toOffice; this.to = toOffice;
if (transactionLocalDate != null) { if (transactionLocalDate != null) {
this.transactionDate = Date.from(transactionLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.transactionDate = Date.from(transactionLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
this.currency = amount.getCurrency(); this.currency = amount.getCurrency();
this.transactionAmount = amount.getAmount(); this.transactionAmount = amount.getAmount();
@@ -19,6 +19,7 @@
package org.apache.fineract.organisation.staff.domain; package org.apache.fineract.organisation.staff.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
@@ -35,7 +36,6 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.documentmanagement.domain.Image; import org.apache.fineract.infrastructure.documentmanagement.domain.Image;
import org.apache.fineract.organisation.office.domain.Office; import org.apache.fineract.organisation.office.domain.Office;
@@ -133,7 +133,7 @@ public class Staff extends AbstractPersistableCustom {
this.active = isActive == null ? true : isActive; this.active = isActive == null ? true : isActive;
deriveDisplayName(firstname); deriveDisplayName(firstname);
if (joiningDate != null) { if (joiningDate != null) {
this.joiningDate = Date.from(joiningDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.joiningDate = Date.from(joiningDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -214,7 +214,7 @@ public class Staff extends AbstractPersistableCustom {
final String valueAsInput = command.stringValueOfParameterNamed(joiningDateParamName); final String valueAsInput = command.stringValueOfParameterNamed(joiningDateParamName);
actualChanges.put(joiningDateParamName, valueAsInput); actualChanges.put(joiningDateParamName, valueAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(joiningDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(joiningDateParamName);
this.joiningDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.joiningDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
return actualChanges; return actualChanges;
@@ -20,6 +20,7 @@ package org.apache.fineract.organisation.teller.domain;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@@ -114,8 +115,8 @@ public class Cashier extends AbstractPersistableCustom {
this.teller = teller; this.teller = teller;
this.staff = staff; this.staff = staff;
this.description = description; this.description = description;
this.startDate = Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.endDate = Date.from(endDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.isFullDay = isFullDay; this.isFullDay = isFullDay;
this.startTime = startTime; this.startTime = startTime;
this.endTime = endTime; this.endTime = endTime;
@@ -143,7 +144,7 @@ public class Cashier extends AbstractPersistableCustom {
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(startDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(startDateParamName);
this.startDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final String endDateParamName = "endDate"; final String endDateParamName = "endDate";
@@ -154,7 +155,7 @@ public class Cashier extends AbstractPersistableCustom {
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(endDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(endDateParamName);
this.endDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final Boolean isFullDay = command.booleanObjectValueOfParameterNamed("isFullDay"); final Boolean isFullDay = command.booleanObjectValueOfParameterNamed("isFullDay");
@@ -20,6 +20,7 @@ package org.apache.fineract.organisation.teller.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
@@ -103,7 +104,7 @@ public class CashierTransaction extends AbstractPersistableCustom {
this.cashier = cashier; this.cashier = cashier;
this.txnType = txnType; this.txnType = txnType;
if (txnDate != null) { if (txnDate != null) {
this.txnDate = Date.from(txnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.txnDate = Date.from(txnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
this.txnAmount = txnAmount; this.txnAmount = txnAmount;
this.entityType = entityType; this.entityType = entityType;
@@ -135,7 +136,7 @@ public class CashierTransaction extends AbstractPersistableCustom {
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(txnDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(txnDateParamName);
this.txnDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.txnDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final String txnAmountParamName = "txnAmount"; final String txnAmountParamName = "txnAmount";
@@ -19,6 +19,7 @@
package org.apache.fineract.organisation.teller.domain; package org.apache.fineract.organisation.teller.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
@@ -86,10 +87,10 @@ public class Teller extends AbstractPersistableCustom {
this.name = StringUtils.defaultIfEmpty(name, null); this.name = StringUtils.defaultIfEmpty(name, null);
this.description = StringUtils.defaultIfEmpty(description, null); this.description = StringUtils.defaultIfEmpty(description, null);
if (startDate != null) { if (startDate != null) {
this.startDate = Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (endDate != null) { if (endDate != null) {
this.endDate = Date.from(endDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (status != null) { if (status != null) {
this.status = status.getValue(); this.status = status.getValue();
@@ -152,7 +153,7 @@ public class Teller extends AbstractPersistableCustom {
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(startDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(startDateParamName);
this.startDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final String endDateParamName = "endDate"; final String endDateParamName = "endDate";
@@ -163,7 +164,7 @@ public class Teller extends AbstractPersistableCustom {
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(endDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(endDateParamName);
this.endDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final String statusParamName = "status"; final String statusParamName = "status";
@@ -22,13 +22,13 @@ import java.math.BigDecimal;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.Iterator; import java.util.Iterator;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException; import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.core.service.Page; import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.core.service.PaginationHelper; import org.apache.fineract.infrastructure.core.service.PaginationHelper;
import org.apache.fineract.infrastructure.core.service.RoutingDataSource; import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
@@ -599,8 +599,8 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
final String endTime = rs.getString("end_time"); final String endTime = rs.getString("end_time");
return CashierData.instance(id, null, null, staffId, staffName, tellerId, tellerName, description, return CashierData.instance(id, null, null, staffId, staffName, tellerId, tellerName, description,
Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant()),
Date.from(endDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), fullDay, startTime, endTime); Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), fullDay, startTime, endTime);
} }
} }
@@ -750,11 +750,11 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
Date txnDate = null; Date txnDate = null;
if (txnLocalDate != null) { if (txnLocalDate != null) {
txnDate = Date.from(txnLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); txnDate = Date.from(txnLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
Date createdDate = null; Date createdDate = null;
if (createdLocalDate != null) { if (createdLocalDate != null) {
createdDate = Date.from(createdLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); createdDate = Date.from(createdLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final Long officeId = rs.getLong("office_id"); final Long officeId = rs.getLong("office_id");
@@ -34,6 +34,7 @@ import static org.apache.fineract.portfolio.account.api.StandingInstructionApiCo
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.MonthDay; import java.time.MonthDay;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@@ -135,12 +136,12 @@ public class AccountTransferStandingInstruction extends AbstractPersistableCusto
this.status = status; this.status = status;
this.amount = amount; this.amount = amount;
if (validFrom != null) { if (validFrom != null) {
this.validFrom = Date.from(validFrom.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.validFrom = Date.from(validFrom.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (validTill == null) { if (validTill == null) {
this.validTill = null; this.validTill = null;
} else { } else {
this.validTill = Date.from(validTill.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.validTill = Date.from(validTill.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
this.recurrenceType = recurrenceType; this.recurrenceType = recurrenceType;
this.recurrenceFrequency = recurrenceFrequency; this.recurrenceFrequency = recurrenceFrequency;
@@ -171,13 +172,13 @@ public class AccountTransferStandingInstruction extends AbstractPersistableCusto
if (command.isChangeInDateParameterNamed(validFromParamName, this.validFrom)) { if (command.isChangeInDateParameterNamed(validFromParamName, this.validFrom)) {
final LocalDate newValue = command.localDateValueOfParameterNamed(validFromParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(validFromParamName);
actualChanges.put(validFromParamName, newValue); actualChanges.put(validFromParamName, newValue);
this.validFrom = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.validFrom = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (command.isChangeInDateParameterNamed(validTillParamName, this.validTill)) { if (command.isChangeInDateParameterNamed(validTillParamName, this.validTill)) {
final LocalDate newValue = command.localDateValueOfParameterNamed(validTillParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(validTillParamName);
actualChanges.put(validTillParamName, newValue); actualChanges.put(validTillParamName, newValue);
this.validTill = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.validTill = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (command.isChangeInBigDecimalParameterNamed(amountParamName, this.amount)) { if (command.isChangeInBigDecimalParameterNamed(amountParamName, this.amount)) {
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.account.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embedded; import javax.persistence.Embedded;
@@ -30,7 +31,6 @@ import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; 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.MonetaryCurrency;
import org.apache.fineract.organisation.monetary.domain.Money; import org.apache.fineract.organisation.monetary.domain.Money;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction; import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
@@ -111,7 +111,7 @@ public class AccountTransferTransaction extends AbstractPersistableCustom {
this.fromSavingsTransaction = withdrawal; this.fromSavingsTransaction = withdrawal;
this.toSavingsTransaction = deposit; this.toSavingsTransaction = deposit;
this.toLoanTransaction = loanRepaymentTransaction; this.toLoanTransaction = loanRepaymentTransaction;
this.date = Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.date = Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.currency = transactionAmount.getCurrency(); this.currency = transactionAmount.getCurrency();
this.amount = transactionAmount.getAmountDefaultedToNullIfZero(); this.amount = transactionAmount.getAmountDefaultedToNullIfZero();
this.description = description; this.description = description;
@@ -25,6 +25,7 @@ import static org.apache.fineract.portfolio.account.api.StandingInstructionApiCo
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
@@ -245,8 +246,8 @@ public class StandingInstructionWritePlatformServiceImpl implements StandingInst
if (transferCompleted) { if (transferCompleted) {
final String updateQuery = "UPDATE m_account_transfer_standing_instructions SET last_run_date = ? where id = ?"; final String updateQuery = "UPDATE m_account_transfer_standing_instructions SET last_run_date = ? where id = ?";
this.jdbcTemplate.update(updateQuery, this.jdbcTemplate.update(updateQuery, Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()),
Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), data.getId()); data.getId());
} }
} }
@@ -21,6 +21,7 @@ package org.apache.fineract.portfolio.address.domain;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
@@ -35,7 +36,6 @@ import javax.persistence.Table;
import org.apache.fineract.infrastructure.codes.domain.CodeValue; import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.client.domain.ClientAddress; import org.apache.fineract.portfolio.client.domain.ClientAddress;
@Entity @Entity
@@ -122,12 +122,12 @@ public class Address extends AbstractPersistableCustom {
// this.updatedOn = updatedOn; // this.updatedOn = updatedOn;
if (createdOn != null) { if (createdOn != null) {
this.createdOn = Date.from(createdOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.createdOn = Date.from(createdOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (updatedOn != null) { if (updatedOn != null) {
this.updatedOn = Date.from(updatedOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.updatedOn = Date.from(updatedOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -363,7 +363,7 @@ public class Address extends AbstractPersistableCustom {
} }
public void setCreatedOn(LocalDate createdOn) { public void setCreatedOn(LocalDate createdOn) {
this.createdOn = Date.from(createdOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.createdOn = Date.from(createdOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public String getUpdatedBy() { public String getUpdatedBy() {
@@ -379,7 +379,7 @@ public class Address extends AbstractPersistableCustom {
} }
public void setUpdatedOn(LocalDate updatedOn) { public void setUpdatedOn(LocalDate updatedOn) {
this.updatedOn = Date.from(updatedOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.updatedOn = Date.from(updatedOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -22,6 +22,7 @@ import static org.apache.fineract.portfolio.calendar.CalendarConstants.CALENDAR_
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoField; import java.time.temporal.ChronoField;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@@ -126,13 +127,13 @@ public class Calendar extends AbstractAuditableCustom {
this.location = StringUtils.defaultIfEmpty(location, null); this.location = StringUtils.defaultIfEmpty(location, null);
if (null != startDate) { if (null != startDate) {
this.startDate = Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} else { } else {
this.startDate = null; this.startDate = null;
} }
if (null != endDate) { if (null != endDate) {
this.endDate = Date.from(endDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} else { } else {
this.endDate = null; this.endDate = null;
} }
@@ -216,7 +217,7 @@ public class Calendar extends AbstractAuditableCustom {
} else { } else {
actualChanges.put(CalendarSupportedParameters.START_DATE.getValue(), newMeetingStartDate.toString()); actualChanges.put(CalendarSupportedParameters.START_DATE.getValue(), newMeetingStartDate.toString());
this.startDate = Date.from(newMeetingStartDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(newMeetingStartDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
/* /*
* If meeting start date is changed then there is possibilities of recurring day may change, so derive the * If meeting start date is changed then there is possibilities of recurring day may change, so derive the
@@ -292,7 +293,7 @@ public class Calendar extends AbstractAuditableCustom {
actualChanges.put(startDateParamName, valueAsInput); actualChanges.put(startDateParamName, valueAsInput);
actualChanges.put("dateFormat", dateFormatAsInput); actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
this.startDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -304,7 +305,7 @@ public class Calendar extends AbstractAuditableCustom {
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(endDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(endDateParamName);
this.endDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final String durationParamName = CalendarSupportedParameters.DURATION.getValue(); final String durationParamName = CalendarSupportedParameters.DURATION.getValue();
@@ -425,7 +426,7 @@ public class Calendar extends AbstractAuditableCustom {
if (calendarStartDate != null && this.startDate != null) { if (calendarStartDate != null && this.startDate != null) {
if (!calendarStartDate.equals(this.getStartDateLocalDate())) { if (!calendarStartDate.equals(this.getStartDateLocalDate())) {
actualChanges.put("startDate", calendarStartDate); actualChanges.put("startDate", calendarStartDate);
this.startDate = Date.from(calendarStartDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(calendarStartDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -663,8 +664,8 @@ public class Calendar extends AbstractAuditableCustom {
final String newRecurrence = Calendar.constructRecurrence(frequencyType, interval, startDate.get(ChronoField.DAY_OF_WEEK), null); final String newRecurrence = Calendar.constructRecurrence(frequencyType, interval, startDate.get(ChronoField.DAY_OF_WEEK), null);
this.recurrence = newRecurrence; this.recurrence = newRecurrence;
this.startDate = Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.endDate = Date.from(endDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public Set<CalendarHistory> getCalendarHistory() { public Set<CalendarHistory> getCalendarHistory() {
@@ -22,6 +22,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
@@ -434,7 +435,7 @@ public class CalendarReadPlatformServiceImpl implements CalendarReadPlatformServ
final String sql = rm.schema() + " where c.calendar_id = ? and date(?) between c.start_date and c.end_date limit 1"; final String sql = rm.schema() + " where c.calendar_id = ? and date(?) between c.start_date and c.end_date limit 1";
return this.jdbcTemplate.queryForObject(sql, rm, return this.jdbcTemplate.queryForObject(sql, rm,
new Object[] { calendarId, Date.from(compareDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()) }); new Object[] { calendarId, Date.from(compareDate.atStartOfDay(ZoneId.systemDefault()).toInstant()) });
} catch (final EmptyResultDataAccessException e) { } catch (final EmptyResultDataAccessException e) {
return null; return null;
} }
@@ -23,6 +23,7 @@ import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
@@ -110,8 +111,7 @@ public final class CalendarUtils {
} }
private static LocalDate getNextRecurringDate(final Recur recur, final LocalDate seedDate, final LocalDate startDate) { private static LocalDate getNextRecurringDate(final Recur recur, final LocalDate seedDate, final LocalDate startDate) {
final DateTime periodStart = new DateTime( final DateTime periodStart = new DateTime(java.util.Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
java.util.Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
final Date seed = convertToiCal4JCompatibleDate(seedDate); final Date seed = convertToiCal4JCompatibleDate(seedDate);
final Date nextRecDate = recur.getNextDate(seed, periodStart); final Date nextRecDate = recur.getNextDate(seed, periodStart);
return nextRecDate == null ? null return nextRecDate == null ? null
@@ -122,7 +122,7 @@ public final class CalendarUtils {
// Date format in iCal4J is hard coded // Date format in iCal4J is hard coded
Date formattedDate = null; Date formattedDate = null;
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
final String seedDateStr = df.format(java.util.Date.from(inputDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); final String seedDateStr = df.format(java.util.Date.from(inputDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
try { try {
formattedDate = new Date(seedDateStr, "yyyy-MM-dd"); formattedDate = new Date(seedDateStr, "yyyy-MM-dd");
} catch (final ParseException e) { } catch (final ParseException e) {
@@ -169,10 +169,8 @@ public final class CalendarUtils {
return null; return null;
} }
final Date seed = convertToiCal4JCompatibleDate(seedDate); final Date seed = convertToiCal4JCompatibleDate(seedDate);
final DateTime periodStart = new DateTime( final DateTime periodStart = new DateTime(java.util.Date.from(periodStartDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
java.util.Date.from(periodStartDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); final DateTime periodEnd = new DateTime(java.util.Date.from(periodEndDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
final DateTime periodEnd = new DateTime(
java.util.Date.from(periodEndDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
final Value value = new Value(Value.DATE.getValue()); final Value value = new Value(Value.DATE.getValue());
final DateList recurringDates = recur.getDates(seed, periodStart, periodEnd, value, maxCount); final DateList recurringDates = recur.getDates(seed, periodStart, periodEnd, value, maxCount);
@@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.calendar.service; package org.apache.fineract.portfolio.calendar.service;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -34,7 +35,6 @@ import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder; import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.calendar.CalendarConstants.CalendarSupportedParameters; import org.apache.fineract.portfolio.calendar.CalendarConstants.CalendarSupportedParameters;
import org.apache.fineract.portfolio.calendar.domain.Calendar; import org.apache.fineract.portfolio.calendar.domain.Calendar;
import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType; import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
@@ -281,8 +281,7 @@ public class CalendarWritePlatformServiceJpaRepositoryImpl implements CalendarWr
presentMeetingDate = command.localDateValueOfParameterNamed(CalendarSupportedParameters.START_DATE.getValue()); presentMeetingDate = command.localDateValueOfParameterNamed(CalendarSupportedParameters.START_DATE.getValue());
} }
if (null != newMeetingDate) { if (null != newMeetingDate) {
final Date endDate = Date final Date endDate = Date.from(presentMeetingDate.minusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant());
.from(presentMeetingDate.minusDays(1).atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
calendarHistory.updateEndDate(endDate); calendarHistory.updateEndDate(endDate);
} }
this.calendarHistoryRepository.save(calendarHistory); this.calendarHistoryRepository.save(calendarHistory);
@@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.client.domain; package org.apache.fineract.portfolio.client.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@@ -303,7 +304,7 @@ public final class Client extends AbstractPersistableCustom {
this.accountNumber = accountNo; this.accountNumber = accountNo;
} }
this.submittedOnDate = Date.from(submittedOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.submittedOnDate = Date.from(submittedOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.submittedBy = currentUser; this.submittedBy = currentUser;
this.status = status.getValue(); this.status = status.getValue();
@@ -327,11 +328,11 @@ public final class Client extends AbstractPersistableCustom {
} }
if (activationDate != null) { if (activationDate != null) {
this.activationDate = Date.from(activationDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.activationDate = Date.from(activationDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.activatedBy = currentUser; this.activatedBy = currentUser;
} }
if (officeJoiningDate != null) { if (officeJoiningDate != null) {
this.officeJoiningDate = Date.from(officeJoiningDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.officeJoiningDate = Date.from(officeJoiningDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (StringUtils.isNotBlank(firstname)) { if (StringUtils.isNotBlank(firstname)) {
this.firstname = firstname.trim(); this.firstname = firstname.trim();
@@ -370,7 +371,7 @@ public final class Client extends AbstractPersistableCustom {
this.gender = gender; this.gender = gender;
} }
if (dateOfBirth != null) { if (dateOfBirth != null) {
this.dateOfBirth = Date.from(dateOfBirth.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dateOfBirth = Date.from(dateOfBirth.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
this.clientType = clientType; this.clientType = clientType;
this.clientClassification = clientClassification; this.clientClassification = clientClassification;
@@ -439,7 +440,7 @@ public final class Client extends AbstractPersistableCustom {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
this.activationDate = Date.from(activationLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.activationDate = Date.from(activationLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.activatedBy = currentUser; this.activatedBy = currentUser;
this.officeJoiningDate = this.activationDate; this.officeJoiningDate = this.activationDate;
this.status = ClientStatus.ACTIVE.getValue(); this.status = ClientStatus.ACTIVE.getValue();
@@ -618,7 +619,7 @@ public final class Client extends AbstractPersistableCustom {
actualChanges.put(ClientApiConstants.localeParamName, localeAsInput); actualChanges.put(ClientApiConstants.localeParamName, localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.activationDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.activationDateParamName);
this.activationDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.activationDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.officeJoiningDate = this.activationDate; this.officeJoiningDate = this.activationDate;
} }
@@ -629,7 +630,7 @@ public final class Client extends AbstractPersistableCustom {
actualChanges.put(ClientApiConstants.localeParamName, localeAsInput); actualChanges.put(ClientApiConstants.localeParamName, localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.dateOfBirthParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.dateOfBirthParamName);
this.dateOfBirth = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dateOfBirth = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (command.isChangeInLocalDateParameterNamed(ClientApiConstants.submittedOnDateParamName, getSubmittedOnDate())) { if (command.isChangeInLocalDateParameterNamed(ClientApiConstants.submittedOnDateParamName, getSubmittedOnDate())) {
@@ -639,7 +640,7 @@ public final class Client extends AbstractPersistableCustom {
actualChanges.put(ClientApiConstants.localeParamName, localeAsInput); actualChanges.put(ClientApiConstants.localeParamName, localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.submittedOnDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.submittedOnDateParamName);
this.submittedOnDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.submittedOnDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
validateUpdate(); validateUpdate();
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.client.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
@@ -115,7 +116,7 @@ public class ClientCharge extends AbstractPersistableCustom {
this.charge = charge; this.charge = charge;
this.penaltyCharge = charge.isPenalty(); this.penaltyCharge = charge.isPenalty();
this.chargeTime = charge.getChargeTimeType(); this.chargeTime = charge.getChargeTimeType();
this.dueDate = (dueDate == null) ? null : Date.from(dueDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dueDate = (dueDate == null) ? null : Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.chargeCalculation = charge.getChargeCalculation(); this.chargeCalculation = charge.getChargeCalculation();
BigDecimal chargeAmount = charge.getAmount(); BigDecimal chargeAmount = charge.getAmount();
@@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.client.domain; package org.apache.fineract.portfolio.client.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -98,7 +99,7 @@ public class ClientNonPerson extends AbstractPersistableCustom {
} }
if (incorpValidityTill != null) { if (incorpValidityTill != null) {
this.incorpValidityTill = Date.from(incorpValidityTill.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.incorpValidityTill = Date.from(incorpValidityTill.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (StringUtils.isNotBlank(remarks)) { if (StringUtils.isNotBlank(remarks)) {
@@ -195,7 +196,7 @@ public class ClientNonPerson extends AbstractPersistableCustom {
actualChanges.put(ClientApiConstants.localeParamName, localeAsInput); actualChanges.put(ClientApiConstants.localeParamName, localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.incorpValidityTillParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.incorpValidityTillParamName);
this.incorpValidityTill = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.incorpValidityTill = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (command.isChangeInLongParameterNamed(ClientApiConstants.constitutionIdParamName, constitutionId())) { if (command.isChangeInLongParameterNamed(ClientApiConstants.constitutionIdParamName, constitutionId())) {
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.client.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
@@ -125,7 +126,7 @@ public class ClientTransaction extends AbstractPersistableCustom {
this.office = office; this.office = office;
this.paymentDetail = paymentDetail; this.paymentDetail = paymentDetail;
this.typeOf = typeOf; this.typeOf = typeOf;
this.dateOf = Date.from(transactionLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dateOf = Date.from(transactionLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.amount = amount.getAmount(); this.amount = amount.getAmount();
this.reversed = reversed; this.reversed = reversed;
this.externalId = externalId; this.externalId = externalId;
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.client.service;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@@ -45,7 +46,6 @@ import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder; import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException; import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.dataqueries.data.EntityTables; import org.apache.fineract.infrastructure.dataqueries.data.EntityTables;
import org.apache.fineract.infrastructure.dataqueries.data.StatusEnum; import org.apache.fineract.infrastructure.dataqueries.data.StatusEnum;
import org.apache.fineract.infrastructure.dataqueries.service.EntityDatatableChecksWritePlatformService; import org.apache.fineract.infrastructure.dataqueries.service.EntityDatatableChecksWritePlatformService;
@@ -735,8 +735,8 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
if (loanStatus.isOpen() || loanStatus.isPendingApproval() || loanStatus.isAwaitingDisbursal()) { if (loanStatus.isOpen() || loanStatus.isPendingApproval() || loanStatus.isAwaitingDisbursal()) {
final String errorMessage = "Client cannot be closed because of non-closed loans."; final String errorMessage = "Client cannot be closed because of non-closed loans.";
throw new InvalidClientStateTransitionException("close", "loan.non-closed", errorMessage); throw new InvalidClientStateTransitionException("close", "loan.non-closed", errorMessage);
} else if (loanStatus.isClosed() && loan.getClosedOnDate() } else if (loanStatus.isClosed()
.after(Date.from(closureDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()))) { && loan.getClosedOnDate().after(Date.from(closureDate.atStartOfDay(ZoneId.systemDefault()).toInstant()))) {
final String errorMessage = "The client closureDate cannot be before the loan closedOnDate."; final String errorMessage = "The client closureDate cannot be before the loan closedOnDate.";
throw new InvalidClientStateTransitionException("close", "date.cannot.before.loan.closed.date", errorMessage, throw new InvalidClientStateTransitionException("close", "date.cannot.before.loan.closed.date", errorMessage,
closureDate, loan.getClosedOnDate()); closureDate, loan.getClosedOnDate());
@@ -754,7 +754,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
} }
} }
client.close(currentUser, closureReason, Date.from(closureDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); client.close(currentUser, closureReason, Date.from(closureDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
this.clientRepository.saveAndFlush(client); this.clientRepository.saveAndFlush(client);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -848,7 +848,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
throw new InvalidClientStateTransitionException("rejection", "date.cannot.before.client.submitted.date", errorMessage, throw new InvalidClientStateTransitionException("rejection", "date.cannot.before.client.submitted.date", errorMessage,
rejectionDate, client.getSubmittedOnDate()); rejectionDate, client.getSubmittedOnDate());
} }
client.reject(currentUser, rejectionReason, Date.from(rejectionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); client.reject(currentUser, rejectionReason, Date.from(rejectionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
this.clientRepository.saveAndFlush(client); this.clientRepository.saveAndFlush(client);
this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.CLIENTS_REJECT, this.businessEventNotifierService.notifyBusinessEventWasExecuted(BusinessEvents.CLIENTS_REJECT,
constructEntityMap(BusinessEntity.CLIENT, client)); constructEntityMap(BusinessEntity.CLIENT, client));
@@ -880,8 +880,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
throw new InvalidClientStateTransitionException("withdrawal", "date.cannot.before.client.submitted.date", errorMessage, throw new InvalidClientStateTransitionException("withdrawal", "date.cannot.before.client.submitted.date", errorMessage,
withdrawalDate, client.getSubmittedOnDate()); withdrawalDate, client.getSubmittedOnDate());
} }
client.withdraw(currentUser, withdrawalReason, client.withdraw(currentUser, withdrawalReason, Date.from(withdrawalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
Date.from(withdrawalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
this.clientRepository.saveAndFlush(client); this.clientRepository.saveAndFlush(client);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -906,7 +905,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
throw new InvalidClientStateTransitionException("reactivation", "date.cannot.before.client.closed.date", errorMessage, throw new InvalidClientStateTransitionException("reactivation", "date.cannot.before.client.closed.date", errorMessage,
reactivateDate, client.getClosureDate()); reactivateDate, client.getClosureDate());
} }
client.reActivate(currentUser, Date.from(reactivateDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); client.reActivate(currentUser, Date.from(reactivateDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
this.clientRepository.saveAndFlush(client); this.clientRepository.saveAndFlush(client);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -932,7 +931,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
undoRejectDate, client.getRejectedDate()); undoRejectDate, client.getRejectedDate());
} }
client.reOpened(currentUser, Date.from(undoRejectDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); client.reOpened(currentUser, Date.from(undoRejectDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
this.clientRepository.saveAndFlush(client); this.clientRepository.saveAndFlush(client);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -958,7 +957,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
throw new InvalidClientStateTransitionException("reopened", "date.cannot.before.client.withdrawal.date", errorMessage, throw new InvalidClientStateTransitionException("reopened", "date.cannot.before.client.withdrawal.date", errorMessage,
undoWithdrawalDate, client.getWithdrawalDate()); undoWithdrawalDate, client.getWithdrawalDate());
} }
client.reOpened(currentUser, Date.from(undoWithdrawalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); client.reOpened(currentUser, Date.from(undoWithdrawalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
this.clientRepository.saveAndFlush(client); this.clientRepository.saveAndFlush(client);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -29,6 +29,7 @@ import java.sql.SQLException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
@@ -40,7 +41,6 @@ import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDoma
import org.apache.fineract.infrastructure.core.api.JsonQuery; import org.apache.fineract.infrastructure.core.api.JsonQuery;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.core.service.RoutingDataSource; import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.organisation.monetary.data.CurrencyData; import org.apache.fineract.organisation.monetary.data.CurrencyData;
@@ -319,8 +319,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
final Long calendarId = query.longValueOfParameterNamed(calendarIdParamName); final Long calendarId = query.longValueOfParameterNamed(calendarIdParamName);
final LocalDate transactionDate = query.localDateValueOfParameterNamed(transactionDateParamName); final LocalDate transactionDate = query.localDateValueOfParameterNamed(transactionDateParamName);
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
final String transactionDateStr = df final String transactionDateStr = df.format(Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
.format(Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
final Calendar calendar = this.calendarRepositoryWrapper.findOneWithNotFoundDetection(calendarId); final Calendar calendar = this.calendarRepositoryWrapper.findOneWithNotFoundDetection(calendarId);
// check if transaction against calendar effective from date // check if transaction against calendar effective from date
@@ -456,7 +455,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
final LocalDate transactionDate = query.localDateValueOfParameterNamed(transactionDateParamName); final LocalDate transactionDate = query.localDateValueOfParameterNamed(transactionDateParamName);
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
final String dueDateStr = df.format(Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); final String dueDateStr = df.format(Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
final JLGCollectionSheetFaltDataMapper mapper = new JLGCollectionSheetFaltDataMapper(); final JLGCollectionSheetFaltDataMapper mapper = new JLGCollectionSheetFaltDataMapper();
@@ -669,8 +668,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
final LocalDate transactionDate = query.localDateValueOfParameterNamed(transactionDateParamName); final LocalDate transactionDate = query.localDateValueOfParameterNamed(transactionDateParamName);
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
final String transactionDateStr = df final String transactionDateStr = df.format(Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
.format(Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
final AppUser currentUser = this.context.authenticatedUser(); final AppUser currentUser = this.context.authenticatedUser();
final String hierarchy = currentUser.getOffice().getHierarchy(); final String hierarchy = currentUser.getOffice().getHierarchy();
@@ -23,6 +23,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
@@ -111,8 +112,8 @@ public class FloatingRate extends AbstractPersistableCustom {
final LocalDate currentDate = DateUtils.getLocalDateOfTenant(); final LocalDate currentDate = DateUtils.getLocalDateOfTenant();
return new FloatingRate(name, isBaseLendingRate, isActive, floatingRatePeriods, currentUser, currentUser, return new FloatingRate(name, isBaseLendingRate, isActive, floatingRatePeriods, currentUser, currentUser,
Date.from(currentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant()),
Date.from(currentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
} }
private static List<FloatingRatePeriod> getRatePeriods(final AppUser currentUser, final JsonCommand command) { private static List<FloatingRatePeriod> getRatePeriods(final AppUser currentUser, final JsonCommand command) {
@@ -125,7 +126,7 @@ public class FloatingRate extends AbstractPersistableCustom {
final JsonObject ratePeriodObject = ratePeriod.getAsJsonObject(); final JsonObject ratePeriodObject = ratePeriod.getAsJsonObject();
final JsonParserHelper helper = new JsonParserHelper(); final JsonParserHelper helper = new JsonParserHelper();
final Date fromDate = Date.from(helper.extractLocalDateNamed("fromDate", ratePeriod, new HashSet<String>()) final Date fromDate = Date.from(helper.extractLocalDateNamed("fromDate", ratePeriod, new HashSet<String>())
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); .atStartOfDay(ZoneId.systemDefault()).toInstant());
final BigDecimal interestRate = ratePeriodObject.get("interestRate").getAsBigDecimal(); final BigDecimal interestRate = ratePeriodObject.get("interestRate").getAsBigDecimal();
final boolean isDifferentialToBaseLendingRate = helper.parameterExists("isDifferentialToBaseLendingRate", ratePeriod) final boolean isDifferentialToBaseLendingRate = helper.parameterExists("isDifferentialToBaseLendingRate", ratePeriod)
? ratePeriodObject.get("isDifferentialToBaseLendingRate").getAsBoolean() ? ratePeriodObject.get("isDifferentialToBaseLendingRate").getAsBoolean()
@@ -210,7 +211,7 @@ public class FloatingRate extends AbstractPersistableCustom {
if (fromDate.isAfter(today)) { if (fromDate.isAfter(today)) {
ratePeriod.setActive(false); ratePeriod.setActive(false);
ratePeriod.setModifiedBy(appUser); ratePeriod.setModifiedBy(appUser);
ratePeriod.setModifiedOn(Date.from(today.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); ratePeriod.setModifiedOn(Date.from(today.atStartOfDay(ZoneId.systemDefault()).toInstant()));
} }
} }
} }
@@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.group.domain; package org.apache.fineract.portfolio.group.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
@@ -208,7 +209,7 @@ public final class Group extends AbstractPersistableCustom {
this.groupMembers.addAll(groupMembers); this.groupMembers.addAll(groupMembers);
} }
this.submittedOnDate = Date.from(submittedOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.submittedOnDate = Date.from(submittedOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.submittedBy = currentUser; this.submittedBy = currentUser;
this.staffHistory = null; this.staffHistory = null;
@@ -240,7 +241,7 @@ public final class Group extends AbstractPersistableCustom {
validateStatusNotEqualToActiveAndLogError(dataValidationErrors); validateStatusNotEqualToActiveAndLogError(dataValidationErrors);
if (dataValidationErrors.isEmpty()) { if (dataValidationErrors.isEmpty()) {
this.status = GroupingTypeStatus.ACTIVE.getValue(); this.status = GroupingTypeStatus.ACTIVE.getValue();
setActivationDate(Date.from(activationLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), currentUser, setActivationDate(Date.from(activationLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), currentUser,
dataValidationErrors); dataValidationErrors);
} }
@@ -335,7 +336,7 @@ public final class Group extends AbstractPersistableCustom {
final LocalDate newValue = command.localDateValueOfParameterNamed(GroupingTypesApiConstants.activationDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(GroupingTypesApiConstants.activationDateParamName);
if (newValue != null) { if (newValue != null) {
this.activationDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.activationDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -353,7 +354,7 @@ public final class Group extends AbstractPersistableCustom {
final LocalDate newValue = command.localDateValueOfParameterNamed(GroupingTypesApiConstants.submittedOnDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(GroupingTypesApiConstants.submittedOnDateParamName);
if (newValue != null) { if (newValue != null) {
this.submittedOnDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.submittedOnDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -539,7 +540,7 @@ public final class Group extends AbstractPersistableCustom {
} }
this.closureReason = closureReason; this.closureReason = closureReason;
this.closureDate = Date.from(closureDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closureDate = Date.from(closureDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.status = GroupingTypeStatus.CLOSED.getValue(); this.status = GroupingTypeStatus.CLOSED.getValue();
this.closedBy = currentUser; this.closedBy = currentUser;
} }
@@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.group.domain; package org.apache.fineract.portfolio.group.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
@@ -52,8 +53,7 @@ public class StaffAssignmentHistory extends AbstractAuditableCustom {
private Date endDate; private Date endDate;
public static StaffAssignmentHistory createNew(final Group center, final Staff staff, final LocalDate startDate) { public static StaffAssignmentHistory createNew(final Group center, final Staff staff, final LocalDate startDate) {
return new StaffAssignmentHistory(center, staff, Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), return new StaffAssignmentHistory(center, staff, Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), null);
null);
} }
protected StaffAssignmentHistory() { protected StaffAssignmentHistory() {
@@ -72,11 +72,11 @@ public class StaffAssignmentHistory extends AbstractAuditableCustom {
} }
public void updateStartDate(final LocalDate startDate) { public void updateStartDate(final LocalDate startDate) {
this.startDate = Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public void updateEndDate(final LocalDate endDate) { public void updateEndDate(final LocalDate endDate) {
this.endDate = Date.from(endDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public boolean matchesStartDateOf(final LocalDate matchingDate) { public boolean matchesStartDateOf(final LocalDate matchingDate) {
@@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.group.service; package org.apache.fineract.portfolio.group.service;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@@ -654,7 +655,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
throw new InvalidGroupStateTransitionException(groupOrCenter.getGroupLevel().getLevelName(), "close", "loan.not.closed", throw new InvalidGroupStateTransitionException(groupOrCenter.getGroupLevel().getLevelName(), "close", "loan.not.closed",
errorMessage); errorMessage);
} else if (loanStatus.isClosed() } else if (loanStatus.isClosed()
&& loan.getClosedOnDate().after(Date.from(closureDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()))) { && loan.getClosedOnDate().after(Date.from(closureDate.atStartOfDay(ZoneId.systemDefault()).toInstant()))) {
final String errorMessage = groupOrCenter.getGroupLevel().getLevelName() final String errorMessage = groupOrCenter.getGroupLevel().getLevelName()
+ "closureDate cannot be before the loan closedOnDate."; + "closureDate cannot be before the loan closedOnDate.";
throw new InvalidGroupStateTransitionException(groupOrCenter.getGroupLevel().getLevelName(), "close", throw new InvalidGroupStateTransitionException(groupOrCenter.getGroupLevel().getLevelName(), "close",
@@ -27,6 +27,7 @@ import static org.apache.fineract.portfolio.interestratechart.InterestRateChartA
import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.nameParamName; import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.nameParamName;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import javax.persistence.Column; import javax.persistence.Column;
@@ -71,8 +72,8 @@ public class InterestRateChartFields {
boolean isPrimaryGroupingByAmount) { boolean isPrimaryGroupingByAmount) {
this.name = name; this.name = name;
this.description = description; this.description = description;
this.fromDate = Date.from(fromDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.fromDate = Date.from(fromDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.endDate = (toDate == null) ? null : Date.from(toDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = (toDate == null) ? null : Date.from(toDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.isPrimaryGroupingByAmount = isPrimaryGroupingByAmount; this.isPrimaryGroupingByAmount = isPrimaryGroupingByAmount;
} }
@@ -99,7 +100,7 @@ public class InterestRateChartFields {
actualChanges.put(fromDateParamName, newValueAsString); actualChanges.put(fromDateParamName, newValueAsString);
actualChanges.put(localeParamName, localeAsInput); actualChanges.put(localeParamName, localeAsInput);
actualChanges.put(dateFormatParamName, dateFormat); actualChanges.put(dateFormatParamName, dateFormat);
this.fromDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.fromDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (command.isChangeInLocalDateParameterNamed(endDateParamName, getEndDateAsLocalDate())) { if (command.isChangeInLocalDateParameterNamed(endDateParamName, getEndDateAsLocalDate())) {
@@ -108,7 +109,7 @@ public class InterestRateChartFields {
actualChanges.put(endDateParamName, newValueAsString); actualChanges.put(endDateParamName, newValueAsString);
actualChanges.put(localeParamName, localeAsInput); actualChanges.put(localeParamName, localeAsInput);
actualChanges.put(dateFormatParamName, dateFormat); actualChanges.put(dateFormatParamName, dateFormat);
this.endDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (command.isChangeInBooleanParameterNamed(isPrimaryGroupingByAmountParamName, this.isPrimaryGroupingByAmount)) { if (command.isChangeInBooleanParameterNamed(isPrimaryGroupingByAmountParamName, this.isPrimaryGroupingByAmount)) {
@@ -20,9 +20,9 @@ package org.apache.fineract.portfolio.loanaccount.data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.data.CurrencyData; import org.apache.fineract.organisation.monetary.data.CurrencyData;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType; import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
@@ -89,7 +89,7 @@ public class LoanScheduleAccrualData {
} }
public Date getDueDate() { public Date getDueDate() {
return Date.from(this.dueDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); return Date.from(this.dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public LocalDate getDueDateAsLocaldate() { public LocalDate getDueDateAsLocaldate() {
@@ -28,6 +28,7 @@ import java.math.MathContext;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
@@ -1308,9 +1309,8 @@ public class Loan extends AbstractPersistableCustom {
} }
public void updateLoanScheduleDependentDerivedFields() { public void updateLoanScheduleDependentDerivedFields() {
this.expectedMaturityDate = Date this.expectedMaturityDate = Date.from(determineExpectedMaturityDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
.from(determineExpectedMaturityDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.actualMaturityDate = Date.from(determineExpectedMaturityDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
this.actualMaturityDate = Date.from(determineExpectedMaturityDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
} }
private void updateLoanSummaryDerivedFields() { private void updateLoanSummaryDerivedFields() {
@@ -1459,7 +1459,7 @@ public class Loan extends AbstractPersistableCustom {
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(submittedOnDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(submittedOnDateParamName);
this.submittedOnDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.submittedOnDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final String expectedDisbursementDateParamName = "expectedDisbursementDate"; final String expectedDisbursementDateParamName = "expectedDisbursementDate";
@@ -1471,7 +1471,7 @@ public class Loan extends AbstractPersistableCustom {
actualChanges.put("recalculateLoanSchedule", true); actualChanges.put("recalculateLoanSchedule", true);
final LocalDate newValue = command.localDateValueOfParameterNamed(expectedDisbursementDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(expectedDisbursementDateParamName);
this.expectedDisbursementDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.expectedDisbursementDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
removeFirstDisbursementTransaction(); removeFirstDisbursementTransaction();
} }
@@ -1485,7 +1485,7 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate newValue = command.localDateValueOfParameterNamed(repaymentsStartingFromDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(repaymentsStartingFromDateParamName);
if (newValue != null) { if (newValue != null) {
this.expectedFirstRepaymentOnDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.expectedFirstRepaymentOnDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} else { } else {
this.expectedFirstRepaymentOnDate = null; this.expectedFirstRepaymentOnDate = null;
} }
@@ -1508,7 +1508,7 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate newValue = command.localDateValueOfParameterNamed(interestChargedFromDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(interestChargedFromDateParamName);
if (newValue != null) { if (newValue != null) {
this.interestChargedFromDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.interestChargedFromDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} else { } else {
this.interestChargedFromDate = null; this.interestChargedFromDate = null;
} }
@@ -1747,7 +1747,7 @@ public class Loan extends AbstractPersistableCustom {
locale); locale);
if (date != null) { if (date != null) {
returnObject.put(LoanApiConstants.disbursementDateParameterName, returnObject.put(LoanApiConstants.disbursementDateParameterName,
Date.from(date.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()));
} }
} }
} }
@@ -1990,10 +1990,10 @@ public class Loan extends AbstractPersistableCustom {
this.externalId = externalId; this.externalId = externalId;
this.termFrequency = loanApplicationTerms.getLoanTermFrequency(); this.termFrequency = loanApplicationTerms.getLoanTermFrequency();
this.termPeriodFrequencyType = loanApplicationTerms.getLoanTermPeriodFrequencyType().getValue(); this.termPeriodFrequencyType = loanApplicationTerms.getLoanTermPeriodFrequencyType().getValue();
this.submittedOnDate = Date.from(submittedOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.submittedOnDate = Date.from(submittedOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.submittedBy = currentUser; this.submittedBy = currentUser;
this.expectedDisbursementDate = Date this.expectedDisbursementDate = Date
.from(loanApplicationTerms.getExpectedDisbursementDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); .from(loanApplicationTerms.getExpectedDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
this.expectedFirstRepaymentOnDate = loanApplicationTerms.getRepaymentStartFromDate(); this.expectedFirstRepaymentOnDate = loanApplicationTerms.getRepaymentStartFromDate();
this.interestChargedFromDate = loanApplicationTerms.getInterestChargedFromDate(); this.interestChargedFromDate = loanApplicationTerms.getInterestChargedFromDate();
@@ -2080,9 +2080,9 @@ public class Loan extends AbstractPersistableCustom {
final Locale locale = new Locale(command.locale()); final Locale locale = new Locale(command.locale());
final DateTimeFormatter fmt = DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(locale); final DateTimeFormatter fmt = DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(locale);
this.rejectedOnDate = Date.from(rejectedOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.rejectedOnDate = Date.from(rejectedOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.rejectedBy = currentUser; this.rejectedBy = currentUser;
this.closedOnDate = Date.from(rejectedOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(rejectedOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.closedBy = currentUser; this.closedBy = currentUser;
actualChanges.put("locale", command.locale()); actualChanges.put("locale", command.locale());
@@ -2129,9 +2129,9 @@ public class Loan extends AbstractPersistableCustom {
final Locale locale = new Locale(command.locale()); final Locale locale = new Locale(command.locale());
final DateTimeFormatter fmt = DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(locale); final DateTimeFormatter fmt = DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(locale);
this.withdrawnOnDate = Date.from(withdrawnOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.withdrawnOnDate = Date.from(withdrawnOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.withdrawnBy = currentUser; this.withdrawnBy = currentUser;
this.closedOnDate = Date.from(withdrawnOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(withdrawnOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.closedBy = currentUser; this.closedBy = currentUser;
actualChanges.put("locale", command.locale()); actualChanges.put("locale", command.locale());
@@ -2241,7 +2241,7 @@ public class Loan extends AbstractPersistableCustom {
loanProduct.maxTrancheCount(), disbursementDetails.size()); loanProduct.maxTrancheCount(), disbursementDetails.size());
} }
} }
this.approvedOnDate = Date.from(approvedOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.approvedOnDate = Date.from(approvedOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.approvedBy = currentUser; this.approvedBy = currentUser;
actualChanges.put("locale", command.locale()); actualChanges.put("locale", command.locale());
actualChanges.put("dateFormat", command.dateFormat()); actualChanges.put("dateFormat", command.dateFormat());
@@ -2256,8 +2256,7 @@ public class Loan extends AbstractPersistableCustom {
} }
if (expecteddisbursementDate != null) { if (expecteddisbursementDate != null) {
this.expectedDisbursementDate = Date this.expectedDisbursementDate = Date.from(expecteddisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
.from(expecteddisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
actualChanges.put("expectedDisbursementDate", expectedDisbursementDate); actualChanges.put("expectedDisbursementDate", expectedDisbursementDate);
if (expecteddisbursementDate.isBefore(approvedOn)) { if (expecteddisbursementDate.isBefore(approvedOn)) {
@@ -2415,10 +2414,9 @@ public class Loan extends AbstractPersistableCustom {
final boolean isSpecificToInstallment = false; final boolean isSpecificToInstallment = false;
final Boolean isChangeEmiIfRepaymentDateSameAsDisbursementDateEnabled = scheduleGeneratorDTO final Boolean isChangeEmiIfRepaymentDateSameAsDisbursementDateEnabled = scheduleGeneratorDTO
.isChangeEmiIfRepaymentDateSameAsDisbursementDateEnabled(); .isChangeEmiIfRepaymentDateSameAsDisbursementDateEnabled();
Date effectiveDateFrom = Date.from(actualDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); Date effectiveDateFrom = Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
if (!isChangeEmiIfRepaymentDateSameAsDisbursementDateEnabled && actualDisbursementDate.equals(nextPossibleRepaymentDate)) { if (!isChangeEmiIfRepaymentDateSameAsDisbursementDateEnabled && actualDisbursementDate.equals(nextPossibleRepaymentDate)) {
effectiveDateFrom = Date effectiveDateFrom = Date.from(nextPossibleRepaymentDate.plusDays(1).atStartOfDay(ZoneId.systemDefault()).toInstant());
.from(nextPossibleRepaymentDate.plusDays(1).atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
} }
LoanTermVariations loanVariationTerms = new LoanTermVariations(LoanTermVariationType.EMI_AMOUNT.getValue(), LoanTermVariations loanVariationTerms = new LoanTermVariations(LoanTermVariationType.EMI_AMOUNT.getValue(),
effectiveDateFrom, emiAmount, dateValue, isSpecificToInstallment, this, LoanStatus.ACTIVE.getValue()); effectiveDateFrom, emiAmount, dateValue, isSpecificToInstallment, this, LoanStatus.ACTIVE.getValue());
@@ -2431,7 +2429,7 @@ public class Loan extends AbstractPersistableCustom {
if (rescheduledRepaymentDate != null && this.loanProduct.isMultiDisburseLoan()) { if (rescheduledRepaymentDate != null && this.loanProduct.isMultiDisburseLoan()) {
final boolean isSpecificToInstallment = false; final boolean isSpecificToInstallment = false;
LoanTermVariations loanVariationTerms = new LoanTermVariations(LoanTermVariationType.DUE_DATE.getValue(), LoanTermVariations loanVariationTerms = new LoanTermVariations(LoanTermVariationType.DUE_DATE.getValue(),
Date.from(nextPossibleRepaymentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), emiAmount, Date.from(nextPossibleRepaymentDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), emiAmount,
rescheduledRepaymentDate, isSpecificToInstallment, this, LoanStatus.ACTIVE.getValue()); rescheduledRepaymentDate, isSpecificToInstallment, this, LoanStatus.ACTIVE.getValue());
this.loanTermVariations.add(loanVariationTerms); this.loanTermVariations.add(loanVariationTerms);
} }
@@ -2458,10 +2456,10 @@ public class Loan extends AbstractPersistableCustom {
if (details != null) { if (details != null) {
lastDusburseDate = details.actualDisbursementDate(); lastDusburseDate = details.actualDisbursementDate();
} }
if (Date.from(actualDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()).before(lastDusburseDate)) { if (Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()).before(lastDusburseDate)) {
final String errorMsg = "Loan can't be disbursed before " + lastDusburseDate; final String errorMsg = "Loan can't be disbursed before " + lastDusburseDate;
throw new LoanDisbursalException(errorMsg, "actualdisbursementdate.before.lastdusbursedate", lastDusburseDate, throw new LoanDisbursalException(errorMsg, "actualdisbursementdate.before.lastdusbursedate", lastDusburseDate,
Date.from(actualDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
} }
isMultiTrancheDisburse = true; isMultiTrancheDisburse = true;
} }
@@ -2472,7 +2470,7 @@ public class Loan extends AbstractPersistableCustom {
Money disburseAmount = this.loanRepaymentScheduleDetail.getPrincipal().zero(); Money disburseAmount = this.loanRepaymentScheduleDetail.getPrincipal().zero();
BigDecimal principalDisbursed = command.bigDecimalValueOfParameterNamed(LoanApiConstants.principalDisbursedParameterName); BigDecimal principalDisbursed = command.bigDecimalValueOfParameterNamed(LoanApiConstants.principalDisbursedParameterName);
if (this.actualDisbursementDate == null) { if (this.actualDisbursementDate == null) {
this.actualDisbursementDate = Date.from(actualDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.actualDisbursementDate = Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
BigDecimal diff = BigDecimal.ZERO; BigDecimal diff = BigDecimal.ZERO;
Collection<LoanDisbursementDetails> details = fetchUndisbursedDetail(); Collection<LoanDisbursementDetails> details = fetchUndisbursedDetail();
@@ -2482,7 +2480,7 @@ public class Loan extends AbstractPersistableCustom {
disburseAmount = disburseAmount.zero(); disburseAmount = disburseAmount.zero();
for (LoanDisbursementDetails disbursementDetails : details) { for (LoanDisbursementDetails disbursementDetails : details) {
disbursementDetails.updateActualDisbursementDate( disbursementDetails.updateActualDisbursementDate(
Date.from(actualDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
disburseAmount = disburseAmount.plus(disbursementDetails.principal()); disburseAmount = disburseAmount.plus(disbursementDetails.principal());
} }
} }
@@ -2498,7 +2496,7 @@ public class Loan extends AbstractPersistableCustom {
} else { } else {
for (LoanDisbursementDetails disbursementDetails : details) { for (LoanDisbursementDetails disbursementDetails : details) {
disbursementDetails.updateActualDisbursementDate( disbursementDetails.updateActualDisbursementDate(
Date.from(actualDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
disbursementDetails.updatePrincipal(principalDisbursed); disbursementDetails.updatePrincipal(principalDisbursed);
} }
} }
@@ -2780,8 +2778,9 @@ public class Loan extends AbstractPersistableCustom {
if (getExpectedFirstRepaymentOnDate() != null if (getExpectedFirstRepaymentOnDate() != null
&& (disbursedOn.isAfter(this.fetchRepaymentScheduleInstallment(1).getDueDate()) && (disbursedOn.isAfter(this.fetchRepaymentScheduleInstallment(1).getDueDate())
|| disbursedOn.isAfter(getExpectedFirstRepaymentOnDate())) || disbursedOn.isAfter(getExpectedFirstRepaymentOnDate()))
&& Date.from(disbursedOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()) && Date.from(disbursedOn.atStartOfDay(ZoneId.systemDefault()).toInstant()).compareTo(this.actualDisbursementDate) == 0
.compareTo(this.actualDisbursementDate) == 0 ? Boolean.TRUE : Boolean.FALSE) { ? Boolean.TRUE
: Boolean.FALSE) {
final String errorMessage = "submittedOnDate cannot be after the loans expectedFirstRepaymentOnDate: " final String errorMessage = "submittedOnDate cannot be after the loans expectedFirstRepaymentOnDate: "
+ getExpectedFirstRepaymentOnDate().toString(); + getExpectedFirstRepaymentOnDate().toString();
throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.after.expected.first.repayment.date", errorMessage, throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.after.expected.first.repayment.date", errorMessage,
@@ -3281,8 +3280,8 @@ public class Loan extends AbstractPersistableCustom {
LoanStatus.fromInt(this.loanStatus)); LoanStatus.fromInt(this.loanStatus));
this.loanStatus = statusEnum.getValue(); this.loanStatus = statusEnum.getValue();
this.closedOnDate = Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.actualMaturityDate = Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.actualMaturityDate = Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} else if (LoanStatus.fromInt(this.loanStatus).isOverpaid()) { } else if (LoanStatus.fromInt(this.loanStatus).isOverpaid()) {
final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.LOAN_REPAYMENT_OR_WAIVER, final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.LOAN_REPAYMENT_OR_WAIVER,
LoanStatus.fromInt(this.loanStatus)); LoanStatus.fromInt(this.loanStatus));
@@ -3633,8 +3632,8 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate writtenOffOnLocalDate = command.localDateValueOfParameterNamed("transactionDate"); final LocalDate writtenOffOnLocalDate = command.localDateValueOfParameterNamed("transactionDate");
final String txnExternalId = command.stringValueOfParameterNamedAllowingNull("externalId"); final String txnExternalId = command.stringValueOfParameterNamedAllowingNull("externalId");
this.closedOnDate = Date.from(writtenOffOnLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(writtenOffOnLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.writtenOffOnDate = Date.from(writtenOffOnLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.writtenOffOnDate = Date.from(writtenOffOnLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.closedBy = currentUser; this.closedBy = currentUser;
changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate"));
changes.put("writtenOffOnDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("writtenOffOnDate", command.stringValueOfParameterNamed("transactionDate"));
@@ -3721,7 +3720,7 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate closureDate = command.localDateValueOfParameterNamed("transactionDate"); final LocalDate closureDate = command.localDateValueOfParameterNamed("transactionDate");
final String txnExternalId = command.stringValueOfParameterNamedAllowingNull("externalId"); final String txnExternalId = command.stringValueOfParameterNamedAllowingNull("externalId");
this.closedOnDate = Date.from(closureDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(closureDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate"));
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.REPAID_IN_FULL, closureDate); validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.REPAID_IN_FULL, closureDate);
@@ -3752,7 +3751,7 @@ public class Loan extends AbstractPersistableCustom {
this.loanStatus = statusEnum.getValue(); this.loanStatus = statusEnum.getValue();
changes.put("status", LoanEnumerations.status(this.loanStatus)); changes.put("status", LoanEnumerations.status(this.loanStatus));
} }
this.closedOnDate = Date.from(closureDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(closureDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
loanTransaction = LoanTransaction.writeoff(this, getOffice(), closureDate, txnExternalId, loanTransaction = LoanTransaction.writeoff(this, getOffice(), closureDate, txnExternalId,
DateUtils.getLocalDateTimeOfTenant(), currentUser); DateUtils.getLocalDateTimeOfTenant(), currentUser);
final boolean isLastTransaction = isChronologicallyLatestTransaction(loanTransaction, getLoanTransactions()); final boolean isLastTransaction = isChronologicallyLatestTransaction(loanTransaction, getLoanTransactions());
@@ -3786,7 +3785,7 @@ public class Loan extends AbstractPersistableCustom {
this.loanStatus = statusEnum.getValue(); this.loanStatus = statusEnum.getValue();
changes.put("status", LoanEnumerations.status(this.loanStatus)); changes.put("status", LoanEnumerations.status(this.loanStatus));
} }
this.closedOnDate = Date.from(closureDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(closureDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} else if (totalLoanOverpayment.isGreaterThanZero()) { } else if (totalLoanOverpayment.isGreaterThanZero()) {
final String errorMessage = "The loan is marked as 'Overpaid' and cannot be moved to 'Closed (obligations met)."; final String errorMessage = "The loan is marked as 'Overpaid' and cannot be moved to 'Closed (obligations met).";
throw new InvalidLoanStateTransitionException("close", "loan.is.overpaid", errorMessage, totalLoanOverpayment.toString()); throw new InvalidLoanStateTransitionException("close", "loan.is.overpaid", errorMessage, totalLoanOverpayment.toString());
@@ -3815,8 +3814,8 @@ public class Loan extends AbstractPersistableCustom {
changes.put("status", LoanEnumerations.status(this.loanStatus)); changes.put("status", LoanEnumerations.status(this.loanStatus));
} }
this.closedOnDate = Date.from(rescheduledOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(rescheduledOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.rescheduledOnDate = Date.from(rescheduledOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.rescheduledOnDate = Date.from(rescheduledOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("closedOnDate", command.stringValueOfParameterNamed("transactionDate"));
changes.put("rescheduledOnDate", command.stringValueOfParameterNamed("transactionDate")); changes.put("rescheduledOnDate", command.stringValueOfParameterNamed("transactionDate"));
@@ -4441,7 +4440,7 @@ public class Loan extends AbstractPersistableCustom {
} }
} }
if (latestRepaymentDate != null) { if (latestRepaymentDate != null) {
this.expectedMaturityDate = Date.from(latestRepaymentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.expectedMaturityDate = Date.from(latestRepaymentDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -4495,7 +4494,7 @@ public class Loan extends AbstractPersistableCustom {
} }
} }
if (latestRepaymentDate != null) { if (latestRepaymentDate != null) {
this.expectedMaturityDate = Date.from(latestRepaymentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.expectedMaturityDate = Date.from(latestRepaymentDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -5041,7 +5040,7 @@ public class Loan extends AbstractPersistableCustom {
final LocalDate expectedDisbursementDate = command final LocalDate expectedDisbursementDate = command
.localDateValueOfParameterNamed(LoanApiConstants.updatedDisbursementDateParameterName); .localDateValueOfParameterNamed(LoanApiConstants.updatedDisbursementDateParameterName);
disbursementDetails.updateExpectedDisbursementDateAndAmount( disbursementDetails.updateExpectedDisbursementDateAndAmount(
Date.from(expectedDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), principal); Date.from(expectedDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), principal);
actualChanges.put(LoanApiConstants.disbursementDateParameterName, actualChanges.put(LoanApiConstants.disbursementDateParameterName,
command.stringValueOfParameterNamed(LoanApiConstants.disbursementDateParameterName)); command.stringValueOfParameterNamed(LoanApiConstants.disbursementDateParameterName));
actualChanges.put(LoanApiConstants.disbursementIdParameterName, actualChanges.put(LoanApiConstants.disbursementIdParameterName,
@@ -5080,7 +5079,7 @@ public class Loan extends AbstractPersistableCustom {
public BigDecimal retriveLastEmiAmount() { public BigDecimal retriveLastEmiAmount() {
BigDecimal emiAmount = this.fixedEmiAmount; BigDecimal emiAmount = this.fixedEmiAmount;
Date startDate = Date.from(this.getDisbursementDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); Date startDate = Date.from(this.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
for (LoanTermVariations loanTermVariations : this.loanTermVariations) { for (LoanTermVariations loanTermVariations : this.loanTermVariations) {
if (loanTermVariations.getTermType().isEMIAmountVariation() && !startDate.after(loanTermVariations.getTermApplicableFrom())) { if (loanTermVariations.getTermType().isEMIAmountVariation() && !startDate.after(loanTermVariations.getTermApplicableFrom())) {
startDate = loanTermVariations.getTermApplicableFrom(); startDate = loanTermVariations.getTermApplicableFrom();
@@ -5306,13 +5305,13 @@ public class Loan extends AbstractPersistableCustom {
if (existingIncomeTransaction == null) { if (existingIncomeTransaction == null) {
LoanTransaction transaction = LoanTransaction.incomePosting(this, this.getOffice(), LoanTransaction transaction = LoanTransaction.incomePosting(this, this.getOffice(),
Date.from(compoundingDetail.getEffectiveDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(compoundingDetail.getEffectiveDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
compoundingDetail.getAmount(), interest, fee, penalties, currentUser); compoundingDetail.getAmount(), interest, fee, penalties, currentUser);
addLoanTransaction(transaction); addLoanTransaction(transaction);
} else if (existingIncomeTransaction.getAmount(getCurrency()).getAmount().compareTo(compoundingDetail.getAmount()) != 0) { } else if (existingIncomeTransaction.getAmount(getCurrency()).getAmount().compareTo(compoundingDetail.getAmount()) != 0) {
existingIncomeTransaction.reverse(); existingIncomeTransaction.reverse();
LoanTransaction transaction = LoanTransaction.incomePosting(this, this.getOffice(), LoanTransaction transaction = LoanTransaction.incomePosting(this, this.getOffice(),
Date.from(compoundingDetail.getEffectiveDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(compoundingDetail.getEffectiveDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
compoundingDetail.getAmount(), interest, fee, penalties, currentUser); compoundingDetail.getAmount(), interest, fee, penalties, currentUser);
addLoanTransaction(transaction); addLoanTransaction(transaction);
} }
@@ -5833,7 +5832,7 @@ public class Loan extends AbstractPersistableCustom {
public void updateRescheduledOnDate(LocalDate rescheduledOnDate) { public void updateRescheduledOnDate(LocalDate rescheduledOnDate) {
if (rescheduledOnDate != null) { if (rescheduledOnDate != null) {
this.rescheduledOnDate = Date.from(rescheduledOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.rescheduledOnDate = Date.from(rescheduledOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -6066,11 +6065,11 @@ public class Loan extends AbstractPersistableCustom {
if ((loanTermVariations.getTermType().isDueDateVariation() if ((loanTermVariations.getTermType().isDueDateVariation()
&& loanTermVariations.fetchDateValue().isAfter(actualDisbursementDate)) && loanTermVariations.fetchDateValue().isAfter(actualDisbursementDate))
|| (loanTermVariations.getTermType().isEMIAmountVariation() && loanTermVariations.getTermApplicableFrom() || (loanTermVariations.getTermType().isEMIAmountVariation() && loanTermVariations.getTermApplicableFrom()
.compareTo(Date.from(actualDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())) == 0 .compareTo(Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant())) == 0
? Boolean.TRUE ? Boolean.TRUE
: Boolean.FALSE) : Boolean.FALSE)
|| loanTermVariations.getTermApplicableFrom() || loanTermVariations.getTermApplicableFrom()
.after(Date.from(actualDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()))) { .after(Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()))) {
iterator.remove(); iterator.remove();
} }
} }
@@ -21,6 +21,7 @@ package org.apache.fineract.portfolio.loanaccount.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@@ -338,8 +339,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
} else { } else {
final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled(); final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), HolidayStatusType.ACTIVE.getValue());
HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne(); final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled(); final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled();
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled(); final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
@@ -419,8 +419,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
txnExternalId, DateUtils.getLocalDateTimeOfTenant(), currentUser); txnExternalId, DateUtils.getLocalDateTimeOfTenant(), currentUser);
final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled(); final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), HolidayStatusType.ACTIVE.getValue());
HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne(); final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled(); final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled();
@@ -614,8 +613,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
transactionDate, txnExternalId, DateUtils.getLocalDateTimeOfTenant(), currentUser); transactionDate, txnExternalId, DateUtils.getLocalDateTimeOfTenant(), currentUser);
final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled(); final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), HolidayStatusType.ACTIVE.getValue());
HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne(); final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled(); final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled();
@@ -21,6 +21,7 @@ package org.apache.fineract.portfolio.loanaccount.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.MathContext; import java.math.MathContext;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
@@ -197,7 +198,7 @@ public class LoanCharge extends AbstractPersistableCustom {
amountPercentageAppliedTo = BigDecimal.ZERO; amountPercentageAppliedTo = BigDecimal.ZERO;
for (final LoanDisbursementDetails loanDisbursementDetails : loan.getDisbursementDetails()) { for (final LoanDisbursementDetails loanDisbursementDetails : loan.getDisbursementDetails()) {
if (!loanDisbursementDetails.expectedDisbursementDate() if (!loanDisbursementDetails.expectedDisbursementDate()
.after(Date.from(dueDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()))) { .after(Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant()))) {
amountPercentageAppliedTo = amountPercentageAppliedTo.add(loanDisbursementDetails.principal()); amountPercentageAppliedTo = amountPercentageAppliedTo.add(loanDisbursementDetails.principal());
} }
} }
@@ -244,7 +245,7 @@ public class LoanCharge extends AbstractPersistableCustom {
chargeDefinition.getName()); chargeDefinition.getName());
} }
this.dueDate = Date.from(dueDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dueDate = Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} else { } else {
this.dueDate = null; this.dueDate = null;
} }
@@ -391,7 +392,7 @@ public class LoanCharge extends AbstractPersistableCustom {
public void update(final BigDecimal amount, final LocalDate dueDate, final BigDecimal loanPrincipal, Integer numberOfRepayments, public void update(final BigDecimal amount, final LocalDate dueDate, final BigDecimal loanPrincipal, Integer numberOfRepayments,
BigDecimal loanCharge) { BigDecimal loanCharge) {
if (dueDate != null) { if (dueDate != null) {
this.dueDate = Date.from(dueDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dueDate = Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (amount != null) { if (amount != null) {
@@ -479,7 +480,7 @@ public class LoanCharge extends AbstractPersistableCustom {
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(dueDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(dueDateParamName);
this.dueDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dueDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final String amountParamName = "amount"; final String amountParamName = "amount";
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.loanaccount.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
@@ -46,7 +47,7 @@ public class LoanInterestRecalcualtionAdditionalDetails extends AbstractPersista
public LoanInterestRecalcualtionAdditionalDetails(final LocalDate effectiveDate, final BigDecimal amount) { public LoanInterestRecalcualtionAdditionalDetails(final LocalDate effectiveDate, final BigDecimal amount) {
if (effectiveDate != null) { if (effectiveDate != null) {
this.effectiveDate = Date.from(effectiveDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.effectiveDate = Date.from(effectiveDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
this.amount = amount; this.amount = amount;
} }
@@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.loanaccount.domain; package org.apache.fineract.portfolio.loanaccount.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
@@ -53,8 +54,8 @@ public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom {
private Date endDate; private Date endDate;
public static LoanOfficerAssignmentHistory createNew(final Loan loan, final Staff loanOfficer, final LocalDate startDate) { public static LoanOfficerAssignmentHistory createNew(final Loan loan, final Staff loanOfficer, final LocalDate startDate) {
return new LoanOfficerAssignmentHistory(loan, loanOfficer, return new LoanOfficerAssignmentHistory(loan, loanOfficer, Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant()),
Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), null); null);
} }
protected LoanOfficerAssignmentHistory() { protected LoanOfficerAssignmentHistory() {
@@ -73,11 +74,11 @@ public class LoanOfficerAssignmentHistory extends AbstractAuditableCustom {
} }
public void updateStartDate(final LocalDate startDate) { public void updateStartDate(final LocalDate startDate) {
this.startDate = Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public void updateEndDate(final LocalDate endDate) { public void updateEndDate(final LocalDate endDate) {
this.endDate = Date.from(endDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public boolean matchesStartDateOf(final LocalDate matchingDate) { public boolean matchesStartDateOf(final LocalDate matchingDate) {
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.loanaccount.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
@@ -149,8 +150,8 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
final Set<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails, final BigDecimal rescheduleInterestPortion) { final Set<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails, final BigDecimal rescheduleInterestPortion) {
this.loan = loan; this.loan = loan;
this.installmentNumber = installmentNumber; this.installmentNumber = installmentNumber;
this.fromDate = Date.from(fromDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.fromDate = Date.from(fromDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.dueDate = Date.from(dueDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dueDate = Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.principal = defaultToNullIfZero(principal); this.principal = defaultToNullIfZero(principal);
this.interestCharged = defaultToNullIfZero(interest); this.interestCharged = defaultToNullIfZero(interest);
this.feeChargesCharged = defaultToNullIfZero(feeCharges); this.feeChargesCharged = defaultToNullIfZero(feeCharges);
@@ -167,8 +168,8 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
final Set<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails) { final Set<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails) {
this.loan = loan; this.loan = loan;
this.installmentNumber = installmentNumber; this.installmentNumber = installmentNumber;
this.fromDate = Date.from(fromDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.fromDate = Date.from(fromDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.dueDate = Date.from(dueDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dueDate = Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.principal = defaultToNullIfZero(principal); this.principal = defaultToNullIfZero(principal);
this.interestCharged = defaultToNullIfZero(interest); this.interestCharged = defaultToNullIfZero(interest);
this.feeChargesCharged = defaultToNullIfZero(feeCharges); this.feeChargesCharged = defaultToNullIfZero(feeCharges);
@@ -592,7 +593,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
public void updateDerivedFields(final MonetaryCurrency currency, final LocalDate actualDisbursementDate) { public void updateDerivedFields(final MonetaryCurrency currency, final LocalDate actualDisbursementDate) {
if (!this.obligationsMet && getTotalOutstanding(currency).isZero()) { if (!this.obligationsMet && getTotalOutstanding(currency).isZero()) {
this.obligationsMet = true; this.obligationsMet = true;
this.obligationsMetOnDate = Date.from(actualDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.obligationsMetOnDate = Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -620,7 +621,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
private void checkIfRepaymentPeriodObligationsAreMet(final LocalDate transactionDate, final MonetaryCurrency currency) { private void checkIfRepaymentPeriodObligationsAreMet(final LocalDate transactionDate, final MonetaryCurrency currency) {
this.obligationsMet = getTotalOutstanding(currency).isZero(); this.obligationsMet = getTotalOutstanding(currency).isZero();
if (this.obligationsMet) { if (this.obligationsMet) {
this.obligationsMetOnDate = Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.obligationsMetOnDate = Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} else { } else {
this.obligationsMetOnDate = null; this.obligationsMetOnDate = null;
} }
@@ -628,13 +629,13 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
public void updateDueDate(final LocalDate newDueDate) { public void updateDueDate(final LocalDate newDueDate) {
if (newDueDate != null) { if (newDueDate != null) {
this.dueDate = Date.from(newDueDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dueDate = Date.from(newDueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
public void updateFromDate(final LocalDate newFromDate) { public void updateFromDate(final LocalDate newFromDate) {
if (newFromDate != null) { if (newFromDate != null) {
this.fromDate = Date.from(newFromDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.fromDate = Date.from(newFromDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -670,7 +671,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
public void updateObligationMetOnDate(final LocalDate obligationsMetOnDate) { public void updateObligationMetOnDate(final LocalDate obligationsMetOnDate) {
this.obligationsMetOnDate = (obligationsMetOnDate != null) this.obligationsMetOnDate = (obligationsMetOnDate != null)
? Date.from(obligationsMetOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()) ? Date.from(obligationsMetOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant())
: null; : null;
} }
@@ -21,6 +21,7 @@ package org.apache.fineract.portfolio.loanaccount.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
@@ -219,9 +220,9 @@ public class LoanTransaction extends AbstractPersistableCustom {
PaymentDetail paymentDetail = null; PaymentDetail paymentDetail = null;
String externalId = null; String externalId = null;
return new LoanTransaction(loan, office, LoanTransactionType.ACCRUAL.getValue(), return new LoanTransaction(loan, office, LoanTransactionType.ACCRUAL.getValue(),
Date.from(interestAppliedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), interestPortion, Date.from(interestAppliedDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), interestPortion, principalPortion,
principalPortion, interestPortion, feesPortion, penaltiesPortion, overPaymentPortion, reversed, paymentDetail, externalId, interestPortion, feesPortion, penaltiesPortion, overPaymentPortion, reversed, paymentDetail, externalId, createdDate,
createdDate, appUser); appUser);
} }
public static LoanTransaction accrual(final Loan loan, final Office office, final Money amount, final Money interest, public static LoanTransaction accrual(final Loan loan, final Office office, final Money amount, final Money interest,
@@ -241,35 +242,35 @@ public class LoanTransaction extends AbstractPersistableCustom {
String externalId = null; String externalId = null;
LocalDateTime createdDate = DateUtils.getLocalDateTimeOfTenant(); LocalDateTime createdDate = DateUtils.getLocalDateTimeOfTenant();
return new LoanTransaction(loan, office, LoanTransactionType.ACCRUAL.getValue(), return new LoanTransaction(loan, office, LoanTransactionType.ACCRUAL.getValue(),
Date.from(dateOf.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), amount, principalPortion, interestPortion, Date.from(dateOf.atStartOfDay(ZoneId.systemDefault()).toInstant()), amount, principalPortion, interestPortion,
feeChargesPortion, penaltyChargesPortion, overPaymentPortion, reversed, paymentDetail, externalId, createdDate, appUser); feeChargesPortion, penaltyChargesPortion, overPaymentPortion, reversed, paymentDetail, externalId, createdDate, appUser);
} }
public static LoanTransaction initiateTransfer(final Office office, final Loan loan, final LocalDate transferDate, public static LoanTransaction initiateTransfer(final Office office, final Loan loan, final LocalDate transferDate,
final LocalDateTime createdDate, final AppUser appUser) { final LocalDateTime createdDate, final AppUser appUser) {
return new LoanTransaction(loan, office, LoanTransactionType.INITIATE_TRANSFER.getValue(), return new LoanTransaction(loan, office, LoanTransactionType.INITIATE_TRANSFER.getValue(),
Date.from(transferDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(transferDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), loan.getSummary().getTotalOutstanding(),
loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary().getTotalInterestOutstanding(),
loan.getSummary().getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary().getTotalPenaltyChargesOutstanding(), null, false, null,
loan.getSummary().getTotalPenaltyChargesOutstanding(), null, false, null, null, createdDate, appUser); null, createdDate, appUser);
} }
public static LoanTransaction approveTransfer(final Office office, final Loan loan, final LocalDate transferDate, public static LoanTransaction approveTransfer(final Office office, final Loan loan, final LocalDate transferDate,
final LocalDateTime createdDate, final AppUser appUser) { final LocalDateTime createdDate, final AppUser appUser) {
return new LoanTransaction(loan, office, LoanTransactionType.APPROVE_TRANSFER.getValue(), return new LoanTransaction(loan, office, LoanTransactionType.APPROVE_TRANSFER.getValue(),
Date.from(transferDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(transferDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), loan.getSummary().getTotalOutstanding(),
loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary().getTotalInterestOutstanding(),
loan.getSummary().getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary().getTotalPenaltyChargesOutstanding(), null, false, null,
loan.getSummary().getTotalPenaltyChargesOutstanding(), null, false, null, null, createdDate, appUser); null, createdDate, appUser);
} }
public static LoanTransaction withdrawTransfer(final Office office, final Loan loan, final LocalDate transferDate, public static LoanTransaction withdrawTransfer(final Office office, final Loan loan, final LocalDate transferDate,
final LocalDateTime createdDate, final AppUser appUser) { final LocalDateTime createdDate, final AppUser appUser) {
return new LoanTransaction(loan, office, LoanTransactionType.WITHDRAW_TRANSFER.getValue(), return new LoanTransaction(loan, office, LoanTransactionType.WITHDRAW_TRANSFER.getValue(),
Date.from(transferDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(transferDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), loan.getSummary().getTotalOutstanding(),
loan.getSummary().getTotalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary().getTotalPrincipalOutstanding(), loan.getSummary().getTotalInterestOutstanding(),
loan.getSummary().getTotalInterestOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary().getTotalFeeChargesOutstanding(), loan.getSummary().getTotalPenaltyChargesOutstanding(), null, false, null,
loan.getSummary().getTotalPenaltyChargesOutstanding(), null, false, null, null, createdDate, appUser); null, createdDate, appUser);
} }
public static LoanTransaction refund(final Office office, final Money amount, final PaymentDetail paymentDetail, public static LoanTransaction refund(final Office office, final Money amount, final PaymentDetail paymentDetail,
@@ -359,7 +360,7 @@ public class LoanTransaction extends AbstractPersistableCustom {
this.loan = loan; this.loan = loan;
this.typeOf = type.getValue(); this.typeOf = type.getValue();
this.amount = amount; this.amount = amount;
this.dateOf = Date.from(date.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dateOf = Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.externalId = externalId; this.externalId = externalId;
this.office = office; this.office = office;
this.submittedOnDate = DateUtils.getDateOfTenant(); this.submittedOnDate = DateUtils.getDateOfTenant();
@@ -374,7 +375,7 @@ public class LoanTransaction extends AbstractPersistableCustom {
this.typeOf = type.getValue(); this.typeOf = type.getValue();
this.paymentDetail = paymentDetail; this.paymentDetail = paymentDetail;
this.amount = amount; this.amount = amount;
this.dateOf = Date.from(date.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dateOf = Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.externalId = externalId; this.externalId = externalId;
this.office = office; this.office = office;
this.submittedOnDate = DateUtils.getDateOfTenant(); this.submittedOnDate = DateUtils.getDateOfTenant();
@@ -20,13 +20,13 @@ package org.apache.fineract.portfolio.loanaccount.guarantor.command;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.infrastructure.core.data.ApiParameterError; import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder; import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants.GuarantorJSONinputParams; import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants.GuarantorJSONinputParams;
import org.apache.fineract.portfolio.loanaccount.guarantor.domain.GuarantorType; import org.apache.fineract.portfolio.loanaccount.guarantor.domain.GuarantorType;
@@ -91,7 +91,7 @@ public class GuarantorCommand {
} }
public Date getDobAsDate() { public Date getDobAsDate() {
return Date.from(this.dob.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); return Date.from(this.dob.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public void validateForCreate() { public void validateForCreate() {
@@ -21,12 +21,12 @@ package org.apache.fineract.portfolio.loanaccount.loanschedule.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.MathContext; import java.math.MathContext;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.domain.ApplicationCurrency; import org.apache.fineract.organisation.monetary.domain.ApplicationCurrency;
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.organisation.monetary.domain.Money; import org.apache.fineract.organisation.monetary.domain.Money;
@@ -1369,7 +1369,7 @@ public final class LoanApplicationTerms {
public Date getRepaymentStartFromDate() { public Date getRepaymentStartFromDate() {
Date dateValue = null; Date dateValue = null;
if (this.repaymentsStartingFromDate != null) { if (this.repaymentsStartingFromDate != null) {
dateValue = Date.from(this.repaymentsStartingFromDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); dateValue = Date.from(this.repaymentsStartingFromDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
return dateValue; return dateValue;
} }
@@ -1377,7 +1377,7 @@ public final class LoanApplicationTerms {
public Date getInterestChargedFromDate() { public Date getInterestChargedFromDate() {
Date dateValue = null; Date dateValue = null;
if (this.interestChargedFromDate != null) { if (this.interestChargedFromDate != null) {
dateValue = Date.from(this.interestChargedFromDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); dateValue = Date.from(this.interestChargedFromDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
return dateValue; return dateValue;
} }
@@ -25,6 +25,7 @@ import java.math.BigDecimal;
import java.math.MathContext; import java.math.MathContext;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoField; import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
@@ -441,8 +442,7 @@ public class LoanScheduleAssembler {
} }
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled(); final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId, final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId,
Date.from(expectedDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(expectedDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), HolidayStatusType.ACTIVE.getValue());
HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne(); final WorkingDays workingDays = this.workingDaysRepository.findOne();
HolidayDetailDTO detailDTO = new HolidayDetailDTO(isHolidayEnabled, holidays, workingDays); HolidayDetailDTO detailDTO = new HolidayDetailDTO(isHolidayEnabled, holidays, workingDays);
@@ -609,8 +609,7 @@ public class LoanScheduleAssembler {
final LocalDate expectedDisbursementDate = this.fromApiJsonHelper.extractLocalDateNamed("expectedDisbursementDate", element); final LocalDate expectedDisbursementDate = this.fromApiJsonHelper.extractLocalDateNamed("expectedDisbursementDate", element);
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId, final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId,
Date.from(expectedDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(expectedDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), HolidayStatusType.ACTIVE.getValue());
HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne(); final WorkingDays workingDays = this.workingDaysRepository.findOne();
validateDisbursementDateIsOnNonWorkingDay(loanApplicationTerms.getExpectedDisbursementDate(), workingDays); validateDisbursementDateIsOnNonWorkingDay(loanApplicationTerms.getExpectedDisbursementDate(), workingDays);
@@ -658,7 +657,7 @@ public class LoanScheduleAssembler {
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled(); final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId, final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId,
Date.from(loanApplicationTerms.getExpectedDisbursementDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(loanApplicationTerms.getExpectedDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
HolidayStatusType.ACTIVE.getValue()); HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne(); final WorkingDays workingDays = this.workingDaysRepository.findOne();
@@ -677,7 +676,7 @@ public class LoanScheduleAssembler {
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled(); final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId, final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(officeId,
Date.from(loanApplicationTerms.getExpectedDisbursementDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(loanApplicationTerms.getExpectedDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
HolidayStatusType.ACTIVE.getValue()); HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne(); final WorkingDays workingDays = this.workingDaysRepository.findOne();
HolidayDetailDTO holidayDetailDTO = new HolidayDetailDTO(isHolidayEnabled, holidays, workingDays); HolidayDetailDTO holidayDetailDTO = new HolidayDetailDTO(isHolidayEnabled, holidays, workingDays);
@@ -859,8 +858,8 @@ public class LoanScheduleAssembler {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
if (loan.getExpectedFirstRepaymentOnDate() == null) { if (loan.getExpectedFirstRepaymentOnDate() == null) {
loan.setExpectedFirstRepaymentOnDate(Date.from( loan.setExpectedFirstRepaymentOnDate(
loan.fetchRepaymentScheduleInstallment(1).getDueDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(loan.fetchRepaymentScheduleInstallment(1).getDueDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
} }
final LocalDate recalculateFrom = null; final LocalDate recalculateFrom = null;
ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom); ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom);
@@ -997,13 +996,13 @@ public class LoanScheduleAssembler {
LocalDate duedateLocalDate = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.dueDateParamName, arrayElement, LocalDate duedateLocalDate = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.dueDateParamName, arrayElement,
dateFormat, locale); dateFormat, locale);
Date dueDate = Date.from(duedateLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); Date dueDate = Date.from(duedateLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
LocalDate modifiedDuedateLocalDate = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.modifiedDueDateParamName, LocalDate modifiedDuedateLocalDate = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.modifiedDueDateParamName,
arrayElement, dateFormat, locale); arrayElement, dateFormat, locale);
Date modifiedDuedate = null; Date modifiedDuedate = null;
if (modifiedDuedateLocalDate != null) { if (modifiedDuedateLocalDate != null) {
modifiedDuedate = Date.from(modifiedDuedateLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); modifiedDuedate = Date.from(modifiedDuedateLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
boolean isSpecificToInstallment = true; boolean isSpecificToInstallment = true;
if (isInsertInstallment) { if (isInsertInstallment) {
@@ -19,10 +19,10 @@
package org.apache.fineract.portfolio.loanaccount.loanschedule.service; package org.apache.fineract.portfolio.loanaccount.loanschedule.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment; import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
@@ -60,13 +60,11 @@ public class LoanScheduleHistoryWritePlatformServiceImpl implements LoanSchedule
Date dueDate = null; Date dueDate = null;
if (repaymentScheduleInstallment.getFromDate() != null) { if (repaymentScheduleInstallment.getFromDate() != null) {
fromDate = Date fromDate = Date.from(repaymentScheduleInstallment.getFromDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
.from(repaymentScheduleInstallment.getFromDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
} }
if (repaymentScheduleInstallment.getDueDate() != null) { if (repaymentScheduleInstallment.getDueDate() != null) {
dueDate = Date dueDate = Date.from(repaymentScheduleInstallment.getDueDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
.from(repaymentScheduleInstallment.getDueDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
} }
final BigDecimal principal = repaymentScheduleInstallment.getPrincipal(currency).getAmount(); final BigDecimal principal = repaymentScheduleInstallment.getPrincipal(currency).getAmount();
@@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.loanaccount.rescheduleloan.domain; package org.apache.fineract.portfolio.loanaccount.rescheduleloan.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -274,7 +275,7 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom {
if (approvedOnDate != null) { if (approvedOnDate != null) {
this.approvedByUser = approvedByUser; this.approvedByUser = approvedByUser;
this.approvedOnDate = Date.from(approvedOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.approvedOnDate = Date.from(approvedOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.statusEnum = LoanStatus.APPROVED.getValue(); this.statusEnum = LoanStatus.APPROVED.getValue();
} }
} }
@@ -293,7 +294,7 @@ public class LoanRescheduleRequest extends AbstractPersistableCustom {
if (approvedOnDate != null) { if (approvedOnDate != null) {
this.rejectedByUser = approvedByUser; this.rejectedByUser = approvedByUser;
this.rejectedOnDate = Date.from(approvedOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.rejectedOnDate = Date.from(approvedOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.statusEnum = LoanStatus.REJECTED.getValue(); this.statusEnum = LoanStatus.REJECTED.getValue();
} }
} }
@@ -21,11 +21,11 @@ package org.apache.fineract.portfolio.loanaccount.rescheduleloan.service;
import java.math.MathContext; import java.math.MathContext;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.domain.MoneyHelper; import org.apache.fineract.organisation.monetary.domain.MoneyHelper;
import org.apache.fineract.portfolio.loanaccount.data.LoanTermVariationsData; import org.apache.fineract.portfolio.loanaccount.data.LoanTermVariationsData;
import org.apache.fineract.portfolio.loanaccount.data.ScheduleGeneratorDTO; import org.apache.fineract.portfolio.loanaccount.data.ScheduleGeneratorDTO;
@@ -109,8 +109,8 @@ public class LoanReschedulePreviewPlatformServiceImpl implements LoanRescheduleP
if (loanRescheduleRequestToTermVariationMapping.getLoanTermVariations().getTermType().isDueDateVariation() if (loanRescheduleRequestToTermVariationMapping.getLoanTermVariations().getTermType().isDueDateVariation()
&& rescheduleFromDate != null) { && rescheduleFromDate != null) {
adjustedApplicableDate = loanRescheduleRequestToTermVariationMapping.getLoanTermVariations().fetchDateValue(); adjustedApplicableDate = loanRescheduleRequestToTermVariationMapping.getLoanTermVariations().fetchDateValue();
loanRescheduleRequestToTermVariationMapping.getLoanTermVariations().setTermApplicableFrom( loanRescheduleRequestToTermVariationMapping.getLoanTermVariations()
Date.from(rescheduleFromDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); .setTermApplicableFrom(Date.from(rescheduleFromDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
} }
loanTermVariationsData.add(loanRescheduleRequestToTermVariationMapping.getLoanTermVariations().toData()); loanTermVariationsData.add(loanRescheduleRequestToTermVariationMapping.getLoanTermVariations().toData());
} }
@@ -22,6 +22,7 @@ import java.math.BigDecimal;
import java.math.MathContext; import java.math.MathContext;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -226,7 +227,7 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
if (localDate != null) { if (localDate != null) {
// update the value of the "submittedOnDate" variable // update the value of the "submittedOnDate" variable
submittedOnDate = Date.from(localDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); submittedOnDate = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -251,7 +252,7 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
rescheduleFromInstallment = installment.getInstallmentNumber(); rescheduleFromInstallment = installment.getInstallmentNumber();
// update the value of the "rescheduleFromDate" variable // update the value of the "rescheduleFromDate" variable
rescheduleFromDate = Date.from(localDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); rescheduleFromDate = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -262,7 +263,7 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
if (localDate != null) { if (localDate != null) {
// update the value of the "adjustedDueDate"variable // update the value of the "adjustedDueDate"variable
adjustedDueDate = Date.from(localDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); adjustedDueDate = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -316,8 +317,8 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
if (installment.getDueDate().isEqual(rescheduleFromLocDate) || installment.getDueDate().isEqual(endDateLocDate) if (installment.getDueDate().isEqual(rescheduleFromLocDate) || installment.getDueDate().isEqual(endDateLocDate)
|| (installment.getDueDate().isAfter(rescheduleFromLocDate) && installment.getDueDate().isBefore(endDateLocDate))) { || (installment.getDueDate().isAfter(rescheduleFromLocDate) && installment.getDueDate().isBefore(endDateLocDate))) {
createLoanTermVariations(termType, loan, createLoanTermVariations(termType, loan,
Date.from(installment.getDueDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(installment.getDueDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
Date.from(installment.getDueDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(installment.getDueDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
loanRescheduleRequestToTermVariationMappings, isActive, true, emi, parent); loanRescheduleRequestToTermVariationMappings, isActive, true, emi, parent);
} }
if (installment.getDueDate().isAfter(endDateLocDate)) { if (installment.getDueDate().isAfter(endDateLocDate)) {
@@ -429,8 +430,8 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
&& activeLoanTermVariation.fetchDateValue().equals(dueDateVariationInCurrentRequest.fetchTermApplicaDate())) { && activeLoanTermVariation.fetchDateValue().equals(dueDateVariationInCurrentRequest.fetchTermApplicaDate())) {
activeLoanTermVariation.markAsInactive(); activeLoanTermVariation.markAsInactive();
rescheduleFromDate = activeLoanTermVariation.fetchTermApplicaDate(); rescheduleFromDate = activeLoanTermVariation.fetchTermApplicaDate();
dueDateVariationInCurrentRequest.setTermApplicableFrom( dueDateVariationInCurrentRequest
Date.from(rescheduleFromDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); .setTermApplicableFrom(Date.from(rescheduleFromDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
} else if (!activeLoanTermVariation.fetchTermApplicaDate().isBefore(fromScheduleDate)) { } else if (!activeLoanTermVariation.fetchTermApplicaDate().isBefore(fromScheduleDate)) {
while (currentScheduleDate.isBefore(activeLoanTermVariation.fetchTermApplicaDate())) { while (currentScheduleDate.isBefore(activeLoanTermVariation.fetchTermApplicaDate())) {
currentScheduleDate = this.scheduledDateGenerator.generateNextRepaymentDate(currentScheduleDate, currentScheduleDate = this.scheduledDateGenerator.generateNextRepaymentDate(currentScheduleDate,
@@ -440,9 +441,8 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
changeMap.put(currentScheduleDate, modifiedScheduleDate); changeMap.put(currentScheduleDate, modifiedScheduleDate);
} }
if (changeMap.containsKey(activeLoanTermVariation.fetchTermApplicaDate())) { if (changeMap.containsKey(activeLoanTermVariation.fetchTermApplicaDate())) {
activeLoanTermVariation activeLoanTermVariation.setTermApplicableFrom(Date.from(changeMap
.setTermApplicableFrom(Date.from(changeMap.get(activeLoanTermVariation.fetchTermApplicaDate()) .get(activeLoanTermVariation.fetchTermApplicaDate()).atStartOfDay(ZoneId.systemDefault()).toInstant()));
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
} }
} }
} }
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.loanaccount.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -270,9 +271,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," 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 (?, ?, 0, ?, ?, ?, ?, ?, ?, ?)"; + "fee_charges_portion_derived,penalty_charges_portion_derived, submitted_on_date) VALUES (?, ?, 0, ?, ?, ?, ?, ?, ?, ?)";
this.jdbcTemplate.update(transactionSql, scheduleAccrualData.getLoanId(), scheduleAccrualData.getOfficeId(), this.jdbcTemplate.update(transactionSql, scheduleAccrualData.getLoanId(), scheduleAccrualData.getOfficeId(),
LoanTransactionType.ACCRUAL.getValue(), LoanTransactionType.ACCRUAL.getValue(), Date.from(accruedTill.atStartOfDay(ZoneId.systemDefault()).toInstant()), amount,
Date.from(accruedTill.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), amount, interestportion, feeportion, interestportion, feeportion, penaltyportion, DateUtils.getDateOfTenant());
penaltyportion, DateUtils.getDateOfTenant());
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
final Long transactonId = this.jdbcTemplate.queryForObject("SELECT LAST_INSERT_ID()", Long.class); final Long transactonId = this.jdbcTemplate.queryForObject("SELECT LAST_INSERT_ID()", Long.class);
@@ -293,7 +293,7 @@ public class LoanAccrualWritePlatformServiceImpl implements LoanAccrualWritePlat
scheduleAccrualData.getRepaymentScheduleId()); scheduleAccrualData.getRepaymentScheduleId());
String updateLoan = "UPDATE m_loan SET accrued_till=? WHERE id=?"; String updateLoan = "UPDATE m_loan SET accrued_till=? WHERE id=?";
this.jdbcTemplate.update(updateLoan, Date.from(accruedTill.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), this.jdbcTemplate.update(updateLoan, Date.from(accruedTill.atStartOfDay(ZoneId.systemDefault()).toInstant()),
scheduleAccrualData.getLoanId()); scheduleAccrualData.getLoanId());
final Map<String, Object> accountingBridgeData = deriveAccountingBridgeData(scheduleAccrualData, transactionMap); final Map<String, Object> accountingBridgeData = deriveAccountingBridgeData(scheduleAccrualData, transactionMap);
this.journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData); this.journalEntryWritePlatformService.createJournalEntriesForLoan(accountingBridgeData);
@@ -21,6 +21,7 @@ package org.apache.fineract.portfolio.loanaccount.service;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
@@ -35,7 +36,6 @@ import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDoma
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.holiday.domain.Holiday; import org.apache.fineract.organisation.holiday.domain.Holiday;
import org.apache.fineract.organisation.holiday.domain.HolidayRepository; import org.apache.fineract.organisation.holiday.domain.HolidayRepository;
import org.apache.fineract.organisation.holiday.domain.HolidayStatusType; import org.apache.fineract.organisation.holiday.domain.HolidayStatusType;
@@ -333,7 +333,7 @@ public class LoanAssembler {
final LoanApplicationTerms loanApplicationTerms = this.loanScheduleAssembler.assembleLoanTerms(element); final LoanApplicationTerms loanApplicationTerms = this.loanScheduleAssembler.assembleLoanTerms(element);
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled(); final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loanApplication.getOfficeId(), final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loanApplication.getOfficeId(),
Date.from(loanApplicationTerms.getExpectedDisbursementDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(loanApplicationTerms.getExpectedDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
HolidayStatusType.ACTIVE.getValue()); HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne(); final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled(); final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled();
@@ -391,7 +391,7 @@ public class LoanAssembler {
final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled(); final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loanApplication.getOfficeId(), final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loanApplication.getOfficeId(),
Date.from(loanApplication.getExpectedDisbursedOnLocalDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(loanApplication.getExpectedDisbursedOnLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
HolidayStatusType.ACTIVE.getValue()); HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne(); final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled(); final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled();
@@ -24,6 +24,7 @@ import java.math.BigDecimal;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
@@ -2078,13 +2079,13 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final Collection<InterestRatePeriodData> intRates = this.floatingRatesReadPlatformService final Collection<InterestRatePeriodData> intRates = this.floatingRatesReadPlatformService
.retrieveInterestRatePeriods(loanData.loanProductId()); .retrieveInterestRatePeriods(loanData.loanProductId());
for (final InterestRatePeriodData rate : intRates) { for (final InterestRatePeriodData rate : intRates) {
if (rate.getFromDate().compareTo( if (rate.getFromDate()
Date.from(loanData.getDisbursementDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())) > 0 .compareTo(Date.from(loanData.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant())) > 0
&& loanData.isFloatingInterestRate()) { && loanData.isFloatingInterestRate()) {
updateInterestRatePeriodData(rate, loanData); updateInterestRatePeriodData(rate, loanData);
intRatePeriodData.add(rate); intRatePeriodData.add(rate);
} else if (rate.getFromDate().compareTo( } else if (rate.getFromDate()
Date.from(loanData.getDisbursementDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())) <= 0) { .compareTo(Date.from(loanData.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant())) <= 0) {
updateInterestRatePeriodData(rate, loanData); updateInterestRatePeriodData(rate, loanData);
intRatePeriodData.add(rate); intRatePeriodData.add(rate);
break; break;
@@ -2110,9 +2111,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
} }
rate.setEffectiveInterestRate(effectiveInterestRate); rate.setEffectiveInterestRate(effectiveInterestRate);
if (rate.getFromDate() if (rate.getFromDate().compareTo(Date.from(loan.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant())) < 0) {
.compareTo(Date.from(loan.getDisbursementDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())) < 0) { rate.setFromDate(Date.from(loan.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
rate.setFromDate(Date.from(loan.getDisbursementDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
} }
} }
@@ -22,6 +22,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -30,7 +31,6 @@ import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService; import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.holiday.domain.Holiday; import org.apache.fineract.organisation.holiday.domain.Holiday;
import org.apache.fineract.organisation.holiday.domain.HolidayRepository; import org.apache.fineract.organisation.holiday.domain.HolidayRepository;
import org.apache.fineract.organisation.holiday.domain.HolidayStatusType; import org.apache.fineract.organisation.holiday.domain.HolidayStatusType;
@@ -190,7 +190,7 @@ public class LoanUtilService {
private HolidayDetailDTO constructHolidayDTO(final Loan loan) { private HolidayDetailDTO constructHolidayDTO(final Loan loan) {
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled(); final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
Date.from(loan.getDisbursementDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(loan.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
HolidayStatusType.ACTIVE.getValue()); HolidayStatusType.ACTIVE.getValue());
final WorkingDays workingDays = this.workingDaysRepository.findOne(); final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled(); final boolean allowTransactionsOnHoliday = this.configurationDomainService.allowTransactionsOnHolidayEnabled();
@@ -323,7 +323,7 @@ public class LoanUtilService {
LocalDate date = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.disbursementDateParameterName, LocalDate date = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.disbursementDateParameterName,
jsonObject, dateFormat, locale); jsonObject, dateFormat, locale);
if (date != null) { if (date != null) {
expectedDisbursementDate = Date.from(date.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); expectedDisbursementDate = Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
if (jsonObject.has(LoanApiConstants.disbursementPrincipalParameterName) if (jsonObject.has(LoanApiConstants.disbursementPrincipalParameterName)
@@ -24,6 +24,7 @@ import com.google.gson.JsonObject;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -399,7 +400,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
LocalDate recalculateFrom = null; LocalDate recalculateFrom = null;
if (!loan.isMultiDisburmentLoan()) { if (!loan.isMultiDisburmentLoan()) {
loan.setActualDisbursementDate(Date.from(actualDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); loan.setActualDisbursementDate(Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
} }
ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom); ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom);
@@ -972,8 +973,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
for (final SingleRepaymentCommand singleLoanRepaymentCommand : repaymentCommand) { for (final SingleRepaymentCommand singleLoanRepaymentCommand : repaymentCommand) {
if (singleLoanRepaymentCommand != null) { if (singleLoanRepaymentCommand != null) {
Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(singleLoanRepaymentCommand.getLoanId()); Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(singleLoanRepaymentCommand.getLoanId());
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), Date.from( final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
singleLoanRepaymentCommand.getTransactionDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(singleLoanRepaymentCommand.getTransactionDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
final WorkingDays workingDays = this.workingDaysRepository.findOne(); final WorkingDays workingDays = this.workingDaysRepository.findOne();
final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled(); final boolean allowTransactionsOnNonWorkingDay = this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled();
boolean isHolidayEnabled = false; boolean isHolidayEnabled = false;
@@ -2409,7 +2410,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
Date.from(loan.getDisbursementDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(loan.getDisbursementDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) { if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
ScheduleGeneratorDTO scheduleGeneratorDTO = loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom); ScheduleGeneratorDTO scheduleGeneratorDTO = loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom);
loan.setHelpers(null, this.loanSummaryWrapper, this.transactionProcessingStrategy); loan.setHelpers(null, this.loanSummaryWrapper, this.transactionProcessingStrategy);
@@ -2463,14 +2464,14 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
if (loan.isGroupLoan()) { if (loan.isGroupLoan()) {
final List<Loan> loansToUpdateForLoanCounter = this.loanRepositoryWrapper.getGroupLoansDisbursedAfter( final List<Loan> loansToUpdateForLoanCounter = this.loanRepositoryWrapper.getGroupLoansDisbursedAfter(
Date.from(actualDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), loan.getGroupId(), Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), loan.getGroupId(),
AccountType.GROUP.getValue()); AccountType.GROUP.getValue());
final Integer newLoanCounter = getNewGroupLoanCounter(loan); final Integer newLoanCounter = getNewGroupLoanCounter(loan);
final Integer newLoanProductCounter = getNewGroupLoanProductCounter(loan); final Integer newLoanProductCounter = getNewGroupLoanProductCounter(loan);
updateLoanCounter(loan, loansToUpdateForLoanCounter, newLoanCounter, newLoanProductCounter); updateLoanCounter(loan, loansToUpdateForLoanCounter, newLoanCounter, newLoanProductCounter);
} else { } else {
final List<Loan> loansToUpdateForLoanCounter = this.loanRepositoryWrapper.getClientOrJLGLoansDisbursedAfter( final List<Loan> loansToUpdateForLoanCounter = this.loanRepositoryWrapper.getClientOrJLGLoansDisbursedAfter(
Date.from(actualDisbursementDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), loan.getClientId()); Date.from(actualDisbursementDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), loan.getClientId());
final Integer newLoanCounter = getNewClientOrJLGLoanCounter(loan); final Integer newLoanCounter = getNewClientOrJLGLoanCounter(loan);
final Integer newLoanProductCounter = getNewClientOrJLGLoanProductCounter(loan); final Integer newLoanProductCounter = getNewClientOrJLGLoanProductCounter(loan);
updateLoanCounter(loan, loansToUpdateForLoanCounter, newLoanCounter, newLoanProductCounter); updateLoanCounter(loan, loansToUpdateForLoanCounter, newLoanCounter, newLoanProductCounter);
@@ -3325,8 +3326,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
private void validateTransactionsForTransfer(final Loan loan, final LocalDate transferDate) { private void validateTransactionsForTransfer(final Loan loan, final LocalDate transferDate) {
for (LoanTransaction transaction : loan.getLoanTransactions()) { for (LoanTransaction transaction : loan.getLoanTransactions()) {
if ((transaction.getTransactionDate().isEqual(transferDate) && transaction.getCreatedDateTime() if ((transaction.getTransactionDate().isEqual(transferDate)
.isEqual(transferDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toLocalDateTime())) && transaction.getCreatedDateTime().isEqual(transferDate.atStartOfDay(ZoneId.systemDefault()).toLocalDateTime()))
|| transaction.getTransactionDate().isAfter(transferDate)) { || transaction.getTransactionDate().isAfter(transferDate)) {
throw new GeneralPlatformDomainRuleException(TransferApiConstants.transferClientLoanException, throw new GeneralPlatformDomainRuleException(TransferApiConstants.transferClientLoanException,
TransferApiConstants.transferClientLoanExceptionMessage, transaction.getCreatedDateTime().toLocalDate(), TransferApiConstants.transferClientLoanExceptionMessage, transaction.getCreatedDateTime().toLocalDate(),
@@ -22,6 +22,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
@@ -642,11 +643,11 @@ public class LoanProduct extends AbstractPersistableCustom {
this.useBorrowerCycle = useBorrowerCycle; this.useBorrowerCycle = useBorrowerCycle;
if (startDate != null) { if (startDate != null) {
this.startDate = Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (closeDate != null) { if (closeDate != null) {
this.closeDate = Date.from(closeDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closeDate = Date.from(closeDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
this.externalId = externalId; this.externalId = externalId;
@@ -878,7 +879,7 @@ public class LoanProduct extends AbstractPersistableCustom {
final LocalDate newValue = command.localDateValueOfParameterNamed(startDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(startDateParamName);
if (newValue != null) { if (newValue != null) {
this.startDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} else { } else {
this.startDate = null; this.startDate = null;
} }
@@ -893,7 +894,7 @@ public class LoanProduct extends AbstractPersistableCustom {
final LocalDate newValue = command.localDateValueOfParameterNamed(closeDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(closeDateParamName);
if (newValue != null) { if (newValue != null) {
this.closeDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closeDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} else { } else {
this.closeDate = null; this.closeDate = null;
} }
@@ -24,6 +24,7 @@ import static org.apache.fineract.portfolio.meeting.MeetingApiConstants.clientsA
import static org.apache.fineract.portfolio.meeting.MeetingApiConstants.meetingDateParamName; import static org.apache.fineract.portfolio.meeting.MeetingApiConstants.meetingDateParamName;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
@@ -106,7 +107,7 @@ public class Meeting extends AbstractPersistableCustom {
actualChanges.put(meetingDateParamName, valueAsInput); actualChanges.put(meetingDateParamName, valueAsInput);
actualChanges.put("dateFormat", dateFormatAsInput); actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
this.meetingDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.meetingDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
if (!isValidMeetingDate(this.calendarInstance, this.meetingDate, isSkipRepaymentOnFirstMonth, numberOfDays)) { if (!isValidMeetingDate(this.calendarInstance, this.meetingDate, isSkipRepaymentOnFirstMonth, numberOfDays)) {
throw new NotValidRecurringDateException("meeting", "Not a valid meeting date", this.meetingDate); throw new NotValidRecurringDateException("meeting", "Not a valid meeting date", this.meetingDate);
@@ -25,6 +25,7 @@ import static org.apache.fineract.portfolio.savings.DepositsApiConstants.transfe
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.MathContext; import java.math.MathContext;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
@@ -308,8 +309,7 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
account.updateOnAccountClosureStatus(onClosureType); account.updateOnAccountClosureStatus(onClosureType);
} }
changes.put("reinvestedDepositId", reinvestedDeposit.getId()); changes.put("reinvestedDepositId", reinvestedDeposit.getId());
reinvestedDeposit.approveAndActivateApplication( reinvestedDeposit.approveAndActivateApplication(Date.from(closedDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), user);
Date.from(closedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), user);
this.savingsAccountRepository.save(reinvestedDeposit); this.savingsAccountRepository.save(reinvestedDeposit);
} else if (onClosureType.isTransferToSavings()) { } else if (onClosureType.isTransferToSavings()) {
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.savings.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
import javax.persistence.Column; import javax.persistence.Column;
@@ -72,7 +73,7 @@ public class DepositAccountOnHoldTransaction extends AbstractPersistableCustom {
this.savingsAccount = savingsAccount; this.savingsAccount = savingsAccount;
this.amount = amount; this.amount = amount;
this.transactionType = transactionType.getValue(); this.transactionType = transactionType.getValue();
this.transactionDate = Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.transactionDate = Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.createdDate = new Date(); this.createdDate = new Date();
this.reversed = reversed; this.reversed = reversed;
} }
@@ -30,6 +30,7 @@ import static org.apache.fineract.portfolio.savings.DepositsApiConstants.transfe
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -113,15 +114,14 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistableCustom {
final DepositAccountOnClosureType accountOnClosureType, Boolean transferInterest, Long transferToSavingsId) { final DepositAccountOnClosureType accountOnClosureType, Boolean transferInterest, Long transferToSavingsId) {
this.depositAmount = depositAmount; this.depositAmount = depositAmount;
this.maturityAmount = maturityAmount; this.maturityAmount = maturityAmount;
this.maturityDate = (maturityDate == null) ? null this.maturityDate = (maturityDate == null) ? null : Date.from(maturityDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
: Date.from(maturityDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
this.depositPeriod = depositPeriod; this.depositPeriod = depositPeriod;
this.depositPeriodFrequency = (depositPeriodFrequency == null) ? null : depositPeriodFrequency.getValue(); this.depositPeriodFrequency = (depositPeriodFrequency == null) ? null : depositPeriodFrequency.getValue();
this.preClosureDetail = preClosureDetail; this.preClosureDetail = preClosureDetail;
this.depositTermDetail = depositTermDetail; this.depositTermDetail = depositTermDetail;
this.account = account; this.account = account;
this.expectedFirstDepositOnDate = expectedFirstDepositOnDate == null ? null this.expectedFirstDepositOnDate = expectedFirstDepositOnDate == null ? null
: Date.from(expectedFirstDepositOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); : Date.from(expectedFirstDepositOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.onAccountClosureType = (accountOnClosureType == null) ? null : accountOnClosureType.getValue(); this.onAccountClosureType = (accountOnClosureType == null) ? null : accountOnClosureType.getValue();
this.transferInterestToLinkedAccount = transferInterest; this.transferInterestToLinkedAccount = transferInterest;
this.transferToSavingsAccountId = transferToSavingsId; this.transferToSavingsAccountId = transferToSavingsId;
@@ -156,7 +156,7 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistableCustom {
actualChanges.put(expectedFirstDepositOnDateParamName, newValueAsString); actualChanges.put(expectedFirstDepositOnDateParamName, newValueAsString);
actualChanges.put(localeParamName, localeAsInput); actualChanges.put(localeParamName, localeAsInput);
actualChanges.put(dateFormatParamName, dateFormat); actualChanges.put(dateFormatParamName, dateFormat);
this.expectedFirstDepositOnDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.expectedFirstDepositOnDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (command.isChangeInBooleanParameterNamed(transferInterestToSavingsParamName, this.transferInterestToLinkedAccount)) { if (command.isChangeInBooleanParameterNamed(transferInterestToSavingsParamName, this.transferInterestToLinkedAccount)) {
@@ -219,13 +219,13 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistableCustom {
public void updateMaturityDetails(final BigDecimal maturityAmount, final LocalDate maturityDate) { public void updateMaturityDetails(final BigDecimal maturityAmount, final LocalDate maturityDate) {
this.maturityAmount = maturityAmount; this.maturityAmount = maturityAmount;
this.maturityDate = Date.from(maturityDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.maturityDate = Date.from(maturityDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public void updateMaturityDetails(final BigDecimal depositAmount, final BigDecimal interestPayable, final LocalDate maturityDate) { public void updateMaturityDetails(final BigDecimal depositAmount, final BigDecimal interestPayable, final LocalDate maturityDate) {
this.depositAmount = depositAmount; this.depositAmount = depositAmount;
this.maturityAmount = this.depositAmount.add(interestPayable); this.maturityAmount = this.depositAmount.add(interestPayable);
this.maturityDate = Date.from(maturityDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.maturityDate = Date.from(maturityDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public void updateDepositAmount(final BigDecimal depositAmount) { public void updateDepositAmount(final BigDecimal depositAmount) {
@@ -325,8 +325,7 @@ public class DepositAccountTermAndPreClosure extends AbstractPersistableCustom {
} }
public void updateExpectedFirstDepositDate(final LocalDate expectedFirstDepositOnDate) { public void updateExpectedFirstDepositDate(final LocalDate expectedFirstDepositOnDate) {
this.expectedFirstDepositOnDate = Date this.expectedFirstDepositOnDate = Date.from(expectedFirstDepositOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
.from(expectedFirstDepositOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant());
} }
public boolean isTransferInterestToLinkedAccount() { public boolean isTransferInterestToLinkedAccount() {
@@ -26,6 +26,7 @@ import static org.apache.fineract.portfolio.savings.DepositsApiConstants.onAccou
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.MathContext; import java.math.MathContext;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -419,7 +420,7 @@ public class FixedDepositAccount extends SavingsAccount {
this.rejectedBy = null; this.rejectedBy = null;
this.withdrawnOnDate = null; this.withdrawnOnDate = null;
this.withdrawnBy = null; this.withdrawnBy = null;
this.closedOnDate = Date.from(closedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(closedDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.closedBy = currentUser; this.closedBy = currentUser;
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions); this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
} }
@@ -507,7 +508,7 @@ public class FixedDepositAccount extends SavingsAccount {
this.rejectedBy = null; this.rejectedBy = null;
this.withdrawnOnDate = null; this.withdrawnOnDate = null;
this.withdrawnBy = null; this.withdrawnBy = null;
this.closedOnDate = Date.from(closedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(closedDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.closedBy = currentUser; this.closedBy = currentUser;
// this.summary.updateSummary(this.currency, // this.summary.updateSummary(this.currency,
// this.savingsAccountTransactionSummaryWrapper, this.transactions); // this.savingsAccountTransactionSummaryWrapper, this.transactions);
@@ -26,6 +26,7 @@ import static org.apache.fineract.portfolio.savings.DepositsApiConstants.onAccou
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.MathContext; import java.math.MathContext;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -388,7 +389,7 @@ public class RecurringDepositAccount extends SavingsAccount {
} }
final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(null, office(), null, dueDate, final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(null, office(), null, dueDate,
installment.getDepositAmountOutstanding(getCurrency()), installment.getDepositAmountOutstanding(getCurrency()),
Date.from(installment.dueDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), null); Date.from(installment.dueDate().atStartOfDay(ZoneId.systemDefault()).toInstant()), null);
allTransactions.add(transaction); allTransactions.add(transaction);
} }
} }
@@ -525,7 +526,7 @@ public class RecurringDepositAccount extends SavingsAccount {
this.rejectedBy = null; this.rejectedBy = null;
this.withdrawnOnDate = null; this.withdrawnOnDate = null;
this.withdrawnBy = null; this.withdrawnBy = null;
this.closedOnDate = Date.from(closedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(closedDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.closedBy = currentUser; this.closedBy = currentUser;
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions); this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
@@ -624,7 +625,7 @@ public class RecurringDepositAccount extends SavingsAccount {
this.rejectedBy = null; this.rejectedBy = null;
this.withdrawnOnDate = null; this.withdrawnOnDate = null;
this.withdrawnBy = null; this.withdrawnBy = null;
this.closedOnDate = Date.from(closedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(closedDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.closedBy = currentUser; this.closedBy = currentUser;
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions); this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
} }
@@ -1156,11 +1157,11 @@ public class RecurringDepositAccount extends SavingsAccount {
this.activatedBy = null; this.activatedBy = null;
this.lockedInUntilDate = null; this.lockedInUntilDate = null;
this.activatedOnDate = Date.from(now.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.activatedOnDate = Date.from(now.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public void setClosedOnDate(final LocalDate closedOnDate) { public void setClosedOnDate(final LocalDate closedOnDate) {
this.closedOnDate = Date.from(closedOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(closedOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
@Override @Override
@@ -1182,7 +1183,7 @@ public class RecurringDepositAccount extends SavingsAccount {
final BigDecimal depositAmount = this.recurringDetail.mandatoryRecommendedDepositAmount(); final BigDecimal depositAmount = this.recurringDetail.mandatoryRecommendedDepositAmount();
while (maturityDate.isAfter(installmentDate)) { while (maturityDate.isAfter(installmentDate)) {
final RecurringDepositScheduleInstallment installment = RecurringDepositScheduleInstallment.installment(this, installmentNumber, final RecurringDepositScheduleInstallment installment = RecurringDepositScheduleInstallment.installment(this, installmentNumber,
Date.from(installmentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), depositAmount); Date.from(installmentDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), depositAmount);
addDepositScheduleInstallment(installment); addDepositScheduleInstallment(installment);
installmentDate = DepositAccountUtils.calculateNextDepositDate(installmentDate, frequency, recurringEvery); installmentDate = DepositAccountUtils.calculateNextDepositDate(installmentDate, frequency, recurringEvery);
installmentNumber += 1; installmentNumber += 1;
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.savings.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
@@ -198,7 +199,7 @@ public class RecurringDepositScheduleInstallment extends AbstractAuditableCustom
private void checkIfInstallmentObligationsAreMet(final LocalDate transactionDate, final MonetaryCurrency currency) { private void checkIfInstallmentObligationsAreMet(final LocalDate transactionDate, final MonetaryCurrency currency) {
this.obligationsMet = getTotalOutstanding(currency).isZero(); this.obligationsMet = getTotalOutstanding(currency).isZero();
if (this.obligationsMet) { if (this.obligationsMet) {
this.obligationsMetOnDate = Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.obligationsMetOnDate = Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -36,6 +36,7 @@ import com.google.gson.JsonArray;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.MathContext; import java.math.MathContext;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -398,7 +399,7 @@ public class SavingsAccount extends AbstractPersistableCustom {
this.externalId = externalId; this.externalId = externalId;
this.status = status.getValue(); this.status = status.getValue();
this.accountType = accountType.getValue(); this.accountType = accountType.getValue();
this.submittedOnDate = Date.from(submittedOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.submittedOnDate = Date.from(submittedOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.submittedBy = submittedBy; this.submittedBy = submittedBy;
this.nominalAnnualInterestRate = nominalAnnualInterestRate; this.nominalAnnualInterestRate = nominalAnnualInterestRate;
this.interestCompoundingPeriodType = interestCompoundingPeriodType.getValue(); this.interestCompoundingPeriodType = interestCompoundingPeriodType.getValue();
@@ -1267,7 +1268,7 @@ public class SavingsAccount extends AbstractPersistableCustom {
actualChanges.put(SavingsApiConstants.submittedOnDateParamName, newValueAsString); actualChanges.put(SavingsApiConstants.submittedOnDateParamName, newValueAsString);
actualChanges.put(SavingsApiConstants.localeParamName, localeAsInput); actualChanges.put(SavingsApiConstants.localeParamName, localeAsInput);
actualChanges.put(SavingsApiConstants.dateFormatParamName, dateFormat); actualChanges.put(SavingsApiConstants.dateFormatParamName, dateFormat);
this.submittedOnDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.submittedOnDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (command.isChangeInStringParameterNamed(SavingsApiConstants.accountNoParamName, this.accountNumber)) { if (command.isChangeInStringParameterNamed(SavingsApiConstants.accountNoParamName, this.accountNumber)) {
@@ -1875,7 +1876,7 @@ public class SavingsAccount extends AbstractPersistableCustom {
final LocalDate approvedOn = command.localDateValueOfParameterNamed(SavingsApiConstants.approvedOnDateParamName); final LocalDate approvedOn = command.localDateValueOfParameterNamed(SavingsApiConstants.approvedOnDateParamName);
final String approvedOnDateChange = command.stringValueOfParameterNamed(SavingsApiConstants.approvedOnDateParamName); final String approvedOnDateChange = command.stringValueOfParameterNamed(SavingsApiConstants.approvedOnDateParamName);
this.approvedOnDate = Date.from(approvedOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.approvedOnDate = Date.from(approvedOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.approvedBy = currentUser; this.approvedBy = currentUser;
actualChanges.put(SavingsApiConstants.localeParamName, command.locale()); actualChanges.put(SavingsApiConstants.localeParamName, command.locale());
actualChanges.put(SavingsApiConstants.dateFormatParamName, command.dateFormat()); actualChanges.put(SavingsApiConstants.dateFormatParamName, command.dateFormat());
@@ -1997,12 +1998,12 @@ public class SavingsAccount extends AbstractPersistableCustom {
if (transaction.isAnnualFeeAndNotReversed()) { if (transaction.isAnnualFeeAndNotReversed()) {
if (lastAnnualFeeTransactionDate == null) { if (lastAnnualFeeTransactionDate == null) {
lastAnnualFeeTransactionDate = transaction.transactionLocalDate(); lastAnnualFeeTransactionDate = transaction.transactionLocalDate();
nextDueDate = Date.from(lastAnnualFeeTransactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); nextDueDate = Date.from(lastAnnualFeeTransactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (transaction.transactionLocalDate().isAfter(lastAnnualFeeTransactionDate)) { if (transaction.transactionLocalDate().isAfter(lastAnnualFeeTransactionDate)) {
lastAnnualFeeTransactionDate = transaction.transactionLocalDate(); lastAnnualFeeTransactionDate = transaction.transactionLocalDate();
nextDueDate = Date.from(lastAnnualFeeTransactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); nextDueDate = Date.from(lastAnnualFeeTransactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
} }
@@ -2035,11 +2036,11 @@ public class SavingsAccount extends AbstractPersistableCustom {
final LocalDate rejectedOn = command.localDateValueOfParameterNamed(SavingsApiConstants.rejectedOnDateParamName); final LocalDate rejectedOn = command.localDateValueOfParameterNamed(SavingsApiConstants.rejectedOnDateParamName);
final String rejectedOnAsString = command.stringValueOfParameterNamed(SavingsApiConstants.rejectedOnDateParamName); final String rejectedOnAsString = command.stringValueOfParameterNamed(SavingsApiConstants.rejectedOnDateParamName);
this.rejectedOnDate = Date.from(rejectedOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.rejectedOnDate = Date.from(rejectedOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.rejectedBy = currentUser; this.rejectedBy = currentUser;
this.withdrawnOnDate = null; this.withdrawnOnDate = null;
this.withdrawnBy = null; this.withdrawnBy = null;
this.closedOnDate = Date.from(rejectedOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(rejectedOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.closedBy = currentUser; this.closedBy = currentUser;
actualChanges.put(SavingsApiConstants.localeParamName, command.locale()); actualChanges.put(SavingsApiConstants.localeParamName, command.locale());
@@ -2103,9 +2104,9 @@ public class SavingsAccount extends AbstractPersistableCustom {
this.rejectedOnDate = null; this.rejectedOnDate = null;
this.rejectedBy = null; this.rejectedBy = null;
this.withdrawnOnDate = Date.from(withdrawnOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.withdrawnOnDate = Date.from(withdrawnOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.withdrawnBy = currentUser; this.withdrawnBy = currentUser;
this.closedOnDate = Date.from(withdrawnOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(withdrawnOn.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.closedBy = currentUser; this.closedBy = currentUser;
actualChanges.put(SavingsApiConstants.localeParamName, command.locale()); actualChanges.put(SavingsApiConstants.localeParamName, command.locale());
@@ -2176,7 +2177,7 @@ public class SavingsAccount extends AbstractPersistableCustom {
this.withdrawnBy = null; this.withdrawnBy = null;
this.closedOnDate = null; this.closedOnDate = null;
this.closedBy = null; this.closedBy = null;
this.activatedOnDate = Date.from(activationDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.activatedOnDate = Date.from(activationDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.activatedBy = currentUser; this.activatedBy = currentUser;
this.lockedInUntilDate = calculateDateAccountIsLockedUntil(getActivationLocalDate()); this.lockedInUntilDate = calculateDateAccountIsLockedUntil(getActivationLocalDate());
@@ -2351,7 +2352,7 @@ public class SavingsAccount extends AbstractPersistableCustom {
this.rejectedBy = null; this.rejectedBy = null;
this.withdrawnOnDate = null; this.withdrawnOnDate = null;
this.withdrawnBy = null; this.withdrawnBy = null;
this.closedOnDate = Date.from(closedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.closedOnDate = Date.from(closedDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.closedBy = currentUser; this.closedBy = currentUser;
return actualChanges; return actualChanges;
@@ -2380,20 +2381,20 @@ public class SavingsAccount extends AbstractPersistableCustom {
case INVALID: case INVALID:
break; break;
case DAYS: case DAYS:
lockedInUntilLocalDate = Date.from(activationLocalDate.plusDays(this.lockinPeriodFrequency) lockedInUntilLocalDate = Date
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); .from(activationLocalDate.plusDays(this.lockinPeriodFrequency).atStartOfDay(ZoneId.systemDefault()).toInstant());
break; break;
case WEEKS: case WEEKS:
lockedInUntilLocalDate = Date.from(activationLocalDate.plusWeeks(this.lockinPeriodFrequency) lockedInUntilLocalDate = Date
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); .from(activationLocalDate.plusWeeks(this.lockinPeriodFrequency).atStartOfDay(ZoneId.systemDefault()).toInstant());
break; break;
case MONTHS: case MONTHS:
lockedInUntilLocalDate = Date.from(activationLocalDate.plusMonths(this.lockinPeriodFrequency) lockedInUntilLocalDate = Date
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); .from(activationLocalDate.plusMonths(this.lockinPeriodFrequency).atStartOfDay(ZoneId.systemDefault()).toInstant());
break; break;
case YEARS: case YEARS:
lockedInUntilLocalDate = Date.from(activationLocalDate.plusYears(this.lockinPeriodFrequency) lockedInUntilLocalDate = Date
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); .from(activationLocalDate.plusYears(this.lockinPeriodFrequency).atStartOfDay(ZoneId.systemDefault()).toInstant());
break; break;
case WHOLE_TERM: case WHOLE_TERM:
LOG.error("TODO Implement calculateDateAccountIsLockedUntil for WHOLE_TERM"); LOG.error("TODO Implement calculateDateAccountIsLockedUntil for WHOLE_TERM");
@@ -31,6 +31,7 @@ import java.math.BigDecimal;
import java.math.MathContext; import java.math.MathContext;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.MonthDay; import java.time.MonthDay;
import java.time.ZoneId;
import java.time.temporal.ChronoField; import java.time.temporal.ChronoField;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -212,7 +213,7 @@ public class SavingsAccountCharge extends AbstractPersistableCustom {
this.feeInterval = (feeInterval == null) ? chargeDefinition.feeInterval() : feeInterval; this.feeInterval = (feeInterval == null) ? chargeDefinition.feeInterval() : feeInterval;
} }
this.dueDate = (dueDate == null) ? null : Date.from(dueDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dueDate = (dueDate == null) ? null : Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.chargeCalculation = chargeDefinition.getChargeCalculation(); this.chargeCalculation = chargeDefinition.getChargeCalculation();
if (chargeCalculation != null) { if (chargeCalculation != null) {
@@ -393,7 +394,7 @@ public class SavingsAccountCharge extends AbstractPersistableCustom {
public void update(final BigDecimal amount, final LocalDate dueDate, final MonthDay feeOnMonthDay, final Integer feeInterval) { public void update(final BigDecimal amount, final LocalDate dueDate, final MonthDay feeOnMonthDay, final Integer feeInterval) {
final BigDecimal transactionAmount = BigDecimal.ZERO; final BigDecimal transactionAmount = BigDecimal.ZERO;
if (dueDate != null) { if (dueDate != null) {
this.dueDate = Date.from(dueDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dueDate = Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
if (isWeeklyFee()) { if (isWeeklyFee()) {
this.feeOnDay = dueDate.get(ChronoField.DAY_OF_WEEK); this.feeOnDay = dueDate.get(ChronoField.DAY_OF_WEEK);
} }
@@ -455,7 +456,7 @@ public class SavingsAccountCharge extends AbstractPersistableCustom {
actualChanges.put(localeParamName, localeAsInput); actualChanges.put(localeParamName, localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(dueAsOfDateParamName); final LocalDate newValue = command.localDateValueOfParameterNamed(dueAsOfDateParamName);
this.dueDate = Date.from(newValue.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dueDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
if (this.isWeeklyFee()) { if (this.isWeeklyFee()) {
this.feeOnDay = newValue.get(ChronoField.DAY_OF_WEEK); this.feeOnDay = newValue.get(ChronoField.DAY_OF_WEEK);
} }
@@ -759,7 +760,7 @@ public class SavingsAccountCharge extends AbstractPersistableCustom {
public void updateToNextDueDateFrom(final LocalDate startingDate) { public void updateToNextDueDateFrom(final LocalDate startingDate) {
if (isAnnualFee() || isMonthlyFee() || isWeeklyFee()) { if (isAnnualFee() || isMonthlyFee() || isWeeklyFee()) {
this.dueDate = Date.from(getNextDueDateFrom(startingDate).atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dueDate = Date.from(getNextDueDateFrom(startingDate).atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -815,7 +816,7 @@ public class SavingsAccountCharge extends AbstractPersistableCustom {
if (isAnnualFee() || isMonthlyFee() || isWeeklyFee()) { if (isAnnualFee() || isMonthlyFee() || isWeeklyFee()) {
LocalDate nextDueLocalDate = LocalDate.ofInstant(dueDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()); LocalDate nextDueLocalDate = LocalDate.ofInstant(dueDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
nextDueLocalDate = calculateNextDueDate(nextDueLocalDate); nextDueLocalDate = calculateNextDueDate(nextDueLocalDate);
this.dueDate = Date.from(nextDueLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dueDate = Date.from(nextDueLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -833,7 +834,7 @@ public class SavingsAccountCharge extends AbstractPersistableCustom {
nextDueLocalDate = setDayOfWeek(nextDueLocalDate); nextDueLocalDate = setDayOfWeek(nextDueLocalDate);
} }
this.dueDate = Date.from(nextDueLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dueDate = Date.from(nextDueLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -863,7 +864,7 @@ public class SavingsAccountCharge extends AbstractPersistableCustom {
} }
public void inactiavateCharge(final LocalDate inactivationOnDate) { public void inactiavateCharge(final LocalDate inactivationOnDate) {
this.inactivationDate = Date.from(inactivationOnDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.inactivationDate = Date.from(inactivationOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.status = false; this.status = false;
this.amountOutstanding = BigDecimal.ZERO; this.amountOutstanding = BigDecimal.ZERO;
this.paid = true; this.paid = true;
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.savings.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
@@ -115,7 +116,7 @@ public final class SavingsAccountSummary {
interestEarned = interestEarned == null ? Money.zero(currency) : interestEarned; interestEarned = interestEarned == null ? Money.zero(currency) : interestEarned;
totalEarned = totalEarned.plus(interestEarned); totalEarned = totalEarned.plus(interestEarned);
} }
this.lastInterestCalculationDate = Date.from(interestCalculationDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.lastInterestCalculationDate = Date.from(interestCalculationDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.totalInterestEarned = totalEarned.getAmount(); this.totalInterestEarned = totalEarned.getAmount();
} }
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.savings.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@@ -291,7 +292,7 @@ public final class SavingsAccountTransaction extends AbstractPersistableCustom {
this.savingsAccount = savingsAccount; this.savingsAccount = savingsAccount;
this.office = office; this.office = office;
this.typeOf = typeOf; this.typeOf = typeOf;
this.dateOf = Date.from(transactionLocalDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.dateOf = Date.from(transactionLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.amount = amount; this.amount = amount;
this.reversed = isReversed; this.reversed = isReversed;
this.paymentDetail = paymentDetail; this.paymentDetail = paymentDetail;
@@ -430,9 +431,9 @@ public final class SavingsAccountTransaction extends AbstractPersistableCustom {
public void updateCumulativeBalanceAndDates(final MonetaryCurrency currency, final LocalDate endOfBalanceDate) { public void updateCumulativeBalanceAndDates(final MonetaryCurrency currency, final LocalDate endOfBalanceDate) {
// balance end date should not be before transaction date // balance end date should not be before transaction date
if (endOfBalanceDate != null && endOfBalanceDate.isBefore(this.transactionLocalDate())) { if (endOfBalanceDate != null && endOfBalanceDate.isBefore(this.transactionLocalDate())) {
this.balanceEndDate = Date.from(this.transactionLocalDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.balanceEndDate = Date.from(this.transactionLocalDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
} else if (endOfBalanceDate != null) { } else if (endOfBalanceDate != null) {
this.balanceEndDate = Date.from(endOfBalanceDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.balanceEndDate = Date.from(endOfBalanceDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} else { } else {
this.balanceEndDate = null; this.balanceEndDate = null;
} }
@@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.savings.domain; package org.apache.fineract.portfolio.savings.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
@@ -55,7 +56,7 @@ public class SavingsOfficerAssignmentHistory extends AbstractAuditableCustom {
public static SavingsOfficerAssignmentHistory createNew(final SavingsAccount account, final Staff savingsOfficer, public static SavingsOfficerAssignmentHistory createNew(final SavingsAccount account, final Staff savingsOfficer,
final LocalDate assignmentDate) { final LocalDate assignmentDate) {
return new SavingsOfficerAssignmentHistory(account, savingsOfficer, return new SavingsOfficerAssignmentHistory(account, savingsOfficer,
Date.from(assignmentDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), null); Date.from(assignmentDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), null);
} }
protected SavingsOfficerAssignmentHistory() { protected SavingsOfficerAssignmentHistory() {
@@ -79,11 +80,11 @@ public class SavingsOfficerAssignmentHistory extends AbstractAuditableCustom {
} }
public void updateStartDate(final LocalDate startDate) { public void updateStartDate(final LocalDate startDate) {
this.startDate = Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public void updateEndDate(final LocalDate endDate) { public void updateEndDate(final LocalDate endDate) {
this.endDate = Date.from(endDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public boolean matchesStartDateOf(final LocalDate matchingDate) { public boolean matchesStartDateOf(final LocalDate matchingDate) {
@@ -31,6 +31,7 @@ import com.google.gson.JsonElement;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.MathContext; import java.math.MathContext;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -514,8 +515,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
} }
List<SavingsAccountTransaction> savingTransactions = account.getTransactions(); List<SavingsAccountTransaction> savingTransactions = account.getTransactions();
for (SavingsAccountTransaction savingTransaction : savingTransactions) { for (SavingsAccountTransaction savingTransaction : savingTransactions) {
if (Date.from(transactionDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()) if (Date.from(transactionDate.atStartOfDay(ZoneId.systemDefault()).toInstant()).before(savingTransaction.getDateOf())) {
.before(savingTransaction.getDateOf())) {
throw new PostInterestAsOnDateException(PostInterestAsOnExceptionType.LAST_TRANSACTION_DATE); throw new PostInterestAsOnDateException(PostInterestAsOnExceptionType.LAST_TRANSACTION_DATE);
} }
} }
@@ -23,6 +23,7 @@ import static org.apache.fineract.portfolio.savings.SavingsApiConstants.SAVINGS_
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@@ -735,7 +736,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
savingsAccountDataDTO.getGroup(), savingsAccountDataDTO.getSavingsProduct(), savingsAccountDataDTO.getApplicationDate(), savingsAccountDataDTO.getGroup(), savingsAccountDataDTO.getSavingsProduct(), savingsAccountDataDTO.getApplicationDate(),
savingsAccountDataDTO.getAppliedBy()); savingsAccountDataDTO.getAppliedBy());
account.approveAndActivateApplication( account.approveAndActivateApplication(
Date.from(savingsAccountDataDTO.getApplicationDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(savingsAccountDataDTO.getApplicationDate().atStartOfDay(ZoneId.systemDefault()).toInstant()),
savingsAccountDataDTO.getAppliedBy()); savingsAccountDataDTO.getAppliedBy());
Money amountForDeposit = account.activateWithBalance(); Money amountForDeposit = account.activateWithBalance();
@@ -22,12 +22,12 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.ZoneId;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.core.service.RoutingDataSource; import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.organisation.office.data.OfficeData; import org.apache.fineract.organisation.office.data.OfficeData;
@@ -246,23 +246,23 @@ public class SearchReadPlatformServiceImpl implements SearchReadPlatformService
if (searchConditions.getLoanDateOption().equals(SearchConstants.SearchLoanDate.APPROVAL_DATE.getValue())) { if (searchConditions.getLoanDateOption().equals(SearchConstants.SearchLoanDate.APPROVAL_DATE.getValue())) {
checkAndUpdateWhereClause(sql); checkAndUpdateWhereClause(sql);
params.addValue("loanFromDate", params.addValue("loanFromDate",
Date.from(searchConditions.getLoanFromDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(searchConditions.getLoanFromDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
params.addValue("loanToDate", params.addValue("loanToDate",
Date.from(searchConditions.getLoanToDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(searchConditions.getLoanToDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
sql.append(" ( ml.approvedon_date between :loanFromDate and :loanToDate ) "); sql.append(" ( ml.approvedon_date between :loanFromDate and :loanToDate ) ");
} else if (searchConditions.getLoanDateOption().equals(SearchConstants.SearchLoanDate.CREATED_DATE.getValue())) { } else if (searchConditions.getLoanDateOption().equals(SearchConstants.SearchLoanDate.CREATED_DATE.getValue())) {
checkAndUpdateWhereClause(sql); checkAndUpdateWhereClause(sql);
params.addValue("loanFromDate", params.addValue("loanFromDate",
Date.from(searchConditions.getLoanFromDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(searchConditions.getLoanFromDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
params.addValue("loanToDate", params.addValue("loanToDate",
Date.from(searchConditions.getLoanToDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(searchConditions.getLoanToDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
sql.append(" ( ml.submittedon_date between :loanFromDate and :loanToDate ) "); sql.append(" ( ml.submittedon_date between :loanFromDate and :loanToDate ) ");
} else if (searchConditions.getLoanDateOption().equals(SearchConstants.SearchLoanDate.DISBURSAL_DATE.getValue())) { } else if (searchConditions.getLoanDateOption().equals(SearchConstants.SearchLoanDate.DISBURSAL_DATE.getValue())) {
checkAndUpdateWhereClause(sql); checkAndUpdateWhereClause(sql);
params.addValue("loanFromDate", params.addValue("loanFromDate",
Date.from(searchConditions.getLoanFromDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(searchConditions.getLoanFromDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
params.addValue("loanToDate", params.addValue("loanToDate",
Date.from(searchConditions.getLoanToDate().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(searchConditions.getLoanToDate().atStartOfDay(ZoneId.systemDefault()).toInstant()));
sql.append(" ( ml.disbursedon_date between :loanFromDate and :loanToDate ) "); sql.append(" ( ml.disbursedon_date between :loanFromDate and :loanToDate ) ");
} }
} }
@@ -25,6 +25,7 @@ import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -210,18 +211,17 @@ public class ShareAccountDataSerializer {
String accountNo = null; String accountNo = null;
Long approvedShares = null; Long approvedShares = null;
Long pendingShares = requestedShares; Long pendingShares = requestedShares;
BigDecimal unitPrice = shareProduct BigDecimal unitPrice = shareProduct.deriveMarketPrice(Date.from(applicationDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
.deriveMarketPrice(Date.from(applicationDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
ShareAccountTransaction transaction = new ShareAccountTransaction( ShareAccountTransaction transaction = new ShareAccountTransaction(
Date.from(applicationDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), requestedShares, unitPrice); Date.from(applicationDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), requestedShares, unitPrice);
Set<ShareAccountTransaction> sharesPurchased = new HashSet<>(); Set<ShareAccountTransaction> sharesPurchased = new HashSet<>();
sharesPurchased.add(transaction); sharesPurchased.add(transaction);
ShareAccount account = new ShareAccount(client, shareProduct, externalId, currency, savingsAccount, accountNo, approvedShares, ShareAccount account = new ShareAccount(client, shareProduct, externalId, currency, savingsAccount, accountNo, approvedShares,
pendingShares, sharesPurchased, allowdividendsForInactiveClients, lockinPeriod, lockPeriodEnum, minimumActivePeriod, pendingShares, sharesPurchased, allowdividendsForInactiveClients, lockinPeriod, lockPeriodEnum, minimumActivePeriod,
minimumActivePeriodEnum, charges, submittedBy, minimumActivePeriodEnum, charges, submittedBy, Date.from(submittedDate.atStartOfDay(ZoneId.systemDefault()).toInstant()),
Date.from(submittedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), approvedBy, approvedDate, approvedBy, approvedDate, rejectedBy, rejectedDate, activatedBy, activatedDate, closedBy, closedDate, modifiedBy,
rejectedBy, rejectedDate, activatedBy, activatedDate, closedBy, closedDate, modifiedBy, modifiedDate); modifiedDate);
for (ShareAccountTransaction pur : sharesPurchased) { for (ShareAccountTransaction pur : sharesPurchased) {
pur.setShareAccount(account); pur.setShareAccount(account);
@@ -239,7 +239,7 @@ public class ShareAccountDataSerializer {
private void createChargeTransaction(ShareAccount account) { private void createChargeTransaction(ShareAccount account) {
BigDecimal totalChargeAmount = BigDecimal.ZERO; BigDecimal totalChargeAmount = BigDecimal.ZERO;
Set<ShareAccountCharge> charges = account.getCharges(); Set<ShareAccountCharge> charges = account.getCharges();
Date currentDate = Date.from(DateUtils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); Date currentDate = Date.from(DateUtils.getLocalDateOfTenant().atStartOfDay(ZoneId.systemDefault()).toInstant());
for (ShareAccountCharge charge : charges) { for (ShareAccountCharge charge : charges) {
if (charge.isActive() && charge.isShareAccountActivation()) { if (charge.isActive() && charge.isShareAccountActivation()) {
charge.deriveChargeAmount(totalChargeAmount, account.getCurrency()); charge.deriveChargeAmount(totalChargeAmount, account.getCurrency());
@@ -288,7 +288,7 @@ public class ShareAccountDataSerializer {
if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.submitteddate_paramname, element)) { if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.submitteddate_paramname, element)) {
final Date submittedDate = Date final Date submittedDate = Date
.from(this.fromApiJsonHelper.extractLocalDateNamed(ShareAccountApiConstants.submitteddate_paramname, element) .from(this.fromApiJsonHelper.extractLocalDateNamed(ShareAccountApiConstants.submitteddate_paramname, element)
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); .atStartOfDay(ZoneId.systemDefault()).toInstant());
baseDataValidator.reset().parameter(ShareAccountApiConstants.submitteddate_paramname).value(submittedDate).notNull(); baseDataValidator.reset().parameter(ShareAccountApiConstants.submitteddate_paramname).value(submittedDate).notNull();
if (account.setSubmittedDate(submittedDate)) { if (account.setSubmittedDate(submittedDate)) {
actualChanges.put(ShareAccountApiConstants.submitteddate_paramname, submittedDate); actualChanges.put(ShareAccountApiConstants.submitteddate_paramname, submittedDate);
@@ -363,7 +363,7 @@ public class ShareAccountDataSerializer {
if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.applicationdate_param, element)) { if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.applicationdate_param, element)) {
applicationDate = Date applicationDate = Date
.from(this.fromApiJsonHelper.extractLocalDateNamed(ShareAccountApiConstants.applicationdate_param, element) .from(this.fromApiJsonHelper.extractLocalDateNamed(ShareAccountApiConstants.applicationdate_param, element)
.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); .atStartOfDay(ZoneId.systemDefault()).toInstant());
baseDataValidator.reset().parameter(ShareAccountApiConstants.applicationdate_param).value(applicationDate).notNull(); baseDataValidator.reset().parameter(ShareAccountApiConstants.applicationdate_param).value(applicationDate).notNull();
} else { } else {
applicationDate = existingApplicationDate; applicationDate = existingApplicationDate;
@@ -495,7 +495,7 @@ public class ShareAccountDataSerializer {
} }
AppUser approvedUser = this.platformSecurityContext.authenticatedUser(); AppUser approvedUser = this.platformSecurityContext.authenticatedUser();
account.approve(Date.from(approvedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), approvedUser); account.approve(Date.from(approvedDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), approvedUser);
actualChanges.put(ShareAccountApiConstants.id_paramname, account.getId()); actualChanges.put(ShareAccountApiConstants.id_paramname, account.getId());
updateTotalChargeDerived(account); updateTotalChargeDerived(account);
return actualChanges; return actualChanges;
@@ -627,10 +627,10 @@ public class ShareAccountDataSerializer {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
AppUser approvedUser = this.platformSecurityContext.authenticatedUser(); AppUser approvedUser = this.platformSecurityContext.authenticatedUser();
account.activate(Date.from(activatedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), approvedUser); account.activate(Date.from(activatedDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), approvedUser);
handlechargesOnActivation(account); handlechargesOnActivation(account);
actualChanges.put(ShareAccountApiConstants.charges_paramname, actualChanges.put(ShareAccountApiConstants.charges_paramname,
Date.from(activatedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(activatedDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
return actualChanges; return actualChanges;
} }
@@ -733,9 +733,9 @@ public class ShareAccountDataSerializer {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
final BigDecimal unitPrice = shareProduct final BigDecimal unitPrice = shareProduct
.deriveMarketPrice(Date.from(requestedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); .deriveMarketPrice(Date.from(requestedDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
ShareAccountTransaction purchaseTransaction = new ShareAccountTransaction( ShareAccountTransaction purchaseTransaction = new ShareAccountTransaction(
Date.from(requestedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), sharesRequested, unitPrice); Date.from(requestedDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), sharesRequested, unitPrice);
account.addAdditionalPurchasedShares(purchaseTransaction); account.addAdditionalPurchasedShares(purchaseTransaction);
handleAdditionalSharesChargeTransactions(account, purchaseTransaction); handleAdditionalSharesChargeTransactions(account, purchaseTransaction);
actualChanges.put(ShareAccountApiConstants.additionalshares_paramname, purchaseTransaction); actualChanges.put(ShareAccountApiConstants.additionalshares_paramname, purchaseTransaction);
@@ -892,9 +892,9 @@ public class ShareAccountDataSerializer {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
BigDecimal unitPrice = account.getShareProduct() BigDecimal unitPrice = account.getShareProduct()
.deriveMarketPrice(Date.from(requestedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); .deriveMarketPrice(Date.from(requestedDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
ShareAccountTransaction transaction = ShareAccountTransaction.createRedeemTransaction( ShareAccountTransaction transaction = ShareAccountTransaction.createRedeemTransaction(
Date.from(requestedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), sharesRequested, unitPrice); Date.from(requestedDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), sharesRequested, unitPrice);
validateRedeemRequest(account, transaction, baseDataValidator, dataValidationErrors); validateRedeemRequest(account, transaction, baseDataValidator, dataValidationErrors);
account.addAdditionalPurchasedShares(transaction); account.addAdditionalPurchasedShares(transaction);
actualChanges.put(ShareAccountApiConstants.requestedshares_paramname, transaction); actualChanges.put(ShareAccountApiConstants.requestedshares_paramname, transaction);
@@ -1055,10 +1055,9 @@ public class ShareAccountDataSerializer {
AppUser approvedUser = this.platformSecurityContext.authenticatedUser(); AppUser approvedUser = this.platformSecurityContext.authenticatedUser();
final BigDecimal unitPrice = account.getShareProduct().deriveMarketPrice(DateUtils.getDateOfTenant()); final BigDecimal unitPrice = account.getShareProduct().deriveMarketPrice(DateUtils.getDateOfTenant());
ShareAccountTransaction transaction = ShareAccountTransaction.createRedeemTransaction( ShareAccountTransaction transaction = ShareAccountTransaction.createRedeemTransaction(
Date.from(closedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), account.getTotalApprovedShares(), Date.from(closedDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), account.getTotalApprovedShares(), unitPrice);
unitPrice);
account.addAdditionalPurchasedShares(transaction); account.addAdditionalPurchasedShares(transaction);
account.close(Date.from(closedDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), approvedUser); account.close(Date.from(closedDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), approvedUser);
handleRedeemSharesChargeTransactions(account, transaction); handleRedeemSharesChargeTransactions(account, transaction);
actualChanges.put(ShareAccountApiConstants.requestedshares_paramname, transaction); actualChanges.put(ShareAccountApiConstants.requestedshares_paramname, transaction);
return actualChanges; return actualChanges;
@@ -22,6 +22,7 @@ import java.math.BigDecimal;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -491,7 +492,7 @@ public class ShareAccountReadPlatformServiceImpl implements ShareAccountReadPlat
public ShareAccountDividendData mapRow(ResultSet rs, int rowNum) throws SQLException { public ShareAccountDividendData mapRow(ResultSet rs, int rowNum) throws SQLException {
final Long id = rs.getLong("id"); final Long id = rs.getLong("id");
final Date postedDate = Date final Date postedDate = Date
.from(JdbcSupport.getLocalDate(rs, "created_date").atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); .from(JdbcSupport.getLocalDate(rs, "created_date").atStartOfDay(ZoneId.systemDefault()).toInstant());
final BigDecimal postedAmount = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "amount"); final BigDecimal postedAmount = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "amount");
final Long savingTransactionId = rs.getLong("savings_transaction_id"); final Long savingTransactionId = rs.getLong("savings_transaction_id");
final Integer status = rs.getInt("status"); final Integer status = rs.getInt("status");
@@ -25,6 +25,7 @@ import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@@ -222,7 +223,7 @@ public class ShareProductDataSerializer {
final BigDecimal shareValue = this.fromApiJsonHelper final BigDecimal shareValue = this.fromApiJsonHelper
.extractBigDecimalWithLocaleNamed(ShareProductApiConstants.sharevalue_paramname, arrayElement); .extractBigDecimalWithLocaleNamed(ShareProductApiConstants.sharevalue_paramname, arrayElement);
ShareProductMarketPriceData obj = new ShareProductMarketPriceData(id, ShareProductMarketPriceData obj = new ShareProductMarketPriceData(id,
Date.from(localDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), shareValue); Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), shareValue);
set.add(obj); set.add(obj);
} }
} }
@@ -240,7 +241,7 @@ public class ShareProductDataSerializer {
final BigDecimal shareValue = this.fromApiJsonHelper final BigDecimal shareValue = this.fromApiJsonHelper
.extractBigDecimalWithLocaleNamed(ShareProductApiConstants.sharevalue_paramname, arrayElement); .extractBigDecimalWithLocaleNamed(ShareProductApiConstants.sharevalue_paramname, arrayElement);
ShareProductMarketPrice obj = new ShareProductMarketPrice( ShareProductMarketPrice obj = new ShareProductMarketPrice(
Date.from(localDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), shareValue); Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()), shareValue);
set.add(obj); set.add(obj);
} }
} }
@@ -20,12 +20,12 @@ package org.apache.fineract.portfolio.shareproducts.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.organisation.monetary.domain.Money; import org.apache.fineract.organisation.monetary.domain.Money;
import org.apache.fineract.portfolio.products.service.ProductReadPlatformService; import org.apache.fineract.portfolio.products.service.ProductReadPlatformService;
@@ -78,8 +78,8 @@ public class ShareProductDividendAssembler {
if (numberOfShareDays > 0) { if (numberOfShareDays > 0) {
double amountPerShareDay = amount.doubleValue() / numberOfShareDays; double amountPerShareDay = amount.doubleValue() / numberOfShareDays;
productDividendPayOutDetails = new ShareProductDividendPayOutDetails(productId, Money.of(currency, amount).getAmount(), productDividendPayOutDetails = new ShareProductDividendPayOutDetails(productId, Money.of(currency, amount).getAmount(),
Date.from(dividendPeriodStartDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(dividendPeriodStartDate.atStartOfDay(ZoneId.systemDefault()).toInstant()),
Date.from(dividendPeriodEndDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(dividendPeriodEndDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
for (ShareAccountData accountData : shareAccountDatas) { for (ShareAccountData accountData : shareAccountDatas) {
long numberOfShareDaysPerAccount = numberOfSharesdaysPerAccount.get(accountData.getId()); long numberOfShareDaysPerAccount = numberOfSharesdaysPerAccount.get(accountData.getId());
double amountForAccount = numberOfShareDaysPerAccount * amountPerShareDay; double amountForAccount = numberOfShareDaysPerAccount * amountPerShareDay;
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.tax.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
@@ -97,7 +98,7 @@ public class TaxComponent extends AbstractAuditableCustom {
this.creditAccountType = creditAccountType.getValue(); this.creditAccountType = creditAccountType.getValue();
} }
this.creditAcount = creditAcount; this.creditAcount = creditAcount;
this.startDate = Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public static TaxComponent createTaxComponent(final String name, final BigDecimal percentage, final GLAccountType debitAccountType, public static TaxComponent createTaxComponent(final String name, final BigDecimal percentage, final GLAccountType debitAccountType,
@@ -138,11 +139,11 @@ public class TaxComponent extends AbstractAuditableCustom {
if (startDateFromUI != null) { if (startDateFromUI != null) {
startDate = startDateFromUI; startDate = startDateFromUI;
} }
this.startDate = Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
changes.put(TaxApiConstants.startDateParamName, startDate); changes.put(TaxApiConstants.startDateParamName, startDate);
} else if (setAsCurrentDate) { } else if (setAsCurrentDate) {
changes.put(TaxApiConstants.startDateParamName, startDate); changes.put(TaxApiConstants.startDateParamName, startDate);
this.startDate = Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.tax.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
@@ -50,8 +51,8 @@ public class TaxComponentHistory extends AbstractAuditableCustom {
private TaxComponentHistory(final BigDecimal percentage, final LocalDate startDate, final LocalDate endDate) { private TaxComponentHistory(final BigDecimal percentage, final LocalDate startDate, final LocalDate endDate) {
this.percentage = percentage; this.percentage = percentage;
this.startDate = Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.endDate = Date.from(endDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
public static TaxComponentHistory createTaxComponentHistory(final BigDecimal percentage, final LocalDate startDate, public static TaxComponentHistory createTaxComponentHistory(final BigDecimal percentage, final LocalDate startDate,
@@ -19,6 +19,7 @@
package org.apache.fineract.portfolio.tax.domain; package org.apache.fineract.portfolio.tax.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@@ -56,10 +57,10 @@ public class TaxGroupMappings extends AbstractAuditableCustom {
this.taxComponent = taxComponent; this.taxComponent = taxComponent;
if (startDate != null) { if (startDate != null) {
this.startDate = Date.from(startDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (endDate != null) { if (endDate != null) {
this.endDate = Date.from(endDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endDate = Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -22,6 +22,7 @@ import com.google.common.collect.Iterables;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -475,7 +476,7 @@ public class TransferWritePlatformServiceJpaRepositoryImpl implements TransferWr
case PROPOSAL: case PROPOSAL:
client.setStatus(ClientStatus.TRANSFER_IN_PROGRESS.getValue()); client.setStatus(ClientStatus.TRANSFER_IN_PROGRESS.getValue());
client.updateTransferToOffice(destinationOffice); client.updateTransferToOffice(destinationOffice);
client.updateProposedTransferDate(Date.from(transferDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); client.updateProposedTransferDate(Date.from(transferDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
break; break;
case REJECTION: case REJECTION:
client.setStatus(ClientStatus.TRANSFER_ON_HOLD.getValue()); client.setStatus(ClientStatus.TRANSFER_ON_HOLD.getValue());
@@ -489,9 +490,7 @@ public class TransferWritePlatformServiceJpaRepositoryImpl implements TransferWr
} }
this.noteWritePlatformService.createAndPersistClientNote(client, jsonCommand); this.noteWritePlatformService.createAndPersistClientNote(client, jsonCommand);
Date proposedTransferDate = transferDate != null Date proposedTransferDate = transferDate != null ? Date.from(transferDate.atStartOfDay(ZoneId.systemDefault()).toInstant()) : null;
? Date.from(transferDate.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())
: null;
this.clientTransferDetailsRepositoryWrapper.save(ClientTransferDetails.instance(client.getId(), client.getOffice().getId(), this.clientTransferDetailsRepositoryWrapper.save(ClientTransferDetails.instance(client.getId(), client.getOffice().getId(),
destinationOffice.getId(), proposedTransferDate, transferEventType.getValue(), destinationOffice.getId(), proposedTransferDate, transferEventType.getValue(),
Date.from(DateUtils.getLocalDateTimeOfTenant().atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()), Date.from(DateUtils.getLocalDateTimeOfTenant().atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()),
@@ -21,11 +21,11 @@ package org.apache.fineract.spm.service;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.infrastructure.core.domain.JdbcSupport; import org.apache.fineract.infrastructure.core.domain.JdbcSupport;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.core.service.RoutingDataSource; import org.apache.fineract.infrastructure.core.service.RoutingDataSource;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.spm.data.ScorecardData; import org.apache.fineract.spm.data.ScorecardData;
@@ -96,7 +96,7 @@ public class ScorecardReadPlatformServiceImpl implements ScorecardReadPlatformSe
final Integer value = rs.getInt("value"); final Integer value = rs.getInt("value");
return ScorecardValue.instance(questionId, responseId, value, return ScorecardValue.instance(questionId, responseId, value,
Date.from(createdOn.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); Date.from(createdOn.atStartOfDay(ZoneId.systemDefault()).toInstant()));
} }
} }
@@ -19,6 +19,7 @@
package org.apache.fineract.spm.service; package org.apache.fineract.spm.service;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.temporal.ChronoField; import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
@@ -84,9 +85,9 @@ public class SpmService {
LocalDate validFrom = DateUtils.getLocalDateOfTenant(); LocalDate validFrom = DateUtils.getLocalDateOfTenant();
// set valid to for 100 years // set valid to for 100 years
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(Date.from(validFrom.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); cal.setTime(Date.from(validFrom.atStartOfDay(ZoneId.systemDefault()).toInstant()));
cal.add(Calendar.YEAR, 100); cal.add(Calendar.YEAR, 100);
survey.setValidFrom(Date.from(validFrom.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); survey.setValidFrom(Date.from(validFrom.atStartOfDay(ZoneId.systemDefault()).toInstant()));
survey.setValidTo(cal.getTime()); survey.setValidTo(cal.getTime());
try { try {
this.surveyRepository.saveAndFlush(survey); this.surveyRepository.saveAndFlush(survey);
@@ -134,9 +135,9 @@ public class SpmService {
final Survey survey = findById(id); final Survey survey = findById(id);
LocalDate validFrom = DateUtils.getLocalDateOfTenant(); LocalDate validFrom = DateUtils.getLocalDateOfTenant();
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(Date.from(validFrom.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); cal.setTime(Date.from(validFrom.atStartOfDay(ZoneId.systemDefault()).toInstant()));
cal.add(Calendar.YEAR, 100); cal.add(Calendar.YEAR, 100);
survey.setValidFrom(Date.from(validFrom.atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant())); survey.setValidFrom(Date.from(validFrom.atStartOfDay(ZoneId.systemDefault()).toInstant()));
survey.setValidTo(cal.getTime()); survey.setValidTo(cal.getTime());
this.surveyRepository.save(survey); this.surveyRepository.save(survey);
@@ -18,6 +18,7 @@
*/ */
package org.apache.fineract.spm.util; package org.apache.fineract.spm.util;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -51,8 +52,7 @@ public final class ScorecardMapper {
ScorecardMapper.setQuestionAndResponse(scorecardValue, scorecard, survey); ScorecardMapper.setQuestionAndResponse(scorecardValue, scorecard, survey);
scorecard.setAppUser(appUser); scorecard.setAppUser(appUser);
scorecard.setClient(client); scorecard.setClient(client);
scorecard.setCreatedOn( scorecard.setCreatedOn(Date.from(DateUtils.getLocalDateOfTenant().atStartOfDay(ZoneId.systemDefault()).toInstant()));
Date.from(DateUtils.getLocalDateOfTenant().atStartOfDay(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
scorecard.setValue(scorecardValue.getValue()); scorecard.setValue(scorecardValue.getValue());
} }
} else { } else {