Date to LocalDate (scheduler excluded due to quartz)

This commit is contained in:
Adam Saghy
2022-07-13 12:16:07 +02:00
committed by Arnold Gálovics
parent f7e21f8db1
commit 1db8ef46fc
207 changed files with 1517 additions and 2304 deletions
@@ -18,7 +18,7 @@
*/ */
package org.apache.fineract.accounting.closure.domain; package org.apache.fineract.accounting.closure.domain;
import java.util.Date; import java.time.LocalDate;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import javax.persistence.Column; import javax.persistence.Column;
@@ -26,8 +26,6 @@ import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.accounting.closure.api.GLClosureJsonInputParams; import org.apache.fineract.accounting.closure.api.GLClosureJsonInputParams;
@@ -48,8 +46,7 @@ public class GLClosure extends AbstractAuditableCustom {
private boolean deleted = true; private boolean deleted = true;
@Column(name = "closing_date") @Column(name = "closing_date")
@Temporal(TemporalType.DATE) private LocalDate closingDate;
private Date closingDate;
@Column(name = "comments", nullable = true, length = 500) @Column(name = "comments", nullable = true, length = 500)
private String comments; private String comments;
@@ -58,7 +55,7 @@ public class GLClosure extends AbstractAuditableCustom {
// //
} }
public GLClosure(final Office office, final Date closingDate, final String comments) { public GLClosure(final Office office, final LocalDate closingDate, final String comments) {
this.office = office; this.office = office;
this.deleted = false; this.deleted = false;
this.closingDate = closingDate; this.closingDate = closingDate;
@@ -69,7 +66,7 @@ public class GLClosure extends AbstractAuditableCustom {
} }
public static GLClosure fromJson(final Office office, final JsonCommand command) { public static GLClosure fromJson(final Office office, final JsonCommand command) {
final Date closingDate = command.dateValueOfParameterNamed(GLClosureJsonInputParams.CLOSING_DATE.getValue()); final LocalDate closingDate = command.localDateValueOfParameterNamed(GLClosureJsonInputParams.CLOSING_DATE.getValue());
final String comments = command.stringValueOfParameterNamed(GLClosureJsonInputParams.COMMENTS.getValue()); final String comments = command.stringValueOfParameterNamed(GLClosureJsonInputParams.COMMENTS.getValue());
return new GLClosure(office, closingDate, comments); return new GLClosure(office, closingDate, comments);
} }
@@ -92,7 +89,7 @@ public class GLClosure extends AbstractAuditableCustom {
} }
} }
public Date getClosingDate() { public LocalDate getClosingDate() {
return this.closingDate; return this.closingDate;
} }
@@ -18,7 +18,7 @@
*/ */
package org.apache.fineract.accounting.closure.exception; package org.apache.fineract.accounting.closure.exception;
import java.util.Date; import java.time.LocalDate;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException; import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
/** /**
@@ -26,7 +26,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
*/ */
public class GLClosureInvalidDeleteException extends AbstractPlatformDomainRuleException { public class GLClosureInvalidDeleteException extends AbstractPlatformDomainRuleException {
public GLClosureInvalidDeleteException(final Long officeId, final String officeName, final Date latestclosureDate) { public GLClosureInvalidDeleteException(final Long officeId, final String officeName, final LocalDate latestclosureDate) {
super("error.msg.glclosure.invalid.delete", "The latest closure for office with Id " + officeId + " and name " + officeName super("error.msg.glclosure.invalid.delete", "The latest closure for office with Id " + officeId + " and name " + officeName
+ " is on " + latestclosureDate.toString() + ", please delete this closure first", latestclosureDate); + " is on " + latestclosureDate.toString() + ", please delete this closure first", latestclosureDate);
} }
@@ -18,7 +18,7 @@
*/ */
package org.apache.fineract.accounting.closure.exception; package org.apache.fineract.accounting.closure.exception;
import java.util.Date; import java.time.LocalDate;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException; import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
/** /**
@@ -50,7 +50,7 @@ public class GLClosureInvalidException extends AbstractPlatformDomainRuleExcepti
} }
} }
public GLClosureInvalidException(final GlClosureInvalidReason reason, final Date date) { public GLClosureInvalidException(final GlClosureInvalidReason reason, final LocalDate date) {
super(reason.errorCode(), reason.errorMessage(), date); super(reason.errorCode(), reason.errorMessage(), date);
} }
} }
@@ -19,7 +19,6 @@
package org.apache.fineract.accounting.closure.service; package org.apache.fineract.accounting.closure.service;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Date;
import java.util.Map; import java.util.Map;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -67,15 +66,15 @@ public class GLClosureWritePlatformServiceJpaRepositoryImpl implements GLClosure
final Office office = this.officeRepositoryWrapper.findOneWithNotFoundDetection(officeId); final Office office = this.officeRepositoryWrapper.findOneWithNotFoundDetection(officeId);
// TODO: Get Tenant specific date // TODO: Get Tenant specific date
// ensure closure date is not in the future // ensure closure date is not in the future
final Date todaysDate = DateUtils.getBusinessDate(); final LocalDate todaysDate = DateUtils.getBusinessLocalDate();
final Date closureDate = command.dateValueOfParameterNamed(GLClosureJsonInputParams.CLOSING_DATE.getValue()); final LocalDate closureDate = command.localDateValueOfParameterNamed(GLClosureJsonInputParams.CLOSING_DATE.getValue());
if (closureDate.after(todaysDate)) { if (closureDate.isAfter(todaysDate)) {
throw new GLClosureInvalidException(GlClosureInvalidReason.FUTURE_DATE, closureDate); throw new GLClosureInvalidException(GlClosureInvalidReason.FUTURE_DATE, closureDate);
} }
// shouldn't be before an existing accounting closure // shouldn't be before an existing accounting closure
final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(officeId); final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(officeId);
if (latestGLClosure != null) { if (latestGLClosure != null) {
if (latestGLClosure.getClosingDate().after(closureDate)) { if (latestGLClosure.getClosingDate().isAfter(closureDate)) {
throw new GLClosureInvalidException(GlClosureInvalidReason.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate()); throw new GLClosureInvalidException(GlClosureInvalidReason.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate());
} }
} }
@@ -121,9 +120,9 @@ public class GLClosureWritePlatformServiceJpaRepositoryImpl implements GLClosure
/** /**
* check if any closures are present for this branch at a later date than this closure date * check if any closures are present for this branch at a later date than this closure date
**/ **/
final Date closureDate = glClosure.getClosingDate(); final LocalDate closureDate = glClosure.getClosingDate();
final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(glClosure.getOffice().getId()); final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(glClosure.getOffice().getId());
if (latestGLClosure.getClosingDate().after(closureDate)) { if (latestGLClosure.getClosingDate().isAfter(closureDate)) {
throw new GLClosureInvalidDeleteException(latestGLClosure.getOffice().getId(), latestGLClosure.getOffice().getName(), throw new GLClosureInvalidDeleteException(latestGLClosure.getOffice().getId(), latestGLClosure.getOffice().getName(),
latestGLClosure.getClosingDate()); latestGLClosure.getClosingDate());
} }
@@ -141,8 +140,7 @@ public class GLClosureWritePlatformServiceJpaRepositoryImpl implements GLClosure
private void handleGLClosureIntegrityIssues(final JsonCommand command, final Throwable realCause, NonTransientDataAccessException dve) { private void handleGLClosureIntegrityIssues(final JsonCommand command, final Throwable realCause, NonTransientDataAccessException dve) {
if (realCause.getMessage().contains("office_id_closing_date")) { if (realCause.getMessage().contains("office_id_closing_date")) {
throw new GLClosureDuplicateException(command.longValueOfParameterNamed(GLClosureJsonInputParams.OFFICE_ID.getValue()), throw new GLClosureDuplicateException(command.longValueOfParameterNamed(GLClosureJsonInputParams.OFFICE_ID.getValue()),
LocalDate.ofInstant(command.dateValueOfParameterNamed(GLClosureJsonInputParams.CLOSING_DATE.getValue()).toInstant(), command.localDateValueOfParameterNamed(GLClosureJsonInputParams.CLOSING_DATE.getValue()));
DateUtils.getDateTimeZoneOfTenant()));
} }
log.error("Error occured.", dve); log.error("Error occured.", dve);
@@ -20,13 +20,11 @@
package org.apache.fineract.accounting.glaccount.domain; package org.apache.fineract.accounting.glaccount.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.time.LocalDate;
import java.util.Objects; import java.util.Objects;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@Entity @Entity
@@ -43,23 +41,21 @@ public class TrialBalance extends AbstractPersistableCustom {
private BigDecimal amount; private BigDecimal amount;
@Column(name = "entry_date", nullable = false) @Column(name = "entry_date", nullable = false)
@Temporal(TemporalType.DATE) private LocalDate entryDate;
private Date entryDate;
@Column(name = "created_date", nullable = true) @Column(name = "created_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate transactionDate;
private Date transactionDate;
@Column(name = "closing_balance", nullable = false) @Column(name = "closing_balance", nullable = false)
private BigDecimal closingBalance; private BigDecimal closingBalance;
public static TrialBalance getInstance(final Long officeId, final Long glAccountId, final BigDecimal amount, final Date entryDate, public static TrialBalance getInstance(final Long officeId, final Long glAccountId, final BigDecimal amount, final LocalDate entryDate,
final Date transactionDate) { final LocalDate transactionDate) {
return new TrialBalance(officeId, glAccountId, amount, entryDate, transactionDate); return new TrialBalance(officeId, glAccountId, amount, entryDate, transactionDate);
} }
private TrialBalance(final Long officeId, final Long glAccountId, final BigDecimal amount, final Date entryDate, private TrialBalance(final Long officeId, final Long glAccountId, final BigDecimal amount, final LocalDate entryDate,
final Date transactionDate) { final LocalDate transactionDate) {
this.officeId = officeId; this.officeId = officeId;
this.glAccountId = glAccountId; this.glAccountId = glAccountId;
this.amount = amount; this.amount = amount;
@@ -73,7 +69,7 @@ public class TrialBalance extends AbstractPersistableCustom {
return officeId; return officeId;
} }
public Date getTransactionDate() { public LocalDate getTransactionDate() {
return transactionDate; return transactionDate;
} }
@@ -85,7 +81,7 @@ public class TrialBalance extends AbstractPersistableCustom {
this.closingBalance = closingBalance; this.closingBalance = closingBalance;
} }
public Date getEntryDate() { public LocalDate getEntryDate() {
return entryDate; return entryDate;
} }
@@ -19,8 +19,6 @@
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.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;
@@ -38,9 +36,8 @@ public class DateParam {
this.dateAsString = dateStr; this.dateAsString = dateStr;
} }
public Date getDate(final String parameterName, final String dateFormat, final String localeAsString) { public LocalDate 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); return JsonParserHelper.convertFrom(this.dateAsString, parameterName, dateFormat, locale);
return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
} }
@@ -28,8 +28,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import java.io.InputStream; import java.io.InputStream;
import java.time.LocalDate;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
@@ -126,11 +126,11 @@ public class JournalEntriesApiResource {
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission); this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission);
Date fromDate = null; LocalDate fromDate = null;
if (fromDateParam != null) { if (fromDateParam != null) {
fromDate = fromDateParam.getDate("fromDate", dateFormat, locale); fromDate = fromDateParam.getDate("fromDate", dateFormat, locale);
} }
Date toDate = null; LocalDate toDate = null;
if (toDateParam != null) { if (toDateParam != null) {
toDate = toDateParam.getDate("toDate", dateFormat, locale); toDate = toDateParam.getDate("toDate", dateFormat, locale);
} }
@@ -19,7 +19,7 @@
package org.apache.fineract.accounting.journalentry.data; package org.apache.fineract.accounting.journalentry.data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.time.LocalDate;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -35,7 +35,7 @@ public class ClientTransactionDTO {
private final Long paymentTypeId; private final Long paymentTypeId;
private final Long transactionId; private final Long transactionId;
private final Date transactionDate; private final LocalDate transactionDate;
private final EnumOptionData transactionType; private final EnumOptionData transactionType;
private final String currencyCode; private final String currencyCode;
@@ -19,7 +19,7 @@
package org.apache.fineract.accounting.journalentry.data; package org.apache.fineract.accounting.journalentry.data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.time.LocalDate;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -33,7 +33,7 @@ public class LoanTransactionDTO {
private final Long officeId; private final Long officeId;
private final Long paymentTypeId; private final Long paymentTypeId;
private final String transactionId; private final String transactionId;
private final Date transactionDate; private final LocalDate transactionDate;
private final LoanTransactionEnumData transactionType; private final LoanTransactionEnumData transactionType;
private final BigDecimal amount; private final BigDecimal amount;
@@ -19,7 +19,7 @@
package org.apache.fineract.accounting.journalentry.data; package org.apache.fineract.accounting.journalentry.data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.time.LocalDate;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -32,7 +32,7 @@ public class SavingsTransactionDTO {
private final Long officeId; private final Long officeId;
private final Long paymentTypeId; private final Long paymentTypeId;
private final String transactionId; private final String transactionId;
private final Date transactionDate; private final LocalDate transactionDate;
private final SavingsAccountTransactionEnumData transactionType; private final SavingsAccountTransactionEnumData transactionType;
private final BigDecimal amount; private final BigDecimal amount;
@@ -19,7 +19,7 @@
package org.apache.fineract.accounting.journalentry.data; package org.apache.fineract.accounting.journalentry.data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.time.LocalDate;
import java.util.List; import java.util.List;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -32,7 +32,7 @@ public class SharesTransactionDTO {
private final Long officeId; private final Long officeId;
private final Long paymentTypeId; private final Long paymentTypeId;
private final String transactionId; private final String transactionId;
private final Date transactionDate; private final LocalDate transactionDate;
private final ShareAccountTransactionEnumData transactionType; private final ShareAccountTransactionEnumData transactionType;
private final ShareAccountTransactionEnumData transactionStatus; private final ShareAccountTransactionEnumData transactionStatus;
@@ -19,15 +19,13 @@
package org.apache.fineract.accounting.journalentry.domain; package org.apache.fineract.accounting.journalentry.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.time.LocalDate;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.accounting.glaccount.domain.GLAccount; import org.apache.fineract.accounting.glaccount.domain.GLAccount;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
@@ -85,8 +83,7 @@ public class JournalEntry extends AbstractAuditableCustom {
private boolean manualEntry = false; private boolean manualEntry = false;
@Column(name = "entry_date") @Column(name = "entry_date")
@Temporal(TemporalType.DATE) private LocalDate transactionDate;
private Date transactionDate;
@Column(name = "type_enum", nullable = false) @Column(name = "type_enum", nullable = false)
private Integer type; private Integer type;
@@ -107,7 +104,7 @@ public class JournalEntry extends AbstractAuditableCustom {
private String referenceNumber; private String referenceNumber;
public static JournalEntry createNew(final Office office, final PaymentDetail paymentDetail, final GLAccount glAccount, public static JournalEntry createNew(final Office office, final PaymentDetail paymentDetail, final GLAccount glAccount,
final String currencyCode, final String transactionId, final boolean manualEntry, final Date transactionDate, final String currencyCode, final String transactionId, final boolean manualEntry, final LocalDate transactionDate,
final JournalEntryType journalEntryType, final BigDecimal amount, final String description, final Integer entityType, final JournalEntryType journalEntryType, final BigDecimal amount, final String description, final Integer entityType,
final Long entityId, final String referenceNumber, final LoanTransaction loanTransaction, final Long entityId, final String referenceNumber, final LoanTransaction loanTransaction,
final SavingsAccountTransaction savingsTransaction, final ClientTransaction clientTransaction, Long shareTransactionId) { final SavingsAccountTransaction savingsTransaction, final ClientTransaction clientTransaction, Long shareTransactionId) {
@@ -121,8 +118,8 @@ public class JournalEntry extends AbstractAuditableCustom {
} }
public JournalEntry(final Office office, final PaymentDetail paymentDetail, final GLAccount glAccount, final String currencyCode, public JournalEntry(final Office office, final PaymentDetail paymentDetail, final GLAccount glAccount, final String currencyCode,
final String transactionId, final boolean manualEntry, final Date transactionDate, final Integer type, final BigDecimal amount, final String transactionId, final boolean manualEntry, final LocalDate transactionDate, final Integer type,
final String description, final Integer entityType, final Long entityId, final String referenceNumber, final BigDecimal amount, final String description, final Integer entityType, final Long entityId, final String referenceNumber,
final LoanTransaction loanTransaction, final SavingsAccountTransaction savingsTransaction, final LoanTransaction loanTransaction, final SavingsAccountTransaction savingsTransaction,
final ClientTransaction clientTransaction, final Long shareTransactionId) { final ClientTransaction clientTransaction, final Long shareTransactionId) {
this.office = office; this.office = office;
@@ -162,7 +159,7 @@ public class JournalEntry extends AbstractAuditableCustom {
return this.glAccount; return this.glAccount;
} }
public Date getTransactionDate() { public LocalDate getTransactionDate() {
return this.transactionDate; return this.transactionDate;
} }
@@ -18,7 +18,7 @@
*/ */
package org.apache.fineract.accounting.journalentry.exception; package org.apache.fineract.accounting.journalentry.exception;
import java.util.Date; import java.time.LocalDate;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException; import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
/** /**
@@ -76,7 +76,7 @@ public class JournalEntryInvalidException extends AbstractPlatformDomainRuleExce
} }
} }
public JournalEntryInvalidException(final GlJournalEntryInvalidReason reason, final Date date, final String accountName, public JournalEntryInvalidException(final GlJournalEntryInvalidReason reason, final LocalDate date, final String accountName,
final String accountGLCode) { final String accountGLCode) {
super(reason.errorCode(), reason.errorMessage(), date, accountName, accountGLCode); super(reason.errorCode(), reason.errorMessage(), date, accountName, accountGLCode);
} }
@@ -20,9 +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.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -116,7 +114,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.from(((LocalDate) map.get("date")).atStartOfDay(ZoneId.systemDefault()).toInstant()); final LocalDate transactionDate = ((LocalDate) map.get("date"));
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");
@@ -183,7 +181,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.from(((LocalDate) map.get("date")).atStartOfDay(ZoneId.systemDefault()).toInstant()); final LocalDate transactionDate = ((LocalDate) map.get("date"));
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");
@@ -252,7 +250,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.from(((LocalDate) map.get("date")).atStartOfDay(ZoneId.systemDefault()).toInstant()); final LocalDate transactionDate = ((LocalDate) map.get("date"));
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");
@@ -288,8 +286,7 @@ public class AccountingProcessorHelper {
final Long transactionOfficeId = (Long) accountingBridgeData.get("officeId"); final Long transactionOfficeId = (Long) accountingBridgeData.get("officeId");
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 LocalDate transactionDate = ((LocalDate) accountingBridgeData.get("date"));
.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");
@@ -343,7 +340,8 @@ public class AccountingProcessorHelper {
*/ */
public void createAccrualBasedJournalEntriesAndReversalsForLoan(final Office office, final String currencyCode, public void createAccrualBasedJournalEntriesAndReversalsForLoan(final Office office, final String currencyCode,
final Integer accountTypeToBeDebited, final Integer accountTypeToBeCredited, final Long loanProductId, final Long paymentTypeId, final Integer accountTypeToBeDebited, final Integer accountTypeToBeCredited, final Long loanProductId, final Long paymentTypeId,
final Long loanId, final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) { final Long loanId, final String transactionId, final LocalDate transactionDate, final BigDecimal amount,
final Boolean isReversal) {
int accountTypeToDebitId = accountTypeToBeDebited; int accountTypeToDebitId = accountTypeToBeDebited;
int accountTypeToCreditId = accountTypeToBeCredited; int accountTypeToCreditId = accountTypeToBeCredited;
// reverse debits and credits for reversals // reverse debits and credits for reversals
@@ -385,7 +383,7 @@ public class AccountingProcessorHelper {
*/ */
public void createAccrualBasedJournalEntriesAndReversalsForLoanCharges(final Office office, final String currencyCode, public void createAccrualBasedJournalEntriesAndReversalsForLoanCharges(final Office office, final String currencyCode,
final Integer accountTypeToBeDebited, final Integer accountTypeToBeCredited, final Long loanProductId, final Long loanId, final Integer accountTypeToBeDebited, final Integer accountTypeToBeCredited, final Long loanProductId, final Long loanId,
final String transactionId, final Date transactionDate, final BigDecimal totalAmount, final Boolean isReversal, final String transactionId, final LocalDate transactionDate, final BigDecimal totalAmount, final Boolean isReversal,
final List<ChargePaymentDTO> chargePaymentDTOs) { final List<ChargePaymentDTO> chargePaymentDTOs) {
GLAccount receivableAccount = getLinkedGLAccountForLoanCharges(loanProductId, accountTypeToBeDebited, null); GLAccount receivableAccount = getLinkedGLAccountForLoanCharges(loanProductId, accountTypeToBeDebited, null);
@@ -446,8 +444,8 @@ public class AccountingProcessorHelper {
*/ */
public void createCashBasedJournalEntriesAndReversalsForSavings(final Office office, final String currencyCode, public void createCashBasedJournalEntriesAndReversalsForSavings(final Office office, final String currencyCode,
final Integer accountTypeToBeDebited, final Integer accountTypeToBeCredited, final Long savingsProductId, final Integer accountTypeToBeDebited, final Integer accountTypeToBeCredited, final Long savingsProductId,
final Long paymentTypeId, final Long loanId, final String transactionId, final Date transactionDate, final BigDecimal amount, final Long paymentTypeId, final Long loanId, final String transactionId, final LocalDate transactionDate,
final Boolean isReversal) { final BigDecimal amount, final Boolean isReversal) {
int accountTypeToDebitId = accountTypeToBeDebited; int accountTypeToDebitId = accountTypeToBeDebited;
int accountTypeToCreditId = accountTypeToBeCredited; int accountTypeToCreditId = accountTypeToBeCredited;
// reverse debits and credits for reversals // reverse debits and credits for reversals
@@ -479,7 +477,8 @@ public class AccountingProcessorHelper {
*/ */
public void createCashBasedJournalEntriesAndReversalsForLoan(final Office office, final String currencyCode, public void createCashBasedJournalEntriesAndReversalsForLoan(final Office office, final String currencyCode,
final Integer accountTypeToBeDebited, final Integer accountTypeToBeCredited, final Long loanProductId, final Long paymentTypeId, final Integer accountTypeToBeDebited, final Integer accountTypeToBeCredited, final Long loanProductId, final Long paymentTypeId,
final Long loanId, final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) { final Long loanId, final String transactionId, final LocalDate transactionDate, final BigDecimal amount,
final Boolean isReversal) {
int accountTypeToDebitId = accountTypeToBeDebited; int accountTypeToDebitId = accountTypeToBeDebited;
int accountTypeToCreditId = accountTypeToBeCredited; int accountTypeToCreditId = accountTypeToBeCredited;
// reverse debits and credits for reversals // reverse debits and credits for reversals
@@ -493,7 +492,7 @@ public class AccountingProcessorHelper {
public void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode, public void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
final CashAccountsForLoan accountMappingType, final Long loanProductId, final Long paymentTypeId, final Long loanId, final CashAccountsForLoan accountMappingType, final Long loanProductId, final Long paymentTypeId, final Long loanId,
final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) { final String transactionId, final LocalDate transactionDate, final BigDecimal amount, final Boolean isReversal) {
final int accountMappingTypeId = accountMappingType.getValue(); final int accountMappingTypeId = accountMappingType.getValue();
createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId, createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
transactionId, transactionDate, amount, isReversal); transactionId, transactionDate, amount, isReversal);
@@ -501,7 +500,7 @@ public class AccountingProcessorHelper {
public void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode, public void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode,
final AccrualAccountsForLoan accountMappingType, final Long loanProductId, final Long paymentTypeId, final Long loanId, final AccrualAccountsForLoan accountMappingType, final Long loanProductId, final Long paymentTypeId, final Long loanId,
final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) { final String transactionId, final LocalDate transactionDate, final BigDecimal amount, final Boolean isReversal) {
final int accountMappingTypeId = accountMappingType.getValue(); final int accountMappingTypeId = accountMappingType.getValue();
createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId, createCreditJournalEntryOrReversalForLoan(office, currencyCode, accountMappingTypeId, loanProductId, paymentTypeId, loanId,
transactionId, transactionDate, amount, isReversal); transactionId, transactionDate, amount, isReversal);
@@ -511,14 +510,13 @@ public class AccountingProcessorHelper {
* @param latestGLClosure * @param latestGLClosure
* @param transactionDate * @param transactionDate
*/ */
public void checkForBranchClosures(final GLClosure latestGLClosure, final Date transactionDate) { public void checkForBranchClosures(final GLClosure latestGLClosure, final LocalDate transactionDate) {
/** /**
* check if an accounting closure has happened for this branch after the transaction Date * check if an accounting closure has happened for this branch after the transaction Date
**/ **/
if (latestGLClosure != null) { if (latestGLClosure != null) {
if (latestGLClosure.getClosingDate().after(transactionDate) || latestGLClosure.getClosingDate().compareTo(transactionDate) == 0 if (latestGLClosure.getClosingDate().isAfter(transactionDate)
? Boolean.TRUE || latestGLClosure.getClosingDate().compareTo(transactionDate) == 0 ? Boolean.TRUE : Boolean.FALSE) {
: Boolean.FALSE) {
throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate(), throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate(),
null, null); null, null);
} }
@@ -535,7 +533,7 @@ public class AccountingProcessorHelper {
private void createJournalEntriesForLoan(final Office office, final String currencyCode, final int accountTypeToDebitId, private void createJournalEntriesForLoan(final Office office, final String currencyCode, final int accountTypeToDebitId,
final int accountTypeToCreditId, final Long loanProductId, final Long paymentTypeId, final Long loanId, final int accountTypeToCreditId, final Long loanProductId, final Long paymentTypeId, final Long loanId,
final String transactionId, final Date transactionDate, final BigDecimal amount) { final String transactionId, final LocalDate transactionDate, final BigDecimal amount) {
final GLAccount debitAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToDebitId, paymentTypeId); final GLAccount debitAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToDebitId, paymentTypeId);
final GLAccount creditAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToCreditId, paymentTypeId); final GLAccount creditAccount = getLinkedGLAccountForLoanProduct(loanProductId, accountTypeToCreditId, paymentTypeId);
createDebitJournalEntryForLoan(office, currencyCode, debitAccount, loanId, transactionId, transactionDate, amount); createDebitJournalEntryForLoan(office, currencyCode, debitAccount, loanId, transactionId, transactionDate, amount);
@@ -544,7 +542,7 @@ public class AccountingProcessorHelper {
private void createJournalEntriesForSavings(final Office office, final String currencyCode, final int accountTypeToDebitId, private void createJournalEntriesForSavings(final Office office, final String currencyCode, final int accountTypeToDebitId,
final int accountTypeToCreditId, final Long savingsProductId, final Long paymentTypeId, final Long savingsId, final int accountTypeToCreditId, final Long savingsProductId, final Long paymentTypeId, final Long savingsId,
final String transactionId, final Date transactionDate, final BigDecimal amount) { final String transactionId, final LocalDate transactionDate, final BigDecimal amount) {
final GLAccount debitAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToDebitId, paymentTypeId); final GLAccount debitAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToDebitId, paymentTypeId);
final GLAccount creditAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToCreditId, paymentTypeId); final GLAccount creditAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToCreditId, paymentTypeId);
createDebitJournalEntryForSavings(office, currencyCode, debitAccount, savingsId, transactionId, transactionDate, amount); createDebitJournalEntryForSavings(office, currencyCode, debitAccount, savingsId, transactionId, transactionDate, amount);
@@ -574,7 +572,7 @@ public class AccountingProcessorHelper {
public void createCashBasedJournalEntriesAndReversalsForSavingsTax(final Office office, final String currencyCode, public void createCashBasedJournalEntriesAndReversalsForSavingsTax(final Office office, final String currencyCode,
final CashAccountsForSavings accountTypeToBeDebited, final CashAccountsForSavings accountTypeToBeCredited, final CashAccountsForSavings accountTypeToBeDebited, final CashAccountsForSavings accountTypeToBeCredited,
final Long savingsProductId, final Long paymentTypeId, final Long savingsId, final String transactionId, final Long savingsProductId, final Long paymentTypeId, final Long savingsId, final String transactionId,
final Date transactionDate, final BigDecimal amount, final Boolean isReversal, final List<TaxPaymentDTO> taxDetails) { final LocalDate transactionDate, final BigDecimal amount, final Boolean isReversal, final List<TaxPaymentDTO> taxDetails) {
for (TaxPaymentDTO taxPaymentDTO : taxDetails) { for (TaxPaymentDTO taxPaymentDTO : taxDetails) {
if (taxPaymentDTO.getAmount() != null) { if (taxPaymentDTO.getAmount() != null) {
@@ -594,7 +592,7 @@ public class AccountingProcessorHelper {
public void createCashBasedDebitJournalEntriesAndReversalsForSavings(final Office office, final String currencyCode, public void createCashBasedDebitJournalEntriesAndReversalsForSavings(final Office office, final String currencyCode,
final Integer accountTypeToBeDebited, final Long savingsProductId, final Long paymentTypeId, final Long savingsId, final Integer accountTypeToBeDebited, final Long savingsProductId, final Long paymentTypeId, final Long savingsId,
final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) { final String transactionId, final LocalDate transactionDate, final BigDecimal amount, final Boolean isReversal) {
// reverse debits and credits for reversals // reverse debits and credits for reversals
if (isReversal) { if (isReversal) {
createCreditJournalEntriesForSavings(office, currencyCode, accountTypeToBeDebited, savingsProductId, paymentTypeId, savingsId, createCreditJournalEntriesForSavings(office, currencyCode, accountTypeToBeDebited, savingsProductId, paymentTypeId, savingsId,
@@ -607,7 +605,7 @@ public class AccountingProcessorHelper {
public void createCashBasedCreditJournalEntriesAndReversalsForSavings(final Office office, final String currencyCode, public void createCashBasedCreditJournalEntriesAndReversalsForSavings(final Office office, final String currencyCode,
final Integer accountTypeToBeCredited, final Long savingsProductId, final Long paymentTypeId, final Long savingsId, final Integer accountTypeToBeCredited, final Long savingsProductId, final Long paymentTypeId, final Long savingsId,
final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) { final String transactionId, final LocalDate transactionDate, final BigDecimal amount, final Boolean isReversal) {
// reverse debits and credits for reversals // reverse debits and credits for reversals
if (isReversal) { if (isReversal) {
createDebitJournalEntriesForSavings(office, currencyCode, accountTypeToBeCredited, savingsProductId, paymentTypeId, savingsId, createDebitJournalEntriesForSavings(office, currencyCode, accountTypeToBeCredited, savingsProductId, paymentTypeId, savingsId,
@@ -619,7 +617,7 @@ public class AccountingProcessorHelper {
} }
public void createCashBasedDebitJournalEntriesAndReversalsForSavings(final Office office, final String currencyCode, public void createCashBasedDebitJournalEntriesAndReversalsForSavings(final Office office, final String currencyCode,
final Long debitAccountId, final Long savingsId, final String transactionId, final Date transactionDate, final Long debitAccountId, final Long savingsId, final String transactionId, final LocalDate transactionDate,
final BigDecimal amount, final Boolean isReversal) { final BigDecimal amount, final Boolean isReversal) {
// reverse debits and credits for reversals // reverse debits and credits for reversals
final GLAccount debitAccount = getGLAccountById(debitAccountId); final GLAccount debitAccount = getGLAccountById(debitAccountId);
@@ -631,7 +629,7 @@ public class AccountingProcessorHelper {
} }
public void createCashBasedCreditJournalEntriesAndReversalsForSavings(final Office office, final String currencyCode, public void createCashBasedCreditJournalEntriesAndReversalsForSavings(final Office office, final String currencyCode,
final Long creditAccountId, final Long savingsId, final String transactionId, final Date transactionDate, final Long creditAccountId, final Long savingsId, final String transactionId, final LocalDate transactionDate,
final BigDecimal amount, final Boolean isReversal) { final BigDecimal amount, final Boolean isReversal) {
// reverse debits and credits for reversals // reverse debits and credits for reversals
final GLAccount creditAccount = getGLAccountById(creditAccountId); final GLAccount creditAccount = getGLAccountById(creditAccountId);
@@ -644,21 +642,21 @@ public class AccountingProcessorHelper {
private void createDebitJournalEntriesForSavings(final Office office, final String currencyCode, final int accountTypeToDebitId, private void createDebitJournalEntriesForSavings(final Office office, final String currencyCode, final int accountTypeToDebitId,
final Long savingsProductId, final Long paymentTypeId, final Long savingsId, final String transactionId, final Long savingsProductId, final Long paymentTypeId, final Long savingsId, final String transactionId,
final Date transactionDate, final BigDecimal amount) { final LocalDate transactionDate, final BigDecimal amount) {
final GLAccount debitAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToDebitId, paymentTypeId); final GLAccount debitAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToDebitId, paymentTypeId);
createDebitJournalEntryForSavings(office, currencyCode, debitAccount, savingsId, transactionId, transactionDate, amount); createDebitJournalEntryForSavings(office, currencyCode, debitAccount, savingsId, transactionId, transactionDate, amount);
} }
private void createCreditJournalEntriesForSavings(final Office office, final String currencyCode, final int accountTypeToCreditId, private void createCreditJournalEntriesForSavings(final Office office, final String currencyCode, final int accountTypeToCreditId,
final Long savingsProductId, final Long paymentTypeId, final Long savingsId, final String transactionId, final Long savingsProductId, final Long paymentTypeId, final Long savingsId, final String transactionId,
final Date transactionDate, final BigDecimal amount) { final LocalDate transactionDate, final BigDecimal amount) {
final GLAccount creditAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToCreditId, paymentTypeId); final GLAccount creditAccount = getLinkedGLAccountForSavingsProduct(savingsProductId, accountTypeToCreditId, paymentTypeId);
createCreditJournalEntryForSavings(office, currencyCode, creditAccount, savingsId, transactionId, transactionDate, amount); createCreditJournalEntryForSavings(office, currencyCode, creditAccount, savingsId, transactionId, transactionDate, amount);
} }
public void createDebitJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId, public void createDebitJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId,
final Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Date transactionDate, final Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId,
final BigDecimal amount, final Boolean isReversal) { final LocalDate transactionDate, final BigDecimal amount, final Boolean isReversal) {
final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId); final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
if (isReversal) { if (isReversal) {
createCreditJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount); createCreditJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
@@ -669,7 +667,7 @@ public class AccountingProcessorHelper {
public void createCreditJournalEntryOrReversalForLoanCharges(final Office office, final String currencyCode, public void createCreditJournalEntryOrReversalForLoanCharges(final Office office, final String currencyCode,
final int accountMappingTypeId, final Long loanProductId, final Long loanId, final String transactionId, final int accountMappingTypeId, final Long loanProductId, final Long loanId, final String transactionId,
final Date transactionDate, final BigDecimal totalAmount, final Boolean isReversal, final LocalDate transactionDate, final BigDecimal totalAmount, final Boolean isReversal,
final List<ChargePaymentDTO> chargePaymentDTOs) { final List<ChargePaymentDTO> chargePaymentDTOs) {
/*** /***
* Map to track each account and the net credit to be made for a particular account * Map to track each account and the net credit to be made for a particular account
@@ -744,7 +742,7 @@ public class AccountingProcessorHelper {
public void createCashBasedJournalEntriesAndReversalsForSavingsCharges(final Office office, final String currencyCode, public void createCashBasedJournalEntriesAndReversalsForSavingsCharges(final Office office, final String currencyCode,
final CashAccountsForSavings accountTypeToBeDebited, CashAccountsForSavings accountTypeToBeCredited, final CashAccountsForSavings accountTypeToBeDebited, CashAccountsForSavings accountTypeToBeCredited,
final Long savingsProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Long savingsProductId, final Long paymentTypeId, final Long loanId, final String transactionId,
final Date transactionDate, final BigDecimal totalAmount, final Boolean isReversal, final LocalDate transactionDate, final BigDecimal totalAmount, final Boolean isReversal,
final List<ChargePaymentDTO> chargePaymentDTOs) { final List<ChargePaymentDTO> chargePaymentDTOs) {
// TODO Vishwas: Remove this validation, as and when appropriate Junit // TODO Vishwas: Remove this validation, as and when appropriate Junit
// tests are written for accounting // tests are written for accounting
@@ -785,15 +783,15 @@ public class AccountingProcessorHelper {
} }
private void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId, private void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId,
final Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId, final Date transactionDate, final Long loanProductId, final Long paymentTypeId, final Long loanId, final String transactionId,
final BigDecimal amount, final Boolean isReversal) { final LocalDate transactionDate, final BigDecimal amount, final Boolean isReversal) {
final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId); final GLAccount account = getLinkedGLAccountForLoanProduct(loanProductId, accountMappingTypeId, paymentTypeId);
createCreditJournalEntryOrReversalForLoan(office, currencyCode, loanId, transactionId, transactionDate, amount, isReversal, createCreditJournalEntryOrReversalForLoan(office, currencyCode, loanId, transactionId, transactionDate, amount, isReversal,
account); account);
} }
public void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final Long loanId, public void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final Long loanId,
final String transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal, final String transactionId, final LocalDate transactionDate, final BigDecimal amount, final Boolean isReversal,
final GLAccount account) { final GLAccount account) {
if (isReversal) { if (isReversal) {
createDebitJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount); createDebitJournalEntryForLoan(office, currencyCode, account, loanId, transactionId, transactionDate, amount);
@@ -803,7 +801,7 @@ public class AccountingProcessorHelper {
} }
private void createCreditJournalEntryForClientPayments(final Office office, final String currencyCode, final GLAccount account, private void createCreditJournalEntryForClientPayments(final Office office, final String currencyCode, final GLAccount account,
final Long clientId, final Long transactionId, final Date transactionDate, final BigDecimal amount) { final Long clientId, final Long transactionId, final LocalDate transactionDate, final BigDecimal amount) {
final boolean manualEntry = false; final boolean manualEntry = false;
LoanTransaction loanTransaction = null; LoanTransaction loanTransaction = null;
SavingsAccountTransaction savingsAccountTransaction = null; SavingsAccountTransaction savingsAccountTransaction = null;
@@ -822,7 +820,7 @@ public class AccountingProcessorHelper {
} }
private void createCreditJournalEntryForSavings(final Office office, final String currencyCode, final GLAccount account, private void createCreditJournalEntryForSavings(final Office office, final String currencyCode, final GLAccount account,
final Long savingsId, final String transactionId, final Date transactionDate, final BigDecimal amount) final Long savingsId, final String transactionId, final LocalDate transactionDate, final BigDecimal amount)
throws DataAccessException { throws DataAccessException {
final boolean manualEntry = false; final boolean manualEntry = false;
LoanTransaction loanTransaction = null; LoanTransaction loanTransaction = null;
@@ -844,7 +842,7 @@ public class AccountingProcessorHelper {
} }
private void createCreditJournalEntryForLoan(final Office office, final String currencyCode, final GLAccount account, final Long loanId, private void createCreditJournalEntryForLoan(final Office office, final String currencyCode, final GLAccount account, final Long loanId,
final String transactionId, final Date transactionDate, final BigDecimal amount) { final String transactionId, final LocalDate transactionDate, final BigDecimal amount) {
final boolean manualEntry = false; final boolean manualEntry = false;
LoanTransaction loanTransaction = null; LoanTransaction loanTransaction = null;
SavingsAccountTransaction savingsAccountTransaction = null; SavingsAccountTransaction savingsAccountTransaction = null;
@@ -863,7 +861,7 @@ public class AccountingProcessorHelper {
this.glJournalEntryRepository.saveAndFlush(journalEntry); this.glJournalEntryRepository.saveAndFlush(journalEntry);
} }
public void createProvisioningDebitJournalEntry(Date transactionDate, Long provisioningentryId, Office office, String currencyCode, public void createProvisioningDebitJournalEntry(LocalDate transactionDate, Long provisioningentryId, Office office, String currencyCode,
GLAccount account, BigDecimal amount) { GLAccount account, BigDecimal amount) {
LoanTransaction loanTransaction = null; LoanTransaction loanTransaction = null;
SavingsAccountTransaction savingsAccountTransaction = null; SavingsAccountTransaction savingsAccountTransaction = null;
@@ -878,8 +876,8 @@ public class AccountingProcessorHelper {
this.glJournalEntryRepository.saveAndFlush(journalEntry); this.glJournalEntryRepository.saveAndFlush(journalEntry);
} }
public void createProvisioningCreditJournalEntry(Date transactionDate, Long provisioningentryId, Office office, String currencyCode, public void createProvisioningCreditJournalEntry(LocalDate transactionDate, Long provisioningentryId, Office office,
GLAccount account, BigDecimal amount) { String currencyCode, GLAccount account, BigDecimal amount) {
LoanTransaction loanTransaction = null; LoanTransaction loanTransaction = null;
SavingsAccountTransaction savingsAccountTransaction = null; SavingsAccountTransaction savingsAccountTransaction = null;
ClientTransaction clientTransaction = null; ClientTransaction clientTransaction = null;
@@ -894,7 +892,7 @@ public class AccountingProcessorHelper {
} }
private void createDebitJournalEntryForLoan(final Office office, final String currencyCode, final GLAccount account, final Long loanId, private void createDebitJournalEntryForLoan(final Office office, final String currencyCode, final GLAccount account, final Long loanId,
final String transactionId, final Date transactionDate, final BigDecimal amount) { final String transactionId, final LocalDate transactionDate, final BigDecimal amount) {
final boolean manualEntry = false; final boolean manualEntry = false;
LoanTransaction loanTransaction = null; LoanTransaction loanTransaction = null;
SavingsAccountTransaction savingsAccountTransaction = null; SavingsAccountTransaction savingsAccountTransaction = null;
@@ -914,7 +912,7 @@ public class AccountingProcessorHelper {
} }
private void createDebitJournalEntryForSavings(final Office office, final String currencyCode, final GLAccount account, private void createDebitJournalEntryForSavings(final Office office, final String currencyCode, final GLAccount account,
final Long savingsId, final String transactionId, final Date transactionDate, final BigDecimal amount) { final Long savingsId, final String transactionId, final LocalDate transactionDate, final BigDecimal amount) {
final boolean manualEntry = false; final boolean manualEntry = false;
LoanTransaction loanTransaction = null; LoanTransaction loanTransaction = null;
SavingsAccountTransaction savingsAccountTransaction = null; SavingsAccountTransaction savingsAccountTransaction = null;
@@ -935,7 +933,7 @@ public class AccountingProcessorHelper {
} }
private void createDebitJournalEntryForClientPayments(final Office office, final String currencyCode, final GLAccount account, private void createDebitJournalEntryForClientPayments(final Office office, final String currencyCode, final GLAccount account,
final Long clientId, final Long transactionId, final Date transactionDate, final BigDecimal amount) { final Long clientId, final Long transactionId, final LocalDate transactionDate, final BigDecimal amount) {
final boolean manualEntry = false; final boolean manualEntry = false;
ClientTransaction clientTransaction = null; ClientTransaction clientTransaction = null;
LoanTransaction loanTransaction = null; LoanTransaction loanTransaction = null;
@@ -955,7 +953,7 @@ public class AccountingProcessorHelper {
public void createJournalEntriesForShares(final Office office, final String currencyCode, final int accountTypeToDebitId, public void createJournalEntriesForShares(final Office office, final String currencyCode, final int accountTypeToDebitId,
final int accountTypeToCreditId, final Long shareProductId, final Long paymentTypeId, final Long shareAccountId, final int accountTypeToCreditId, final Long shareProductId, final Long paymentTypeId, final Long shareAccountId,
final String transactionId, final Date transactionDate, final BigDecimal amount) { final String transactionId, final LocalDate transactionDate, final BigDecimal amount) {
createDebitJournalEntryForShares(office, currencyCode, accountTypeToDebitId, shareProductId, paymentTypeId, shareAccountId, createDebitJournalEntryForShares(office, currencyCode, accountTypeToDebitId, shareProductId, paymentTypeId, shareAccountId,
transactionId, transactionDate, amount); transactionId, transactionDate, amount);
createCreditJournalEntryForShares(office, currencyCode, accountTypeToCreditId, shareProductId, paymentTypeId, shareAccountId, createCreditJournalEntryForShares(office, currencyCode, accountTypeToCreditId, shareProductId, paymentTypeId, shareAccountId,
@@ -964,14 +962,14 @@ public class AccountingProcessorHelper {
public void createDebitJournalEntryForShares(final Office office, final String currencyCode, final int accountTypeToDebitId, public void createDebitJournalEntryForShares(final Office office, final String currencyCode, final int accountTypeToDebitId,
final Long shareProductId, final Long paymentTypeId, final Long shareAccountId, final String transactionId, final Long shareProductId, final Long paymentTypeId, final Long shareAccountId, final String transactionId,
final Date transactionDate, final BigDecimal amount) { final LocalDate transactionDate, final BigDecimal amount) {
final GLAccount debitAccount = getLinkedGLAccountForShareProduct(shareProductId, accountTypeToDebitId, paymentTypeId); final GLAccount debitAccount = getLinkedGLAccountForShareProduct(shareProductId, accountTypeToDebitId, paymentTypeId);
createDebitJournalEntryForShares(office, currencyCode, debitAccount, shareAccountId, transactionId, transactionDate, amount); createDebitJournalEntryForShares(office, currencyCode, debitAccount, shareAccountId, transactionId, transactionDate, amount);
} }
public void createCreditJournalEntryForShares(final Office office, final String currencyCode, final int accountTypeToCreditId, public void createCreditJournalEntryForShares(final Office office, final String currencyCode, final int accountTypeToCreditId,
final Long shareProductId, final Long paymentTypeId, final Long shareAccountId, final String transactionId, final Long shareProductId, final Long paymentTypeId, final Long shareAccountId, final String transactionId,
final Date transactionDate, final BigDecimal amount) { final LocalDate transactionDate, final BigDecimal amount) {
final GLAccount creditAccount = getLinkedGLAccountForShareProduct(shareProductId, accountTypeToCreditId, paymentTypeId); final GLAccount creditAccount = getLinkedGLAccountForShareProduct(shareProductId, accountTypeToCreditId, paymentTypeId);
createCreditJournalEntryForShares(office, currencyCode, creditAccount, shareAccountId, transactionId, transactionDate, amount); createCreditJournalEntryForShares(office, currencyCode, creditAccount, shareAccountId, transactionId, transactionDate, amount);
} }
@@ -979,7 +977,7 @@ public class AccountingProcessorHelper {
public void createCashBasedJournalEntriesForSharesCharges(final Office office, final String currencyCode, public void createCashBasedJournalEntriesForSharesCharges(final Office office, final String currencyCode,
final CashAccountsForShares accountTypeToBeDebited, final CashAccountsForShares accountTypeToBeCredited, final CashAccountsForShares accountTypeToBeDebited, final CashAccountsForShares accountTypeToBeCredited,
final Long shareProductId, final Long paymentTypeId, final Long shareAccountId, final String transactionId, final Long shareProductId, final Long paymentTypeId, final Long shareAccountId, final String transactionId,
final Date transactionDate, final BigDecimal totalAmount, final List<ChargePaymentDTO> chargePaymentDTOs) { final LocalDate transactionDate, final BigDecimal totalAmount, final List<ChargePaymentDTO> chargePaymentDTOs) {
createDebitJournalEntryForShares(office, currencyCode, accountTypeToBeDebited.getValue(), shareProductId, paymentTypeId, createDebitJournalEntryForShares(office, currencyCode, accountTypeToBeDebited.getValue(), shareProductId, paymentTypeId,
shareAccountId, transactionId, transactionDate, totalAmount); shareAccountId, transactionId, transactionDate, totalAmount);
@@ -989,7 +987,7 @@ public class AccountingProcessorHelper {
public void createCashBasedJournalEntryForSharesCharges(final Office office, final String currencyCode, public void createCashBasedJournalEntryForSharesCharges(final Office office, final String currencyCode,
final CashAccountsForShares accountTypeToBeCredited, final Long shareProductId, final Long shareAccountId, final CashAccountsForShares accountTypeToBeCredited, final Long shareProductId, final Long shareAccountId,
final String transactionId, final Date transactionDate, final BigDecimal totalAmount, final String transactionId, final LocalDate transactionDate, final BigDecimal totalAmount,
final List<ChargePaymentDTO> chargePaymentDTOs) { final List<ChargePaymentDTO> chargePaymentDTOs) {
final Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<>(); final Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<>();
for (final ChargePaymentDTO chargePaymentDTO : chargePaymentDTOs) { for (final ChargePaymentDTO chargePaymentDTO : chargePaymentDTOs) {
@@ -1021,7 +1019,7 @@ public class AccountingProcessorHelper {
public void revertCashBasedJournalEntryForSharesCharges(final Office office, final String currencyCode, public void revertCashBasedJournalEntryForSharesCharges(final Office office, final String currencyCode,
final CashAccountsForShares accountTypeToBeCredited, final Long shareProductId, final Long shareAccountId, final CashAccountsForShares accountTypeToBeCredited, final Long shareProductId, final Long shareAccountId,
final String transactionId, final Date transactionDate, final BigDecimal totalAmount, final String transactionId, final LocalDate transactionDate, final BigDecimal totalAmount,
final List<ChargePaymentDTO> chargePaymentDTOs) { final List<ChargePaymentDTO> chargePaymentDTOs) {
final Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<>(); final Map<GLAccount, BigDecimal> creditDetailsMap = new LinkedHashMap<>();
for (final ChargePaymentDTO chargePaymentDTO : chargePaymentDTOs) { for (final ChargePaymentDTO chargePaymentDTO : chargePaymentDTOs) {
@@ -1052,7 +1050,7 @@ public class AccountingProcessorHelper {
} }
private void createDebitJournalEntryForShares(final Office office, final String currencyCode, final GLAccount account, private void createDebitJournalEntryForShares(final Office office, final String currencyCode, final GLAccount account,
final Long shareAccountId, final String transactionId, final Date transactionDate, final BigDecimal amount) { final Long shareAccountId, final String transactionId, final LocalDate transactionDate, final BigDecimal amount) {
final boolean manualEntry = false; final boolean manualEntry = false;
LoanTransaction loanTransaction = null; LoanTransaction loanTransaction = null;
SavingsAccountTransaction savingsAccountTransaction = null; SavingsAccountTransaction savingsAccountTransaction = null;
@@ -1071,7 +1069,7 @@ public class AccountingProcessorHelper {
} }
private void createCreditJournalEntryForShares(final Office office, final String currencyCode, final GLAccount account, private void createCreditJournalEntryForShares(final Office office, final String currencyCode, final GLAccount account,
final Long shareAccountId, final String transactionId, final Date transactionDate, final BigDecimal amount) { final Long shareAccountId, final String transactionId, final LocalDate transactionDate, final BigDecimal amount) {
final boolean manualEntry = false; final boolean manualEntry = false;
LoanTransaction loanTransaction = null; LoanTransaction loanTransaction = null;
SavingsAccountTransaction savingsAccountTransaction = null; SavingsAccountTransaction savingsAccountTransaction = null;
@@ -1253,7 +1251,7 @@ public class AccountingProcessorHelper {
} }
public BigDecimal createCreditJournalEntryOrReversalForClientPayments(final Office office, final String currencyCode, public BigDecimal createCreditJournalEntryOrReversalForClientPayments(final Office office, final String currencyCode,
final Long clientId, final Long transactionId, final Date transactionDate, final Boolean isReversal, final Long clientId, final Long transactionId, final LocalDate transactionDate, final Boolean isReversal,
final List<ClientChargePaymentDTO> clientChargePaymentDTOs) { final List<ClientChargePaymentDTO> clientChargePaymentDTOs) {
/*** /***
* Map to track each account affected and the net credit to be made for a particular account * Map to track each account affected and the net credit to be made for a particular account
@@ -1289,7 +1287,8 @@ public class AccountingProcessorHelper {
} }
public void createDebitJournalEntryOrReversalForClientChargePayments(final Office office, final String currencyCode, public void createDebitJournalEntryOrReversalForClientChargePayments(final Office office, final String currencyCode,
final Long clientId, final Long transactionId, final Date transactionDate, final BigDecimal amount, final Boolean isReversal) { final Long clientId, final Long transactionId, final LocalDate transactionDate, final BigDecimal amount,
final Boolean isReversal) {
final GLAccount account = financialActivityAccountRepository final GLAccount account = financialActivityAccountRepository
.findByFinancialActivityTypeWithNotFoundDetection(FinancialActivity.ASSET_FUND_SOURCE.getValue()).getGlAccount(); .findByFinancialActivityTypeWithNotFoundDetection(FinancialActivity.ASSET_FUND_SOURCE.getValue()).getGlAccount();
if (isReversal) { if (isReversal) {
@@ -19,8 +19,8 @@
package org.apache.fineract.accounting.journalentry.service; package org.apache.fineract.accounting.journalentry.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -47,7 +47,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(loanDTO.getOfficeId()); final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(loanDTO.getOfficeId());
final Office office = this.helper.getOfficeById(loanDTO.getOfficeId()); final Office office = this.helper.getOfficeById(loanDTO.getOfficeId());
for (final LoanTransactionDTO loanTransactionDTO : loanDTO.getNewLoanTransactions()) { for (final LoanTransactionDTO loanTransactionDTO : loanDTO.getNewLoanTransactions()) {
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
this.helper.checkForBranchClosures(latestGLClosure, transactionDate); this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
/** Handle Disbursements **/ /** Handle Disbursements **/
@@ -116,7 +116,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal disbursalAmount = loanTransactionDTO.getAmount(); final BigDecimal disbursalAmount = loanTransactionDTO.getAmount();
final boolean isReversed = loanTransactionDTO.isReversed(); final boolean isReversed = loanTransactionDTO.isReversed();
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId(); final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
@@ -181,7 +181,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal principalAmount = loanTransactionDTO.getPrincipal(); final BigDecimal principalAmount = loanTransactionDTO.getPrincipal();
final BigDecimal interestAmount = loanTransactionDTO.getInterest(); final BigDecimal interestAmount = loanTransactionDTO.getInterest();
final BigDecimal feesAmount = loanTransactionDTO.getFees(); final BigDecimal feesAmount = loanTransactionDTO.getFees();
@@ -323,7 +323,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal amount = loanTransactionDTO.getAmount(); final BigDecimal amount = loanTransactionDTO.getAmount();
final boolean isReversal = loanTransactionDTO.isReversed(); final boolean isReversal = loanTransactionDTO.isReversed();
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId(); final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
@@ -357,7 +357,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal interestAmount = loanTransactionDTO.getInterest(); final BigDecimal interestAmount = loanTransactionDTO.getInterest();
final BigDecimal feesAmount = loanTransactionDTO.getFees(); final BigDecimal feesAmount = loanTransactionDTO.getFees();
final BigDecimal penaltiesAmount = loanTransactionDTO.getPenalties(); final BigDecimal penaltiesAmount = loanTransactionDTO.getPenalties();
@@ -394,7 +394,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal refundAmount = loanTransactionDTO.getAmount(); final BigDecimal refundAmount = loanTransactionDTO.getAmount();
final boolean isReversal = loanTransactionDTO.isReversed(); final boolean isReversal = loanTransactionDTO.isReversed();
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId(); final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
@@ -419,7 +419,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal refundAmount = loanTransactionDTO.getAmount(); final BigDecimal refundAmount = loanTransactionDTO.getAmount();
final boolean isReversal = loanTransactionDTO.isReversed(); final boolean isReversal = loanTransactionDTO.isReversed();
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId(); final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
@@ -438,7 +438,7 @@ public class AccrualBasedAccountingProcessorForLoan implements AccountingProcess
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal principalAmount = loanTransactionDTO.getPrincipal(); final BigDecimal principalAmount = loanTransactionDTO.getPrincipal();
final BigDecimal interestAmount = loanTransactionDTO.getInterest(); final BigDecimal interestAmount = loanTransactionDTO.getInterest();
final BigDecimal feesAmount = loanTransactionDTO.getFees(); final BigDecimal feesAmount = loanTransactionDTO.getFees();
@@ -19,7 +19,7 @@
package org.apache.fineract.accounting.journalentry.service; package org.apache.fineract.accounting.journalentry.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.time.LocalDate;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.fineract.accounting.closure.domain.GLClosure; import org.apache.fineract.accounting.closure.domain.GLClosure;
import org.apache.fineract.accounting.journalentry.data.ClientTransactionDTO; import org.apache.fineract.accounting.journalentry.data.ClientTransactionDTO;
@@ -36,7 +36,7 @@ public class CashBasedAccountingProcessorForClientTransactions implements Accoun
public void createJournalEntriesForClientTransaction(ClientTransactionDTO clientTransactionDTO) { public void createJournalEntriesForClientTransaction(ClientTransactionDTO clientTransactionDTO) {
if (clientTransactionDTO.isAccountingEnabled()) { if (clientTransactionDTO.isAccountingEnabled()) {
final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(clientTransactionDTO.getOfficeId()); final GLClosure latestGLClosure = this.helper.getLatestClosureByBranch(clientTransactionDTO.getOfficeId());
final Date transactionDate = clientTransactionDTO.getTransactionDate(); final LocalDate transactionDate = clientTransactionDTO.getTransactionDate();
final Office office = this.helper.getOfficeById(clientTransactionDTO.getOfficeId()); final Office office = this.helper.getOfficeById(clientTransactionDTO.getOfficeId());
this.helper.checkForBranchClosures(latestGLClosure, transactionDate); this.helper.checkForBranchClosures(latestGLClosure, transactionDate);
@@ -60,7 +60,7 @@ public class CashBasedAccountingProcessorForClientTransactions implements Accoun
// transaction properties // transaction properties
final String currencyCode = clientTransactionDTO.getCurrencyCode(); final String currencyCode = clientTransactionDTO.getCurrencyCode();
final Long transactionId = clientTransactionDTO.getTransactionId(); final Long transactionId = clientTransactionDTO.getTransactionId();
final Date transactionDate = clientTransactionDTO.getTransactionDate(); final LocalDate transactionDate = clientTransactionDTO.getTransactionDate();
final BigDecimal amount = clientTransactionDTO.getAmount(); final BigDecimal amount = clientTransactionDTO.getAmount();
final boolean isReversal = clientTransactionDTO.isReversed(); final boolean isReversal = clientTransactionDTO.isReversed();
@@ -19,8 +19,8 @@
package org.apache.fineract.accounting.journalentry.service; package org.apache.fineract.accounting.journalentry.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.fineract.accounting.closure.domain.GLClosure; import org.apache.fineract.accounting.closure.domain.GLClosure;
@@ -46,7 +46,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
final Long loanProductId = loanDTO.getLoanProductId(); final Long loanProductId = loanDTO.getLoanProductId();
final String currencyCode = loanDTO.getCurrencyCode(); final String currencyCode = loanDTO.getCurrencyCode();
for (final LoanTransactionDTO loanTransactionDTO : loanDTO.getNewLoanTransactions()) { for (final LoanTransactionDTO loanTransactionDTO : loanDTO.getNewLoanTransactions()) {
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Office office = this.helper.getOfficeById(loanTransactionDTO.getOfficeId()); final Office office = this.helper.getOfficeById(loanTransactionDTO.getOfficeId());
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId(); final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
@@ -126,7 +126,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal disbursalAmount = loanTransactionDTO.getAmount(); final BigDecimal disbursalAmount = loanTransactionDTO.getAmount();
final boolean isReversal = loanTransactionDTO.isReversed(); final boolean isReversal = loanTransactionDTO.isReversed();
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId(); final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
@@ -164,7 +164,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal refundAmount = loanTransactionDTO.getAmount(); final BigDecimal refundAmount = loanTransactionDTO.getAmount();
final boolean isReversal = loanTransactionDTO.isReversed(); final boolean isReversal = loanTransactionDTO.isReversed();
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId(); final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
@@ -196,7 +196,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal principalAmount = loanTransactionDTO.getPrincipal(); final BigDecimal principalAmount = loanTransactionDTO.getPrincipal();
final BigDecimal interestAmount = loanTransactionDTO.getInterest(); final BigDecimal interestAmount = loanTransactionDTO.getInterest();
final BigDecimal feesAmount = loanTransactionDTO.getFees(); final BigDecimal feesAmount = loanTransactionDTO.getFees();
@@ -272,7 +272,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal amount = loanTransactionDTO.getAmount(); final BigDecimal amount = loanTransactionDTO.getAmount();
final boolean isReversal = loanTransactionDTO.isReversed(); final boolean isReversal = loanTransactionDTO.isReversed();
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId(); final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
@@ -302,7 +302,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal principalAmount = loanTransactionDTO.getPrincipal(); final BigDecimal principalAmount = loanTransactionDTO.getPrincipal();
final boolean isReversal = loanTransactionDTO.isReversed(); final boolean isReversal = loanTransactionDTO.isReversed();
// final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId(); // final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
@@ -328,7 +328,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal refundAmount = loanTransactionDTO.getAmount(); final BigDecimal refundAmount = loanTransactionDTO.getAmount();
final boolean isReversal = loanTransactionDTO.isReversed(); final boolean isReversal = loanTransactionDTO.isReversed();
final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId(); final Long paymentTypeId = loanTransactionDTO.getPaymentTypeId();
@@ -346,7 +346,7 @@ public class CashBasedAccountingProcessorForLoan implements AccountingProcessorF
// transaction properties // transaction properties
final String transactionId = loanTransactionDTO.getTransactionId(); final String transactionId = loanTransactionDTO.getTransactionId();
final Date transactionDate = loanTransactionDTO.getTransactionDate(); final LocalDate transactionDate = loanTransactionDTO.getTransactionDate();
final BigDecimal principalAmount = loanTransactionDTO.getPrincipal(); final BigDecimal principalAmount = loanTransactionDTO.getPrincipal();
final BigDecimal interestAmount = loanTransactionDTO.getInterest(); final BigDecimal interestAmount = loanTransactionDTO.getInterest();
final BigDecimal feesAmount = loanTransactionDTO.getFees(); final BigDecimal feesAmount = loanTransactionDTO.getFees();
@@ -19,7 +19,7 @@
package org.apache.fineract.accounting.journalentry.service; package org.apache.fineract.accounting.journalentry.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.time.LocalDate;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.fineract.accounting.closure.domain.GLClosure; import org.apache.fineract.accounting.closure.domain.GLClosure;
@@ -44,7 +44,7 @@ public class CashBasedAccountingProcessorForSavings implements AccountingProcess
final Long savingsId = savingsDTO.getSavingsId(); final Long savingsId = savingsDTO.getSavingsId();
final String currencyCode = savingsDTO.getCurrencyCode(); final String currencyCode = savingsDTO.getCurrencyCode();
for (final SavingsTransactionDTO savingsTransactionDTO : savingsDTO.getNewSavingsTransactions()) { for (final SavingsTransactionDTO savingsTransactionDTO : savingsDTO.getNewSavingsTransactions()) {
final Date transactionDate = savingsTransactionDTO.getTransactionDate(); final LocalDate transactionDate = savingsTransactionDTO.getTransactionDate();
final String transactionId = savingsTransactionDTO.getTransactionId(); final String transactionId = savingsTransactionDTO.getTransactionId();
final Office office = this.helper.getOfficeById(savingsTransactionDTO.getOfficeId()); final Office office = this.helper.getOfficeById(savingsTransactionDTO.getOfficeId());
final Long paymentTypeId = savingsTransactionDTO.getPaymentTypeId(); final Long paymentTypeId = savingsTransactionDTO.getPaymentTypeId();
@@ -19,7 +19,7 @@
package org.apache.fineract.accounting.journalentry.service; package org.apache.fineract.accounting.journalentry.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.time.LocalDate;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.fineract.accounting.closure.domain.GLClosure; import org.apache.fineract.accounting.closure.domain.GLClosure;
@@ -43,7 +43,7 @@ public class CashBasedAccountingProcessorForShares implements AccountingProcesso
final Long shareProductId = sharesDTO.getShareProductId(); final Long shareProductId = sharesDTO.getShareProductId();
final String currencyCode = sharesDTO.getCurrencyCode(); final String currencyCode = sharesDTO.getCurrencyCode();
for (SharesTransactionDTO transactionDTO : sharesDTO.getNewTransactions()) { for (SharesTransactionDTO transactionDTO : sharesDTO.getNewTransactions()) {
final Date transactionDate = transactionDTO.getTransactionDate(); final LocalDate transactionDate = transactionDTO.getTransactionDate();
final String transactionId = transactionDTO.getTransactionId(); final String transactionId = transactionDTO.getTransactionId();
final Office office = this.helper.getOfficeById(transactionDTO.getOfficeId()); final Office office = this.helper.getOfficeById(transactionDTO.getOfficeId());
final Long paymentTypeId = transactionDTO.getPaymentTypeId(); final Long paymentTypeId = transactionDTO.getPaymentTypeId();
@@ -70,8 +70,8 @@ public class CashBasedAccountingProcessorForShares implements AccountingProcesso
} }
public void createJournalEntriesForRedeem(final Long shareAccountId, final Long shareProductId, final String currencyCode, public void createJournalEntriesForRedeem(final Long shareAccountId, final Long shareProductId, final String currencyCode,
final Date transactionDate, final String transactionId, final Office office, final Long paymentTypeId, final BigDecimal amount, final LocalDate transactionDate, final String transactionId, final Office office, final Long paymentTypeId,
final BigDecimal chargeAmount, final List<ChargePaymentDTO> feePayments) { final BigDecimal amount, final BigDecimal chargeAmount, final List<ChargePaymentDTO> feePayments) {
if (chargeAmount == null || chargeAmount.compareTo(BigDecimal.ZERO) <= 0) { if (chargeAmount == null || chargeAmount.compareTo(BigDecimal.ZERO) <= 0) {
this.helper.createJournalEntriesForShares(office, currencyCode, CashAccountsForShares.SHARES_EQUITY.getValue(), this.helper.createJournalEntriesForShares(office, currencyCode, CashAccountsForShares.SHARES_EQUITY.getValue(),
CashAccountsForShares.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId, CashAccountsForShares.SHARES_REFERENCE.getValue(), shareProductId, paymentTypeId, shareAccountId, transactionId,
@@ -87,7 +87,7 @@ public class CashBasedAccountingProcessorForShares implements AccountingProcesso
} }
public void createJournalEntriesForPurchase(final Long shareAccountId, final Long shareProductId, final String currencyCode, public void createJournalEntriesForPurchase(final Long shareAccountId, final Long shareProductId, final String currencyCode,
SharesTransactionDTO transactionDTO, final Date transactionDate, final String transactionId, final Office office, SharesTransactionDTO transactionDTO, final LocalDate transactionDate, final String transactionId, final Office office,
final Long paymentTypeId, final BigDecimal amount, final BigDecimal chargeAmount, final List<ChargePaymentDTO> feePayments) { final Long paymentTypeId, final BigDecimal amount, final BigDecimal chargeAmount, final List<ChargePaymentDTO> feePayments) {
if (transactionDTO.getTransactionStatus().isApplied()) { if (transactionDTO.getTransactionStatus().isApplied()) {
if (chargeAmount == null || chargeAmount.compareTo(BigDecimal.ZERO) <= 0) { if (chargeAmount == null || chargeAmount.compareTo(BigDecimal.ZERO) <= 0) {
@@ -18,7 +18,7 @@
*/ */
package org.apache.fineract.accounting.journalentry.service; package org.apache.fineract.accounting.journalentry.service;
import java.util.Date; import java.time.LocalDate;
import org.apache.fineract.accounting.journalentry.data.JournalEntryAssociationParametersData; import org.apache.fineract.accounting.journalentry.data.JournalEntryAssociationParametersData;
import org.apache.fineract.accounting.journalentry.data.JournalEntryData; import org.apache.fineract.accounting.journalentry.data.JournalEntryData;
import org.apache.fineract.accounting.journalentry.data.OfficeOpeningBalancesData; import org.apache.fineract.accounting.journalentry.data.OfficeOpeningBalancesData;
@@ -29,8 +29,8 @@ public interface JournalEntryReadPlatformService {
JournalEntryData retrieveGLJournalEntryById(long glJournalEntryId, JournalEntryAssociationParametersData associationParametersData); JournalEntryData retrieveGLJournalEntryById(long glJournalEntryId, JournalEntryAssociationParametersData associationParametersData);
Page<JournalEntryData> retrieveAll(SearchParameters searchParameters, Long glAccountId, Boolean onlyManualEntries, Date fromDate, Page<JournalEntryData> retrieveAll(SearchParameters searchParameters, Long glAccountId, Boolean onlyManualEntries, LocalDate fromDate,
Date toDate, String transactionId, Integer entityType, JournalEntryAssociationParametersData associationParametersData); LocalDate toDate, String transactionId, Integer entityType, JournalEntryAssociationParametersData associationParametersData);
OfficeOpeningBalancesData retrieveOfficeOpeningBalances(Long officeId, String currencyCode); OfficeOpeningBalancesData retrieveOfficeOpeningBalances(Long officeId, String currencyCode);
@@ -21,12 +21,11 @@ package org.apache.fineract.accounting.journalentry.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -235,8 +234,8 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
@Override @Override
public Page<JournalEntryData> retrieveAll(final SearchParameters searchParameters, final Long glAccountId, public Page<JournalEntryData> retrieveAll(final SearchParameters searchParameters, final Long glAccountId,
final Boolean onlyManualEntries, final Date fromDate, final Date toDate, final String transactionId, final Integer entityType, final Boolean onlyManualEntries, final LocalDate fromDate, final LocalDate toDate, final String transactionId,
final JournalEntryAssociationParametersData associationParametersData) { final Integer entityType, final JournalEntryAssociationParametersData associationParametersData) {
GLJournalEntryMapper rm = new GLJournalEntryMapper(associationParametersData); GLJournalEntryMapper rm = new GLJournalEntryMapper(associationParametersData);
final StringBuilder sqlBuilder = new StringBuilder(200); final StringBuilder sqlBuilder = new StringBuilder(200);
@@ -290,7 +289,7 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
} }
if (fromDate != null || toDate != null) { if (fromDate != null || toDate != null) {
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); final DateTimeFormatter df = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd").toFormatter();
String fromDateString = null; String fromDateString = null;
String toDateString = null; String toDateString = null;
if (fromDate != null && toDate != null) { if (fromDate != null && toDate != null) {
@@ -492,8 +491,8 @@ public class JournalEntryReadPlatformServiceImpl implements JournalEntryReadPlat
final String sortOrder = "ASC"; final String sortOrder = "ASC";
final Integer entityType = null; final Integer entityType = null;
final Boolean onlyManualEntries = null; final Boolean onlyManualEntries = null;
final Date fromDate = null; final LocalDate fromDate = null;
final Date toDate = null; final LocalDate toDate = null;
final JournalEntryAssociationParametersData associationParametersData = null; final JournalEntryAssociationParametersData associationParametersData = null;
final Long loanId = null; final Long loanId = null;
final Long savingsId = null; final Long savingsId = null;
@@ -21,8 +21,8 @@ package org.apache.fineract.accounting.journalentry.service;
import java.math.BigDecimal; 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.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -71,7 +71,7 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
String dateFinder = "select MIN(je.entry_date) as entityDate from acc_gl_journal_entry je " String dateFinder = "select MIN(je.entry_date) as entityDate from acc_gl_journal_entry je "
+ "where je.is_running_balance_calculated=false "; + "where je.is_running_balance_calculated=false ";
try { try {
Date entityDate = this.jdbcTemplate.queryForObject(dateFinder, Date.class); LocalDate entityDate = this.jdbcTemplate.queryForObject(dateFinder, LocalDate.class);
updateOrganizationRunningBalance(entityDate); updateOrganizationRunningBalance(entityDate);
} catch (EmptyResultDataAccessException e) { } catch (EmptyResultDataAccessException e) {
log.debug("No results found for updation of running balance "); log.debug("No results found for updation of running balance ");
@@ -92,7 +92,7 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
String dateFinder = "select MIN(je.entry_date) as entityDate " + "from acc_gl_journal_entry je " String dateFinder = "select MIN(je.entry_date) as entityDate " + "from acc_gl_journal_entry je "
+ "where je.is_running_balance_calculated=false and je.office_id=?"; + "where je.is_running_balance_calculated=false and je.office_id=?";
try { try {
Date entityDate = this.jdbcTemplate.queryForObject(dateFinder, Date.class, officeId); LocalDate entityDate = this.jdbcTemplate.queryForObject(dateFinder, LocalDate.class, officeId);
updateRunningBalance(officeId, entityDate); updateRunningBalance(officeId, entityDate);
} catch (EmptyResultDataAccessException e) { } catch (EmptyResultDataAccessException e) {
log.debug("No results found for updation of office running balance with office id: {}", officeId); log.debug("No results found for updation of office running balance with office id: {}", officeId);
@@ -102,7 +102,7 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
return commandProcessingResultBuilder.build(); return commandProcessingResultBuilder.build();
} }
private void updateOrganizationRunningBalance(Date entityDate) { private void updateOrganizationRunningBalance(LocalDate entityDate) {
Map<Long, BigDecimal> runningBalanceMap = new HashMap<>(5); Map<Long, BigDecimal> runningBalanceMap = new HashMap<>(5);
Map<Long, Map<Long, BigDecimal>> officesRunningBalance = new HashMap<>(); Map<Long, Map<Long, BigDecimal>> officesRunningBalance = new HashMap<>();
@@ -112,7 +112,7 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
+ "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0); + "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0);
List<Map<String, Object>> list = jdbcTemplate.queryForList(organizationRunningBalanceQuery, // NOSONAR List<Map<String, Object>> list = jdbcTemplate.queryForList(organizationRunningBalanceQuery, // NOSONAR
new Object[] { entityDate, entityDate }); entityDate, entityDate);
for (Map<String, Object> entries : list) { for (Map<String, Object> entries : list) {
Long accountId = Long.parseLong(entries.get("accountId").toString()); // Drizzle Long accountId = Long.parseLong(entries.get("accountId").toString()); // Drizzle
@@ -137,7 +137,7 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
+ "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0); + "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0);
List<Map<String, Object>> officesRunningBalanceList = jdbcTemplate.queryForList(offlineRunningBalanceQuery, // NOSONAR List<Map<String, Object>> officesRunningBalanceList = jdbcTemplate.queryForList(offlineRunningBalanceQuery, // NOSONAR
new Object[] { entityDate, entityDate }); entityDate, entityDate);
for (Map<String, Object> entries : officesRunningBalanceList) { for (Map<String, Object> entries : officesRunningBalanceList) {
Long accountId = Long.parseLong(entries.get("accountId").toString()); Long accountId = Long.parseLong(entries.get("accountId").toString());
Long officeId = Long.parseLong(entries.get("officeId").toString()); Long officeId = Long.parseLong(entries.get("officeId").toString());
@@ -153,8 +153,7 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
} }
} }
List<JournalEntryData> entryDatas = jdbcTemplate.query(entryMapper.organizationRunningBalanceSchema(), entryMapper, List<JournalEntryData> entryDatas = jdbcTemplate.query(entryMapper.organizationRunningBalanceSchema(), entryMapper, entityDate);
new Object[] { entityDate });
if (entryDatas.size() > 0) { if (entryDatas.size() > 0) {
// run a batch update of 1000 SQL statements at a time // run a batch update of 1000 SQL statements at a time
final Integer batchUpdateSize = 1000; final Integer batchUpdateSize = 1000;
@@ -189,7 +188,7 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
} }
private void updateRunningBalance(Long officeId, Date entityDate) { private void updateRunningBalance(Long officeId, LocalDate entityDate) {
Map<Long, BigDecimal> runningBalanceMap = new HashMap<>(5); Map<Long, BigDecimal> runningBalanceMap = new HashMap<>(5);
final String offlineRunningBalanceQuery = "select je.office_running_balance as runningBalance,je.account_id as accountId from acc_gl_journal_entry je " final String offlineRunningBalanceQuery = "select je.office_running_balance as runningBalance,je.account_id as accountId from acc_gl_journal_entry je "
@@ -198,15 +197,14 @@ public class JournalEntryRunningBalanceUpdateServiceImpl implements JournalEntry
+ "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0); + "group by je.id order by je.entry_date DESC " + sqlGenerator.limit(10000, 0);
List<Map<String, Object>> list = jdbcTemplate.queryForList(offlineRunningBalanceQuery, // NOSONAR List<Map<String, Object>> list = jdbcTemplate.queryForList(offlineRunningBalanceQuery, // NOSONAR
new Object[] { officeId, entityDate, officeId, entityDate }); officeId, entityDate, officeId, entityDate);
for (Map<String, Object> entries : list) { for (Map<String, Object> entries : list) {
Long accountId = (Long) entries.get("accountId"); Long accountId = (Long) entries.get("accountId");
if (!runningBalanceMap.containsKey(accountId)) { if (!runningBalanceMap.containsKey(accountId)) {
runningBalanceMap.put(accountId, (BigDecimal) entries.get("runningBalance")); runningBalanceMap.put(accountId, (BigDecimal) entries.get("runningBalance"));
} }
} }
List<JournalEntryData> entryDatas = jdbcTemplate.query(entryMapper.officeRunningBalanceSchema(), entryMapper, List<JournalEntryData> entryDatas = jdbcTemplate.query(entryMapper.officeRunningBalanceSchema(), entryMapper, officeId, entityDate);
new Object[] { officeId, entityDate });
String[] updateSql = new String[entryDatas.size()]; String[] updateSql = new String[entryDatas.size()];
int i = 0; int i = 0;
for (JournalEntryData entryData : entryDatas) { for (JournalEntryData entryData : entryDatas) {
@@ -18,8 +18,8 @@
*/ */
package org.apache.fineract.accounting.journalentry.service; package org.apache.fineract.accounting.journalentry.service;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.Map; import java.util.Map;
import org.apache.fineract.accounting.provisioning.domain.ProvisioningEntry; import org.apache.fineract.accounting.provisioning.domain.ProvisioningEntry;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -39,12 +39,12 @@ public interface JournalEntryWritePlatformService {
CommandProcessingResult defineOpeningBalance(JsonCommand command); CommandProcessingResult defineOpeningBalance(JsonCommand command);
String revertProvisioningJournalEntries(Date reversalTransactionDate, Long entityId, Integer entityType); String revertProvisioningJournalEntries(LocalDate reversalTransactionDate, Long entityId, Integer entityType);
String createProvisioningJournalEntries(ProvisioningEntry entry); String createProvisioningJournalEntries(ProvisioningEntry entry);
void createJournalEntriesForShares(Map<String, Object> accountingBridgeData); void createJournalEntriesForShares(Map<String, Object> accountingBridgeData);
void revertShareAccountJournalEntries(ArrayList<Long> transactionId, Date transactionDate); void revertShareAccountJournalEntries(ArrayList<Long> transactionId, LocalDate transactionDate);
} }
@@ -20,10 +20,8 @@ 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.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@@ -130,7 +128,8 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes); final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
/** Set a transaction Id and save these Journal entries **/ /** Set a transaction Id and save these Journal entries **/
final Date transactionDate = command.dateValueOfParameterNamed(JournalEntryJsonInputParams.TRANSACTION_DATE.getValue()); final LocalDate transactionDate = command
.localDateValueOfParameterNamed(JournalEntryJsonInputParams.TRANSACTION_DATE.getValue());
final String transactionId = generateTransactionId(officeId); final String transactionId = generateTransactionId(officeId);
final String referenceNumber = command.stringValueOfParameterNamed(JournalEntryJsonInputParams.REFERENCE_NUMBER.getValue()); final String referenceNumber = command.stringValueOfParameterNamed(JournalEntryJsonInputParams.REFERENCE_NUMBER.getValue());
@@ -315,10 +314,10 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
// Before reversal validate accounting closure is done for that branch // Before reversal validate accounting closure is done for that branch
// or not. // or not.
final Date journalEntriesTransactionDate = journalEntries.get(0).getTransactionDate(); final LocalDate journalEntriesTransactionDate = journalEntries.get(0).getTransactionDate();
final GLClosure latestGLClosureByBranch = this.glClosureRepository.getLatestGLClosureByBranch(officeId); final GLClosure latestGLClosureByBranch = this.glClosureRepository.getLatestGLClosureByBranch(officeId);
if (latestGLClosureByBranch != null) { if (latestGLClosureByBranch != null) {
if (latestGLClosureByBranch.getClosingDate().after(journalEntriesTransactionDate) if (latestGLClosureByBranch.getClosingDate().isAfter(journalEntriesTransactionDate)
|| latestGLClosureByBranch.getClosingDate().compareTo(journalEntriesTransactionDate) == 0 ? Boolean.TRUE || latestGLClosureByBranch.getClosingDate().compareTo(journalEntriesTransactionDate) == 0 ? Boolean.TRUE
: Boolean.FALSE) { : Boolean.FALSE) {
final String accountName = null; final String accountName = null;
@@ -358,7 +357,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
} }
@Override @Override
public String revertProvisioningJournalEntries(final Date reversalTransactionDate, final Long entityId, final Integer entityType) { public String revertProvisioningJournalEntries(final LocalDate reversalTransactionDate, final Long entityId, final Integer entityType) {
List<JournalEntry> journalEntries = this.glJournalEntryRepository.findProvisioningJournalEntriesByEntityId(entityId, entityType); List<JournalEntry> journalEntries = this.glJournalEntryRepository.findProvisioningJournalEntriesByEntityId(entityId, entityType);
final String reversalTransactionId = journalEntries.get(0).getTransactionId(); final String reversalTransactionId = journalEntries.get(0).getTransactionId();
for (final JournalEntry journalEntry : journalEntries) { for (final JournalEntry journalEntry : journalEntries) {
@@ -435,13 +434,13 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
expenseMap.put(entry.getExpenseAccount(), amount); expenseMap.put(entry.getExpenseAccount(), amount);
} }
} }
createJournalEnry(provisioningEntry.getCreatedDate(), provisioningEntry.getId(), key.office, key.currency, liabilityMap, createJournalEntry(provisioningEntry.getCreatedDate(), provisioningEntry.getId(), key.office, key.currency, liabilityMap,
expenseMap); expenseMap);
} }
return "P" + provisioningEntry.getId(); return "P" + provisioningEntry.getId();
} }
private void createJournalEnry(Date transactionDate, Long entryId, Office office, String currencyCode, private void createJournalEntry(LocalDate transactionDate, Long entryId, Office office, String currencyCode,
Map<GLAccount, BigDecimal> liabilityMap, Map<GLAccount, BigDecimal> expenseMap) { Map<GLAccount, BigDecimal> liabilityMap, Map<GLAccount, BigDecimal> expenseMap) {
Set<GLAccount> liabilityAccounts = liabilityMap.keySet(); Set<GLAccount> liabilityAccounts = liabilityMap.keySet();
for (GLAccount account : liabilityAccounts) { for (GLAccount account : liabilityAccounts) {
@@ -519,7 +518,7 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
} }
@Override @Override
public void revertShareAccountJournalEntries(final ArrayList<Long> transactionIds, final Date transactionDate) { public void revertShareAccountJournalEntries(final ArrayList<Long> transactionIds, final LocalDate transactionDate) {
for (Long shareTransactionId : transactionIds) { for (Long shareTransactionId : transactionIds) {
String transactionId = AccountingProcessorHelper.SHARE_TRANSACTION_IDENTIFIER + shareTransactionId.longValue(); String transactionId = AccountingProcessorHelper.SHARE_TRANSACTION_IDENTIFIER + shareTransactionId.longValue();
List<JournalEntry> journalEntries = this.glJournalEntryRepository.findJournalEntries(transactionId, List<JournalEntry> journalEntries = this.glJournalEntryRepository.findJournalEntries(transactionId,
@@ -561,18 +560,17 @@ 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(ZoneId.systemDefault()).toInstant()); final LocalDate transactionDate = entryLocalDate;
// shouldn't be in the future // shouldn't be in the future
final Date todaysDate = DateUtils.getBusinessDate(); final LocalDate todaysDate = DateUtils.getBusinessLocalDate();
if (transactionDate.after(todaysDate)) { if (transactionDate.isAfter(todaysDate)) {
throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.FUTURE_DATE, transactionDate, null, null); throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.FUTURE_DATE, transactionDate, null, null);
} }
// shouldn't be before an accounting closure // shouldn't be before an accounting closure
final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(command.getOfficeId()); final GLClosure latestGLClosure = this.glClosureRepository.getLatestGLClosureByBranch(command.getOfficeId());
if (latestGLClosure != null) { if (latestGLClosure != null) {
if (latestGLClosure.getClosingDate().after(transactionDate) || latestGLClosure.getClosingDate().compareTo(transactionDate) == 0 if (latestGLClosure.getClosingDate().isAfter(transactionDate)
? Boolean.TRUE || latestGLClosure.getClosingDate().compareTo(transactionDate) == 0 ? Boolean.TRUE : Boolean.FALSE) {
: Boolean.FALSE) {
throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate(), throw new JournalEntryInvalidException(GlJournalEntryInvalidReason.ACCOUNTING_CLOSED, latestGLClosure.getClosingDate(),
null, null); null, null);
} }
@@ -591,8 +589,9 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
} }
private void saveAllDebitOrCreditEntries(final JournalEntryCommand command, final Office office, final PaymentDetail paymentDetail, private void saveAllDebitOrCreditEntries(final JournalEntryCommand command, final Office office, final PaymentDetail paymentDetail,
final String currencyCode, final Date transactionDate, final SingleDebitOrCreditEntryCommand[] singleDebitOrCreditEntryCommands, final String currencyCode, final LocalDate transactionDate,
final String transactionId, final JournalEntryType type, final String referenceNumber) { final SingleDebitOrCreditEntryCommand[] singleDebitOrCreditEntryCommands, final String transactionId,
final JournalEntryType type, final String referenceNumber) {
final boolean manualEntry = true; final boolean manualEntry = true;
for (final SingleDebitOrCreditEntryCommand singleDebitOrCreditEntryCommand : singleDebitOrCreditEntryCommands) { for (final SingleDebitOrCreditEntryCommand singleDebitOrCreditEntryCommand : singleDebitOrCreditEntryCommands) {
final GLAccount glAccount = this.glAccountRepository.findById(singleDebitOrCreditEntryCommand.getGlAccountId()) final GLAccount glAccount = this.glAccountRepository.findById(singleDebitOrCreditEntryCommand.getGlAccountId())
@@ -673,7 +672,8 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
} }
/** Set a transaction Id and save these Journal entries **/ /** Set a transaction Id and save these Journal entries **/
final Date transactionDate = command.dateValueOfParameterNamed(JournalEntryJsonInputParams.TRANSACTION_DATE.getValue()); final LocalDate transactionDate = command
.localDateValueOfParameterNamed(JournalEntryJsonInputParams.TRANSACTION_DATE.getValue());
final String transactionId = generateTransactionId(officeId); final String transactionId = generateTransactionId(officeId);
saveAllDebitOrCreditOpeningBalanceEntries(journalEntryCommand, office, currencyCode, transactionDate, saveAllDebitOrCreditOpeningBalanceEntries(journalEntryCommand, office, currencyCode, transactionDate,
@@ -691,8 +691,9 @@ public class JournalEntryWritePlatformServiceJpaRepositoryImpl implements Journa
} }
private void saveAllDebitOrCreditOpeningBalanceEntries(final JournalEntryCommand command, final Office office, private void saveAllDebitOrCreditOpeningBalanceEntries(final JournalEntryCommand command, final Office office,
final String currencyCode, final Date transactionDate, final SingleDebitOrCreditEntryCommand[] singleDebitOrCreditEntryCommands, final String currencyCode, final LocalDate transactionDate,
final String transactionId, final JournalEntryType type, final Long contraAccountId) { final SingleDebitOrCreditEntryCommand[] singleDebitOrCreditEntryCommands, final String transactionId,
final JournalEntryType type, final Long contraAccountId) {
final boolean manualEntry = true; final boolean manualEntry = true;
final GLAccount contraAccount = this.glAccountRepository.findById(contraAccountId) final GLAccount contraAccount = this.glAccountRepository.findById(contraAccountId)
@@ -19,8 +19,8 @@
package org.apache.fineract.accounting.provisioning.data; package org.apache.fineract.accounting.provisioning.data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class ProvisioningEntryData { public class ProvisioningEntryData {
@@ -33,7 +33,7 @@ public class ProvisioningEntryData {
private String createdUser; private String createdUser;
Date createdDate; LocalDate createdDate;
Long modifiedById; Long modifiedById;
@@ -48,8 +48,8 @@ public class ProvisioningEntryData {
this.id = id; this.id = id;
} }
public ProvisioningEntryData(Long id, Boolean journalEntry, Long createdById, String createdUser, Date createdDate, Long modifiedById, public ProvisioningEntryData(Long id, Boolean journalEntry, Long createdById, String createdUser, LocalDate createdDate,
String modifiedUser, BigDecimal totalReservedAmount) { Long modifiedById, String modifiedUser, BigDecimal totalReservedAmount) {
this.id = id; this.id = id;
this.journalEntry = journalEntry; this.journalEntry = journalEntry;
this.createdById = createdById; this.createdById = createdById;
@@ -68,7 +68,7 @@ public class ProvisioningEntryData {
return this.id; return this.id;
} }
public Date getCreatedDate() { public LocalDate getCreatedDate() {
return this.createdDate; return this.createdDate;
} }
} }
@@ -18,8 +18,8 @@
*/ */
package org.apache.fineract.accounting.provisioning.domain; package org.apache.fineract.accounting.provisioning.domain;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
@@ -30,8 +30,6 @@ import javax.persistence.JoinColumn;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.domain.AppUser;
@@ -50,22 +48,20 @@ public class ProvisioningEntry extends AbstractPersistableCustom {
private AppUser createdBy; private AppUser createdBy;
@Column(name = "created_date") @Column(name = "created_date")
@Temporal(TemporalType.DATE) private LocalDate createdDate;
private Date createdDate;
@OneToOne @OneToOne
@JoinColumn(name = "lastmodifiedby_id") @JoinColumn(name = "lastmodifiedby_id")
private AppUser lastModifiedBy; private AppUser lastModifiedBy;
@Column(name = "lastmodified_date") @Column(name = "lastmodified_date")
@Temporal(TemporalType.DATE) private LocalDate lastModifiedDate;
private Date lastModifiedDate;
protected ProvisioningEntry() { protected ProvisioningEntry() {
} }
public ProvisioningEntry(AppUser createdBy, Date createdDate, AppUser lastModifiedBy, Date lastModifiedDate, public ProvisioningEntry(AppUser createdBy, LocalDate createdDate, AppUser lastModifiedBy, LocalDate lastModifiedDate,
Set<LoanProductProvisioningEntry> provisioningEntries) { Set<LoanProductProvisioningEntry> provisioningEntries) {
this.provisioningEntries = provisioningEntries; this.provisioningEntries = provisioningEntries;
this.createdBy = createdBy; this.createdBy = createdBy;
@@ -89,7 +85,7 @@ public class ProvisioningEntry extends AbstractPersistableCustom {
this.isJournalEntryCreated = bool; this.isJournalEntryCreated = bool;
} }
public Date getCreatedDate() { public LocalDate getCreatedDate() {
return this.createdDate; return this.createdDate;
} }
@@ -18,7 +18,7 @@
*/ */
package org.apache.fineract.accounting.provisioning.domain; package org.apache.fineract.accounting.provisioning.domain;
import java.util.Date; import java.time.LocalDate;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
@@ -28,7 +28,7 @@ public interface ProvisioningEntryRepository extends JpaRepository<ProvisioningE
// OPENJPA throws error if we use entry // OPENJPA throws error if we use entry
@Query("select entry1 from ProvisioningEntry entry1 where entry1.createdDate = :createdDate") @Query("select entry1 from ProvisioningEntry entry1 where entry1.createdDate = :createdDate")
ProvisioningEntry findByProvisioningEntryDate(@Param("createdDate") Date createdDate); ProvisioningEntry findByProvisioningEntryDate(@Param("createdDate") LocalDate createdDate);
@Query("select entry1 from ProvisioningEntry entry1 where entry1.createdDate = (select max(entry2.createdDate) from ProvisioningEntry entry2 where entry2.isJournalEntryCreated=true)") @Query("select entry1 from ProvisioningEntry entry1 where entry1.createdDate = (select max(entry2.createdDate) from ProvisioningEntry entry2 where entry2.isJournalEntryCreated=true)")
ProvisioningEntry findExistingProvisioningEntryWithJournalEntries(); ProvisioningEntry findExistingProvisioningEntryWithJournalEntries();
@@ -18,12 +18,12 @@
*/ */
package org.apache.fineract.accounting.provisioning.exception; package org.apache.fineract.accounting.provisioning.exception;
import java.util.Date; import java.time.LocalDate;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
public class ProvisioningEntryAlreadyCreatedException extends AbstractPlatformResourceNotFoundException { public class ProvisioningEntryAlreadyCreatedException extends AbstractPlatformResourceNotFoundException {
public ProvisioningEntryAlreadyCreatedException(Long id, Date date) { public ProvisioningEntryAlreadyCreatedException(Long id, LocalDate date) {
super("error.msg.provisioningentry.already.exists.for.this.date", super("error.msg.provisioningentry.already.exists.for.this.date",
"ProvisioningEntry with identifier " + id + " exists for given date" + date, id); "ProvisioningEntry with identifier " + id + " exists for given date" + date, id);
} }
@@ -18,12 +18,12 @@
*/ */
package org.apache.fineract.accounting.provisioning.exception; package org.apache.fineract.accounting.provisioning.exception;
import java.util.Date; import java.time.LocalDate;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
public class ProvisioningJournalEntriesCannotbeCreatedException extends AbstractPlatformResourceNotFoundException { public class ProvisioningJournalEntriesCannotbeCreatedException extends AbstractPlatformResourceNotFoundException {
public ProvisioningJournalEntriesCannotbeCreatedException(Date existingEntriesDate, Date requestedDate) { public ProvisioningJournalEntriesCannotbeCreatedException(LocalDate existingEntriesDate, LocalDate requestedDate) {
super("error.msg.provisioning.journalentries.cannot.be.created", "Provisioning Journal Entries already created on later date " super("error.msg.provisioning.journalentries.cannot.be.created", "Provisioning Journal Entries already created on later date "
+ existingEntriesDate + " than requested date " + requestedDate); + existingEntriesDate + " than requested date " + requestedDate);
} }
@@ -18,8 +18,8 @@
*/ */
package org.apache.fineract.accounting.provisioning.service; package org.apache.fineract.accounting.provisioning.service;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import org.apache.fineract.accounting.provisioning.data.LoanProductProvisioningEntryData; import org.apache.fineract.accounting.provisioning.data.LoanProductProvisioningEntryData;
import org.apache.fineract.accounting.provisioning.data.ProvisioningEntryData; import org.apache.fineract.accounting.provisioning.data.ProvisioningEntryData;
import org.apache.fineract.infrastructure.core.service.Page; import org.apache.fineract.infrastructure.core.service.Page;
@@ -27,7 +27,7 @@ import org.apache.fineract.infrastructure.core.service.SearchParameters;
public interface ProvisioningEntriesReadPlatformService { public interface ProvisioningEntriesReadPlatformService {
Collection<LoanProductProvisioningEntryData> retrieveLoanProductsProvisioningData(Date date); Collection<LoanProductProvisioningEntryData> retrieveLoanProductsProvisioningData(LocalDate date);
ProvisioningEntryData retrieveProvisioningEntryData(Long entryId); ProvisioningEntryData retrieveProvisioningEntryData(Long entryId);
@@ -19,17 +19,18 @@
package org.apache.fineract.accounting.provisioning.service; package org.apache.fineract.accounting.provisioning.service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Date;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.SimpleDateFormat; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.accounting.provisioning.data.LoanProductProvisioningEntryData; import org.apache.fineract.accounting.provisioning.data.LoanProductProvisioningEntryData;
import org.apache.fineract.accounting.provisioning.data.ProvisioningEntryData; import org.apache.fineract.accounting.provisioning.data.ProvisioningEntryData;
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.SearchParameters; import org.apache.fineract.infrastructure.core.service.SearchParameters;
@@ -51,11 +52,11 @@ public class ProvisioningEntriesReadPlatformServiceImpl implements ProvisioningE
private final DatabaseSpecificSQLGenerator sqlGenerator; private final DatabaseSpecificSQLGenerator sqlGenerator;
@Override @Override
public Collection<LoanProductProvisioningEntryData> retrieveLoanProductsProvisioningData(Date date) { public Collection<LoanProductProvisioningEntryData> retrieveLoanProductsProvisioningData(LocalDate date) {
String formattedDate = new SimpleDateFormat("yyyy-MM-dd").format(date); String formattedDate = DateUtils.DEFAULT_DATE_FORMATER.format(date);
LoanProductProvisioningEntryMapper mapper = new LoanProductProvisioningEntryMapper(sqlGenerator); LoanProductProvisioningEntryMapper mapper = new LoanProductProvisioningEntryMapper(sqlGenerator);
final String sql = mapper.schema(); final String sql = mapper.schema();
return this.jdbcTemplate.query(sql, mapper, new Object[] { formattedDate, formattedDate, formattedDate }); return this.jdbcTemplate.query(sql, mapper, formattedDate, formattedDate, formattedDate);
} }
private static final class LoanProductProvisioningEntryMapper implements RowMapper<LoanProductProvisioningEntryData> { private static final class LoanProductProvisioningEntryMapper implements RowMapper<LoanProductProvisioningEntryData> {
@@ -107,8 +108,7 @@ public class ProvisioningEntriesReadPlatformServiceImpl implements ProvisioningE
public ProvisioningEntryData retrieveProvisioningEntryData(Long entryId) { public ProvisioningEntryData retrieveProvisioningEntryData(Long entryId) {
ProvisioningEntryDataMapperWithSumReserved mapper1 = new ProvisioningEntryDataMapperWithSumReserved(); ProvisioningEntryDataMapperWithSumReserved mapper1 = new ProvisioningEntryDataMapperWithSumReserved();
final String sql = "select" + mapper1.getSchema() + " where entry.id = ? group by entry.id, created.username, modified.username"; final String sql = "select" + mapper1.getSchema() + " where entry.id = ? group by entry.id, created.username, modified.username";
ProvisioningEntryData data = this.jdbcTemplate.queryForObject(sql, mapper1, new Object[] { entryId }); // NOSONAR return this.jdbcTemplate.queryForObject(sql, mapper1, entryId);
return data;
} }
private static final class ProvisioningEntryDataMapper implements RowMapper<ProvisioningEntryData> { private static final class ProvisioningEntryDataMapper implements RowMapper<ProvisioningEntryData> {
@@ -130,7 +130,8 @@ public class ProvisioningEntriesReadPlatformServiceImpl implements ProvisioningE
Long modifiedById = rs.getLong("lastmodifiedby_id"); Long modifiedById = rs.getLong("lastmodifiedby_id");
String modifieUser = rs.getString("modifieduser"); String modifieUser = rs.getString("modifieduser");
BigDecimal totalReservedAmount = null; BigDecimal totalReservedAmount = null;
return new ProvisioningEntryData(id, journalEntry, createdById, createdUser, createdDate, modifiedById, modifieUser, LocalDate createdLocalDate = createdDate != null ? createdDate.toLocalDate() : null;
return new ProvisioningEntryData(id, journalEntry, createdById, createdUser, createdLocalDate, modifiedById, modifieUser,
totalReservedAmount); totalReservedAmount);
} }
@@ -203,7 +204,8 @@ public class ProvisioningEntriesReadPlatformServiceImpl implements ProvisioningE
Long modifiedById = rs.getLong("lastmodifiedby_id"); Long modifiedById = rs.getLong("lastmodifiedby_id");
String modifieUser = rs.getString("modifieduser"); String modifieUser = rs.getString("modifieduser");
BigDecimal totalReservedAmount = rs.getBigDecimal("totalreserved"); BigDecimal totalReservedAmount = rs.getBigDecimal("totalreserved");
return new ProvisioningEntryData(id, journalEntry, createdById, createdUser, createdDate, modifiedById, modifieUser, LocalDate createdLocalDate = createdDate != null ? createdDate.toLocalDate() : null;
return new ProvisioningEntryData(id, journalEntry, createdById, createdUser, createdLocalDate, modifiedById, modifieUser,
totalReservedAmount); totalReservedAmount);
} }
@@ -239,7 +241,7 @@ public class ProvisioningEntriesReadPlatformServiceImpl implements ProvisioningE
final String sql1 = "select " + mapper1.getSchema() + " where entry.created_date like ? "; final String sql1 = "select " + mapper1.getSchema() + " where entry.created_date like ? ";
ProvisioningEntryData data = null; ProvisioningEntryData data = null;
try { try {
data = this.jdbcTemplate.queryForObject(sql1, mapper1, new Object[] { date }); // NOSONAR data = this.jdbcTemplate.queryForObject(sql1, mapper1, date); // NOSONAR
} catch (EmptyResultDataAccessException e) { } catch (EmptyResultDataAccessException e) {
log.error("Problem occurred in retrieveProvisioningEntryData function", e); log.error("Problem occurred in retrieveProvisioningEntryData function", e);
} }
@@ -252,12 +254,12 @@ public class ProvisioningEntriesReadPlatformServiceImpl implements ProvisioningE
ProvisioningEntryData data = null; ProvisioningEntryData data = null;
LoanProductProvisioningEntryRowMapper mapper = new LoanProductProvisioningEntryRowMapper(); LoanProductProvisioningEntryRowMapper mapper = new LoanProductProvisioningEntryRowMapper();
final String sql = "select " + mapper.getSchema() + " where entry.criteria_id = ?"; final String sql = "select " + mapper.getSchema() + " where entry.criteria_id = ?";
Collection<LoanProductProvisioningEntryData> entries = this.jdbcTemplate.query(sql, mapper, new Object[] { criteriaId }); // NOSONAR Collection<LoanProductProvisioningEntryData> entries = this.jdbcTemplate.query(sql, mapper, criteriaId); // NOSONAR
if (entries != null && entries.size() > 0) { if (entries != null && entries.size() > 0) {
Long entryId = ((LoanProductProvisioningEntryData) entries.toArray()[0]).getHistoryId(); Long entryId = ((LoanProductProvisioningEntryData) entries.toArray()[0]).getHistoryId();
ProvisioningEntryDataMapper mapper1 = new ProvisioningEntryDataMapper(); ProvisioningEntryDataMapper mapper1 = new ProvisioningEntryDataMapper();
final String sql1 = "select " + mapper1.getSchema() + " where entry.id = ?"; final String sql1 = "select " + mapper1.getSchema() + " where entry.id = ?";
data = this.jdbcTemplate.queryForObject(sql1, mapper1, new Object[] { entryId }); // NOSONAR data = this.jdbcTemplate.queryForObject(sql1, mapper1, entryId); // NOSONAR
data.setEntries(entries); data.setEntries(entries);
} }
return data; return data;
@@ -290,7 +292,8 @@ public class ProvisioningEntriesReadPlatformServiceImpl implements ProvisioningE
Long modifiedBy = null; Long modifiedBy = null;
String modifiedName = null; String modifiedName = null;
BigDecimal totalReservedAmount = null; BigDecimal totalReservedAmount = null;
return new ProvisioningEntryData(id, Boolean.TRUE, createdBy, createdName, createdDate, modifiedBy, modifiedName, LocalDate createdLocalDate = createdDate != null ? createdDate.toLocalDate() : null;
return new ProvisioningEntryData(id, Boolean.TRUE, createdBy, createdName, createdLocalDate, modifiedBy, modifiedName,
totalReservedAmount); totalReservedAmount);
} }
@@ -20,9 +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.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -111,9 +109,9 @@ public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements
} }
private void validateForCreateJournalEntry(ProvisioningEntryData existingEntry, ProvisioningEntry requested) { private void validateForCreateJournalEntry(ProvisioningEntryData existingEntry, ProvisioningEntry requested) {
Date existingDate = existingEntry.getCreatedDate(); LocalDate existingDate = existingEntry.getCreatedDate();
Date requestedDate = requested.getCreatedDate(); LocalDate requestedDate = requested.getCreatedDate();
if (existingDate.after(requestedDate) || existingDate.compareTo(requestedDate) == 0 ? Boolean.TRUE : Boolean.FALSE) { if (existingDate.isAfter(requestedDate) || existingDate.compareTo(requestedDate) == 0 ? Boolean.TRUE : Boolean.FALSE) {
throw new ProvisioningJournalEntriesCannotbeCreatedException(existingEntry.getCreatedDate(), requestedDate); throw new ProvisioningJournalEntriesCannotbeCreatedException(existingEntry.getCreatedDate(), requestedDate);
} }
} }
@@ -127,15 +125,14 @@ public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements
return bool; return bool;
} }
private Date parseDate(JsonCommand command) { private LocalDate parseDate(JsonCommand command) {
LocalDate localDate = this.fromApiJsonHelper.extractLocalDateNamed("date", command.parsedJson()); return this.fromApiJsonHelper.extractLocalDateNamed("date", command.parsedJson());
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 = DateUtils.getBusinessDate(); LocalDate currentDate = DateUtils.getBusinessLocalDate();
boolean addJournalEntries = true; boolean addJournalEntries = true;
try { try {
Collection<ProvisioningCriteriaData> criteriaCollection = this.provisioningCriteriaReadPlatformService Collection<ProvisioningCriteriaData> criteriaCollection = this.provisioningCriteriaReadPlatformService
@@ -156,7 +153,7 @@ public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements
@Override @Override
public CommandProcessingResult createProvisioningEntries(JsonCommand command) { public CommandProcessingResult createProvisioningEntries(JsonCommand command) {
this.fromApiJsonDeserializer.validateForCreate(command.json()); this.fromApiJsonDeserializer.validateForCreate(command.json());
Date createdDate = parseDate(command); LocalDate createdDate = parseDate(command);
boolean addJournalEntries = isJournalEntriesRequired(command); boolean addJournalEntries = isJournalEntriesRequired(command);
try { try {
Collection<ProvisioningCriteriaData> criteriaCollection = this.provisioningCriteriaReadPlatformService Collection<ProvisioningCriteriaData> criteriaCollection = this.provisioningCriteriaReadPlatformService
@@ -171,14 +168,14 @@ public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements
} }
} }
private ProvisioningEntry createProvsioningEntry(Date date, boolean addJournalEntries) { private ProvisioningEntry createProvsioningEntry(LocalDate date, boolean addJournalEntries) {
ProvisioningEntry existingEntry = this.provisioningEntryRepository.findByProvisioningEntryDate(date); ProvisioningEntry existingEntry = this.provisioningEntryRepository.findByProvisioningEntryDate(date);
if (existingEntry != null) { if (existingEntry != null) {
throw new ProvisioningEntryAlreadyCreatedException(existingEntry.getId(), existingEntry.getCreatedDate()); throw new ProvisioningEntryAlreadyCreatedException(existingEntry.getId(), existingEntry.getCreatedDate());
} }
AppUser currentUser = this.platformSecurityContext.authenticatedUser(); AppUser currentUser = this.platformSecurityContext.authenticatedUser();
AppUser lastModifiedBy = null; AppUser lastModifiedBy = null;
Date lastModifiedDate = null; LocalDate lastModifiedDate = null;
Set<LoanProductProvisioningEntry> nullEntries = null; Set<LoanProductProvisioningEntry> nullEntries = null;
ProvisioningEntry requestedEntry = new ProvisioningEntry(currentUser, date, lastModifiedBy, lastModifiedDate, nullEntries); ProvisioningEntry requestedEntry = new ProvisioningEntry(currentUser, date, lastModifiedBy, lastModifiedDate, nullEntries);
Collection<LoanProductProvisioningEntry> entries = generateLoanProvisioningEntry(requestedEntry, date); Collection<LoanProductProvisioningEntry> entries = generateLoanProvisioningEntry(requestedEntry, date);
@@ -205,7 +202,7 @@ public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements
return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(requestedEntry.getId()).build(); return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(requestedEntry.getId()).build();
} }
private Collection<LoanProductProvisioningEntry> generateLoanProvisioningEntry(ProvisioningEntry parent, Date date) { private Collection<LoanProductProvisioningEntry> generateLoanProvisioningEntry(ProvisioningEntry parent, LocalDate date) {
Collection<LoanProductProvisioningEntryData> entries = this.provisioningEntriesReadPlatformService Collection<LoanProductProvisioningEntryData> entries = this.provisioningEntriesReadPlatformService
.retrieveLoanProductsProvisioningData(date); .retrieveLoanProductsProvisioningData(date);
Map<Integer, LoanProductProvisioningEntry> provisioningEntries = new HashMap<>(); Map<Integer, LoanProductProvisioningEntry> provisioningEntries = new HashMap<>();
@@ -18,7 +18,7 @@
*/ */
package org.apache.fineract.accounting.rule.exception; package org.apache.fineract.accounting.rule.exception;
import java.util.Date; import java.time.LocalDate;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException; import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
/** /**
@@ -26,7 +26,7 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
*/ */
public class AccountingRuleInvalidDeleteException extends AbstractPlatformDomainRuleException { public class AccountingRuleInvalidDeleteException extends AbstractPlatformDomainRuleException {
public AccountingRuleInvalidDeleteException(final Long officeId, final String officeName, final Date latestclosureDate) { public AccountingRuleInvalidDeleteException(final Long officeId, final String officeName, final LocalDate latestclosureDate) {
super("error.msg.glclosure.invalid.delete", "The latest closure for office with Id " + officeId + " and name " + officeName super("error.msg.glclosure.invalid.delete", "The latest closure for office with Id " + officeId + " and name " + officeName
+ " is on " + latestclosureDate.toString() + ", please delete this closure first", latestclosureDate); + " is on " + latestclosureDate.toString() + ", please delete this closure first", latestclosureDate);
} }
@@ -18,7 +18,7 @@
*/ */
package org.apache.fineract.accounting.rule.exception; package org.apache.fineract.accounting.rule.exception;
import java.util.Date; import java.time.LocalDate;
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException; import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
/** /**
@@ -50,7 +50,7 @@ public class AccountingRuleInvalidException extends AbstractPlatformDomainRuleEx
} }
} }
public AccountingRuleInvalidException(final GlClosureInvalidReason reason, final Date date) { public AccountingRuleInvalidException(final GlClosureInvalidReason reason, final LocalDate date) {
super(reason.errorCode(), reason.errorMessage(), date); super(reason.errorCode(), reason.errorMessage(), date);
} }
} }
@@ -21,4 +21,6 @@ package org.apache.fineract.cob.loan;
import org.apache.fineract.cob.COBBusinessStep; import org.apache.fineract.cob.COBBusinessStep;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
public interface LoanCOBBusinessStep extends COBBusinessStep<Loan> {} public interface LoanCOBBusinessStep extends COBBusinessStep<Loan> {
}
@@ -18,15 +18,13 @@
*/ */
package org.apache.fineract.commands.domain; package org.apache.fineract.commands.domain;
import java.time.LocalDateTime;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.commons.lang3.StringUtils; 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.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@@ -75,16 +73,14 @@ public class CommandSource extends AbstractPersistableCustom {
private AppUser maker; private AppUser maker;
@Column(name = "made_on_date", nullable = false) @Column(name = "made_on_date", nullable = false)
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime madeOnDate;
private Date madeOnDate;
@ManyToOne @ManyToOne
@JoinColumn(name = "checker_id", nullable = true) @JoinColumn(name = "checker_id", nullable = true)
private AppUser checker; private AppUser checker;
@Column(name = "checked_on_date", nullable = true) @Column(name = "checked_on_date", nullable = true)
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime checkedOnDate;
private Date checkedOnDate;
@Column(name = "processing_result_enum", nullable = false) @Column(name = "processing_result_enum", nullable = false)
private Integer processingResult; private Integer processingResult;
@@ -119,7 +115,7 @@ public class CommandSource extends AbstractPersistableCustom {
this.subresourceId = subresourceId; this.subresourceId = subresourceId;
this.commandAsJson = commandSerializedAsJson; this.commandAsJson = commandSerializedAsJson;
this.maker = maker; this.maker = maker;
this.madeOnDate = Date.from(madeOnDateTime.toInstant()); this.madeOnDate = madeOnDateTime != null ? madeOnDateTime.toLocalDateTime() : null;
this.processingResult = CommandProcessingResultType.PROCESSED.getValue(); this.processingResult = CommandProcessingResultType.PROCESSED.getValue();
} }
@@ -141,13 +137,13 @@ public class CommandSource extends AbstractPersistableCustom {
public void markAsChecked(final AppUser checker, final ZonedDateTime checkedOnDate) { public void markAsChecked(final AppUser checker, final ZonedDateTime checkedOnDate) {
this.checker = checker; this.checker = checker;
this.checkedOnDate = Date.from(checkedOnDate.toInstant()); this.checkedOnDate = checkedOnDate != null ? checkedOnDate.toLocalDateTime() : null;
this.processingResult = CommandProcessingResultType.PROCESSED.getValue(); this.processingResult = CommandProcessingResultType.PROCESSED.getValue();
} }
public void markAsRejected(final AppUser checker, final ZonedDateTime checkedOnDate) { public void markAsRejected(final AppUser checker, final ZonedDateTime checkedOnDate) {
this.checker = checker; this.checker = checker;
this.checkedOnDate = Date.from(checkedOnDate.toInstant()); this.checkedOnDate = checkedOnDate != null ? checkedOnDate.toLocalDateTime() : null;
this.processingResult = CommandProcessingResultType.REJECTED.getValue(); this.processingResult = CommandProcessingResultType.REJECTED.getValue();
} }
@@ -19,15 +19,12 @@
package org.apache.fineract.infrastructure.bulkimport.domain; package org.apache.fineract.infrastructure.bulkimport.domain;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.documentmanagement.domain.Document; import org.apache.fineract.infrastructure.documentmanagement.domain.Document;
@@ -41,13 +38,11 @@ public class ImportDocument extends AbstractPersistableCustom {
@JoinColumn(name = "document_id") @JoinColumn(name = "document_id")
private Document document; private Document document;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "import_time") @Column(name = "import_time")
private Date importTime; private LocalDateTime importTime;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "end_time") @Column(name = "end_time")
private Date endTime; private LocalDateTime endTime;
@Column(name = "completed", nullable = false) @Column(name = "completed", nullable = false)
private Boolean completed; private Boolean completed;
@@ -88,8 +83,8 @@ public class ImportDocument extends AbstractPersistableCustom {
final Integer entityType, final AppUser createdBy, final Integer totalRecords, final Integer successCount, final Integer entityType, final AppUser createdBy, final Integer totalRecords, final Integer successCount,
final Integer failureCount) { final Integer failureCount) {
this.document = document; this.document = document;
this.importTime = Date.from(importTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.importTime = importTime;
this.endTime = Date.from(endTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endTime = endTime;
this.completed = completed; this.completed = completed;
this.entityType = entityType; this.entityType = entityType;
this.createdBy = createdBy; this.createdBy = createdBy;
@@ -100,7 +95,7 @@ public class ImportDocument extends AbstractPersistableCustom {
} }
public void update(final LocalDateTime endTime, final Integer successCount, final Integer errorCount) { public void update(final LocalDateTime endTime, final Integer successCount, final Integer errorCount) {
this.endTime = Date.from(endTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.endTime = endTime;
this.completed = Boolean.TRUE; this.completed = Boolean.TRUE;
this.successCount = successCount; this.successCount = successCount;
this.failureCount = errorCount; this.failureCount = errorCount;
@@ -19,10 +19,10 @@
package org.apache.fineract.infrastructure.bulkimport.populator; package org.apache.fineract.infrastructure.bulkimport.populator;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.ParseException; import java.time.LocalDate;
import java.text.SimpleDateFormat; import java.time.format.DateTimeFormatter;
import java.util.Calendar; import java.time.format.DateTimeFormatterBuilder;
import java.util.Date; import java.time.format.DateTimeParseException;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.fineract.organisation.office.data.OfficeData; import org.apache.fineract.organisation.office.data.OfficeData;
@@ -67,27 +67,21 @@ public abstract class AbstractWorkbookPopulator implements WorkbookPopulator {
protected void writeDate(int colIndex, Row row, String value, CellStyle dateCellStyle, String dateFormat) { protected void writeDate(int colIndex, Row row, String value, CellStyle dateCellStyle, String dateFormat) {
try { try {
SimpleDateFormat formatinDB = null; DateTimeFormatter formatinDB;
if (value.matches("\\d{4}-\\d{1,2}-\\d{1,2}")) { if (value.matches("\\d{4}-\\d{1,2}-\\d{1,2}")) {
formatinDB = new SimpleDateFormat("yyyy-MM-dd"); formatinDB = new DateTimeFormatterBuilder().appendPattern("yyyy-M-d").toFormatter();
} else if (value.matches("\\d{1,2}/\\d{1,2}/\\d{4}")) { } else if (value.matches("\\d{1,2}/\\d{1,2}/\\d{4}")) {
formatinDB = new SimpleDateFormat("dd/MM/yyyy"); formatinDB = new DateTimeFormatterBuilder().appendPattern("d/M/yyyy").toFormatter();
} else if (value.matches("\\d{1,2} \\w{3,12} \\d{4}")) { } else if (value.matches("\\d{1,2} \\w{3,12} \\d{4}")) {
formatinDB = new SimpleDateFormat("dd MMMM yyyy"); formatinDB = new DateTimeFormatterBuilder().appendPattern("d MMMM yyyy").toFormatter();
} else {
throw new IllegalArgumentException("Unrecognised format of date value: " + value);
} }
Date date1 = formatinDB.parse(value); LocalDate date1 = LocalDate.parse(value, formatinDB);
SimpleDateFormat expectedFormat = new SimpleDateFormat(dateFormat); DateTimeFormatter expectedFormat = new DateTimeFormatterBuilder().appendPattern(dateFormat).toFormatter();
Date date2 = expectedFormat.parse(expectedFormat.format(date1)); row.createCell(colIndex).setCellValue(expectedFormat.format(date1));
Calendar cal = Calendar.getInstance();
cal.setTime(date2);
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date dateWithoutTime = cal.getTime();
row.createCell(colIndex).setCellValue(dateWithoutTime);
row.getCell(colIndex).setCellStyle(dateCellStyle); row.getCell(colIndex).setCellStyle(dateCellStyle);
} catch (ParseException pe) { } catch (DateTimeParseException pe) {
throw new IllegalArgumentException(pe); throw new IllegalArgumentException(pe);
} }
} }
@@ -121,9 +115,7 @@ public abstract class AbstractWorkbookPopulator implements WorkbookPopulator {
short df = workbook.createDataFormat().getFormat(dateFormat); short df = workbook.createDataFormat().getFormat(dateFormat);
dateCellStyle.setDataFormat(df); dateCellStyle.setDataFormat(df);
int rowIndex = 0; int rowIndex = 0;
SimpleDateFormat outputFormat = new SimpleDateFormat(dateFormat); DateTimeFormatter outputFormat = new DateTimeFormatterBuilder().appendPattern(dateFormat).toFormatter();
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try { try {
if (clients != null) { if (clients != null) {
for (ClientData client : clients) { for (ClientData client : clients) {
@@ -134,8 +126,7 @@ public abstract class AbstractWorkbookPopulator implements WorkbookPopulator {
writeString(nameCol, row, client.displayName().replaceAll("[ )(] ", "_") + "(" + client.id() + ")"); writeString(nameCol, row, client.displayName().replaceAll("[ )(] ", "_") + "(" + client.id() + ")");
if (client.getActivationDate() != null) { if (client.getActivationDate() != null) {
date = inputFormat.parse(client.getActivationDate().toString()); writeDate(activationDateCol, row, outputFormat.format(client.getActivationDate()), dateCellStyle, dateFormat);
writeDate(activationDateCol, row, outputFormat.format(date), dateCellStyle, dateFormat);
} }
if (containsClientExtId) { if (containsClientExtId) {
if (client.getExternalId() != null) { if (client.getExternalId() != null) {
@@ -154,13 +145,12 @@ public abstract class AbstractWorkbookPopulator implements WorkbookPopulator {
writeString(nameCol, row, group.getName().replaceAll("[ )(] ", "_")); writeString(nameCol, row, group.getName().replaceAll("[ )(] ", "_"));
if (group.getActivationDate() != null) { if (group.getActivationDate() != null) {
date = inputFormat.parse(group.getActivationDate().toString()); writeDate(activationDateCol, row, outputFormat.format(group.getActivationDate()), dateCellStyle, dateFormat);
writeDate(activationDateCol, row, outputFormat.format(date), dateCellStyle, dateFormat);
} }
} }
} }
} catch (ParseException e) { } catch (DateTimeParseException e) {
LOG.error("Problem occurred in setClientAndGroupDateLookupTable function", e); LOG.error("Problem occurred in setClientAndGroupDateLookupTable function", e);
} }
} }
@@ -19,8 +19,8 @@
package org.apache.fineract.infrastructure.bulkimport.populator; package org.apache.fineract.infrastructure.bulkimport.populator;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -99,10 +99,10 @@ public class SharedProductsSheetPopulator extends AbstractWorkbookPopulator {
BigDecimal marketValue = shareProductData.getUnitPrice(); BigDecimal marketValue = shareProductData.getUnitPrice();
Collection<ShareProductMarketPriceData> marketDataSet = shareProductData.getMarketPrice(); Collection<ShareProductMarketPriceData> marketDataSet = shareProductData.getMarketPrice();
if (marketDataSet != null && !marketDataSet.isEmpty()) { if (marketDataSet != null && !marketDataSet.isEmpty()) {
Date currentDate = DateUtils.getBusinessDate(); LocalDate currentDate = DateUtils.getBusinessLocalDate();
for (ShareProductMarketPriceData data : marketDataSet) { for (ShareProductMarketPriceData data : marketDataSet) {
Date futureDate = data.getStartDate(); LocalDate futureDate = data.getStartDate();
if (currentDate.after(futureDate)) { if (currentDate.isAfter(futureDate)) {
marketValue = data.getShareValue(); marketValue = data.getShareValue();
} }
} }
@@ -18,11 +18,10 @@
*/ */
package org.apache.fineract.infrastructure.bulkimport.populator.loanrepayment; package org.apache.fineract.infrastructure.bulkimport.populator.loanrepayment;
import java.text.ParseException; import java.time.format.DateTimeFormatter;
import java.text.SimpleDateFormat; import java.time.format.DateTimeFormatterBuilder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -229,9 +228,7 @@ public class LoanRepaymentWorkbookPopulator extends AbstractWorkbookPopulator {
CellStyle dateCellStyle = workbook.createCellStyle(); CellStyle dateCellStyle = workbook.createCellStyle();
short df = workbook.createDataFormat().getFormat(dateFormat); short df = workbook.createDataFormat().getFormat(dateFormat);
dateCellStyle.setDataFormat(df); dateCellStyle.setDataFormat(df);
SimpleDateFormat outputFormat = new SimpleDateFormat(dateFormat); DateTimeFormatter outputFormat = new DateTimeFormatterBuilder().appendPattern(dateFormat).toFormatter();
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
Collections.sort(allloans, new LoanComparatorByStatusActive()); Collections.sort(allloans, new LoanComparatorByStatusActive());
for (LoanAccountData loan : allloans) { for (LoanAccountData loan : allloans) {
row = loanRepaymentSheet.createRow(rowIndex++); row = loanRepaymentSheet.createRow(rowIndex++);
@@ -244,13 +241,8 @@ public class LoanRepaymentWorkbookPopulator extends AbstractWorkbookPopulator {
writeBigDecimal(LoanRepaymentConstants.LOOKUP_TOTAL_OUTSTANDING_AMOUNT_COL, row, loan.getTotalOutstandingAmount()); writeBigDecimal(LoanRepaymentConstants.LOOKUP_TOTAL_OUTSTANDING_AMOUNT_COL, row, loan.getTotalOutstandingAmount());
} }
if (loan.getDisbursementDate() != null) { if (loan.getDisbursementDate() != null) {
try { writeDate(LoanRepaymentConstants.LOOKUP_LOAN_DISBURSEMENT_DATE_COL, row, outputFormat.format(loan.getDisbursementDate()),
date = inputFormat.parse(loan.getDisbursementDate().toString()); dateCellStyle, dateFormat);
} catch (ParseException e) {
LOG.error("Problem occurred in populateLoansTable function", e);
}
writeDate(LoanRepaymentConstants.LOOKUP_LOAN_DISBURSEMENT_DATE_COL, row, outputFormat.format(date), dateCellStyle,
dateFormat);
} }
} }
} }
@@ -18,8 +18,8 @@
*/ */
package org.apache.fineract.infrastructure.campaigns.email.api; package org.apache.fineract.infrastructure.campaigns.email.api;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
import javax.ws.rs.GET; import javax.ws.rs.GET;
@@ -119,11 +119,11 @@ public class EmailApiResource {
@QueryParam("locale") final String locale, @QueryParam("dateFormat") final String dateFormat, @Context final UriInfo uriInfo) { @QueryParam("locale") final String locale, @QueryParam("dateFormat") final String dateFormat, @Context final UriInfo uriInfo) {
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
Date fromDate = null; LocalDate fromDate = null;
if (fromDateParam != null) { if (fromDateParam != null) {
fromDate = fromDateParam.getDate("fromDate", dateFormat, locale); fromDate = fromDateParam.getDate("fromDate", dateFormat, locale);
} }
Date toDate = null; LocalDate toDate = null;
if (toDateParam != null) { if (toDateParam != null) {
toDate = toDateParam.getDate("toDate", dateFormat, locale); toDate = toDateParam.getDate("toDate", dateFormat, locale);
} }
@@ -20,11 +20,8 @@ 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.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@@ -34,9 +31,6 @@ import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.campaigns.email.ScheduledEmailConstants; import org.apache.fineract.infrastructure.campaigns.email.ScheduledEmailConstants;
import org.apache.fineract.infrastructure.campaigns.email.data.EmailCampaignValidator; import org.apache.fineract.infrastructure.campaigns.email.data.EmailCampaignValidator;
@@ -86,24 +80,21 @@ public class EmailCampaign extends AbstractPersistableCustom {
private String stretchyReportParamMap; private String stretchyReportParamMap;
@Column(name = "closedon_date", nullable = true) @Column(name = "closedon_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate closureDate;
private Date closureDate;
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "closedon_userid", nullable = true) @JoinColumn(name = "closedon_userid", nullable = true)
private AppUser closedBy; private AppUser closedBy;
@Column(name = "submittedon_date", nullable = true) @Column(name = "submittedon_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate submittedOnDate;
private Date submittedOnDate;
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "submittedon_userid", nullable = true) @JoinColumn(name = "submittedon_userid", nullable = true)
private AppUser submittedBy; private AppUser submittedBy;
@Column(name = "approvedon_date", nullable = true) @Column(name = "approvedon_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate approvedOnDate;
private Date approvedOnDate;
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "approvedon_userid", nullable = true) @JoinColumn(name = "approvedon_userid", nullable = true)
@@ -113,16 +104,13 @@ public class EmailCampaign extends AbstractPersistableCustom {
private String recurrence; private String recurrence;
@Column(name = "next_trigger_date") @Column(name = "next_trigger_date")
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime nextTriggerDate;
private Date nextTriggerDate;
@Column(name = "last_trigger_date") @Column(name = "last_trigger_date")
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime lastTriggerDate;
private Date lastTriggerDate;
@Column(name = "recurrence_start_date") @Column(name = "recurrence_start_date")
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime recurrenceStartDate;
private Date recurrenceStartDate;
@Column(name = "is_visible", nullable = true) @Column(name = "is_visible", nullable = true)
private boolean isVisible; private boolean isVisible;
@@ -153,15 +141,15 @@ 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(ZoneId.systemDefault()).toInstant()); this.submittedOnDate = submittedOnDate;
this.submittedBy = submittedBy; this.submittedBy = submittedBy;
this.recurrence = recurrence; this.recurrence = recurrence;
LocalDateTime recurrenceStartDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()); LocalDateTime recurrenceStartDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
this.isVisible = true; this.isVisible = true;
if (localDateTime != null) { if (localDateTime != null) {
this.recurrenceStartDate = Date.from(localDateTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.recurrenceStartDate = localDateTime;
} else { } else {
this.recurrenceStartDate = Date.from(recurrenceStartDate.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.recurrenceStartDate = recurrenceStartDate;
} }
} }
@@ -248,15 +236,13 @@ public class EmailCampaign extends AbstractPersistableCustom {
final Locale locale = command.extractLocale(); final Locale locale = command.extractLocale();
final DateTimeFormatter fmt = DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(locale); final DateTimeFormatter fmt = DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(locale);
if (command.isChangeInLocalDateParameterNamed(EmailCampaignValidator.recurrenceStartDate, getRecurrenceStartDate())) { if (command.isChangeInLocalDateTimeParameterNamed(EmailCampaignValidator.recurrenceStartDate, getRecurrenceStartDateTime())) {
final String valueAsInput = command.stringValueOfParameterNamed(EmailCampaignValidator.recurrenceStartDate); final String valueAsInput = command.stringValueOfParameterNamed(EmailCampaignValidator.recurrenceStartDate);
actualChanges.put(EmailCampaignValidator.recurrenceStartDate, valueAsInput); actualChanges.put(EmailCampaignValidator.recurrenceStartDate, valueAsInput);
actualChanges.put(ClientApiConstants.dateFormatParamName, dateFormatAsInput); actualChanges.put(ClientApiConstants.dateFormatParamName, dateFormatAsInput);
actualChanges.put(ClientApiConstants.localeParamName, localeAsInput); actualChanges.put(ClientApiConstants.localeParamName, localeAsInput);
final LocalDateTime newValue = LocalDateTime.parse(valueAsInput, fmt); this.recurrenceStartDate = LocalDateTime.parse(valueAsInput, fmt);
this.recurrenceStartDate = Date.from(newValue.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant());
} }
return actualChanges; return actualChanges;
@@ -275,7 +261,7 @@ public class EmailCampaign extends AbstractPersistableCustom {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
this.approvedOnDate = Date.from(activationLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.approvedOnDate = activationLocalDate;
this.approvedBy = currentUser; this.approvedBy = currentUser;
this.status = EmailCampaignStatus.ACTIVE.getValue(); this.status = EmailCampaignStatus.ACTIVE.getValue();
@@ -299,7 +285,7 @@ public class EmailCampaign extends AbstractPersistableCustom {
this.lastTriggerDate = null; this.lastTriggerDate = null;
} }
this.closedBy = currentUser; this.closedBy = currentUser;
this.closureDate = Date.from(closureLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.closureDate = closureLocalDate;
this.status = EmailCampaignStatus.CLOSED.getValue(); this.status = EmailCampaignStatus.CLOSED.getValue();
validateClosureDate(); validateClosureDate();
} }
@@ -318,7 +304,7 @@ public class EmailCampaign extends AbstractPersistableCustom {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
this.approvedOnDate = Date.from(reactivateLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.approvedOnDate = reactivateLocalDate;
this.status = EmailCampaignStatus.ACTIVE.getValue(); this.status = EmailCampaignStatus.ACTIVE.getValue();
this.approvedBy = currentUser; this.approvedBy = currentUser;
this.closureDate = null; this.closureDate = null;
@@ -457,20 +443,16 @@ public class EmailCampaign extends AbstractPersistableCustom {
} }
public LocalDate getSubmittedOnDate() { public LocalDate getSubmittedOnDate() {
return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.submittedOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), null); return this.submittedOnDate;
} }
public LocalDate getClosureDate() { public LocalDate getClosureDate() {
return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.closureDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), null); return this.closureDate;
} }
public LocalDate getActivationLocalDate() { public LocalDate getActivationLocalDate() {
LocalDate activationLocalDate = null; return this.approvedOnDate;
if (this.approvedOnDate != null) {
activationLocalDate = LocalDate.ofInstant(this.approvedOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return activationLocalDate;
} }
private boolean isDateInTheFuture(final LocalDate localDate) { private boolean isDateInTheFuture(final LocalDate localDate) {
@@ -501,36 +483,28 @@ public class EmailCampaign extends AbstractPersistableCustom {
return this.recurrence; return this.recurrence;
} }
public LocalDate getRecurrenceStartDate() {
return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.recurrenceStartDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()),
null);
}
public LocalDateTime getRecurrenceStartDateTime() { public LocalDateTime getRecurrenceStartDateTime() {
return ObjectUtils.defaultIfNull( return this.recurrenceStartDate;
ZonedDateTime.ofInstant(this.recurrenceStartDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()).toLocalDateTime(), null);
} }
public void setLastTriggerDate(Date lastTriggerDate) { public void setLastTriggerDate(LocalDateTime lastTriggerDate) {
this.lastTriggerDate = lastTriggerDate; this.lastTriggerDate = lastTriggerDate;
} }
public void setNextTriggerDate(Date nextTriggerDate) { public void setNextTriggerDate(LocalDateTime nextTriggerDate) {
this.nextTriggerDate = nextTriggerDate; this.nextTriggerDate = nextTriggerDate;
} }
public LocalDateTime getNextTriggerDate() { public LocalDateTime getNextTriggerDate() {
return ObjectUtils.defaultIfNull(
ZonedDateTime.ofInstant(this.nextTriggerDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()).toLocalDateTime(), null);
}
public Date getNextTriggerDateInDate() {
return this.nextTriggerDate; return this.nextTriggerDate;
} }
public LocalDate getLastTriggerDate() { public LocalDateTime getNextTriggerDateInDate() {
return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.lastTriggerDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), null); return this.nextTriggerDate;
}
public LocalDateTime getLastTriggerDate() {
return this.lastTriggerDate;
} }
public void updateIsVisible(boolean isVisible) { public void updateIsVisible(boolean isVisible) {
@@ -18,7 +18,7 @@
*/ */
package org.apache.fineract.infrastructure.campaigns.email.domain; package org.apache.fineract.infrastructure.campaigns.email.domain;
import java.util.Date; import java.time.LocalDate;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import javax.persistence.Column; import javax.persistence.Column;
@@ -26,8 +26,6 @@ import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.campaigns.email.EmailApiConstants; import org.apache.fineract.infrastructure.campaigns.email.EmailApiConstants;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -73,8 +71,7 @@ public class EmailMessage extends AbstractPersistableCustom {
private String campaignName; private String campaignName;
@Column(name = "submittedon_date", nullable = true) @Column(name = "submittedon_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate submittedOnDate;
private Date submittedOnDate;
@Column(name = "error_message") @Column(name = "error_message")
private String errorMessage; private String errorMessage;
@@ -107,7 +104,7 @@ public class EmailMessage extends AbstractPersistableCustom {
this.emailSubject = emailSubject; this.emailSubject = emailSubject;
this.message = message; this.message = message;
this.campaignName = campaignName; this.campaignName = campaignName;
this.submittedOnDate = DateUtils.getBusinessDate(); this.submittedOnDate = DateUtils.getBusinessLocalDate();
} }
public Map<String, Object> update(final JsonCommand command) { public Map<String, Object> update(final JsonCommand command) {
@@ -159,7 +156,7 @@ public class EmailMessage extends AbstractPersistableCustom {
return this.campaignName; return this.campaignName;
} }
public Date getSubmittedOnDate() { public LocalDate getSubmittedOnDate() {
return this.submittedOnDate; return this.submittedOnDate;
} }
@@ -38,7 +38,6 @@ import java.time.format.DateTimeFormatterBuilder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@@ -344,33 +343,29 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
final EmailCampaign emailCampaign = this.emailCampaignRepository.findById(campaignId) final EmailCampaign emailCampaign = this.emailCampaignRepository.findById(campaignId)
.orElseThrow(() -> new EmailCampaignNotFound(campaignId)); .orElseThrow(() -> new EmailCampaignNotFound(campaignId));
LocalDateTime nextTriggerDate = emailCampaign.getNextTriggerDate(); LocalDateTime nextTriggerDate = emailCampaign.getNextTriggerDate();
emailCampaign.setLastTriggerDate(Date.from(nextTriggerDate.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant())); emailCampaign.setLastTriggerDate(nextTriggerDate);
// calculate new trigger date and insert into next trigger date // calculate new trigger date and insert into next trigger date
/** /**
* next run time has to be in the future if not calculate a new future date * next run time has to be in the future if not calculate a new future date
*/ */
LocalDate nextRuntime = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), LocalDateTime newTriggerDateWithTime = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(),
emailCampaign.getNextTriggerDate().toLocalDate(), nextTriggerDate.toLocalDate()); emailCampaign.getNextTriggerDate(), nextTriggerDate);
if (nextRuntime.isBefore(DateUtils.getLocalDateOfTenant())) { // means if (newTriggerDateWithTime.isBefore(DateUtils.getLocalDateTimeOfTenant())) { // means
// next // next
// run // run
// time is // time is
// in the // in the
// past // past
// calculate // calculate
// a new // a new
// future // future
// date // date
nextRuntime = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), newTriggerDateWithTime = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getNextTriggerDate(),
emailCampaign.getNextTriggerDate().toLocalDate(), DateUtils.getLocalDateOfTenant()); DateUtils.getLocalDateTimeOfTenant());
} }
final LocalDateTime getTime = emailCampaign.getRecurrenceStartDateTime();
final String dateString = nextRuntime.toString() + " " + getTime.getHour() + ":" + getTime.getMinute() + ":" + getTime.getSecond();
final DateTimeFormatter simpleDateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
final LocalDateTime newTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat);
emailCampaign.setNextTriggerDate(Date.from(newTriggerDateWithTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant())); emailCampaign.setNextTriggerDate(newTriggerDateWithTime);
this.emailCampaignRepository.saveAndFlush(emailCampaign); this.emailCampaignRepository.saveAndFlush(emailCampaign);
} }
@@ -402,24 +397,15 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
* if recurrence start date is in the future calculate next trigger date if not use recurrence start * if recurrence start date is in the future calculate next trigger date if not use recurrence start
* date us next trigger date when activating * date us next trigger date when activating
*/ */
LocalDate nextTriggerDate = null; LocalDateTime nextTriggerDateWithTime;
if (emailCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) { if (emailCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) {
nextTriggerDate = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), nextTriggerDateWithTime = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(),
emailCampaign.getRecurrenceStartDate(), DateUtils.getLocalDateOfTenant()); emailCampaign.getRecurrenceStartDateTime(), DateUtils.getLocalDateTimeOfTenant());
} else { } else {
nextTriggerDate = emailCampaign.getRecurrenceStartDate(); nextTriggerDateWithTime = emailCampaign.getRecurrenceStartDateTime();
} }
// to get time of tenant
final LocalDateTime getTime = emailCampaign.getRecurrenceStartDateTime();
final String dateString = nextTriggerDate.toString() + " " + getTime.getHour() + ":" + getTime.getMinute() + ":" emailCampaign.setNextTriggerDate(nextTriggerDateWithTime);
+ getTime.getSecond();
final DateTimeFormatter simpleDateFormat = new DateTimeFormatterBuilder().parseCaseInsensitive().parseLenient()
.appendPattern("yyyy-MM-dd HH:mm:ss").toFormatter();
final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat);
emailCampaign
.setNextTriggerDate(Date.from(nextTriggerDateWithTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
this.emailCampaignRepository.saveAndFlush(emailCampaign); this.emailCampaignRepository.saveAndFlush(emailCampaign);
} }
} }
@@ -554,12 +540,12 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
* if recurrence start date is in the future calculate next trigger date if not use recurrence start date us * if recurrence start date is in the future calculate next trigger date if not use recurrence start date us
* next trigger date when activating * next trigger date when activating
*/ */
LocalDate nextTriggerDate = null; LocalDateTime nextTriggerDate = null;
if (emailCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) { if (emailCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) {
nextTriggerDate = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(), emailCampaign.getRecurrenceStartDate(), nextTriggerDate = CalendarUtils.getNextRecurringDate(emailCampaign.getRecurrence(),
DateUtils.getLocalDateOfTenant()); emailCampaign.getRecurrenceStartDateTime(), DateUtils.getLocalDateTimeOfTenant());
} else { } else {
nextTriggerDate = emailCampaign.getRecurrenceStartDate(); nextTriggerDate = emailCampaign.getRecurrenceStartDateTime();
} }
// to get time of tenant // to get time of tenant
final LocalDateTime getTime = emailCampaign.getRecurrenceStartDateTime(); final LocalDateTime getTime = emailCampaign.getRecurrenceStartDateTime();
@@ -570,7 +556,7 @@ public class EmailCampaignWritePlatformCommandHandlerImpl implements EmailCampai
.appendPattern("yyyy-MM-dd HH:mm:ss").toFormatter(); .appendPattern("yyyy-MM-dd HH:mm:ss").toFormatter();
final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat); final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat);
emailCampaign.setNextTriggerDate(Date.from(nextTriggerDateWithTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant())); emailCampaign.setNextTriggerDate(nextTriggerDateWithTime);
this.emailCampaignRepository.saveAndFlush(emailCampaign); this.emailCampaignRepository.saveAndFlush(emailCampaign);
} }
@@ -18,8 +18,8 @@
*/ */
package org.apache.fineract.infrastructure.campaigns.email.service; package org.apache.fineract.infrastructure.campaigns.email.service;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.infrastructure.campaigns.email.data.EmailData; import org.apache.fineract.infrastructure.campaigns.email.data.EmailData;
import org.apache.fineract.infrastructure.core.service.Page; import org.apache.fineract.infrastructure.core.service.Page;
@@ -39,7 +39,7 @@ public interface EmailReadPlatformService {
Collection<EmailData> retrieveAllFailed(SearchParameters searchParameters); Collection<EmailData> retrieveAllFailed(SearchParameters searchParameters);
Page<EmailData> retrieveEmailByStatus(Integer limit, Integer status, Date dateFrom, Date dateTo); Page<EmailData> retrieveEmailByStatus(Integer limit, Integer status, LocalDate dateFrom, LocalDate dateTo);
List<Long> retrieveExternalIdsOfAllSent(Integer limit); List<Long> retrieveExternalIdsOfAllSent(Integer limit);
} }
@@ -20,11 +20,8 @@ package org.apache.fineract.infrastructure.campaigns.email.service;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.infrastructure.campaigns.email.data.EmailData; import org.apache.fineract.infrastructure.campaigns.email.data.EmailData;
import org.apache.fineract.infrastructure.campaigns.email.domain.EmailMessageEnumerations; import org.apache.fineract.infrastructure.campaigns.email.domain.EmailMessageEnumerations;
@@ -32,6 +29,7 @@ import org.apache.fineract.infrastructure.campaigns.email.domain.EmailMessageSta
import org.apache.fineract.infrastructure.campaigns.email.exception.EmailNotFoundException; import org.apache.fineract.infrastructure.campaigns.email.exception.EmailNotFoundException;
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.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.SearchParameters; import org.apache.fineract.infrastructure.core.service.SearchParameters;
@@ -172,7 +170,8 @@ public class EmailReadPlatformServiceImpl implements EmailReadPlatformService {
} }
@Override @Override
public Page<EmailData> retrieveEmailByStatus(final Integer limit, final Integer status, final Date dateFrom, final Date dateTo) { public Page<EmailData> retrieveEmailByStatus(final Integer limit, final Integer status, final LocalDate dateFrom,
final LocalDate dateTo) {
final StringBuilder sqlBuilder = new StringBuilder(200); final StringBuilder sqlBuilder = new StringBuilder(200);
sqlBuilder.append("select " + sqlGenerator.calcFoundRows() + " "); sqlBuilder.append("select " + sqlGenerator.calcFoundRows() + " ");
sqlBuilder.append(this.emailRowMapper.schema()); sqlBuilder.append(this.emailRowMapper.schema());
@@ -182,9 +181,8 @@ public class EmailReadPlatformServiceImpl implements EmailReadPlatformService {
String fromDateString = null; String fromDateString = null;
String toDateString = null; String toDateString = null;
if (dateFrom != null && dateTo != null) { if (dateFrom != null && dateTo != null) {
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); fromDateString = DateUtils.DEFAULT_DATE_FORMATER.format(dateFrom);
fromDateString = df.format(dateFrom); toDateString = DateUtils.DEFAULT_DATE_FORMATER.format(dateTo);
toDateString = df.format(dateTo);
sqlBuilder.append(" and emo.submittedon_date >= ? and emo.submittedon_date <= ? "); sqlBuilder.append(" and emo.submittedon_date >= ? and emo.submittedon_date <= ? ");
} }
final String sqlPlusLimit = (limit > 0) ? " " + sqlGenerator.limit(limit) : ""; final String sqlPlusLimit = (limit > 0) ? " " + sqlGenerator.limit(limit) : "";
@@ -20,11 +20,8 @@ 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.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@@ -34,10 +31,7 @@ import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.campaigns.constants.CampaignType; import org.apache.fineract.infrastructure.campaigns.constants.CampaignType;
import org.apache.fineract.infrastructure.campaigns.sms.constants.SmsCampaignStatus; import org.apache.fineract.infrastructure.campaigns.sms.constants.SmsCampaignStatus;
@@ -83,24 +77,21 @@ public class SmsCampaign extends AbstractPersistableCustom {
private String message; private String message;
@Column(name = "closedon_date", nullable = true) @Column(name = "closedon_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate closureDate;
private Date closureDate;
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "closedon_userid", nullable = true) @JoinColumn(name = "closedon_userid", nullable = true)
private AppUser closedBy; private AppUser closedBy;
@Column(name = "submittedon_date", nullable = true) @Column(name = "submittedon_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate submittedOnDate;
private Date submittedOnDate;
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "submittedon_userid", nullable = true) @JoinColumn(name = "submittedon_userid", nullable = true)
private AppUser submittedBy; private AppUser submittedBy;
@Column(name = "approvedon_date", nullable = true) @Column(name = "approvedon_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate approvedOnDate;
private Date approvedOnDate;
@ManyToOne(optional = true) @ManyToOne(optional = true)
@JoinColumn(name = "approvedon_userid", nullable = true) @JoinColumn(name = "approvedon_userid", nullable = true)
@@ -110,16 +101,13 @@ public class SmsCampaign extends AbstractPersistableCustom {
private String recurrence; private String recurrence;
@Column(name = "next_trigger_date", nullable = true) @Column(name = "next_trigger_date", nullable = true)
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime nextTriggerDate;
private Date nextTriggerDate;
@Column(name = "last_trigger_date", nullable = true) @Column(name = "last_trigger_date", nullable = true)
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime lastTriggerDate;
private Date lastTriggerDate;
@Column(name = "recurrence_start_date", nullable = true) @Column(name = "recurrence_start_date", nullable = true)
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime recurrenceStartDate;
private Date recurrenceStartDate;
@Column(name = "is_visible", nullable = true) @Column(name = "is_visible", nullable = true)
private boolean isVisible; private boolean isVisible;
@@ -140,15 +128,15 @@ 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(ZoneId.systemDefault()).toInstant()); this.submittedOnDate = submittedOnDate;
this.submittedBy = submittedBy; this.submittedBy = submittedBy;
this.recurrence = recurrence; this.recurrence = recurrence;
LocalDateTime recurrenceStartDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant()); LocalDateTime recurrenceStartDate = LocalDateTime.now(DateUtils.getDateTimeZoneOfTenant());
this.isVisible = true; this.isVisible = true;
if (localDateTime != null) { if (localDateTime != null) {
this.recurrenceStartDate = Date.from(localDateTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.recurrenceStartDate = localDateTime;
} else { } else {
this.recurrenceStartDate = Date.from(recurrenceStartDate.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.recurrenceStartDate = recurrenceStartDate;
} }
this.isNotification = isNotification; this.isNotification = isNotification;
} }
@@ -260,9 +248,7 @@ public class SmsCampaign extends AbstractPersistableCustom {
actualChanges.put(SmsCampaignValidator.dateTimeFormat, dateTimeFormatAsInput); actualChanges.put(SmsCampaignValidator.dateTimeFormat, dateTimeFormatAsInput);
actualChanges.put(SmsCampaignValidator.localeParamName, localeAsInput); actualChanges.put(SmsCampaignValidator.localeParamName, localeAsInput);
final LocalDateTime newValue = LocalDateTime.parse(valueAsInput, fmt); this.recurrenceStartDate = LocalDateTime.parse(valueAsInput, fmt);
this.recurrenceStartDate = Date.from(newValue.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant());
} }
return actualChanges; return actualChanges;
@@ -281,7 +267,7 @@ public class SmsCampaign extends AbstractPersistableCustom {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
this.approvedOnDate = Date.from(activationLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.approvedOnDate = activationLocalDate;
this.approvedBy = currentUser; this.approvedBy = currentUser;
this.status = SmsCampaignStatus.ACTIVE.getValue(); this.status = SmsCampaignStatus.ACTIVE.getValue();
@@ -305,7 +291,7 @@ public class SmsCampaign extends AbstractPersistableCustom {
this.lastTriggerDate = null; this.lastTriggerDate = null;
} }
this.closedBy = currentUser; this.closedBy = currentUser;
this.closureDate = Date.from(closureLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.closureDate = closureLocalDate;
this.status = SmsCampaignStatus.CLOSED.getValue(); this.status = SmsCampaignStatus.CLOSED.getValue();
validateClosureDate(); validateClosureDate();
} }
@@ -324,7 +310,7 @@ public class SmsCampaign extends AbstractPersistableCustom {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
this.approvedOnDate = Date.from(reactivateLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.approvedOnDate = reactivateLocalDate;
this.status = SmsCampaignStatus.ACTIVE.getValue(); this.status = SmsCampaignStatus.ACTIVE.getValue();
this.approvedBy = currentUser; this.approvedBy = currentUser;
this.closureDate = null; this.closureDate = null;
@@ -467,20 +453,16 @@ public class SmsCampaign extends AbstractPersistableCustom {
} }
public LocalDate getSubmittedOnDate() { public LocalDate getSubmittedOnDate() {
return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.submittedOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), null); return this.submittedOnDate;
} }
public LocalDate getClosureDate() { public LocalDate getClosureDate() {
return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.closureDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), null); return this.closureDate;
} }
public LocalDate getActivationLocalDate() { public LocalDate getActivationLocalDate() {
LocalDate activationLocalDate = null; return this.approvedOnDate;
if (this.approvedOnDate != null) {
activationLocalDate = LocalDate.ofInstant(this.approvedOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return activationLocalDate;
} }
private boolean isDateInTheFuture(final LocalDate localDate) { private boolean isDateInTheFuture(final LocalDate localDate) {
@@ -507,36 +489,28 @@ public class SmsCampaign extends AbstractPersistableCustom {
return this.recurrence; return this.recurrence;
} }
public LocalDate getRecurrenceStartDate() { public LocalDateTime getRecurrenceStartDate() {
return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.recurrenceStartDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), return this.recurrenceStartDate;
null);
} }
public LocalDateTime getRecurrenceStartDateTime() { public LocalDateTime getRecurrenceStartDateTime() {
return ObjectUtils.defaultIfNull( return this.recurrenceStartDate;
ZonedDateTime.ofInstant(this.recurrenceStartDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()).toLocalDateTime(), null);
} }
public void setLastTriggerDate(Date lastTriggerDate) { public void setLastTriggerDate(LocalDateTime lastTriggerDate) {
this.lastTriggerDate = lastTriggerDate; this.lastTriggerDate = lastTriggerDate;
} }
public void setNextTriggerDate(Date nextTriggerDate) { public void setNextTriggerDate(LocalDateTime nextTriggerDate) {
this.nextTriggerDate = nextTriggerDate; this.nextTriggerDate = nextTriggerDate;
} }
public LocalDateTime getNextTriggerDate() { public LocalDateTime getNextTriggerDate() {
return ObjectUtils.defaultIfNull(
ZonedDateTime.ofInstant(this.nextTriggerDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()).toLocalDateTime(), null);
}
public Date getNextTriggerDateInDate() {
return this.nextTriggerDate; return this.nextTriggerDate;
} }
public LocalDate getLastTriggerDate() { public LocalDateTime getLastTriggerDate() {
return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.lastTriggerDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), null); return this.lastTriggerDate;
} }
public void updateIsVisible(boolean isVisible) { public void updateIsVisible(boolean isVisible) {
@@ -32,10 +32,8 @@ import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@@ -146,7 +144,7 @@ public class SmsCampaignWritePlatformServiceJpaImpl implements SmsCampaignWriteP
Report report = this.reportRepository.findById(runReportId).orElseThrow(() -> new ReportNotFoundException(runReportId)); Report report = this.reportRepository.findById(runReportId).orElseThrow(() -> new ReportNotFoundException(runReportId));
SmsCampaign smsCampaign = SmsCampaign.instance(currentUser, report, command); SmsCampaign smsCampaign = SmsCampaign.instance(currentUser, report, command);
if (smsCampaign.getRecurrenceStartDate() != null if (smsCampaign.getRecurrenceStartDate() != null
&& smsCampaign.getRecurrenceStartDate().isBefore(DateUtils.getLocalDateOfTenant())) { && smsCampaign.getRecurrenceStartDate().isBefore(DateUtils.getLocalDateTimeOfTenant())) {
throw new GeneralPlatformDomainRuleException("error.msg.campaign.recurrenceStartDate.in.the.past", throw new GeneralPlatformDomainRuleException("error.msg.campaign.recurrenceStartDate.in.the.past",
"Recurrence start date cannot be the past date.", smsCampaign.getRecurrenceStartDate()); "Recurrence start date cannot be the past date.", smsCampaign.getRecurrenceStartDate());
} }
@@ -409,34 +407,29 @@ public class SmsCampaignWritePlatformServiceJpaImpl implements SmsCampaignWriteP
final SmsCampaign smsCampaign = this.smsCampaignRepository.findById(campaignId) final SmsCampaign smsCampaign = this.smsCampaignRepository.findById(campaignId)
.orElseThrow(() -> new SmsCampaignNotFound(campaignId)); .orElseThrow(() -> new SmsCampaignNotFound(campaignId));
LocalDateTime nextTriggerDate = smsCampaign.getNextTriggerDate(); LocalDateTime nextTriggerDate = smsCampaign.getNextTriggerDate();
smsCampaign.setLastTriggerDate(Date.from(nextTriggerDate.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant())); smsCampaign.setLastTriggerDate(nextTriggerDate);
// calculate new trigger date and insert into next trigger date // calculate new trigger date and insert into next trigger date
/** /**
* next run time has to be in the future if not calculate a new future date * next run time has to be in the future if not calculate a new future date
*/ */
LocalDate nextRuntime = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), LocalDateTime nextRuntime = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getNextTriggerDate(),
smsCampaign.getNextTriggerDate().toLocalDate(), nextTriggerDate.toLocalDate()); nextTriggerDate);
if (nextRuntime.isBefore(DateUtils.getLocalDateOfTenant())) { // means if (nextRuntime.isBefore(DateUtils.getLocalDateTimeOfTenant())) { // means
// next // next
// run // run
// time is // time is
// in the // in the
// past // past
// calculate // calculate
// a new // a new
// future // future
// date // date
nextRuntime = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getNextTriggerDate().toLocalDate(), nextRuntime = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getNextTriggerDate(),
DateUtils.getLocalDateOfTenant()); DateUtils.getLocalDateTimeOfTenant());
} }
final LocalDateTime getTime = smsCampaign.getRecurrenceStartDateTime();
final String dateString = nextRuntime.toString() + " " + getTime.getHour() + ":" + getTime.getMinute() + ":" + getTime.getSecond();
final DateTimeFormatter simpleDateFormat = new DateTimeFormatterBuilder().parseCaseInsensitive().parseLenient()
.appendPattern("yyyy-MM-dd HH:mm:ss").toFormatter();
final LocalDateTime newTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat);
smsCampaign.setNextTriggerDate(Date.from(newTriggerDateWithTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant())); smsCampaign.setNextTriggerDate(nextRuntime);
this.smsCampaignRepository.saveAndFlush(smsCampaign); this.smsCampaignRepository.saveAndFlush(smsCampaign);
} }
@@ -466,23 +459,15 @@ public class SmsCampaignWritePlatformServiceJpaImpl implements SmsCampaignWriteP
* if recurrence start date is in the future calculate next trigger date if not use recurrence start date us * if recurrence start date is in the future calculate next trigger date if not use recurrence start date us
* next trigger date when activating * next trigger date when activating
*/ */
LocalDate nextTriggerDate = null; LocalDateTime nextTriggerDate = null;
if (smsCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) { if (smsCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) {
nextTriggerDate = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getRecurrenceStartDate(), nextTriggerDate = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getRecurrenceStartDate(),
DateUtils.getLocalDateOfTenant()); DateUtils.getLocalDateTimeOfTenant());
} else { } else {
nextTriggerDate = smsCampaign.getRecurrenceStartDate(); nextTriggerDate = smsCampaign.getRecurrenceStartDate();
} }
// to get time of tenant
final LocalDateTime getTime = smsCampaign.getRecurrenceStartDateTime();
final String dateString = nextTriggerDate.toString() + " " + getTime.getHour() + ":" + getTime.getMinute() + ":" smsCampaign.setNextTriggerDate(nextTriggerDate);
+ getTime.getSecond();
final DateTimeFormatter simpleDateFormat = new DateTimeFormatterBuilder().parseCaseInsensitive().parseLenient()
.appendPattern("yyyy-MM-dd HH:mm:ss").toFormatter();
final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat);
smsCampaign.setNextTriggerDate(Date.from(nextTriggerDateWithTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
this.smsCampaignRepository.saveAndFlush(smsCampaign); this.smsCampaignRepository.saveAndFlush(smsCampaign);
} }
@@ -629,23 +614,17 @@ public class SmsCampaignWritePlatformServiceJpaImpl implements SmsCampaignWriteP
* if recurrence start date is in the future calculate next trigger date if not use recurrence start date us * if recurrence start date is in the future calculate next trigger date if not use recurrence start date us
* next trigger date when activating * next trigger date when activating
*/ */
LocalDate nextTriggerDate = null; LocalDateTime nextTriggerDate = null;
if (smsCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) { if (smsCampaign.getRecurrenceStartDateTime().isBefore(tenantDateTime())) {
nextTriggerDate = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getRecurrenceStartDate(), nextTriggerDate = CalendarUtils.getNextRecurringDate(smsCampaign.getRecurrence(), smsCampaign.getRecurrenceStartDate(),
DateUtils.getLocalDateOfTenant()); DateUtils.getLocalDateTimeOfTenant());
} else { } else {
nextTriggerDate = smsCampaign.getRecurrenceStartDate(); nextTriggerDate = smsCampaign.getRecurrenceStartDate();
} }
// to get time of tenant // to get time of tenant
final LocalDateTime getTime = smsCampaign.getRecurrenceStartDateTime(); final LocalDateTime getTime = smsCampaign.getRecurrenceStartDateTime();
final String dateString = nextTriggerDate.toString() + " " + getTime.getHour() + ":" + getTime.getMinute() + ":" smsCampaign.setNextTriggerDate(nextTriggerDate);
+ getTime.getSecond();
final DateTimeFormatter simpleDateFormat = new DateTimeFormatterBuilder().parseCaseInsensitive().parseLenient()
.appendPattern("yyyy-MM-dd HH:mm:ss").toFormatter();
final LocalDateTime nextTriggerDateWithTime = LocalDateTime.parse(dateString, simpleDateFormat);
smsCampaign.setNextTriggerDate(Date.from(nextTriggerDateWithTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
} }
this.smsCampaignRepository.saveAndFlush(smsCampaign); this.smsCampaignRepository.saveAndFlush(smsCampaign);
@@ -665,8 +644,8 @@ public class SmsCampaignWritePlatformServiceJpaImpl implements SmsCampaignWriteP
LocalDateTime tenantDateNow = tenantDateTime(); LocalDateTime tenantDateNow = tenantDateTime();
LocalDateTime nextTriggerDate = smsCampaign.getNextTriggerDate(); LocalDateTime nextTriggerDate = smsCampaign.getNextTriggerDate();
LOG.info("tenant time {} trigger time {} {}", LOG.info("tenant time {} trigger time {} {}", tenantDateNow, nextTriggerDate,
new Object[] { tenantDateNow, nextTriggerDate, JobName.UPDATE_SMS_OUTBOUND_WITH_CAMPAIGN_MESSAGE.name() }); JobName.UPDATE_SMS_OUTBOUND_WITH_CAMPAIGN_MESSAGE.name());
if (nextTriggerDate.isBefore(tenantDateNow)) { if (nextTriggerDate.isBefore(tenantDateNow)) {
insertDirectCampaignIntoSmsOutboundTable(smsCampaign); insertDirectCampaignIntoSmsOutboundTable(smsCampaign);
this.updateTriggerDates(smsCampaign.getId()); this.updateTriggerDates(smsCampaign.getId());
@@ -25,11 +25,11 @@ import java.lang.reflect.Type;
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.LocalTime;
import java.time.MonthDay; import java.time.MonthDay;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -255,19 +255,7 @@ public final class JsonCommand {
return this.productId; return this.productId;
} }
private boolean differenceExistsTime(final LocalDateTime baseValue, final LocalDateTime workingCopyValue) { private boolean differenceExists(final TemporalAccessor baseValue, final TemporalAccessor workingCopyValue) {
boolean differenceExists = false;
if (baseValue != null) {
differenceExists = !baseValue.equals(workingCopyValue);
} else {
differenceExists = workingCopyValue != null;
}
return differenceExists;
}
private boolean differenceExists(final LocalDate baseValue, final LocalDate workingCopyValue) {
boolean differenceExists = false; boolean differenceExists = false;
if (baseValue != null) { if (baseValue != null) {
@@ -374,20 +362,29 @@ public final class JsonCommand {
return isChangeInLocalDateParameterNamed(parameterName, existingValue); return isChangeInLocalDateParameterNamed(parameterName, existingValue);
} }
public boolean isChangeInTimeParameterNamed(final String parameterName, final Date existingValue, final String timeFormat) { public boolean isChangeInTimeParameterNamed(final String parameterName, final LocalTime existingValue, final String timeFormat) {
LocalDateTime time = null; LocalTime time = null;
if (existingValue != null) { if (existingValue != null) {
DateTimeFormatter timeFormtter = DateTimeFormatter.ofPattern(timeFormat); DateTimeFormatter timeFormtter = DateTimeFormatter.ofPattern(timeFormat);
time = LocalDateTime.parse(existingValue.toString(), timeFormtter); time = LocalTime.parse(existingValue.toString(), timeFormtter);
} }
return isChangeInLocalTimeParameterNamed(parameterName, time); return isChangeInLocalTimeParameterNamed(parameterName, time);
} }
public boolean isChangeInLocalTimeParameterNamed(final String parameterName, final LocalDateTime existingValue) { public boolean isChangeInLocalTimeParameterNamed(final String parameterName, final LocalTime existingValue) {
boolean isChanged = false; boolean isChanged = false;
if (parameterExists(parameterName)) { if (parameterExists(parameterName)) {
final LocalDateTime workingValue = localTimeValueOfParameterNamed(parameterName); final LocalTime workingValue = localTimeValueOfParameterNamed(parameterName);
isChanged = differenceExistsTime(existingValue, workingValue); isChanged = differenceExists(existingValue, workingValue);
}
return isChanged;
}
public boolean isChangeInLocalDateTimeParameterNamed(final String parameterName, final LocalDateTime existingValue) {
boolean isChanged = false;
if (parameterExists(parameterName)) {
final LocalTime workingValue = localTimeValueOfParameterNamed(parameterName);
isChanged = differenceExists(existingValue, workingValue);
} }
return isChanged; return isChanged;
} }
@@ -405,20 +402,20 @@ public final class JsonCommand {
return this.fromApiJsonHelper.extractLocalDateNamed(parameterName, this.parsedCommand); return this.fromApiJsonHelper.extractLocalDateNamed(parameterName, this.parsedCommand);
} }
public LocalDateTime localTimeValueOfParameterNamed(final String parameterName) { public LocalTime localTimeValueOfParameterNamed(final String parameterName) {
return this.fromApiJsonHelper.extractLocalTimeNamed(parameterName, this.parsedCommand); return this.fromApiJsonHelper.extractLocalTimeNamed(parameterName, this.parsedCommand);
} }
public LocalDateTime localDateTimeValueOfParameterNamed(final String parameterName) {
return this.fromApiJsonHelper.extractLocalDateTimeNamed(parameterName, this.parsedCommand);
}
public MonthDay extractMonthDayNamed(final String parameterName) { public MonthDay extractMonthDayNamed(final String parameterName) {
return this.fromApiJsonHelper.extractMonthDayNamed(parameterName, this.parsedCommand); return this.fromApiJsonHelper.extractMonthDayNamed(parameterName, this.parsedCommand);
} }
public Date dateValueOfParameterNamed(final String parameterName) { public LocalDate dateValueOfParameterNamed(final String parameterName) {
final LocalDate localDate = this.fromApiJsonHelper.extractLocalDateNamed(parameterName, this.parsedCommand); return this.fromApiJsonHelper.extractLocalDateNamed(parameterName, this.parsedCommand);
if (localDate == null) {
return null;
}
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) {
@@ -18,9 +18,10 @@
*/ */
package org.apache.fineract.infrastructure.core.data; package org.apache.fineract.infrastructure.core.data;
import java.text.SimpleDateFormat; import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
public final class ApiParameterError { public final class ApiParameterError {
@@ -91,9 +92,9 @@ public final class ApiParameterError {
final List<ApiErrorMessageArg> messageArgs = new ArrayList<>(); final List<ApiErrorMessageArg> messageArgs = new ArrayList<>();
if (defaultUserMessageArgs != null) { if (defaultUserMessageArgs != null) {
for (final Object object : defaultUserMessageArgs) { for (final Object object : defaultUserMessageArgs) {
if (object instanceof Date) { if (object instanceof LocalDate) {
final SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd"); final DateTimeFormatter dateFormatter = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd").toFormatter();
final String formattedDate = dateFormatter.format(object); final String formattedDate = dateFormatter.format((LocalDate) object);
messageArgs.add(ApiErrorMessageArg.from(formattedDate)); messageArgs.add(ApiErrorMessageArg.from(formattedDate));
} else { } else {
messageArgs.add(ApiErrorMessageArg.from(object)); messageArgs.add(ApiErrorMessageArg.from(object));
@@ -18,13 +18,10 @@
*/ */
package org.apache.fineract.infrastructure.core.domain; package org.apache.fineract.infrastructure.core.domain;
import java.time.Instant; import java.time.LocalDateTime;
import java.util.Date;
import java.util.Optional; import java.util.Optional;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.MappedSuperclass; import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.springframework.data.domain.Auditable; import org.springframework.data.domain.Auditable;
import org.springframework.data.jpa.domain.AbstractAuditable; import org.springframework.data.jpa.domain.AbstractAuditable;
@@ -40,7 +37,7 @@ import org.springframework.data.jpa.domain.AbstractAuditable;
* the type of the auditing type's identifier * the type of the auditing type's identifier
*/ */
@MappedSuperclass @MappedSuperclass
public abstract class AbstractAuditableCustom extends AbstractPersistableCustom implements Auditable<Long, Long, Instant> { public abstract class AbstractAuditableCustom extends AbstractPersistableCustom implements Auditable<Long, Long, LocalDateTime> {
private static final long serialVersionUID = 141481953116476081L; private static final long serialVersionUID = 141481953116476081L;
@@ -48,15 +45,13 @@ public abstract class AbstractAuditableCustom extends AbstractPersistableCustom
private Long createdBy; private Long createdBy;
@Column(name = "created_date") @Column(name = "created_date")
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime createdDate;
private Date createdDate;
@Column(name = "lastmodifiedby_id") @Column(name = "lastmodifiedby_id")
private Long lastModifiedBy; private Long lastModifiedBy;
@Column(name = "lastmodified_date") @Column(name = "lastmodified_date")
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime lastModifiedDate;
private Date lastModifiedDate;
@Override @Override
public Optional<Long> getCreatedBy() { public Optional<Long> getCreatedBy() {
@@ -69,13 +64,13 @@ public abstract class AbstractAuditableCustom extends AbstractPersistableCustom
} }
@Override @Override
public Optional<Instant> getCreatedDate() { public Optional<LocalDateTime> getCreatedDate() {
return null == this.createdDate ? Optional.empty() : Optional.of(this.createdDate.toInstant()); return null == this.createdDate ? Optional.empty() : Optional.of(this.createdDate);
} }
@Override @Override
public void setCreatedDate(final Instant createdDate) { public void setCreatedDate(final LocalDateTime createdDate) {
this.createdDate = null == createdDate ? null : Date.from(createdDate); this.createdDate = createdDate;
} }
@Override @Override
@@ -89,12 +84,12 @@ public abstract class AbstractAuditableCustom extends AbstractPersistableCustom
} }
@Override @Override
public Optional<Instant> getLastModifiedDate() { public Optional<LocalDateTime> getLastModifiedDate() {
return null == this.lastModifiedDate ? Optional.empty() : Optional.of(this.lastModifiedDate.toInstant()); return null == this.lastModifiedDate ? Optional.empty() : Optional.of(this.lastModifiedDate);
} }
@Override @Override
public void setLastModifiedDate(final Instant lastModifiedDate) { public void setLastModifiedDate(final LocalDateTime lastModifiedDate) {
this.lastModifiedDate = null == lastModifiedDate ? null : Date.from(lastModifiedDate); this.lastModifiedDate = lastModifiedDate;
} }
} }
@@ -28,6 +28,7 @@ import java.math.BigDecimal;
import java.security.InvalidParameterException; import java.security.InvalidParameterException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.MonthDay; import java.time.MonthDay;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@@ -203,19 +204,32 @@ public class FromJsonHelper {
return this.helperDelegator.extractLocalDateNamed(parameterName, element, new HashSet<>()); return this.helperDelegator.extractLocalDateNamed(parameterName, element, new HashSet<>());
} }
public LocalDateTime extractLocalTimeNamed(final String parameterName, final JsonElement element) { public LocalTime extractLocalTimeNamed(final String parameterName, final JsonElement element) {
return this.helperDelegator.extractLocalTimeNamed(parameterName, element, new HashSet<>()); return this.helperDelegator.extractLocalTimeNamed(parameterName, element, new HashSet<>());
} }
public LocalDateTime extractLocalTimeNamed(final String parameterName, final JsonElement element, final String dateFormat, public LocalDateTime extractLocalDateTimeNamed(final String parameterName, final JsonElement element) {
return this.helperDelegator.extractLocalDateTimeNamed(parameterName, element, new HashSet<>());
}
public LocalTime extractLocalTimeNamed(final String parameterName, final JsonElement element, final String dateFormat,
final Locale locale) { final Locale locale) {
return this.helperDelegator.extractLocalTimeNamed(parameterName, element, dateFormat, locale, new HashSet<>()); return this.helperDelegator.extractLocalTimeNamed(parameterName, element, dateFormat, locale, new HashSet<>());
} }
public LocalDateTime extractLocalTimeNamed(final String parameterName, final JsonElement element, String timeFormat) { public LocalTime extractLocalTimeNamed(final String parameterName, final JsonElement element, String timeFormat) {
return this.helperDelegator.extractLocalTimeNamed(parameterName, element, timeFormat, new HashSet<>()); return this.helperDelegator.extractLocalTimeNamed(parameterName, element, timeFormat, new HashSet<>());
} }
public LocalDateTime extractLocalDateTimeNamed(final String parameterName, final JsonElement element, final String dateFormat,
final Locale locale) {
return this.helperDelegator.extractLocalDateTimeNamed(parameterName, element, dateFormat, locale, new HashSet<>());
}
public LocalDateTime extractLocalDateTimeNamed(final String parameterName, final JsonElement element, String timeFormat) {
return this.helperDelegator.extractLocalDateTimeNamed(parameterName, element, timeFormat, new HashSet<>());
}
public LocalDate extractLocalDateNamed(final String parameterName, final JsonElement element, final String dateFormat, public LocalDate extractLocalDateNamed(final String parameterName, final JsonElement element, final String dateFormat,
final Locale locale) { final Locale locale) {
return this.helperDelegator.extractLocalDateNamed(parameterName, element.getAsJsonObject(), dateFormat, locale, new HashSet<>()); return this.helperDelegator.extractLocalDateNamed(parameterName, element.getAsJsonObject(), dateFormat, locale, new HashSet<>());
@@ -29,6 +29,7 @@ import java.text.NumberFormat;
import java.text.ParseException; import java.text.ParseException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.MonthDay; import java.time.MonthDay;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder; import java.time.format.DateTimeFormatterBuilder;
@@ -370,10 +371,10 @@ public class JsonParserHelper {
return value; return value;
} }
public LocalDateTime extractLocalTimeNamed(final String parameterName, final JsonElement element, public LocalTime extractLocalTimeNamed(final String parameterName, final JsonElement element,
final Set<String> parametersPassedInCommand) { final Set<String> parametersPassedInCommand) {
LocalDateTime value = null; LocalTime value = null;
if (element.isJsonObject()) { if (element.isJsonObject()) {
final JsonObject object = element.getAsJsonObject(); final JsonObject object = element.getAsJsonObject();
@@ -382,11 +383,23 @@ public class JsonParserHelper {
return value; return value;
} }
public LocalDateTime extractLocalTimeNamed(final String parameterName, final JsonElement element, String timeFormat, public LocalDateTime extractLocalDateTimeNamed(final String parameterName, final JsonElement element,
final Set<String> parametersPassedInCommand) { final Set<String> parametersPassedInCommand) {
LocalDateTime value = null; LocalDateTime value = null;
if (element.isJsonObject()) {
final JsonObject object = element.getAsJsonObject();
value = extractLocalDateTimeNamed(parameterName, element, extractTimeFormatParameter(object), parametersPassedInCommand);
}
return value;
}
public LocalTime extractLocalTimeNamed(final String parameterName, final JsonElement element, String timeFormat,
final Set<String> parametersPassedInCommand) {
LocalTime value = null;
if (element.isJsonObject()) { if (element.isJsonObject()) {
final JsonObject object = element.getAsJsonObject(); final JsonObject object = element.getAsJsonObject();
final Locale clientApplicationLocale = extractLocaleParameter(object); final Locale clientApplicationLocale = extractLocaleParameter(object);
@@ -395,7 +408,52 @@ public class JsonParserHelper {
return value; return value;
} }
public LocalDateTime extractLocalTimeNamed(final String parameterName, final JsonElement element, final String timeFormat, public LocalDateTime extractLocalDateTimeNamed(final String parameterName, final JsonElement element, String timeFormat,
final Set<String> parametersPassedInCommand) {
LocalDateTime value = null;
if (element.isJsonObject()) {
final JsonObject object = element.getAsJsonObject();
final Locale clientApplicationLocale = extractLocaleParameter(object);
value = extractLocalDateTimeNamed(parameterName, object, timeFormat, clientApplicationLocale, parametersPassedInCommand);
}
return value;
}
public LocalTime extractLocalTimeNamed(final String parameterName, final JsonElement element, final String timeFormat,
final Locale clientApplicationLocale, final Set<String> parametersPassedInCommand) {
LocalTime value = null;
String timeValueAsString = null;
if (element.isJsonObject()) {
final JsonObject object = element.getAsJsonObject();
if (object.has(parameterName) && object.get(parameterName).isJsonPrimitive()) {
parametersPassedInCommand.add(parameterName);
try {
DateTimeFormatter timeFormtter = DateTimeFormatter.ofPattern(timeFormat);
final JsonPrimitive primitive = object.get(parameterName).getAsJsonPrimitive();
timeValueAsString = primitive.getAsString();
if (StringUtils.isNotBlank(timeValueAsString)) {
value = LocalTime.parse(timeValueAsString, timeFormtter);
}
} catch (IllegalArgumentException e) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final String defaultMessage = new StringBuilder("The parameter `" + timeValueAsString + "` is not in correct format.")
.toString();
final ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.TimeFormat", defaultMessage,
parameterName);
dataValidationErrors.add(error);
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
dataValidationErrors, e);
}
}
}
return value;
}
public LocalDateTime extractLocalDateTimeNamed(final String parameterName, final JsonElement element, final String timeFormat,
final Locale clientApplicationLocale, final Set<String> parametersPassedInCommand) { final Locale clientApplicationLocale, final Set<String> parametersPassedInCommand) {
LocalDateTime value = null; LocalDateTime value = null;
String timeValueAsString = null; String timeValueAsString = null;
@@ -18,9 +18,6 @@
*/ */
package org.apache.fineract.infrastructure.core.service; package org.apache.fineract.infrastructure.core.service;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
@@ -29,8 +26,6 @@ import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder; import java.time.format.DateTimeFormatterBuilder;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import org.apache.fineract.infrastructure.core.data.ApiParameterError; import org.apache.fineract.infrastructure.core.data.ApiParameterError;
@@ -68,26 +63,6 @@ public final class DateUtils {
return zone; return zone;
} }
public static Date getDateOfTenant() {
return convertLocalDateToDate(getLocalDateOfTenant());
}
private static Date convertLocalDateToDate(LocalDate localDate) {
return createDate(localDate.getYear(), localDate.getMonthValue(), localDate.getDayOfMonth());
}
public static LocalDate convertToLocalDate(final Date dateToConvert, final ZoneId zoneId) {
return dateToConvert.toInstant().atZone(zoneId).toLocalDate();
}
public static Date createDate(int year, int month, int day) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month - 1);
cal.set(Calendar.DAY_OF_MONTH, day);
return cal.getTime();
}
public static LocalDate getLocalDateOfTenant() { public static LocalDate getLocalDateOfTenant() {
final ZoneId zone = getDateTimeZoneOfTenant(); final ZoneId zone = getDateTimeZoneOfTenant();
return LocalDate.now(zone); return LocalDate.now(zone);
@@ -98,17 +73,8 @@ public final class DateUtils {
return LocalDateTime.now(zone).truncatedTo(ChronoUnit.SECONDS); return LocalDateTime.now(zone).truncatedTo(ChronoUnit.SECONDS);
} }
public static Date parseDate(final String stringDate, final String pattern, final ZoneId zoneId) { public static LocalDateTime getLocalDateTimeOfSystem() {
try { return LocalDateTime.now(ZoneId.systemDefault()).truncatedTo(ChronoUnit.SECONDS);
return new SimpleDateFormat(pattern).parse(stringDate);
} catch (final ParseException e) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
final ApiParameterError error = ApiParameterError.parameterError("validation.msg.invalid.date.pattern",
"The parameter date (" + stringDate + ") is invalid w.r.t. pattern " + pattern, "date", stringDate, pattern);
dataValidationErrors.add(error);
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
dataValidationErrors, e);
}
} }
public static LocalDate parseLocalDate(final String stringDate, final String pattern, final ZoneId zoneId) { public static LocalDate parseLocalDate(final String stringDate, final String pattern, final ZoneId zoneId) {
@@ -136,12 +102,6 @@ public final class DateUtils {
return parseLocalDate(stringDate, pattern, getDateTimeZoneOfTenant()); return parseLocalDate(stringDate, pattern, getDateTimeZoneOfTenant());
} }
public static String formatToSqlDate(final Date date) {
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
df.setTimeZone(getTimeZoneOfTenant());
return df.format(date);
}
public static boolean isDateInTheFuture(final LocalDate localDate) { public static boolean isDateInTheFuture(final LocalDate localDate) {
return localDate.isAfter(getLocalDateOfTenant()); return localDate.isAfter(getLocalDateOfTenant());
} }
@@ -150,8 +110,4 @@ public final class DateUtils {
return ThreadLocalContextUtil.getBusinessDate(); return ThreadLocalContextUtil.getBusinessDate();
} }
public static Date getBusinessDate() {
return Date.from(ThreadLocalContextUtil.getBusinessDate().atStartOfDay(ZoneId.systemDefault()).toInstant());
}
} }
@@ -19,10 +19,9 @@
package org.apache.fineract.infrastructure.creditbureau.domain; package org.apache.fineract.infrastructure.creditbureau.domain;
import java.text.ParseException; import java.time.LocalDate;
import java.text.SimpleDateFormat; import java.time.format.DateTimeFormatter;
import java.util.Date; import java.time.format.DateTimeFormatterBuilder;
import java.util.Locale;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
@@ -53,7 +52,7 @@ public class CreditBureauToken extends AbstractPersistableCustom {
private String issued; private String issued;
@Column(name = "expiry_date") @Column(name = "expiry_date")
private Date expires; private LocalDate expires;
public static CreditBureauToken fromJson(final JsonCommand command) { public static CreditBureauToken fromJson(final JsonCommand command) {
final String userName = command.stringValueOfParameterNamed("userName"); final String userName = command.stringValueOfParameterNamed("userName");
@@ -63,19 +62,14 @@ public class CreditBureauToken extends AbstractPersistableCustom {
final String issued = command.stringValueOfParameterNamed(".issued"); final String issued = command.stringValueOfParameterNamed(".issued");
final String expiry = command.stringValueOfParameterNamed(".expires"); final String expiry = command.stringValueOfParameterNamed(".expires");
SimpleDateFormat dateformat = new SimpleDateFormat("EEE, dd MMM yyyy kk:mm:ss zzz", Locale.ENGLISH); DateTimeFormatter dateformat = new DateTimeFormatterBuilder().appendPattern("EEE, dd MMM yyyy kk:mm:ss zzz").toFormatter();
Date expires = null; LocalDate expires = LocalDate.parse(expiry, dateformat);
try {
expires = dateformat.parse(expiry);
} catch (ParseException Ex) {
LOG.error("Error occured while converting Date(String) to SimpleDateFormat", Ex);
}
return new CreditBureauToken(userName, accessToken, tokenType, expiresIn, issued, expires); return new CreditBureauToken(userName, accessToken, tokenType, expiresIn, issued, expires);
} }
public CreditBureauToken(String userName, String accessToken, String tokenType, String expiresIn, String issued, Date expires) { public CreditBureauToken(String userName, String accessToken, String tokenType, String expiresIn, String issued, LocalDate expires) {
this.userName = userName; this.userName = userName;
this.accessToken = accessToken; this.accessToken = accessToken;
this.tokenType = tokenType; this.tokenType = tokenType;
@@ -109,7 +103,7 @@ public class CreditBureauToken extends AbstractPersistableCustom {
this.accessToken = tokens; this.accessToken = tokens;
} }
public Date getTokenExpiryDate() { public LocalDate getTokenExpiryDate() {
return this.expires; return this.expires;
} }
@@ -27,8 +27,8 @@ import com.google.gson.JsonParser;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.MediaType; import okhttp3.MediaType;
@@ -45,6 +45,7 @@ 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.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.creditbureau.data.CreditBureauConfigurations; import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauConfigurations;
import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauReportData; import org.apache.fineract.infrastructure.creditbureau.data.CreditBureauReportData;
import org.apache.fineract.infrastructure.creditbureau.domain.CreditBureauConfiguration; import org.apache.fineract.infrastructure.creditbureau.domain.CreditBureauConfiguration;
@@ -412,10 +413,10 @@ public class ThitsaWorksCreditBureauIntegrationWritePlatformServiceImpl implemen
// check the expiry date of the previous token. // check the expiry date of the previous token.
if (creditBureauToken != null) { if (creditBureauToken != null) {
Date current = new Date(); LocalDate current = DateUtils.getLocalDateOfTenant();
Date getExpiryDate = creditBureauToken.getTokenExpiryDate(); LocalDate getExpiryDate = creditBureauToken.getTokenExpiryDate();
if (getExpiryDate.before(current)) { if (getExpiryDate.isBefore(current)) {
this.tokenRepositoryWrapper.delete(creditBureauToken); this.tokenRepositoryWrapper.delete(creditBureauToken);
creditBureauToken = null; creditBureauToken = null;
} }
@@ -19,7 +19,7 @@
package org.apache.fineract.infrastructure.entityaccess.data; package org.apache.fineract.infrastructure.entityaccess.data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.time.LocalDate;
public final class FineractEntityToEntityMappingData implements Serializable { public final class FineractEntityToEntityMappingData implements Serializable {
@@ -36,10 +36,10 @@ public final class FineractEntityToEntityMappingData implements Serializable {
private Long toId; private Long toId;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private Date startDate; private LocalDate startDate;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private Date endDate; private LocalDate endDate;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private final String fromEntity; private final String fromEntity;
@@ -48,7 +48,7 @@ public final class FineractEntityToEntityMappingData implements Serializable {
private final String toEntity; private final String toEntity;
private FineractEntityToEntityMappingData(final Long mapId, final Long relationId, final Long fromId, final Long toId, private FineractEntityToEntityMappingData(final Long mapId, final Long relationId, final Long fromId, final Long toId,
final Date startDate, final Date endDate, final String fromEntity, final String toEntity) { final LocalDate startDate, final LocalDate endDate, final String fromEntity, final String toEntity) {
this.mapId = mapId; this.mapId = mapId;
this.relationId = relationId; this.relationId = relationId;
this.fromId = fromId; this.fromId = fromId;
@@ -60,14 +60,14 @@ public final class FineractEntityToEntityMappingData implements Serializable {
} }
public static FineractEntityToEntityMappingData getRelatedEntities(final Long mapId, final Long relationId, final Long fromId, public static FineractEntityToEntityMappingData getRelatedEntities(final Long mapId, final Long relationId, final Long fromId,
final Long toId, final Date startDate, final Date endDate, final String fromEntity, final String toEntity) { final Long toId, final LocalDate startDate, final LocalDate endDate, final String fromEntity, final String toEntity) {
return new FineractEntityToEntityMappingData(mapId, relationId, fromId, toId, startDate, endDate, fromEntity, toEntity); return new FineractEntityToEntityMappingData(mapId, relationId, fromId, toId, startDate, endDate, fromEntity, toEntity);
} }
public static FineractEntityToEntityMappingData getRelatedEntities(final Long relationId, final Long fromId, final Long toId, public static FineractEntityToEntityMappingData getRelatedEntities(final Long relationId, final Long fromId, final Long toId,
final Date startDate, final Date endDate) { final LocalDate startDate, final LocalDate endDate) {
final Long mapId = null; final Long mapId = null;
final String fromEntity = null; final String fromEntity = null;
final String toEntity = null; final String toEntity = null;
@@ -18,10 +18,11 @@
*/ */
package org.apache.fineract.infrastructure.entityaccess.service; package org.apache.fineract.infrastructure.entityaccess.service;
import java.sql.Date;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import org.apache.fineract.infrastructure.entityaccess.data.FineractEntityRelationData; import org.apache.fineract.infrastructure.entityaccess.data.FineractEntityRelationData;
import org.apache.fineract.infrastructure.entityaccess.data.FineractEntityToEntityMappingData; import org.apache.fineract.infrastructure.entityaccess.data.FineractEntityToEntityMappingData;
import org.apache.fineract.infrastructure.entityaccess.domain.FineractEntityAccessType; import org.apache.fineract.infrastructure.entityaccess.domain.FineractEntityAccessType;
@@ -242,7 +243,9 @@ public class FineractEntityAccessReadServiceImpl implements FineractEntityAccess
final Long toId = rs.getLong("toId"); final Long toId = rs.getLong("toId");
final Date startDate = rs.getDate("startDate"); final Date startDate = rs.getDate("startDate");
final Date endDate = rs.getDate("endDate"); final Date endDate = rs.getDate("endDate");
return FineractEntityToEntityMappingData.getRelatedEntities(relId, fromId, toId, startDate, endDate); final LocalDate startLocalDate = startDate != null ? startDate.toLocalDate() : null;
final LocalDate endLocalDate = endDate != null ? endDate.toLocalDate() : null;
return FineractEntityToEntityMappingData.getRelatedEntities(relId, fromId, toId, startLocalDate, endLocalDate);
} }
} }
@@ -314,8 +317,10 @@ public class FineractEntityAccessReadServiceImpl implements FineractEntityAccess
final String toEntity = rs.getString("to_name"); final String toEntity = rs.getString("to_name");
final Date startDate = rs.getDate("startDate"); final Date startDate = rs.getDate("startDate");
final Date endDate = rs.getDate("endDate"); final Date endDate = rs.getDate("endDate");
return FineractEntityToEntityMappingData.getRelatedEntities(mapId, relId, fromId, toId, startDate, endDate, fromEntity, final LocalDate startLocalDate = startDate != null ? startDate.toLocalDate() : null;
toEntity); final LocalDate endLocalDate = endDate != null ? endDate.toLocalDate() : null;
return FineractEntityToEntityMappingData.getRelatedEntities(mapId, relId, fromId, toId, startLocalDate, endLocalDate,
fromEntity, toEntity);
} }
} }
@@ -18,14 +18,12 @@
*/ */
package org.apache.fineract.infrastructure.gcm.domain; package org.apache.fineract.infrastructure.gcm.domain;
import java.util.Date; import java.time.LocalDateTime;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
@@ -42,15 +40,14 @@ public final class DeviceRegistration extends AbstractPersistableCustom {
private String registrationId; private String registrationId;
@Column(name = "updatedon_date", nullable = false) @Column(name = "updatedon_date", nullable = false)
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime updatedOnDate;
private Date updatedOnDate;
private DeviceRegistration() {} private DeviceRegistration() {}
private DeviceRegistration(final Client client, final String registrationId) { private DeviceRegistration(final Client client, final String registrationId) {
this.client = client; this.client = client;
this.registrationId = registrationId; this.registrationId = registrationId;
this.updatedOnDate = Date.from(DateUtils.getLocalDateTimeOfTenant().atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.updatedOnDate = DateUtils.getLocalDateTimeOfTenant();
} }
public static DeviceRegistration instance(final Client client, final String registrationId) { public static DeviceRegistration instance(final Client client, final String registrationId) {
@@ -73,11 +70,11 @@ public final class DeviceRegistration extends AbstractPersistableCustom {
this.registrationId = registrationId; this.registrationId = registrationId;
} }
public Date getUpdatedOnDate() { public LocalDateTime getUpdatedOnDate() {
return this.updatedOnDate; return this.updatedOnDate;
} }
public void setUpdatedOnDate(Date updatedOnDate) { public void setUpdatedOnDate(LocalDateTime updatedOnDate) {
this.updatedOnDate = updatedOnDate; this.updatedOnDate = updatedOnDate;
} }
@@ -18,7 +18,7 @@
*/ */
package org.apache.fineract.infrastructure.gcm.domain; package org.apache.fineract.infrastructure.gcm.domain;
import java.util.Date; import java.time.LocalDateTime;
import org.apache.fineract.portfolio.client.data.ClientData; import org.apache.fineract.portfolio.client.data.ClientData;
public final class DeviceRegistrationData { public final class DeviceRegistrationData {
@@ -26,9 +26,10 @@ public final class DeviceRegistrationData {
public Long id; public Long id;
public ClientData clientData; public ClientData clientData;
public String registrationId; public String registrationId;
public Date updatedOnDate; public LocalDateTime updatedOnDate;
private DeviceRegistrationData(final Long id, final ClientData clientData, final String registrationId, final Date updatedOnDate) { private DeviceRegistrationData(final Long id, final ClientData clientData, final String registrationId,
final LocalDateTime updatedOnDate) {
this.id = id; this.id = id;
this.clientData = clientData; this.clientData = clientData;
this.registrationId = registrationId; this.registrationId = registrationId;
@@ -36,7 +37,7 @@ public final class DeviceRegistrationData {
} }
public static DeviceRegistrationData instance(final Long id, final ClientData clientData, final String registrationId, public static DeviceRegistrationData instance(final Long id, final ClientData clientData, final String registrationId,
final Date updatedOnDate) { final LocalDateTime updatedOnDate) {
return new DeviceRegistrationData(id, clientData, registrationId, updatedOnDate); return new DeviceRegistrationData(id, clientData, registrationId, updatedOnDate);
} }
@@ -20,10 +20,8 @@ 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.LocalDateTime;
import java.time.ZoneId;
import java.util.Collection; import java.util.Collection;
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.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;
@@ -68,13 +66,12 @@ public class DeviceRegistrationReadPlatformServiceImpl implements DeviceRegistra
public DeviceRegistrationData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { public DeviceRegistrationData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
final Long id = JdbcSupport.getLong(rs, "id"); final Long id = JdbcSupport.getLong(rs, "id");
final LocalDate updatedOnDate = JdbcSupport.getLocalDate(rs, "updatedOnDate"); final LocalDateTime updatedOnDate = JdbcSupport.getLocalDateTime(rs, "updatedOnDate");
final String registrationId = rs.getString("registrationId"); final String registrationId = rs.getString("registrationId");
final Long clientId = rs.getLong("clientId"); final Long clientId = rs.getLong("clientId");
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, updatedOnDate);
Date.from(updatedOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
} }
} }
@@ -18,7 +18,6 @@
*/ */
package org.apache.fineract.infrastructure.gcm.service; package org.apache.fineract.infrastructure.gcm.service;
import java.util.Date;
import javax.persistence.EntityExistsException; import javax.persistence.EntityExistsException;
import javax.persistence.PersistenceException; import javax.persistence.PersistenceException;
import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.exception.ExceptionUtils;
@@ -94,8 +93,7 @@ public class DeviceRegistrationWritePlatformServiceImpl implements DeviceRegistr
Client client = this.clientRepositoryWrapper.findOneWithNotFoundDetection(clientId); Client client = this.clientRepositoryWrapper.findOneWithNotFoundDetection(clientId);
deviceRegistration.setClient(client); deviceRegistration.setClient(client);
deviceRegistration.setRegistrationId(registrationId); deviceRegistration.setRegistrationId(registrationId);
deviceRegistration deviceRegistration.setUpdatedOnDate(DateUtils.getLocalDateTimeOfTenant());
.setUpdatedOnDate(Date.from(DateUtils.getLocalDateTimeOfTenant().atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()));
return deviceRegistration; return deviceRegistration;
} }
@@ -19,10 +19,8 @@
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.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -109,8 +107,7 @@ public class NotificationSenderService {
res = s.send(msg, registrationId, 3); res = s.send(msg, registrationId, 3);
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(DateUtils.getLocalDateTimeOfTenant());
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,9 +19,7 @@
package org.apache.fineract.infrastructure.reportmailingjob.domain; package org.apache.fineract.infrastructure.reportmailingjob.domain;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import javax.persistence.Column; import javax.persistence.Column;
@@ -29,8 +27,6 @@ import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -55,8 +51,7 @@ public class ReportMailingJob extends AbstractAuditableCustom {
private String description; private String description;
@Column(name = "start_datetime", nullable = false) @Column(name = "start_datetime", nullable = false)
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime startDateTime;
private Date startDateTime;
@Column(name = "recurrence", nullable = true) @Column(name = "recurrence", nullable = true)
private String recurrence; private String recurrence;
@@ -81,12 +76,10 @@ public class ReportMailingJob extends AbstractAuditableCustom {
private String stretchyReportParamMap; private String stretchyReportParamMap;
@Column(name = "previous_run_datetime", nullable = true) @Column(name = "previous_run_datetime", nullable = true)
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime previousRunDateTime;
private Date previousRunDateTime;
@Column(name = "next_run_datetime", nullable = true) @Column(name = "next_run_datetime", nullable = true)
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime nextRunDateTime;
private Date nextRunDateTime;
@Column(name = "previous_run_status", nullable = true) @Column(name = "previous_run_status", nullable = true)
private String previousRunStatus; private String previousRunStatus;
@@ -129,7 +122,7 @@ public class ReportMailingJob extends AbstractAuditableCustom {
this.startDateTime = null; this.startDateTime = null;
if (startDateTime != null) { if (startDateTime != null) {
this.startDateTime = Date.from(startDateTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDateTime = startDateTime;
} }
this.recurrence = recurrence; this.recurrence = recurrence;
@@ -142,13 +135,13 @@ public class ReportMailingJob extends AbstractAuditableCustom {
this.previousRunDateTime = null; this.previousRunDateTime = null;
if (previousRunDateTime != null) { if (previousRunDateTime != null) {
this.previousRunDateTime = Date.from(previousRunDateTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.previousRunDateTime = previousRunDateTime;
} }
this.nextRunDateTime = null; this.nextRunDateTime = null;
if (nextRunDateTime != null) { if (nextRunDateTime != null) {
this.nextRunDateTime = Date.from(nextRunDateTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.nextRunDateTime = nextRunDateTime;
} }
this.previousRunStatus = null; this.previousRunStatus = null;
@@ -307,14 +300,12 @@ public class ReportMailingJob extends AbstractAuditableCustom {
final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(jsonCommand.dateFormat()) final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(jsonCommand.dateFormat())
.withLocale(jsonCommand.extractLocale()); .withLocale(jsonCommand.extractLocale());
final LocalDateTime newStartDateTime = LocalDateTime.parse(newStartDateTimeString, dateTimeFormatter); final LocalDateTime newStartDateTime = LocalDateTime.parse(newStartDateTimeString, dateTimeFormatter);
final LocalDateTime oldStartDateTime = (this.startDateTime != null) final LocalDateTime oldStartDateTime = this.startDateTime;
? ZonedDateTime.ofInstant(this.startDateTime.toInstant(), DateUtils.getDateTimeZoneOfTenant()).toLocalDateTime()
: null;
if ((oldStartDateTime != null) && !newStartDateTime.equals(oldStartDateTime)) { if ((oldStartDateTime != null) && !newStartDateTime.equals(oldStartDateTime)) {
actualChanges.put(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME, newStartDateTimeString); actualChanges.put(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME, newStartDateTimeString);
this.startDateTime = Date.from(newStartDateTime.atZone(DateUtils.getDateTimeZoneOfTenant()).toInstant()); this.startDateTime = newStartDateTime;
} }
} }
@@ -374,9 +365,8 @@ public class ReportMailingJob extends AbstractAuditableCustom {
/** /**
* @return the value of the startDateTime property * @return the value of the startDateTime property
**/ **/
public ZonedDateTime getStartDateTime() { public LocalDateTime getStartDateTime() {
return (this.startDateTime != null) ? ZonedDateTime.ofInstant(this.startDateTime.toInstant(), DateUtils.getDateTimeZoneOfTenant()) return this.startDateTime;
: null;
} }
/** /**
@@ -459,19 +449,15 @@ public class ReportMailingJob extends AbstractAuditableCustom {
/** /**
* @return the previousRunDateTime * @return the previousRunDateTime
*/ */
public ZonedDateTime getPreviousRunDateTime() { public LocalDateTime getPreviousRunDateTime() {
return (this.previousRunDateTime != null) return this.previousRunDateTime;
? ZonedDateTime.ofInstant(this.previousRunDateTime.toInstant(), DateUtils.getDateTimeZoneOfTenant())
: null;
} }
/** /**
* @return the nextRunDateTime * @return the nextRunDateTime
*/ */
public ZonedDateTime getNextRunDateTime() { public LocalDateTime getNextRunDateTime() {
return (this.nextRunDateTime != null) return this.nextRunDateTime;
? ZonedDateTime.ofInstant(this.nextRunDateTime.toInstant(), DateUtils.getDateTimeZoneOfTenant())
: null;
} }
/** /**
@@ -538,9 +524,9 @@ public class ReportMailingJob extends AbstractAuditableCustom {
* -- previous run date * -- previous run date
* *
**/ **/
public void updatePreviousRunDateTime(final ZonedDateTime previousRunDateTime) { public void updatePreviousRunDateTime(final LocalDateTime previousRunDateTime) {
if (previousRunDateTime != null) { if (previousRunDateTime != null) {
this.previousRunDateTime = Date.from(previousRunDateTime.toInstant()); this.previousRunDateTime = previousRunDateTime;
} }
} }
@@ -551,9 +537,9 @@ public class ReportMailingJob extends AbstractAuditableCustom {
* -- the next run DateTime * -- the next run DateTime
* *
**/ **/
public void updateNextRunDateTime(final ZonedDateTime nextRunDateTime) { public void updateNextRunDateTime(final LocalDateTime nextRunDateTime) {
if (nextRunDateTime != null) { if (nextRunDateTime != null) {
this.nextRunDateTime = Date.from(nextRunDateTime.toInstant()); this.nextRunDateTime = nextRunDateTime;
} }
else { else {
@@ -18,17 +18,13 @@
*/ */
package org.apache.fineract.infrastructure.reportmailingjob.domain; package org.apache.fineract.infrastructure.reportmailingjob.domain;
import java.time.ZonedDateTime; import java.time.LocalDateTime;
import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.infrastructure.core.service.DateUtils;
@Entity @Entity
@Table(name = "m_report_mailing_job_run_history") @Table(name = "m_report_mailing_job_run_history")
@@ -41,12 +37,10 @@ public class ReportMailingJobRunHistory extends AbstractPersistableCustom {
private ReportMailingJob reportMailingJob; private ReportMailingJob reportMailingJob;
@Column(name = "start_datetime", nullable = false) @Column(name = "start_datetime", nullable = false)
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime startDateTime;
private Date startDateTime;
@Column(name = "end_datetime", nullable = false) @Column(name = "end_datetime", nullable = false)
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime endDateTime;
private Date endDateTime;
@Column(name = "status", nullable = false) @Column(name = "status", nullable = false)
private String status; private String status;
@@ -65,19 +59,19 @@ public class ReportMailingJobRunHistory extends AbstractPersistableCustom {
/** /**
* ReportMailingJobRunHistory private constructor * ReportMailingJobRunHistory private constructor
**/ **/
private ReportMailingJobRunHistory(final ReportMailingJob reportMailingJob, final ZonedDateTime startDateTime, private ReportMailingJobRunHistory(final ReportMailingJob reportMailingJob, final LocalDateTime startDateTime,
final ZonedDateTime endDateTime, final String status, final String errorMessage, final String errorLog) { final LocalDateTime endDateTime, final String status, final String errorMessage, final String errorLog) {
this.reportMailingJob = reportMailingJob; this.reportMailingJob = reportMailingJob;
this.startDateTime = null; this.startDateTime = null;
if (startDateTime != null) { if (startDateTime != null) {
this.startDateTime = Date.from(startDateTime.toInstant()); this.startDateTime = startDateTime;
} }
this.endDateTime = null; this.endDateTime = null;
if (endDateTime != null) { if (endDateTime != null) {
this.endDateTime = Date.from(endDateTime.toInstant()); this.endDateTime = endDateTime;
} }
this.status = status; this.status = status;
@@ -90,8 +84,8 @@ public class ReportMailingJobRunHistory extends AbstractPersistableCustom {
* *
* @return ReportMailingJobRunHistory object * @return ReportMailingJobRunHistory object
**/ **/
public static ReportMailingJobRunHistory newInstance(final ReportMailingJob reportMailingJob, final ZonedDateTime startDateTime, public static ReportMailingJobRunHistory newInstance(final ReportMailingJob reportMailingJob, final LocalDateTime startDateTime,
final ZonedDateTime endDateTime, final String status, final String errorMessage, final String errorLog) { final LocalDateTime endDateTime, final String status, final String errorMessage, final String errorLog) {
return new ReportMailingJobRunHistory(reportMailingJob, startDateTime, endDateTime, status, errorMessage, errorLog); return new ReportMailingJobRunHistory(reportMailingJob, startDateTime, endDateTime, status, errorMessage, errorLog);
} }
@@ -105,17 +99,15 @@ public class ReportMailingJobRunHistory extends AbstractPersistableCustom {
/** /**
* @return the startDateTime * @return the startDateTime
*/ */
public ZonedDateTime getStartDateTime() { public LocalDateTime getStartDateTime() {
return (this.startDateTime != null) ? ZonedDateTime.ofInstant(this.startDateTime.toInstant(), DateUtils.getDateTimeZoneOfTenant()) return this.startDateTime;
: null;
} }
/** /**
* @return the endDateTime * @return the endDateTime
*/ */
public ZonedDateTime getEndDateTime() { public LocalDateTime getEndDateTime() {
return (this.endDateTime != null) ? ZonedDateTime.ofInstant(this.endDateTime.toInstant(), DateUtils.getDateTimeZoneOfTenant()) return this.endDateTime;
: null;
} }
/** /**
@@ -23,9 +23,7 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDate; import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
@@ -152,8 +150,8 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo
// get the recurrence rule string // get the recurrence rule string
final String recurrence = reportMailingJob.getRecurrence(); final String recurrence = reportMailingJob.getRecurrence();
// get the next run ZonedDateTime from the ReportMailingJob entity // get the next run LocalDateTime from the ReportMailingJob entity
ZonedDateTime nextRunDateTime = reportMailingJob.getNextRunDateTime(); LocalDateTime nextRunDateTime = reportMailingJob.getNextRunDateTime();
// check if the stretchy report id was updated // check if the stretchy report id was updated
if (changes.containsKey(ReportMailingJobConstants.STRETCHY_REPORT_ID_PARAM_NAME)) { if (changes.containsKey(ReportMailingJobConstants.STRETCHY_REPORT_ID_PARAM_NAME)) {
@@ -169,10 +167,10 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo
// go ahead if the recurrence is not null // go ahead if the recurrence is not null
if (StringUtils.isNotBlank(recurrence)) { if (StringUtils.isNotBlank(recurrence)) {
// set the start ZonedDateTime to the current tenant date time // set the start LocalDateTime to the current tenant date time
ZonedDateTime startDateTime = DateUtils.getLocalDateTimeOfTenant().atZone(DateUtils.getDateTimeZoneOfTenant()); LocalDateTime startDateTime = DateUtils.getLocalDateTimeOfTenant();
// check if the start ZonedDateTime was updated // check if the start LocalDateTime was updated
if (changes.containsKey(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME)) { if (changes.containsKey(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME)) {
// get the updated start DateTime // get the updated start DateTime
startDateTime = reportMailingJob.getStartDateTime(); startDateTime = reportMailingJob.getStartDateTime();
@@ -181,25 +179,25 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo
startDateTime = reportMailingJob.getStartDateTime(); startDateTime = reportMailingJob.getStartDateTime();
// get the next recurring DateTime // get the next recurring DateTime
final ZonedDateTime nextRecurringDateTime = this.createNextRecurringDateTime(recurrence, startDateTime); final LocalDateTime nextRecurringDateTime = this.createNextRecurringDateTime(recurrence, startDateTime);
// update the next run time property // update the next run time property
reportMailingJob.updateNextRunDateTime(nextRecurringDateTime); reportMailingJob.updateNextRunDateTime(nextRecurringDateTime);
// check if the next run ZonedDateTime is not empty and the // check if the next run LocalDateTime is not empty and the
// recurrence is empty // recurrence is empty
} else if (StringUtils.isBlank(recurrence) && (nextRunDateTime != null)) { } else if (StringUtils.isBlank(recurrence) && (nextRunDateTime != null)) {
// the next run ZonedDateTime should be set to null // the next run LocalDateTime should be set to null
reportMailingJob.updateNextRunDateTime(null); reportMailingJob.updateNextRunDateTime(null);
} }
} }
if (changes.containsKey(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME)) { if (changes.containsKey(ReportMailingJobConstants.START_DATE_TIME_PARAM_NAME)) {
final ZonedDateTime startDateTime = reportMailingJob.getStartDateTime(); final LocalDateTime startDateTime = reportMailingJob.getStartDateTime();
// initially set the next recurring date time to the new start // initially set the next recurring date time to the new start
// date time // date time
ZonedDateTime nextRecurringDateTime = startDateTime; LocalDateTime nextRecurringDateTime = startDateTime;
// ensure that the recurrence pattern string is not empty // ensure that the recurrence pattern string is not empty
if (StringUtils.isNotBlank(recurrence)) { if (StringUtils.isNotBlank(recurrence)) {
@@ -251,9 +249,8 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo
.findByIsActiveTrueAndIsDeletedFalse(); .findByIsActiveTrueAndIsDeletedFalse();
for (ReportMailingJob reportMailingJob : reportMailingJobCollection) { for (ReportMailingJob reportMailingJob : reportMailingJobCollection) {
// get the tenant's date as a ZonedDateTime object final LocalDateTime localDateTimeOftenant = DateUtils.getLocalDateTimeOfTenant();
final ZonedDateTime localDateTimeOftenant = DateUtils.getLocalDateTimeOfTenant().atZone(DateUtils.getDateTimeZoneOfTenant()); final LocalDateTime nextRunDateTime = reportMailingJob.getNextRunDateTime();
final ZonedDateTime nextRunDateTime = reportMailingJob.getNextRunDateTime();
if (nextRunDateTime != null && nextRunDateTime.isBefore(localDateTimeOftenant)) { if (nextRunDateTime != null && nextRunDateTime.isBefore(localDateTimeOftenant)) {
// get the emailAttachmentFileFormat enum object // get the emailAttachmentFileFormat enum object
@@ -310,13 +307,13 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo
* @param errorLog * @param errorLog
* -- StringBuilder object containing the error log if any * -- StringBuilder object containing the error log if any
* @param jobStartDateTime * @param jobStartDateTime
* -- the start ZonedDateTime of the job * -- the start LocalDateTime of the job
* *
**/ **/
private void updateReportMailingJobAfterJobExecution(final ReportMailingJob reportMailingJob, final StringBuilder errorLog, private void updateReportMailingJobAfterJobExecution(final ReportMailingJob reportMailingJob, final StringBuilder errorLog,
final ZonedDateTime jobStartDateTime) { final LocalDateTime jobStartDateTime) {
final String recurrence = reportMailingJob.getRecurrence(); final String recurrence = reportMailingJob.getRecurrence();
final ZonedDateTime nextRunDateTime = reportMailingJob.getNextRunDateTime(); final LocalDateTime nextRunDateTime = reportMailingJob.getNextRunDateTime();
ReportMailingJobPreviousRunStatus reportMailingJobPreviousRunStatus = ReportMailingJobPreviousRunStatus.SUCCESS; ReportMailingJobPreviousRunStatus reportMailingJobPreviousRunStatus = ReportMailingJobPreviousRunStatus.SUCCESS;
reportMailingJob.updatePreviousRunErrorLog(null); reportMailingJob.updatePreviousRunErrorLog(null);
@@ -339,7 +336,7 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo
// job will only run once, no next run time // job will only run once, no next run time
reportMailingJob.updateNextRunDateTime(null); reportMailingJob.updateNextRunDateTime(null);
} else if (nextRunDateTime != null) { } else if (nextRunDateTime != null) {
final ZonedDateTime nextRecurringDateTime = this.createNextRecurringDateTime(recurrence, nextRunDateTime); final LocalDateTime nextRecurringDateTime = this.createNextRecurringDateTime(recurrence, nextRunDateTime);
// finally update the next run date time property // finally update the next run date time property
reportMailingJob.updateNextRunDateTime(nextRecurringDateTime); reportMailingJob.updateNextRunDateTime(nextRecurringDateTime);
@@ -354,25 +351,19 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo
} }
/** /**
* create the next recurring ZonedDateTime from recurrence pattern, start ZonedDateTime and current DateTime * create the next recurring LocalDateTime from recurrence pattern, start LocalDateTime and current DateTime
* *
* @param recurrencePattern * @param recurrencePattern
* @param startDateTime * @param startDateTime
* @return ZonedDateTime object * @return LocalDateTime object
*/ */
private ZonedDateTime createNextRecurringDateTime(final String recurrencePattern, final ZonedDateTime startDateTime) { private LocalDateTime createNextRecurringDateTime(final String recurrencePattern, final LocalDateTime startDateTime) {
ZonedDateTime nextRecurringDateTime = null; LocalDateTime nextRecurringDateTime = null;
// the recurrence pattern/rule cannot be empty // the recurrence pattern/rule cannot be empty
if (StringUtils.isNotBlank(recurrencePattern) && startDateTime != null) { if (StringUtils.isNotBlank(recurrencePattern) && startDateTime != null) {
final LocalDate nextDayLocalDate = startDateTime.plus(Duration.ofDays(1)).toLocalDate(); final LocalDateTime nextDayLocalDate = startDateTime.plus(Duration.ofDays(1));
final LocalDate nextRecurringLocalDate = CalendarUtils.getNextRecurringDate(recurrencePattern, startDateTime.toLocalDate(), nextRecurringDateTime = CalendarUtils.getNextRecurringDate(recurrencePattern, startDateTime, nextDayLocalDate);
nextDayLocalDate);
final String nextDateTimeString = nextRecurringLocalDate + " " + startDateTime.getHour() + ":" + startDateTime.getMinute() + ":"
+ startDateTime.getSecond();
final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(DATETIME_FORMAT);
nextRecurringDateTime = ZonedDateTime.parse(nextDateTimeString, dateTimeFormatter);
} }
return nextRecurringDateTime; return nextRecurringDateTime;
@@ -386,14 +377,14 @@ public class ReportMailingJobWritePlatformServiceImpl implements ReportMailingJo
* @param errorLog * @param errorLog
* -- StringBuilder object containing the error log if any * -- StringBuilder object containing the error log if any
* @param jobStartDateTime * @param jobStartDateTime
* -- the start ZonedDateTime of the job * -- the start LocalDateTime of the job
* @param jobRunStatus * @param jobRunStatus
* -- the status of the job (success/error) * -- the status of the job (success/error)
* *
**/ **/
private void createReportMailingJobRunHistroryAfterJobExecution(final ReportMailingJob reportMailingJob, final StringBuilder errorLog, private void createReportMailingJobRunHistroryAfterJobExecution(final ReportMailingJob reportMailingJob, final StringBuilder errorLog,
final ZonedDateTime jobStartDateTime, final String jobRunStatus) { final LocalDateTime jobStartDateTime, final String jobRunStatus) {
final ZonedDateTime jobEndDateTime = DateUtils.getLocalDateTimeOfTenant().atZone(DateUtils.getDateTimeZoneOfTenant()); final LocalDateTime jobEndDateTime = DateUtils.getLocalDateTimeOfTenant();
final String errorLogToString = (errorLog != null) ? errorLog.toString() : null; final String errorLogToString = (errorLog != null) ? errorLog.toString() : null;
final ReportMailingJobRunHistory reportMailingJobRunHistory = ReportMailingJobRunHistory.newInstance(reportMailingJob, final ReportMailingJobRunHistory reportMailingJobRunHistory = ReportMailingJobRunHistory.newInstance(reportMailingJob,
jobStartDateTime, jobEndDateTime, jobRunStatus, null, errorLogToString); jobStartDateTime, jobEndDateTime, jobRunStatus, null, errorLogToString);
@@ -18,9 +18,7 @@
*/ */
package org.apache.fineract.infrastructure.reportmailingjob.util; package org.apache.fineract.infrastructure.reportmailingjob.util;
import java.text.SimpleDateFormat; import org.apache.fineract.infrastructure.core.service.DateUtils;
import java.util.Calendar;
import java.util.Date;
import org.apache.fineract.infrastructure.reportmailingjob.data.ReportMailingJobStretchyReportParamDateOption; import org.apache.fineract.infrastructure.reportmailingjob.data.ReportMailingJobStretchyReportParamDateOption;
public final class ReportMailingJobDateUtil { public final class ReportMailingJobDateUtil {
@@ -35,60 +33,21 @@ public final class ReportMailingJobDateUtil {
* get the current date as string using the mysql date format yyyy-MM-dd * get the current date as string using the mysql date format yyyy-MM-dd
**/ **/
public static String getTodayDateAsString() { public static String getTodayDateAsString() {
// get a calendar instance, which defaults to "now" return DateUtils.getLocalDateOfTenant().format(DateUtils.DEFAULT_DATE_FORMATER);
Calendar calendar = Calendar.getInstance();
// get a date to represent "today"
Date today = calendar.getTime();
// get a SimpleDateFormat instance, passing the mysql date format as
// parameter
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(MYSQL_DATE_FORMAT);
// return date as string
return simpleDateFormat.format(today);
} }
/** /**
* get the yesterday's date as string using the mysql date format yyyy-MM-dd * get the yesterday's date as string using the mysql date format yyyy-MM-dd
**/ **/
public static String getYesterdayDateAsString() { public static String getYesterdayDateAsString() {
// get a calendar instance, which defaults to "now" return DateUtils.getLocalDateOfTenant().minusDays(1).format(DateUtils.DEFAULT_DATE_FORMATER);
Calendar calendar = Calendar.getInstance();
// add one day to the date/calendar
calendar.add(Calendar.DAY_OF_YEAR, -1);
// now get "yesterday"
Date yesterday = calendar.getTime();
// get a SimpleDateFormat instance, passing the mysql date format as
// parameter
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(MYSQL_DATE_FORMAT);
// return date as string
return simpleDateFormat.format(yesterday);
} }
/** /**
* get the tomorrow's date as string using the mysql date format yyyy-MM-dd * get the tomorrow's date as string using the mysql date format yyyy-MM-dd
**/ **/
public static String getTomorrowDateAsString() { public static String getTomorrowDateAsString() {
// get a calendar instance, which defaults to "now" return DateUtils.getLocalDateOfTenant().plusDays(1).format(DateUtils.DEFAULT_DATE_FORMATER);
Calendar calendar = Calendar.getInstance();
// add one day to the date/calendar
calendar.add(Calendar.DAY_OF_YEAR, 1);
// now get "tomorrow"
Date tomorrow = calendar.getTime();
// get a SimpleDateFormat instance, passing the mysql date format as
// parameter
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(MYSQL_DATE_FORMAT);
// return date as string
return simpleDateFormat.format(tomorrow);
} }
/** /**
@@ -19,15 +19,11 @@
package org.apache.fineract.infrastructure.security.domain; package org.apache.fineract.infrastructure.security.domain;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.util.Date;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
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.core.service.DateUtils;
@@ -46,13 +42,11 @@ public class TFAccessToken extends AbstractPersistableCustom {
@JoinColumn(name = "appuser_id", nullable = false) @JoinColumn(name = "appuser_id", nullable = false)
private AppUser user; private AppUser user;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "valid_from", nullable = false) @Column(name = "valid_from", nullable = false)
private Date validFrom; private LocalDateTime validFrom;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "valid_to", nullable = false) @Column(name = "valid_to", nullable = false)
private Date validTo; private LocalDateTime validTo;
@Column(name = "enabled", nullable = false) @Column(name = "enabled", nullable = false)
private boolean enabled; private boolean enabled;
@@ -60,13 +54,13 @@ public class TFAccessToken extends AbstractPersistableCustom {
public TFAccessToken() {} public TFAccessToken() {}
public static TFAccessToken create(String token, AppUser user, int tokenLiveTimeInSec) { public static TFAccessToken create(String token, AppUser user, int tokenLiveTimeInSec) {
ZonedDateTime validFrom = DateUtils.getLocalDateTimeOfTenant().atZone(DateUtils.getDateTimeZoneOfTenant()); LocalDateTime validFrom = DateUtils.getLocalDateTimeOfTenant();
ZonedDateTime validTo = validFrom.plusSeconds(tokenLiveTimeInSec); LocalDateTime validTo = validFrom.plusSeconds(tokenLiveTimeInSec);
return new TFAccessToken(token, user, Date.from(validFrom.toInstant()), Date.from(validTo.toInstant()), true); return new TFAccessToken(token, user, validFrom, validTo, true);
} }
public TFAccessToken(String token, AppUser user, Date validFrom, Date validTo, boolean enabled) { public TFAccessToken(String token, AppUser user, LocalDateTime validFrom, LocalDateTime validTo, boolean enabled) {
this.token = token; this.token = token;
this.user = user; this.user = user;
this.validFrom = validFrom; this.validFrom = validFrom;
@@ -96,11 +90,11 @@ public class TFAccessToken extends AbstractPersistableCustom {
} }
public LocalDateTime getValidFromDate() { public LocalDateTime getValidFromDate() {
return ZonedDateTime.ofInstant(validFrom.toInstant(), DateUtils.getDateTimeZoneOfTenant()).toLocalDateTime(); return validFrom;
} }
public LocalDateTime getValidToDate() { public LocalDateTime getValidToDate() {
return ZonedDateTime.ofInstant(validTo.toInstant(), DateUtils.getDateTimeZoneOfTenant()).toLocalDateTime(); return validTo;
} }
public void setToken(String token) { public void setToken(String token) {
@@ -111,11 +105,11 @@ public class TFAccessToken extends AbstractPersistableCustom {
this.user = user; this.user = user;
} }
public void setValidFrom(Date validFrom) { public void setValidFrom(LocalDateTime validFrom) {
this.validFrom = validFrom; this.validFrom = validFrom;
} }
public void setValidTo(Date validTo) { public void setValidTo(LocalDateTime validTo) {
this.validTo = validTo; this.validTo = validTo;
} }
@@ -18,9 +18,8 @@
*/ */
package org.apache.fineract.infrastructure.security.service; package org.apache.fineract.infrastructure.security.service;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.CommandWrapperBuilder;
@@ -149,15 +148,11 @@ public class SpringSecurityPlatformSecurityContext implements PlatformSecurityCo
if (this.configurationDomainService.isPasswordForcedResetEnable() && !currentUser.getPasswordNeverExpires()) { if (this.configurationDomainService.isPasswordForcedResetEnable() && !currentUser.getPasswordNeverExpires()) {
Long passwordDurationDays = this.configurationDomainService.retrievePasswordLiveTime(); Long passwordDurationDays = this.configurationDomainService.retrievePasswordLiveTime();
final Date passWordLastUpdateDate = currentUser.getLastTimePasswordUpdated(); final LocalDate passWordLastUpdateDate = currentUser.getLastTimePasswordUpdated();
Calendar c = Calendar.getInstance(); final LocalDate passwordExpirationDate = passWordLastUpdateDate.plusDays(passwordDurationDays);
c.setTime(passWordLastUpdateDate);
c.add(Calendar.DATE, passwordDurationDays.intValue());
final Date passwordExpirationDate = c.getTime(); if (DateUtils.getLocalDateOfTenant().isAfter(passwordExpirationDate)) {
if (DateUtils.getDateOfTenant().after(passwordExpirationDate)) {
return true; return true;
} }
} }
@@ -19,8 +19,8 @@
package org.apache.fineract.infrastructure.sms.api; package org.apache.fineract.infrastructure.sms.api;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
import javax.ws.rs.GET; import javax.ws.rs.GET;
@@ -121,11 +121,11 @@ public class SmsApiResource {
final SearchParameters searchParameters = SearchParameters.forSMSCampaign(sqlSearch, offset, limit, orderBy, sortOrder); final SearchParameters searchParameters = SearchParameters.forSMSCampaign(sqlSearch, offset, limit, orderBy, sortOrder);
Date fromDate = null; LocalDate fromDate = null;
if (fromDateParam != null) { if (fromDateParam != null) {
fromDate = fromDateParam.getDate("fromDate", dateFormat, locale); fromDate = fromDateParam.getDate("fromDate", dateFormat, locale);
} }
Date toDate = null; LocalDate toDate = null;
if (toDateParam != null) { if (toDateParam != null) {
toDate = toDateParam.getDate("toDate", dateFormat, locale); toDate = toDateParam.getDate("toDate", dateFormat, locale);
} }
@@ -18,7 +18,8 @@
*/ */
package org.apache.fineract.infrastructure.sms.domain; package org.apache.fineract.infrastructure.sms.domain;
import java.util.Date; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import javax.persistence.Column; import javax.persistence.Column;
@@ -26,8 +27,6 @@ import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaign; import org.apache.fineract.infrastructure.campaigns.sms.domain.SmsCampaign;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -77,12 +76,10 @@ public class SmsMessage extends AbstractPersistableCustom {
// private String campaignName; // private String campaignName;
@Column(name = "submittedon_date", nullable = true) @Column(name = "submittedon_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate submittedOnDate;
private Date submittedOnDate;
@Column(name = "delivered_on_date", nullable = true) @Column(name = "delivered_on_date", nullable = true)
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime deliveredOnDate;
private Date deliveredOnDate;
@Column(name = "is_notification", nullable = true) @Column(name = "is_notification", nullable = true)
private boolean isNotification; private boolean isNotification;
@@ -120,7 +117,7 @@ public class SmsMessage extends AbstractPersistableCustom {
this.mobileNo = mobileNo; this.mobileNo = mobileNo;
this.message = message; this.message = message;
this.smsCampaign = smsCampaign; this.smsCampaign = smsCampaign;
this.submittedOnDate = DateUtils.getBusinessDate(); this.submittedOnDate = DateUtils.getBusinessLocalDate();
this.isNotification = isNotification; this.isNotification = isNotification;
} }
@@ -177,15 +174,15 @@ public class SmsMessage extends AbstractPersistableCustom {
this.statusType = statusType; this.statusType = statusType;
} }
public Date getSubmittedOnDate() { public LocalDate getSubmittedOnDate() {
return this.submittedOnDate; return this.submittedOnDate;
} }
public Date getDeliveredOnDate() { public LocalDateTime getDeliveredOnDate() {
return this.deliveredOnDate; return this.deliveredOnDate;
} }
public void setDeliveredOnDate(final Date deliveredOnDate) { public void setDeliveredOnDate(final LocalDateTime deliveredOnDate) {
this.deliveredOnDate = deliveredOnDate; this.deliveredOnDate = deliveredOnDate;
} }
@@ -18,8 +18,8 @@
*/ */
package org.apache.fineract.infrastructure.sms.service; package org.apache.fineract.infrastructure.sms.service;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.infrastructure.core.service.Page; import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.core.service.SearchParameters; import org.apache.fineract.infrastructure.core.service.SearchParameters;
@@ -39,7 +39,8 @@ public interface SmsReadPlatformService {
Collection<SmsData> retrieveAllFailed(Integer limit); Collection<SmsData> retrieveAllFailed(Integer limit);
Page<SmsData> retrieveSmsByStatus(Long campaignId, SearchParameters searchParameters, Integer status, Date dateFrom, Date dateTo); Page<SmsData> retrieveSmsByStatus(Long campaignId, SearchParameters searchParameters, Integer status, LocalDate dateFrom,
LocalDate dateTo);
List<Long> retrieveExternalIdsOfAllSent(Integer limit); List<Long> retrieveExternalIdsOfAllSent(Integer limit);
@@ -20,14 +20,13 @@ package org.apache.fineract.infrastructure.sms.service;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.DateFormat; import java.time.LocalDate;
import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
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.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.SearchParameters; import org.apache.fineract.infrastructure.core.service.SearchParameters;
@@ -203,7 +202,7 @@ public class SmsReadPlatformServiceImpl implements SmsReadPlatformService {
@Override @Override
public Page<SmsData> retrieveSmsByStatus(final Long campaignId, final SearchParameters searchParameters, final Integer status, public Page<SmsData> retrieveSmsByStatus(final Long campaignId, final SearchParameters searchParameters, final Integer status,
final Date dateFrom, final Date dateTo) { final LocalDate dateFrom, final LocalDate dateTo) {
final StringBuilder sqlBuilder = new StringBuilder(200); final StringBuilder sqlBuilder = new StringBuilder(200);
final Object[] objectArray = new Object[10]; final Object[] objectArray = new Object[10];
int arrayPos = 0; int arrayPos = 0;
@@ -219,9 +218,8 @@ public class SmsReadPlatformServiceImpl implements SmsReadPlatformService {
String fromDateString = null; String fromDateString = null;
String toDateString = null; String toDateString = null;
if (dateFrom != null && dateTo != null) { if (dateFrom != null && dateTo != null) {
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); fromDateString = DateUtils.DEFAULT_DATE_FORMATER.format(dateFrom);
fromDateString = df.format(dateFrom); toDateString = DateUtils.DEFAULT_DATE_FORMATER.format(dateTo);
toDateString = df.format(dateTo);
sqlBuilder.append(" and smo.submittedon_date >= ? and smo.submittedon_date <= ? "); sqlBuilder.append(" and smo.submittedon_date >= ? and smo.submittedon_date <= ? ");
objectArray[arrayPos] = fromDateString; objectArray[arrayPos] = fromDateString;
arrayPos = arrayPos + 1; arrayPos = arrayPos + 1;
@@ -18,11 +18,8 @@
*/ */
package org.apache.fineract.infrastructure.survey.service; package org.apache.fineract.infrastructure.survey.service;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.dataqueries.api.DataTableApiConstant; import org.apache.fineract.infrastructure.dataqueries.api.DataTableApiConstant;
import org.apache.fineract.infrastructure.dataqueries.data.DatatableData; import org.apache.fineract.infrastructure.dataqueries.data.DatatableData;
import org.apache.fineract.infrastructure.dataqueries.data.GenericResultsetData; import org.apache.fineract.infrastructure.dataqueries.data.GenericResultsetData;
@@ -137,9 +134,7 @@ public class ReadSurveyServiceImpl implements ReadSurveyService {
while (rs.next()) { while (rs.next()) {
scoresOverviews.add(new ClientScoresOverview(rs.getString("code"), rs.getString("name"), rs.getLong("score"), scoresOverviews.add(new ClientScoresOverview(rs.getString("code"), rs.getString("name"), rs.getLong("score"),
rs.getDouble("poverty_line"), rs.getDouble("poverty_line"), rs.getDate("date").toLocalDate(), rs.getLong("id"), surveyName));
LocalDate.ofInstant(new Date(rs.getTimestamp("date").getTime()).toInstant(), DateUtils.getDateTimeZoneOfTenant()),
rs.getLong("id"), surveyName));
} }
return scoresOverviews; return scoresOverviews;
@@ -168,9 +163,7 @@ public class ReadSurveyServiceImpl implements ReadSurveyService {
while (rs.next()) { while (rs.next()) {
scoresOverviews.add(new ClientScoresOverview(rs.getString("code"), rs.getString("name"), rs.getLong("score"), scoresOverviews.add(new ClientScoresOverview(rs.getString("code"), rs.getString("name"), rs.getLong("score"),
rs.getDouble("poverty_line"), rs.getDouble("poverty_line"), rs.getDate("date").toLocalDate(), rs.getLong("id"), rs.getString("surveyName")));
LocalDate.ofInstant(new Date(rs.getTimestamp("date").getTime()).toInstant(), DateUtils.getDateTimeZoneOfTenant()),
rs.getLong("id"), rs.getString("surveyName")));
} }
} }
@@ -193,12 +193,12 @@ public class InteropRequestData {
String locale = jsonHelper.extractStringNamed(PARAM_LOCALE, element); String locale = jsonHelper.extractStringNamed(PARAM_LOCALE, element);
LocalDateTime expiration = locale == null LocalDateTime expiration = locale == null
? jsonHelper.extractLocalTimeNamed(PARAM_EXPIRATION, element, ISO8601_DATE_TIME_FORMAT, DEFAULT_LOCALE) ? jsonHelper.extractLocalDateTimeNamed(PARAM_EXPIRATION, element, ISO8601_DATE_TIME_FORMAT, DEFAULT_LOCALE)
: jsonHelper.extractLocalTimeNamed(PARAM_EXPIRATION, element); // PARAM_DATE_FORMAT : jsonHelper.extractLocalDateTimeNamed(PARAM_EXPIRATION, element); // PARAM_DATE_FORMAT
// also // also
// must // must
// be // be
// set // set
JsonArray extensionArray = jsonHelper.extractJsonArrayNamed(PARAM_EXTENSION_LIST, element); JsonArray extensionArray = jsonHelper.extractJsonArrayNamed(PARAM_EXTENSION_LIST, element);
ArrayList<ExtensionData> extensionList = null; ArrayList<ExtensionData> extensionList = null;
@@ -18,7 +18,7 @@
*/ */
package org.apache.fineract.interoperation.domain; package org.apache.fineract.interoperation.domain;
import java.util.Date; import java.time.LocalDateTime;
import java.util.Objects; import java.util.Objects;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
@@ -27,8 +27,6 @@ import javax.persistence.Enumerated;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@@ -57,21 +55,19 @@ public class InteropIdentifier extends AbstractPersistableCustom {
@Column(name = "created_by", nullable = false, length = 32) @Column(name = "created_by", nullable = false, length = 32)
private String createdBy; private String createdBy;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "created_on", nullable = false) @Column(name = "created_on", nullable = false)
private Date createdOn; private LocalDateTime createdOn;
@Column(name = "modified_by", length = 32) @Column(name = "modified_by", length = 32)
private String modifiedBy; private String modifiedBy;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "modified_on") @Column(name = "modified_on")
private Date modifiedOn; private LocalDateTime modifiedOn;
protected InteropIdentifier() {} protected InteropIdentifier() {}
public InteropIdentifier(@NotNull SavingsAccount account, @NotNull InteropIdentifierType type, @NotNull String value, String subType, public InteropIdentifier(@NotNull SavingsAccount account, @NotNull InteropIdentifierType type, @NotNull String value, String subType,
@NotNull String createdBy, @NotNull Date createdOn) { @NotNull String createdBy, @NotNull LocalDateTime createdOn) {
this.account = account; this.account = account;
this.type = type; this.type = type;
this.value = value; this.value = value;
@@ -81,7 +77,7 @@ public class InteropIdentifier extends AbstractPersistableCustom {
} }
public InteropIdentifier(@NotNull SavingsAccount account, @NotNull InteropIdentifierType type, @NotNull String createdBy, public InteropIdentifier(@NotNull SavingsAccount account, @NotNull InteropIdentifierType type, @NotNull String createdBy,
@NotNull Date createdOn) { @NotNull LocalDateTime createdOn) {
this(account, type, null, null, createdBy, createdOn); this(account, type, null, null, createdBy, createdOn);
} }
@@ -113,7 +109,7 @@ public class InteropIdentifier extends AbstractPersistableCustom {
return createdBy; return createdBy;
} }
public Date getCreatedOn() { public LocalDateTime getCreatedOn() {
return createdOn; return createdOn;
} }
@@ -125,11 +121,11 @@ public class InteropIdentifier extends AbstractPersistableCustom {
this.modifiedBy = modifiedBy; this.modifiedBy = modifiedBy;
} }
public Date getModifiedOn() { public LocalDateTime getModifiedOn() {
return modifiedOn; return modifiedOn;
} }
public void setModifiedOn(Date modifiedOn) { public void setModifiedOn(LocalDateTime modifiedOn) {
this.modifiedOn = modifiedOn; this.modifiedOn = modifiedOn;
} }
@@ -33,7 +33,6 @@ import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.function.Predicate; import java.util.function.Predicate;
@@ -285,7 +284,7 @@ public class InteropServiceImpl implements InteropService {
AppUser createdBy = getLoginUser(); AppUser createdBy = getLoginUser();
InteropIdentifier identifier = new InteropIdentifier(savingsAccount, request.getIdType(), request.getIdValue(), InteropIdentifier identifier = new InteropIdentifier(savingsAccount, request.getIdType(), request.getIdValue(),
request.getSubIdOrType(), createdBy.getUsername(), DateUtils.getDateOfTenant()); request.getSubIdOrType(), createdBy.getUsername(), DateUtils.getLocalDateTimeOfTenant());
identifierRepository.saveAndFlush(identifier); identifierRepository.saveAndFlush(identifier);
@@ -401,7 +400,8 @@ public class InteropServiceImpl implements InteropService {
PaymentDetail paymentDetail = instance(findPaymentType(), savingsAccount.getExternalId(), null, getRoutingCode(), transferCode, PaymentDetail paymentDetail = instance(findPaymentType(), savingsAccount.getExternalId(), null, getRoutingCode(), transferCode,
null); null);
SavingsAccountTransaction holdTransaction = SavingsAccountTransaction.holdAmount(savingsAccount, savingsAccount.office(), SavingsAccountTransaction holdTransaction = SavingsAccountTransaction.holdAmount(savingsAccount, savingsAccount.office(),
paymentDetail, transactionDate, Money.of(savingsAccount.getCurrency(), total), new Date(), getLoginUser(), false); paymentDetail, transactionDate, Money.of(savingsAccount.getCurrency(), total), DateUtils.getLocalDateTimeOfTenant(),
getLoginUser(), false);
MonetaryCurrency accountCurrency = savingsAccount.getCurrency().copy(); MonetaryCurrency accountCurrency = savingsAccount.getCurrency().copy();
holdTransaction.updateRunningBalance( holdTransaction.updateRunningBalance(
Money.of(accountCurrency, savingsAccount.getWithdrawableBalance().subtract(holdTransaction.getAmount()))); Money.of(accountCurrency, savingsAccount.getWithdrawableBalance().subtract(holdTransaction.getAmount())));
@@ -453,8 +453,8 @@ public class InteropServiceImpl implements InteropService {
} }
if (holdTransaction.getReleaseIdOfHoldAmountTransaction() == null) { if (holdTransaction.getReleaseIdOfHoldAmountTransaction() == null) {
SavingsAccountTransaction releaseTransaction = savingsAccountTransactionRepository SavingsAccountTransaction releaseTransaction = savingsAccountTransactionRepository.saveAndFlush(
.saveAndFlush(releaseAmount(holdTransaction, transactionDate, new Date(), getLoginUser())); releaseAmount(holdTransaction, transactionDate, DateUtils.getLocalDateTimeOfSystem(), getLoginUser()));
holdTransaction.updateReleaseId(releaseTransaction.getId()); holdTransaction.updateReleaseId(releaseTransaction.getId());
savingsAccount.releaseOnHoldAmount(holdTransaction.getAmount()); savingsAccount.releaseOnHoldAmount(holdTransaction.getAmount());
savingsAccount.addTransaction(releaseTransaction); savingsAccount.addTransaction(releaseTransaction);
@@ -492,7 +492,8 @@ public class InteropServiceImpl implements InteropService {
SavingsAccountTransaction holdTransaction = findTransaction(savingsAccount, request.getTransferCode(), AMOUNT_HOLD.getValue()); SavingsAccountTransaction holdTransaction = findTransaction(savingsAccount, request.getTransferCode(), AMOUNT_HOLD.getValue());
if (holdTransaction != null && holdTransaction.getReleaseIdOfHoldAmountTransaction() == null) { if (holdTransaction != null && holdTransaction.getReleaseIdOfHoldAmountTransaction() == null) {
SavingsAccountTransaction releaseTransaction = releaseAmount(holdTransaction, transactionDate, new Date(), getLoginUser()); SavingsAccountTransaction releaseTransaction = releaseAmount(holdTransaction, transactionDate,
DateUtils.getLocalDateTimeOfSystem(), getLoginUser());
MonetaryCurrency accountCurrency = savingsAccount.getCurrency().copy(); MonetaryCurrency accountCurrency = savingsAccount.getCurrency().copy();
releaseTransaction.updateRunningBalance( releaseTransaction.updateRunningBalance(
Money.of(accountCurrency, savingsAccount.getWithdrawableBalance().add(holdTransaction.getAmount()))); Money.of(accountCurrency, savingsAccount.getWithdrawableBalance().add(holdTransaction.getAmount())));
@@ -18,12 +18,10 @@
*/ */
package org.apache.fineract.notification.domain; package org.apache.fineract.notification.domain;
import java.util.Date; import java.time.LocalDateTime;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@Entity @Entity
@@ -49,13 +47,12 @@ public class Notification extends AbstractPersistableCustom {
private String notificationContent; private String notificationContent;
@Column(name = "created_at") @Column(name = "created_at")
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime createdAt;
private Date createdAt;
public Notification() {} public Notification() {}
public Notification(String objectType, Long objectIdentifier, String action, Long actorId, boolean isSystemGenerated, public Notification(String objectType, Long objectIdentifier, String action, Long actorId, boolean isSystemGenerated,
String notificationContent, Date createdAt) { String notificationContent, LocalDateTime createdAt) {
this.objectType = objectType; this.objectType = objectType;
this.objectIdentifier = objectIdentifier; this.objectIdentifier = objectIdentifier;
this.action = action; this.action = action;
@@ -18,14 +18,12 @@
*/ */
package org.apache.fineract.notification.domain; package org.apache.fineract.notification.domain;
import java.util.Date; import java.time.LocalDateTime;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.useradministration.domain.AppUser; import org.apache.fineract.useradministration.domain.AppUser;
@@ -45,12 +43,11 @@ public class NotificationMapper extends AbstractPersistableCustom {
private boolean isRead; private boolean isRead;
@Column(name = "created_at") @Column(name = "created_at")
@Temporal(TemporalType.TIMESTAMP) private LocalDateTime createdAt;
private Date createdAt;
public NotificationMapper() {} public NotificationMapper() {}
public NotificationMapper(Notification notification, AppUser userId, boolean isRead, Date createdAt) { public NotificationMapper(Notification notification, AppUser userId, boolean isRead, LocalDateTime createdAt) {
this.notification = notification; this.notification = notification;
this.userId = userId; this.userId = userId;
this.isRead = isRead; this.isRead = isRead;
@@ -54,7 +54,7 @@ public class NotificationWritePlatformServiceImpl implements NotificationWritePl
AppUser appUser = this.appUserRepository.findById(userId).orElse(null); AppUser appUser = this.appUserRepository.findById(userId).orElse(null);
NotificationMapper notificationMapper = new NotificationMapper( NotificationMapper notificationMapper = new NotificationMapper(
this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId), appUser, false, this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId), appUser, false,
DateUtils.getDateOfTenant()); DateUtils.getLocalDateTimeOfSystem());
this.notificationMapperWritePlatformService.create(notificationMapper); this.notificationMapperWritePlatformService.create(notificationMapper);
return notificationMapper.getId(); return notificationMapper.getId();
@@ -64,7 +64,7 @@ public class NotificationWritePlatformServiceImpl implements NotificationWritePl
String notificationContent, boolean isSystemGenerated) { String notificationContent, boolean isSystemGenerated) {
Notification notification = new Notification(objectType, objectIdentifier, action, actorId, isSystemGenerated, notificationContent, Notification notification = new Notification(objectType, objectIdentifier, action, actorId, isSystemGenerated, notificationContent,
DateUtils.getDateOfTenant()); DateUtils.getLocalDateTimeOfSystem());
return this.notificationGeneratorWritePlatformService.create(notification); return this.notificationGeneratorWritePlatformService.create(notification);
} }
@@ -86,7 +86,7 @@ public class NotificationWritePlatformServiceImpl implements NotificationWritePl
AppUser appUser = this.appUserRepository.findById(userId).orElseThrow(); AppUser appUser = this.appUserRepository.findById(userId).orElseThrow();
NotificationMapper notificationMapper = new NotificationMapper( NotificationMapper notificationMapper = new NotificationMapper(
this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId), appUser, false, this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId), appUser, false,
DateUtils.getDateOfTenant()); DateUtils.getLocalDateTimeOfSystem());
this.notificationMapperWritePlatformService.create(notificationMapper); this.notificationMapperWritePlatformService.create(notificationMapper);
mappedIds.add(notificationMapper.getId()); mappedIds.add(notificationMapper.getId());
} }
@@ -30,8 +30,8 @@ import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
import javax.ws.rs.GET; import javax.ws.rs.GET;
@@ -208,11 +208,11 @@ public class HolidaysApiResource {
this.context.authenticatedUser().validateHasReadPermission(HOLIDAY_RESOURCE_NAME); this.context.authenticatedUser().validateHasReadPermission(HOLIDAY_RESOURCE_NAME);
Date fromDate = null; LocalDate fromDate = null;
if (fromDateParam != null) { if (fromDateParam != null) {
fromDate = fromDateParam.getDate("fromDate", dateFormat, locale); fromDate = fromDateParam.getDate("fromDate", dateFormat, locale);
} }
Date toDate = null; LocalDate toDate = null;
if (toDateParam != null) { if (toDateParam != null) {
toDate = toDateParam.getDate("toDate", dateFormat, locale); toDate = toDateParam.getDate("toDate", dateFormat, locale);
} }
@@ -18,15 +18,15 @@
*/ */
package org.apache.fineract.organisation.holiday.service; package org.apache.fineract.organisation.holiday.service;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import org.apache.fineract.organisation.holiday.data.HolidayData; import org.apache.fineract.organisation.holiday.data.HolidayData;
public interface HolidayReadPlatformService { public interface HolidayReadPlatformService {
Collection<HolidayData> retrieveAllHolidaysBySearchParamerters(Long officeId, Date fromDate, Date toDate); Collection<HolidayData> retrieveAllHolidaysBySearchParamerters(Long officeId, LocalDate fromDate, LocalDate toDate);
HolidayData retrieveHoliday(Long holidayId); HolidayData retrieveHoliday(Long holidayId);
@@ -20,15 +20,14 @@ package org.apache.fineract.organisation.holiday.service;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
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.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.organisation.holiday.data.HolidayData; import org.apache.fineract.organisation.holiday.data.HolidayData;
import org.apache.fineract.organisation.holiday.domain.RescheduleType; import org.apache.fineract.organisation.holiday.domain.RescheduleType;
@@ -86,10 +85,11 @@ public class HolidayReadPlatformServiceImpl implements HolidayReadPlatformServic
} }
@Override @Override
public Collection<HolidayData> retrieveAllHolidaysBySearchParamerters(final Long officeId, final Date fromDate, final Date toDate) { public Collection<HolidayData> retrieveAllHolidaysBySearchParamerters(final Long officeId, final LocalDate fromDate,
final LocalDate toDate) {
this.context.authenticatedUser(); this.context.authenticatedUser();
final DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); final DateTimeFormatter df = DateUtils.DEFAULT_DATE_FORMATER;
final Object[] objectArray = new Object[3]; final Object[] objectArray = new Object[3];
int arrayPos = 0; int arrayPos = 0;
@@ -20,9 +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.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -33,13 +31,10 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import org.apache.commons.lang3.StringUtils; 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.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.office.exception.CannotUpdateOfficeWithParentOfficeSameAsSelf; import org.apache.fineract.organisation.office.exception.CannotUpdateOfficeWithParentOfficeSameAsSelf;
import org.apache.fineract.organisation.office.exception.RootOfficeParentCannotBeUpdated; import org.apache.fineract.organisation.office.exception.RootOfficeParentCannotBeUpdated;
@@ -63,8 +58,7 @@ public class Office extends AbstractPersistableCustom implements Serializable {
private String hierarchy; private String hierarchy;
@Column(name = "opening_date", nullable = false) @Column(name = "opening_date", nullable = false)
@Temporal(TemporalType.DATE) private LocalDate openingDate;
private Date openingDate;
@Column(name = "external_id", length = 100) @Column(name = "external_id", length = 100)
private String externalId; private String externalId;
@@ -90,7 +84,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(ZoneId.systemDefault()).toInstant()); this.openingDate = openingDate;
if (parent != null) { if (parent != null) {
this.parent.addChild(this); this.parent.addChild(this);
} }
@@ -136,8 +130,7 @@ public class Office extends AbstractPersistableCustom implements Serializable {
actualChanges.put("dateFormat", dateFormatAsInput); actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(openingDateParamName); this.openingDate = command.localDateValueOfParameterNamed(openingDateParamName);
this.openingDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final String nameParamName = "name"; final String nameParamName = "name";
@@ -166,11 +159,7 @@ public class Office extends AbstractPersistableCustom implements Serializable {
} }
public LocalDate getOpeningLocalDate() { public LocalDate getOpeningLocalDate() {
LocalDate openingLocalDate = null; return this.openingDate;
if (this.openingDate != null) {
openingLocalDate = LocalDate.ofInstant(this.openingDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return openingLocalDate;
} }
public void update(final Office newParent) { public void update(final Office newParent) {
@@ -20,8 +20,6 @@ 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 javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Embedded; import javax.persistence.Embedded;
import javax.persistence.Entity; import javax.persistence.Entity;
@@ -29,8 +27,6 @@ import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
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.organisation.monetary.domain.MonetaryCurrency; import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
@@ -49,8 +45,7 @@ public class OfficeTransaction extends AbstractPersistableCustom {
private Office to; private Office to;
@Column(name = "transaction_date", nullable = false) @Column(name = "transaction_date", nullable = false)
@Temporal(TemporalType.DATE) private LocalDate transactionDate;
private Date transactionDate;
@Embedded @Embedded
private MonetaryCurrency currency; private MonetaryCurrency currency;
@@ -79,7 +74,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(ZoneId.systemDefault()).toInstant()); this.transactionDate = transactionLocalDate;
} }
this.currency = amount.getCurrency(); this.currency = amount.getCurrency();
this.transactionAmount = amount.getAmount(); this.transactionAmount = amount.getAmount();
@@ -18,8 +18,7 @@
*/ */
package org.apache.fineract.organisation.provisioning.domain; package org.apache.fineract.organisation.provisioning.domain;
import java.time.Instant; import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@@ -66,13 +65,13 @@ public class ProvisioningCriteria extends AbstractAuditableCustom {
} }
public ProvisioningCriteria(String criteriaName, AppUser createdBy, ZonedDateTime createdDate, AppUser lastModifiedBy, public ProvisioningCriteria(String criteriaName, AppUser createdBy, LocalDateTime createdDate, AppUser lastModifiedBy,
ZonedDateTime lastModifiedDate) { LocalDateTime lastModifiedDate) {
this.criteriaName = criteriaName; this.criteriaName = criteriaName;
setCreatedBy(createdBy.getId()); setCreatedBy(createdBy.getId());
setCreatedDate(Instant.ofEpochMilli(createdDate.toInstant().toEpochMilli())); setCreatedDate(createdDate);
setLastModifiedBy(lastModifiedBy.getId()); setLastModifiedBy(lastModifiedBy.getId());
setLastModifiedDate(Instant.ofEpochMilli(lastModifiedDate.toInstant().toEpochMilli())); setLastModifiedDate(lastModifiedDate);
} }
public void setProvisioningCriteriaDefinitions(Set<ProvisioningCriteriaDefinition> provisioningCriteriaDefinition) { public void setProvisioningCriteriaDefinitions(Set<ProvisioningCriteriaDefinition> provisioningCriteriaDefinition) {
@@ -22,7 +22,6 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement; 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.ZonedDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -122,8 +121,7 @@ public class ProvisioningCriteriaAssembler {
jsonElement); jsonElement);
ProvisioningCriteria criteria = new ProvisioningCriteria(criteriaName, platformSecurityContext.authenticatedUser(), ProvisioningCriteria criteria = new ProvisioningCriteria(criteriaName, platformSecurityContext.authenticatedUser(),
ZonedDateTime.now(DateUtils.getDateTimeZoneOfTenant()), platformSecurityContext.authenticatedUser(), DateUtils.getLocalDateTimeOfSystem(), platformSecurityContext.authenticatedUser(), DateUtils.getLocalDateTimeOfSystem());
ZonedDateTime.now(DateUtils.getDateTimeZoneOfTenant()));
return criteria; return criteria;
} }
@@ -19,10 +19,9 @@
package org.apache.fineract.organisation.teller.api; package org.apache.fineract.organisation.teller.api;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import java.time.ZonedDateTime; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
@@ -30,6 +29,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.teller.data.CashierData; import org.apache.fineract.organisation.teller.data.CashierData;
import org.apache.fineract.organisation.teller.service.TellerManagementReadPlatformService; import org.apache.fineract.organisation.teller.service.TellerManagementReadPlatformService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -60,7 +60,7 @@ public class CashierApiResource {
@QueryParam("staffId") final Long staffId, @QueryParam("date") final String date) { @QueryParam("staffId") final Long staffId, @QueryParam("date") final String date) {
final DateTimeFormatter dateFormatter = DateTimeFormatter.BASIC_ISO_DATE; final DateTimeFormatter dateFormatter = DateTimeFormatter.BASIC_ISO_DATE;
final Date dateRestriction = (date != null ? Date.from(ZonedDateTime.parse(date, dateFormatter).toInstant()) : new Date()); final LocalDate dateRestriction = (date != null ? LocalDate.parse(date, dateFormatter) : DateUtils.getBusinessLocalDate());
final Collection<CashierData> allCashiers = this.readPlatformService.getCashierData(officeId, tellerId, staffId, dateRestriction); final Collection<CashierData> allCashiers = this.readPlatformService.getCashierData(officeId, tellerId, staffId, dateRestriction);
@@ -27,10 +27,9 @@ import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import java.time.ZonedDateTime; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
import javax.ws.rs.GET; import javax.ws.rs.GET;
@@ -46,6 +45,7 @@ import org.apache.fineract.commands.service.CommandWrapperBuilder;
import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
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.SearchParameters; import org.apache.fineract.infrastructure.core.service.SearchParameters;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
@@ -166,8 +166,8 @@ public class TellerApiResource {
@QueryParam("todate") @Parameter(description = "todate") final String toDateStr) { @QueryParam("todate") @Parameter(description = "todate") final String toDateStr) {
final DateTimeFormatter dateFormatter = DateTimeFormatter.BASIC_ISO_DATE; final DateTimeFormatter dateFormatter = DateTimeFormatter.BASIC_ISO_DATE;
final Date fromDate = fromDateStr != null ? Date.from(ZonedDateTime.parse(fromDateStr, dateFormatter).toInstant()) : new Date(); final LocalDate fromDate = fromDateStr != null ? LocalDate.parse(fromDateStr, dateFormatter) : DateUtils.getBusinessLocalDate();
final Date toDate = toDateStr != null ? Date.from(ZonedDateTime.parse(toDateStr, dateFormatter).toInstant()) : new Date(); final LocalDate toDate = toDateStr != null ? LocalDate.parse(toDateStr, dateFormatter) : DateUtils.getBusinessLocalDate();
final TellerData teller = this.readPlatformService.findTeller(tellerId); final TellerData teller = this.readPlatformService.findTeller(tellerId);
final Collection<CashierData> cashiers = this.readPlatformService.getCashiersForTeller(tellerId, fromDate, toDate); final Collection<CashierData> cashiers = this.readPlatformService.getCashiersForTeller(tellerId, fromDate, toDate);
@@ -324,8 +324,8 @@ public class TellerApiResource {
final TellerData teller = this.readPlatformService.findTeller(tellerId); final TellerData teller = this.readPlatformService.findTeller(tellerId);
final CashierData cashier = this.readPlatformService.findCashier(cashierId); final CashierData cashier = this.readPlatformService.findCashier(cashierId);
final Date fromDate = null; final LocalDate fromDate = null;
final Date toDate = null; final LocalDate toDate = null;
final SearchParameters searchParameters = SearchParameters.forPagination(offset, limit, orderBy, sortOrder); final SearchParameters searchParameters = SearchParameters.forPagination(offset, limit, orderBy, sortOrder);
final Page<CashierTransactionData> cashierTxns = this.readPlatformService.retrieveCashierTransactions(cashierId, false, fromDate, final Page<CashierTransactionData> cashierTxns = this.readPlatformService.retrieveCashierTransactions(cashierId, false, fromDate,
toDate, currencyCode, searchParameters); toDate, currencyCode, searchParameters);
@@ -350,8 +350,8 @@ public class TellerApiResource {
final TellerData teller = this.readPlatformService.findTeller(tellerId); final TellerData teller = this.readPlatformService.findTeller(tellerId);
final CashierData cashier = this.readPlatformService.findCashier(cashierId); final CashierData cashier = this.readPlatformService.findCashier(cashierId);
final Date fromDate = null; final LocalDate fromDate = null;
final Date toDate = null; final LocalDate toDate = null;
final SearchParameters searchParameters = SearchParameters.forPagination(offset, limit, orderBy, sortOrder); final SearchParameters searchParameters = SearchParameters.forPagination(offset, limit, orderBy, sortOrder);
@@ -21,8 +21,8 @@ package org.apache.fineract.organisation.teller.api;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import org.apache.fineract.infrastructure.core.service.Page; import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.organisation.monetary.data.CurrencyData; import org.apache.fineract.organisation.monetary.data.CurrencyData;
import org.apache.fineract.organisation.staff.data.StaffData; import org.apache.fineract.organisation.staff.data.StaffData;
@@ -343,16 +343,16 @@ final class TellerApiResourceSwagger {
public CashierTxnType txnType; public CashierTxnType txnType;
@Schema(example = "1000") @Schema(example = "1000")
public BigDecimal txnAmount; public BigDecimal txnAmount;
@Schema(example = "Feb 25, 2015 12:00:00 AM") @Schema(example = "[2015, 02, 25]")
public Date txnDate; public LocalDate txnDate;
@Schema(example = "2") @Schema(example = "2")
public Long entityId; public Long entityId;
@Schema(example = "loans") @Schema(example = "loans")
public String entityType; public String entityType;
@Schema(example = "Disbursement, Loan:2-000000002,Client:1-Test 1") @Schema(example = "Disbursement, Loan:2-000000002,Client:1-Test 1")
public String txnNote; public String txnNote;
@Schema(example = "Feb 25, 2015 12:00:00 AM") @Schema(example = "[2015, 02, 25, 12, 00, 00]")
public Date createdDate; public LocalDateTime createdDate;
@Schema(example = "1") @Schema(example = "1")
public Long officeId; public Long officeId;
@Schema(example = "Head Office") @Schema(example = "Head Office")
@@ -380,8 +380,8 @@ final class TellerApiResourceSwagger {
public String locale; public String locale;
@Schema(example = "dd-MM-yyyy") @Schema(example = "dd-MM-yyyy")
public String dateFormat; public String dateFormat;
@Schema(example = "01 February 2015") @Schema(example = "[2015, 02, 01]")
public Date txnDate; public LocalDate txnDate;
} }
@Schema(description = "PostTellersTellerIdCashiersCashierIdAllocateResponse") @Schema(description = "PostTellersTellerIdCashiersCashierIdAllocateResponse")
@@ -414,8 +414,8 @@ final class TellerApiResourceSwagger {
public String locale; public String locale;
@Schema(example = "dd-MM-yyyy") @Schema(example = "dd-MM-yyyy")
public String dateFormat; public String dateFormat;
@Schema(example = "20 February 2015") @Schema(example = "[2015, 02, 20]")
public Date txnDate; public LocalDate txnDate;
} }
@@ -19,8 +19,8 @@
package org.apache.fineract.organisation.teller.data; package org.apache.fineract.organisation.teller.data;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import org.apache.fineract.organisation.staff.data.StaffData; import org.apache.fineract.organisation.staff.data.StaffData;
/** /**
@@ -39,8 +39,8 @@ public final class CashierData implements Serializable {
private final Long officeId; private final Long officeId;
private final Long staffId; private final Long staffId;
private final String description; private final String description;
private final Date startDate; private final LocalDate startDate;
private final Date endDate; private final LocalDate endDate;
private final Boolean isFullDay; private final Boolean isFullDay;
private final String startTime; private final String startTime;
private final String endTime; private final String endTime;
@@ -55,7 +55,7 @@ public final class CashierData implements Serializable {
* Creates a new cashier. * Creates a new cashier.
*/ */
private CashierData(final Long id, final Long officeId, String officeName, final Long staffId, final String staffName, private CashierData(final Long id, final Long officeId, String officeName, final Long staffId, final String staffName,
final Long tellerId, final String tellerName, final String description, final Date startDate, final Date endDate, final Long tellerId, final String tellerName, final String description, final LocalDate startDate, final LocalDate endDate,
final Boolean isFullDay, final String startTime, final String endTime, Collection<StaffData> staffOptions) { final Boolean isFullDay, final String startTime, final String endTime, Collection<StaffData> staffOptions) {
this.id = id; this.id = id;
this.officeId = officeId; this.officeId = officeId;
@@ -113,7 +113,7 @@ public final class CashierData implements Serializable {
* @return * @return
*/ */
public static CashierData instance(final Long id, final Long officeId, String officeName, final Long staffId, final String staffName, public static CashierData instance(final Long id, final Long officeId, String officeName, final Long staffId, final String staffName,
final Long tellerId, final String tellerName, final String description, final Date startDate, final Date endDate, final Long tellerId, final String tellerName, final String description, final LocalDate startDate, final LocalDate endDate,
final Boolean isFullDay, final String startTime, final String endTime) { final Boolean isFullDay, final String startTime, final String endTime) {
return new CashierData(id, officeId, officeName, staffId, staffName, tellerId, tellerName, description, startDate, endDate, return new CashierData(id, officeId, officeName, staffId, staffName, tellerId, tellerName, description, startDate, endDate,
isFullDay, startTime, endTime, null); isFullDay, startTime, endTime, null);
@@ -182,7 +182,7 @@ public final class CashierData implements Serializable {
* *
* @return the valid from date of this cashier * @return the valid from date of this cashier
*/ */
public Date getStartDate() { public LocalDate getStartDate() {
return startDate; return startDate;
} }
@@ -195,7 +195,7 @@ public final class CashierData implements Serializable {
* *
* @return the valid to date of this cashier * @return the valid to date of this cashier
*/ */
public Date getEndDate() { public LocalDate getEndDate() {
return endDate; return endDate;
} }
@@ -20,8 +20,9 @@ package org.apache.fineract.organisation.teller.data;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import org.apache.fineract.organisation.monetary.data.CurrencyData; import org.apache.fineract.organisation.monetary.data.CurrencyData;
import org.apache.fineract.organisation.teller.domain.CashierTxnType; import org.apache.fineract.organisation.teller.domain.CashierTxnType;
@@ -31,11 +32,11 @@ public final class CashierTransactionData implements Serializable {
private final Long cashierId; private final Long cashierId;
private final CashierTxnType txnType; private final CashierTxnType txnType;
private final BigDecimal txnAmount; private final BigDecimal txnAmount;
private final Date txnDate; private final LocalDate txnDate;
private final Long entityId; private final Long entityId;
private final String entityType; private final String entityType;
private final String txnNote; private final String txnNote;
private final Date createdDate; private final LocalDateTime createdDate;
// Template fields // Template fields
private final Long officeId; private final Long officeId;
@@ -45,8 +46,8 @@ public final class CashierTransactionData implements Serializable {
private final String cashierName; private final String cashierName;
private final CashierData cashierData; private final CashierData cashierData;
private final Date startDate; private final LocalDate startDate;
private final Date endDate; private final LocalDate endDate;
private final Collection<CurrencyData> currencyOptions; private final Collection<CurrencyData> currencyOptions;
@@ -54,9 +55,9 @@ public final class CashierTransactionData implements Serializable {
* Creates a new cashier. * Creates a new cashier.
*/ */
private CashierTransactionData(final Long id, final Long cashierId, CashierTxnType txnType, final BigDecimal txnAmount, private CashierTransactionData(final Long id, final Long cashierId, CashierTxnType txnType, final BigDecimal txnAmount,
final Date txnDate, String txnNote, String entityType, Long entityId, Date createdDate, Long officeId, String officeName, final LocalDate txnDate, String txnNote, String entityType, Long entityId, LocalDateTime createdDate, Long officeId,
Long tellerId, String tellerName, String cashierName, CashierData cashierData, Date startDate, Date endDate, String officeName, Long tellerId, String tellerName, String cashierName, CashierData cashierData, LocalDate startDate,
final Collection<CurrencyData> currencyOptions) { LocalDate endDate, final Collection<CurrencyData> currencyOptions) {
this.id = id; this.id = id;
this.cashierId = cashierId; this.cashierId = cashierId;
this.txnType = txnType; this.txnType = txnType;
@@ -81,15 +82,15 @@ public final class CashierTransactionData implements Serializable {
} }
public static CashierTransactionData instance(final Long id, final Long cashierId, CashierTxnType txnType, final BigDecimal txnAmount, public static CashierTransactionData instance(final Long id, final Long cashierId, CashierTxnType txnType, final BigDecimal txnAmount,
final Date txnDate, final String txnNote, final String entityType, final Long entityId, final Date createdDate, final LocalDate txnDate, final String txnNote, final String entityType, final Long entityId, final LocalDateTime createdDate,
final Long officeId, final String officeName, final Long tellerId, final String tellerName, final String cashierName, final Long officeId, final String officeName, final Long tellerId, final String tellerName, final String cashierName,
final CashierData cashierData, Date startDate, Date endDate) { final CashierData cashierData, LocalDate startDate, LocalDate endDate) {
return new CashierTransactionData(id, cashierId, txnType, txnAmount, txnDate, txnNote, entityType, entityId, createdDate, officeId, return new CashierTransactionData(id, cashierId, txnType, txnAmount, txnDate, txnNote, entityType, entityId, createdDate, officeId,
officeName, tellerId, tellerName, cashierName, cashierData, startDate, endDate, null); officeName, tellerId, tellerName, cashierName, cashierData, startDate, endDate, null);
} }
public static CashierTransactionData template(final Long cashierId, final Long tellerId, final String tellerName, final Long officeId, public static CashierTransactionData template(final Long cashierId, final Long tellerId, final String tellerName, final Long officeId,
final String officeName, final String cashierName, final CashierData cashierData, Date startDate, Date endDate, final String officeName, final String cashierName, final CashierData cashierData, LocalDate startDate, LocalDate endDate,
final Collection<CurrencyData> currencyOptions) { final Collection<CurrencyData> currencyOptions) {
return new CashierTransactionData(null, cashierId, null, null, null, null, null, null, null, officeId, officeName, tellerId, return new CashierTransactionData(null, cashierId, null, null, null, null, null, null, null, officeId, officeName, tellerId,
tellerName, cashierName, cashierData, startDate, endDate, currencyOptions); tellerName, cashierName, cashierData, startDate, endDate, currencyOptions);
@@ -111,7 +112,7 @@ public final class CashierTransactionData implements Serializable {
return txnAmount; return txnAmount;
} }
public Date getTxnDate() { public LocalDate getTxnDate() {
return txnDate; return txnDate;
} }
@@ -127,7 +128,7 @@ public final class CashierTransactionData implements Serializable {
return entityId; return entityId;
} }
public Date getCreatedDate() { public LocalDateTime getCreatedDate() {
return createdDate; return createdDate;
} }
@@ -151,11 +152,11 @@ public final class CashierTransactionData implements Serializable {
return cashierName; return cashierName;
} }
public Date getStartDate() { public LocalDate getStartDate() {
return startDate; return startDate;
} }
public Date getEndDate() { public LocalDate getEndDate() {
return endDate; return endDate;
} }
@@ -22,7 +22,6 @@ import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.Date;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.service.DateUtils; import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.core.service.SearchParameters; import org.apache.fineract.infrastructure.core.service.SearchParameters;
@@ -60,8 +59,8 @@ public class CashierTransactionDataValidator {
final Integer limit = null; final Integer limit = null;
final String orderBy = null; final String orderBy = null;
final String sortOrder = null; final String sortOrder = null;
final Date fromDate = null; final LocalDate fromDate = null;
final Date toDate = null; final LocalDate toDate = null;
final SearchParameters searchParameters = SearchParameters.forPagination(offset, limit, orderBy, sortOrder); final SearchParameters searchParameters = SearchParameters.forPagination(offset, limit, orderBy, sortOrder);
final CashierTransactionsWithSummaryData cashierTxnWithSummary = this.tellerManagementReadPlatformService final CashierTransactionsWithSummaryData cashierTxnWithSummary = this.tellerManagementReadPlatformService
.retrieveCashierTransactionsWithSummary(cashierId, false, fromDate, toDate, currencyCode, searchParameters); .retrieveCashierTransactionsWithSummary(cashierId, false, fromDate, toDate, currencyCode, searchParameters);
@@ -78,8 +77,8 @@ public class CashierTransactionDataValidator {
public void validateCashierAllowedDateAndTime(final Cashier cashier, final Teller teller) { public void validateCashierAllowedDateAndTime(final Cashier cashier, final Teller teller) {
Long staffId = cashier.getStaff().getId(); Long staffId = cashier.getStaff().getId();
final LocalDate fromDate = LocalDate.ofInstant(cashier.getStartDate().toInstant(), DateUtils.getDateTimeZoneOfTenant()); final LocalDate fromDate = cashier.getStartDate();
final LocalDate endDate = LocalDate.ofInstant(cashier.getEndDate().toInstant(), DateUtils.getDateTimeZoneOfTenant()); final LocalDate endDate = cashier.getEndDate();
final LocalDate tellerFromDate = teller.getStartLocalDate(); final LocalDate tellerFromDate = teller.getStartLocalDate();
final LocalDate tellerEndDate = teller.getEndLocalDate(); final LocalDate tellerEndDate = teller.getEndLocalDate();
/** /**
@@ -19,7 +19,7 @@
package org.apache.fineract.organisation.teller.data; package org.apache.fineract.organisation.teller.data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.time.LocalDate;
/** /**
* {@code TellerJournalData} represents an immutable journal data object. * {@code TellerJournalData} represents an immutable journal data object.
@@ -34,7 +34,7 @@ public final class TellerJournalData implements Serializable {
private final Long officeId; private final Long officeId;
private final Long tellerId; private final Long tellerId;
private final Date day; private final LocalDate day;
private final Double openingBalance; private final Double openingBalance;
private final Double settledBalance; private final Double settledBalance;
private final Double closingBalance; private final Double closingBalance;
@@ -44,7 +44,7 @@ public final class TellerJournalData implements Serializable {
/* /*
* Sole private CTOR to create a new instance. * Sole private CTOR to create a new instance.
*/ */
private TellerJournalData(final Long officeId, final Long tellerId, final Date day, final Double openingBalance, private TellerJournalData(final Long officeId, final Long tellerId, final LocalDate day, final Double openingBalance,
final Double settledBalance, final Double closingBalance, final Double sumReceipts, final Double sumPayments) { final Double settledBalance, final Double closingBalance, final Double sumReceipts, final Double sumPayments) {
this.officeId = officeId; this.officeId = officeId;
this.tellerId = tellerId; this.tellerId = tellerId;
@@ -77,7 +77,7 @@ public final class TellerJournalData implements Serializable {
* - sum of all posted payments * - sum of all posted payments
* @return the new created {@code TellerJournalData} * @return the new created {@code TellerJournalData}
*/ */
public static TellerJournalData instance(final Long officeId, final Long tellerId, final Date day, final Double openingBalance, public static TellerJournalData instance(final Long officeId, final Long tellerId, final LocalDate day, final Double openingBalance,
final Double settledBalance, final Double closingBalance, final Double sumReceipts, final Double sumPayments) { final Double settledBalance, final Double closingBalance, final Double sumReceipts, final Double sumPayments) {
return new TellerJournalData(officeId, tellerId, day, openingBalance, settledBalance, closingBalance, sumReceipts, sumPayments); return new TellerJournalData(officeId, tellerId, day, openingBalance, settledBalance, closingBalance, sumReceipts, sumPayments);
} }
@@ -90,7 +90,7 @@ public final class TellerJournalData implements Serializable {
return tellerId; return tellerId;
} }
public Date getDay() { public LocalDate getDay() {
return day; return day;
} }
@@ -19,7 +19,7 @@
package org.apache.fineract.organisation.teller.data; package org.apache.fineract.organisation.teller.data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.time.LocalDate;
import org.apache.fineract.infrastructure.core.data.EnumOptionData; import org.apache.fineract.infrastructure.core.data.EnumOptionData;
/** /**
@@ -40,13 +40,13 @@ public final class TellerTransactionData implements Serializable {
private final Long clientId; private final Long clientId;
private final EnumOptionData type; private final EnumOptionData type;
private final Double amount; private final Double amount;
private final Date postingDate; private final LocalDate postingDate;
/* /*
* Sole private CTOR to create a new instance * Sole private CTOR to create a new instance
*/ */
private TellerTransactionData(final Long id, final Long officeId, final Long tellerId, final Long cashierId, final Long clientId, private TellerTransactionData(final Long id, final Long officeId, final Long tellerId, final Long cashierId, final Long clientId,
final EnumOptionData type, final Double amount, final Date postingDate) { final EnumOptionData type, final Double amount, final LocalDate postingDate) {
this.id = id; this.id = id;
this.officeId = officeId; this.officeId = officeId;
this.tellerId = tellerId; this.tellerId = tellerId;
@@ -79,7 +79,7 @@ public final class TellerTransactionData implements Serializable {
* @return the new created {@code TellerTransactionData} * @return the new created {@code TellerTransactionData}
*/ */
public static TellerTransactionData instance(final Long id, final Long officeId, final Long tellerId, final Long cashierId, public static TellerTransactionData instance(final Long id, final Long officeId, final Long tellerId, final Long cashierId,
final Long clientId, final EnumOptionData type, final Double amount, final Date postingDate) { final Long clientId, final EnumOptionData type, final Double amount, final LocalDate postingDate) {
return new TellerTransactionData(id, officeId, tellerId, cashierId, clientId, type, amount, postingDate); return new TellerTransactionData(id, officeId, tellerId, cashierId, clientId, type, amount, postingDate);
} }
@@ -111,7 +111,7 @@ public final class TellerTransactionData implements Serializable {
return amount; return amount;
} }
public Date getPostingDate() { public LocalDate getPostingDate() {
return postingDate; return postingDate;
} }
} }
@@ -20,8 +20,6 @@ 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.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -31,13 +29,10 @@ import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient; import javax.persistence.Transient;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
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.office.domain.Office; import org.apache.fineract.organisation.office.domain.Office;
import org.apache.fineract.organisation.staff.domain.Staff; import org.apache.fineract.organisation.staff.domain.Staff;
@@ -69,13 +64,11 @@ public class Cashier extends AbstractPersistableCustom {
@Column(name = "description", nullable = true, length = 500) @Column(name = "description", nullable = true, length = 500)
private String description; private String description;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "start_date", nullable = false) @Column(name = "start_date", nullable = false)
private Date startDate; private LocalDate startDate;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "end_date", nullable = false) @Column(name = "end_date", nullable = false)
private Date endDate; private LocalDate endDate;
@Column(name = "full_day", nullable = true) @Column(name = "full_day", nullable = true)
private Boolean isFullDay; private Boolean isFullDay;
@@ -115,8 +108,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(ZoneId.systemDefault()).toInstant()); this.startDate = startDate;
this.endDate = Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.endDate = endDate;
this.isFullDay = isFullDay; this.isFullDay = isFullDay;
this.startTime = startTime; this.startTime = startTime;
this.endTime = endTime; this.endTime = endTime;
@@ -137,25 +130,23 @@ public class Cashier extends AbstractPersistableCustom {
} }
final String startDateParamName = "startDate"; final String startDateParamName = "startDate";
if (command.isChangeInLocalDateParameterNamed(startDateParamName, getStartLocalDate())) { if (command.isChangeInLocalDateParameterNamed(startDateParamName, getStartDate())) {
final String valueAsInput = command.stringValueOfParameterNamed(startDateParamName); final String valueAsInput = command.stringValueOfParameterNamed(startDateParamName);
actualChanges.put(startDateParamName, valueAsInput); actualChanges.put(startDateParamName, valueAsInput);
actualChanges.put("dateFormat", dateFormatAsInput); actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(startDateParamName); this.startDate = command.localDateValueOfParameterNamed(startDateParamName);
this.startDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final String endDateParamName = "endDate"; final String endDateParamName = "endDate";
if (command.isChangeInLocalDateParameterNamed(endDateParamName, getEndLocalDate())) { if (command.isChangeInLocalDateParameterNamed(endDateParamName, getEndDate())) {
final String valueAsInput = command.stringValueOfParameterNamed(endDateParamName); final String valueAsInput = command.stringValueOfParameterNamed(endDateParamName);
actualChanges.put(endDateParamName, valueAsInput); actualChanges.put(endDateParamName, valueAsInput);
actualChanges.put("dateFormat", dateFormatAsInput); actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(endDateParamName); this.endDate = command.localDateValueOfParameterNamed(endDateParamName);
this.endDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final Boolean isFullDay = command.booleanObjectValueOfParameterNamed("isFullDay"); final Boolean isFullDay = command.booleanObjectValueOfParameterNamed("isFullDay");
@@ -341,18 +332,10 @@ public class Cashier extends AbstractPersistableCustom {
* *
* @return the valid from date of this cashier * @return the valid from date of this cashier
*/ */
public Date getStartDate() { public LocalDate getStartDate() {
return startDate; return startDate;
} }
public LocalDate getStartLocalDate() {
LocalDate startLocalDate = null;
if (this.startDate != null) {
startLocalDate = LocalDate.ofInstant(this.startDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return startLocalDate;
}
/** /**
* Sets the valid from date of this cashier. * Sets the valid from date of this cashier.
* *
@@ -363,7 +346,7 @@ public class Cashier extends AbstractPersistableCustom {
* @param startDate * @param startDate
* validFrom the valid from date of this cashier * validFrom the valid from date of this cashier
*/ */
public void setStartDate(Date startDate) { public void setStartDate(LocalDate startDate) {
this.startDate = startDate; this.startDate = startDate;
} }
@@ -376,18 +359,10 @@ public class Cashier extends AbstractPersistableCustom {
* *
* @return the valid to date of this cashier * @return the valid to date of this cashier
*/ */
public Date getEndDate() { public LocalDate getEndDate() {
return endDate; return endDate;
} }
public LocalDate getEndLocalDate() {
LocalDate endLocalDate = null;
if (this.endDate != null) {
endLocalDate = LocalDate.ofInstant(this.endDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return endLocalDate;
}
/** /**
* Sets the valid to date of this cashier. * Sets the valid to date of this cashier.
* *
@@ -398,7 +373,7 @@ public class Cashier extends AbstractPersistableCustom {
* @param endDate * @param endDate
* validTo the valid to date of this cashier * validTo the valid to date of this cashier
*/ */
public void setEndDate(Date endDate) { public void setEndDate(LocalDate endDate) {
this.endDate = endDate; this.endDate = endDate;
} }
@@ -20,8 +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.time.LocalDateTime;
import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import javax.persistence.Column; import javax.persistence.Column;
@@ -30,8 +29,6 @@ import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient; import javax.persistence.Transient;
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;
@@ -55,9 +52,8 @@ public class CashierTransaction extends AbstractPersistableCustom {
@Column(name = "txn_type", nullable = false) @Column(name = "txn_type", nullable = false)
private Integer txnType; private Integer txnType;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "txn_date", nullable = false) @Column(name = "txn_date", nullable = false)
private Date txnDate; private LocalDate txnDate;
@Column(name = "txn_amount", scale = 6, precision = 19, nullable = false) @Column(name = "txn_amount", scale = 6, precision = 19, nullable = false)
private BigDecimal txnAmount; private BigDecimal txnAmount;
@@ -71,9 +67,8 @@ public class CashierTransaction extends AbstractPersistableCustom {
@Column(name = "entity_id", nullable = true) @Column(name = "entity_id", nullable = true)
private Long entityId; private Long entityId;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "created_date", nullable = false) @Column(name = "created_date", nullable = false)
private Date createdDate; private LocalDateTime createdDate;
@Column(name = "currency_code", nullable = true) @Column(name = "currency_code", nullable = true)
private String currencyCode; private String currencyCode;
@@ -104,13 +99,13 @@ 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(ZoneId.systemDefault()).toInstant()); this.txnDate = txnDate;
} }
this.txnAmount = txnAmount; this.txnAmount = txnAmount;
this.entityType = entityType; this.entityType = entityType;
this.entityId = entityId; this.entityId = entityId;
this.txnNote = txnNote; this.txnNote = txnNote;
this.createdDate = new Date(); this.createdDate = DateUtils.getLocalDateTimeOfSystem();
this.currencyCode = currencyCode; this.currencyCode = currencyCode;
} }
@@ -135,8 +130,7 @@ public class CashierTransaction extends AbstractPersistableCustom {
actualChanges.put("dateFormat", dateFormatAsInput); actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(txnDateParamName); this.txnDate = command.localDateValueOfParameterNamed(txnDateParamName);
this.txnDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final String txnAmountParamName = "txnAmount"; final String txnAmountParamName = "txnAmount";
@@ -229,16 +223,12 @@ public class CashierTransaction extends AbstractPersistableCustom {
* *
* @return the transaction date of this cashier transaction * @return the transaction date of this cashier transaction
*/ */
public Date getTxnDate() { public LocalDate getTxnDate() {
return txnDate; return txnDate;
} }
public LocalDate getTxnLocalDate() { public LocalDate getTxnLocalDate() {
LocalDate txnLocalDate = null; return this.txnDate;
if (this.txnDate != null) {
txnLocalDate = LocalDate.ofInstant(this.txnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return txnLocalDate;
} }
/** /**
@@ -247,7 +237,7 @@ public class CashierTransaction extends AbstractPersistableCustom {
* @param txnDate * @param txnDate
* transaction date of this cashier transaction * transaction date of this cashier transaction
*/ */
public void setTxnDate(Date txnDate) { public void setTxnDate(LocalDate txnDate) {
this.txnDate = txnDate; this.txnDate = txnDate;
} }
@@ -19,8 +19,6 @@
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.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@@ -31,14 +29,10 @@ import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.accounting.glaccount.domain.GLAccount; import org.apache.fineract.accounting.glaccount.domain.GLAccount;
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.office.domain.Office; import org.apache.fineract.organisation.office.domain.Office;
@Entity @Entity
@@ -63,13 +57,11 @@ public class Teller extends AbstractPersistableCustom {
@Column(name = "description", nullable = true, length = 500) @Column(name = "description", nullable = true, length = 500)
private String description; private String description;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "valid_from", nullable = true) @Column(name = "valid_from", nullable = true)
private Date startDate; private LocalDate startDate;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "valid_to", nullable = true) @Column(name = "valid_to", nullable = true)
private Date endDate; private LocalDate endDate;
@Column(name = "state", nullable = false) @Column(name = "state", nullable = false)
private Integer status; private Integer status;
@@ -84,14 +76,11 @@ public class Teller extends AbstractPersistableCustom {
private Teller(final Office staffOffice, final String name, final String description, final LocalDate startDate, private Teller(final Office staffOffice, final String name, final String description, final LocalDate startDate,
final LocalDate endDate, final TellerStatus status) { final LocalDate endDate, final TellerStatus status) {
this.name = StringUtils.defaultIfEmpty(name, null); this.name = name;
this.description = StringUtils.defaultIfEmpty(description, null); this.description = description;
if (startDate != null) { this.startDate = startDate;
this.startDate = Date.from(startDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.endDate = endDate;
}
if (endDate != null) {
this.endDate = Date.from(endDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
}
if (status != null) { if (status != null) {
this.status = status.getValue(); this.status = status.getValue();
} }
@@ -152,8 +141,7 @@ public class Teller extends AbstractPersistableCustom {
actualChanges.put("dateFormat", dateFormatAsInput); actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(startDateParamName); this.startDate = command.localDateValueOfParameterNamed(startDateParamName);
this.startDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final String endDateParamName = "endDate"; final String endDateParamName = "endDate";
@@ -163,8 +151,7 @@ public class Teller extends AbstractPersistableCustom {
actualChanges.put("dateFormat", dateFormatAsInput); actualChanges.put("dateFormat", dateFormatAsInput);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(endDateParamName); this.endDate = command.localDateValueOfParameterNamed(endDateParamName);
this.endDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
final String statusParamName = "status"; final String statusParamName = "status";
@@ -221,35 +208,27 @@ public class Teller extends AbstractPersistableCustom {
this.description = description; this.description = description;
} }
public Date getStartDate() { public LocalDate getStartDate() {
return startDate; return startDate;
} }
public LocalDate getStartLocalDate() { public LocalDate getStartLocalDate() {
LocalDate startLocalDate = null; return this.startDate;
if (this.startDate != null) {
startLocalDate = LocalDate.ofInstant(this.startDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return startLocalDate;
} }
public void setStartDate(Date startDate) { public void setStartDate(LocalDate startDate) {
this.startDate = startDate; this.startDate = startDate;
} }
public Date getEndDate() { public LocalDate getEndDate() {
return endDate; return endDate;
} }
public LocalDate getEndLocalDate() { public LocalDate getEndLocalDate() {
LocalDate endLocalDate = null; return this.endDate;
if (this.endDate != null) {
endLocalDate = LocalDate.ofInstant(this.endDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return endLocalDate;
} }
public void setEndDate(Date endDate) { public void setEndDate(LocalDate endDate) {
this.endDate = endDate; this.endDate = endDate;
} }
@@ -18,15 +18,13 @@
*/ */
package org.apache.fineract.organisation.teller.domain; package org.apache.fineract.organisation.teller.domain;
import java.util.Date; import java.time.LocalDate;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.organisation.office.domain.Office; import org.apache.fineract.organisation.office.domain.Office;
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
@@ -57,9 +55,8 @@ public class TellerTransaction extends AbstractPersistableCustom {
@Column(name = "amount", nullable = false) @Column(name = "amount", nullable = false)
private Double amount; private Double amount;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "posting_date", nullable = false) @Column(name = "posting_date", nullable = false)
private Date postingDate; private LocalDate postingDate;
public TellerTransaction() { public TellerTransaction() {
@@ -113,11 +110,11 @@ public class TellerTransaction extends AbstractPersistableCustom {
this.amount = amount; this.amount = amount;
} }
public Date getPostingDate() { public LocalDate getPostingDate() {
return postingDate; return postingDate;
} }
public void setPostingDate(Date postingDate) { public void setPostingDate(LocalDate postingDate) {
this.postingDate = postingDate; this.postingDate = postingDate;
} }
} }
@@ -18,8 +18,8 @@
*/ */
package org.apache.fineract.organisation.teller.service; package org.apache.fineract.organisation.teller.service;
import java.time.LocalDate;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import org.apache.fineract.infrastructure.core.service.Page; import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.core.service.SearchParameters; import org.apache.fineract.infrastructure.core.service.SearchParameters;
import org.apache.fineract.organisation.teller.data.CashierData; import org.apache.fineract.organisation.teller.data.CashierData;
@@ -37,9 +37,9 @@ public interface TellerManagementReadPlatformService {
CashierData findCashier(Long cashierId); CashierData findCashier(Long cashierId);
Collection<CashierData> getCashierData(Long officeId, Long tellerId, Long staffId, Date date); Collection<CashierData> getCashierData(Long officeId, Long tellerId, Long staffId, LocalDate date);
Collection<CashierData> getTellerCashiers(Long tellerId, Date date); Collection<CashierData> getTellerCashiers(Long tellerId, LocalDate date);
CashierData retrieveCashierTemplate(Long officeId, Long tellerId, boolean staffInSelectedOfficeOnly); CashierData retrieveCashierTemplate(Long officeId, Long tellerId, boolean staffInSelectedOfficeOnly);
@@ -47,24 +47,24 @@ public interface TellerManagementReadPlatformService {
TellerTransactionData findTellerTransaction(Long transactionId); TellerTransactionData findTellerTransaction(Long transactionId);
Collection<TellerTransactionData> fetchTellerTransactionsByTellerId(Long tellerId, Date fromDate, Date toDate); Collection<TellerTransactionData> fetchTellerTransactionsByTellerId(Long tellerId, LocalDate fromDate, LocalDate toDate);
Collection<TellerJournalData> getJournals(Long officeId, Long tellerId, Long cashierId, Date dateFrom, Date dateTo); Collection<TellerJournalData> getJournals(Long officeId, Long tellerId, Long cashierId, LocalDate dateFrom, LocalDate dateTo);
Collection<TellerJournalData> fetchTellerJournals(Long tellerId, Long cashierId, Date fromDate, Date toDate); Collection<TellerJournalData> fetchTellerJournals(Long tellerId, Long cashierId, LocalDate fromDate, LocalDate toDate);
Collection<TellerData> retrieveAllTellersForDropdown(Long officeId); Collection<TellerData> retrieveAllTellersForDropdown(Long officeId);
Collection<TellerData> retrieveAllTellers(String sqlSearch, Long officeId, String status); Collection<TellerData> retrieveAllTellers(String sqlSearch, Long officeId, String status);
Collection<CashierData> getCashiersForTeller(Long tellerId, Date fromDate, Date toDate); Collection<CashierData> getCashiersForTeller(Long tellerId, LocalDate fromDate, LocalDate toDate);
Collection<CashierData> retrieveCashiersForTellers(String sqlSearch, Long tellerId); Collection<CashierData> retrieveCashiersForTellers(String sqlSearch, Long tellerId);
Page<CashierTransactionData> retrieveCashierTransactions(Long cashierId, boolean includeAllTellers, Date fromDate, Date toDate, Page<CashierTransactionData> retrieveCashierTransactions(Long cashierId, boolean includeAllTellers, LocalDate fromDate,
String currencyCode, SearchParameters searchParameters); LocalDate toDate, String currencyCode, SearchParameters searchParameters);
CashierTransactionsWithSummaryData retrieveCashierTransactionsWithSummary(Long cashierId, boolean includeAllTellers, Date fromDate, CashierTransactionsWithSummaryData retrieveCashierTransactionsWithSummary(Long cashierId, boolean includeAllTellers, LocalDate fromDate,
Date toDate, String currencyCode, SearchParameters searchParameters); LocalDate toDate, String currencyCode, SearchParameters searchParameters);
} }

Some files were not shown because too many files have changed in this diff Show More