Date to LocalDate - Client

This commit is contained in:
Adam Saghy
2022-07-11 13:22:09 +02:00
committed by Arnold Gálovics
parent ef96d5cc50
commit 7ce19d703b
13 changed files with 109 additions and 227 deletions
@@ -30,7 +30,6 @@ import java.io.InputStream;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@@ -61,7 +60,6 @@ import org.apache.fineract.infrastructure.core.data.UploadRequest;
import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException; import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException;
import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer; import org.apache.fineract.infrastructure.core.serialization.ToApiJsonSerializer;
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;
@@ -442,8 +440,7 @@ public class ClientsApiResource {
public String retrieveTransferTemplate(@PathParam("clientId") final Long clientId, @Context final UriInfo uriInfo) { public String retrieveTransferTemplate(@PathParam("clientId") final Long clientId, @Context final UriInfo uriInfo) {
this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME);
final Date transferDate = this.clientReadPlatformService.retrieveClientTransferProposalDate(clientId); final LocalDate transferDate = this.clientReadPlatformService.retrieveClientTransferProposalDate(clientId);
return this.toApiJsonSerializer.serialize( return this.toApiJsonSerializer.serialize(transferDate);
(transferDate != null ? LocalDate.ofInstant(transferDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()) : null));
} }
} }
@@ -19,10 +19,8 @@
package org.apache.fineract.portfolio.client.domain; package org.apache.fineract.portfolio.client.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@@ -39,11 +37,8 @@ import javax.persistence.ManyToOne;
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 javax.persistence.Transient; import javax.persistence.Transient;
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.codes.domain.CodeValue; import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -92,12 +87,10 @@ public final class Client extends AbstractPersistableCustom {
private CodeValue subStatus; private CodeValue subStatus;
@Column(name = "activation_date", nullable = true) @Column(name = "activation_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate activationDate;
private Date activationDate;
@Column(name = "office_joining_date", nullable = true) @Column(name = "office_joining_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate officeJoiningDate;
private Date officeJoiningDate;
@Column(name = "firstname", length = 50, nullable = true) @Column(name = "firstname", length = 50, nullable = true)
private String firstname; private String firstname;
@@ -127,8 +120,7 @@ public final class Client extends AbstractPersistableCustom {
private String externalId; private String externalId;
@Column(name = "date_of_birth", nullable = true) @Column(name = "date_of_birth", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate dateOfBirth;
private Date dateOfBirth;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "gender_cv_id", nullable = true) @JoinColumn(name = "gender_cv_id", nullable = true)
@@ -150,16 +142,14 @@ public final class Client extends AbstractPersistableCustom {
private CodeValue closureReason; private CodeValue closureReason;
@Column(name = "closedon_date", nullable = true) @Column(name = "closedon_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate closureDate;
private Date closureDate;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "reject_reason_cv_id", nullable = true) @JoinColumn(name = "reject_reason_cv_id", nullable = true)
private CodeValue rejectionReason; private CodeValue rejectionReason;
@Column(name = "rejectedon_date", nullable = true) @Column(name = "rejectedon_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate rejectionDate;
private Date rejectionDate;
@ManyToOne(optional = true, fetch = FetchType.LAZY) @ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "rejectedon_userid", nullable = true) @JoinColumn(name = "rejectedon_userid", nullable = true)
@@ -170,16 +160,14 @@ public final class Client extends AbstractPersistableCustom {
private CodeValue withdrawalReason; private CodeValue withdrawalReason;
@Column(name = "withdrawn_on_date", nullable = true) @Column(name = "withdrawn_on_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate withdrawalDate;
private Date withdrawalDate;
@ManyToOne(optional = true, fetch = FetchType.LAZY) @ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "withdraw_on_userid", nullable = true) @JoinColumn(name = "withdraw_on_userid", nullable = true)
private AppUser withdrawnBy; private AppUser withdrawnBy;
@Column(name = "reactivated_on_date", nullable = true) @Column(name = "reactivated_on_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate reactivateDate;
private Date reactivateDate;
@ManyToOne(optional = true, fetch = FetchType.LAZY) @ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "reactivated_on_userid", nullable = true) @JoinColumn(name = "reactivated_on_userid", nullable = true)
@@ -190,16 +178,14 @@ public final class Client extends AbstractPersistableCustom {
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, fetch = FetchType.LAZY) @ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "submittedon_userid", nullable = true) @JoinColumn(name = "submittedon_userid", nullable = true)
private AppUser submittedBy; private AppUser submittedBy;
@Column(name = "updated_on", nullable = true) @Column(name = "updated_on", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate updatedOnDate;
private Date updatedOnDate;
@ManyToOne(optional = true, fetch = FetchType.LAZY) @ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "updated_by", nullable = true) @JoinColumn(name = "updated_by", nullable = true)
@@ -227,16 +213,14 @@ public final class Client extends AbstractPersistableCustom {
private Integer legalForm; private Integer legalForm;
@Column(name = "reopened_on_date", nullable = true) @Column(name = "reopened_on_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate reopenedDate;
private Date reopenedDate;
@ManyToOne(optional = true, fetch = FetchType.LAZY) @ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "reopened_by_userid", nullable = true) @JoinColumn(name = "reopened_by_userid", nullable = true)
private AppUser reopenedBy; private AppUser reopenedBy;
@Column(name = "proposed_transfer_date", nullable = true) @Column(name = "proposed_transfer_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate proposedTransferDate;
private Date proposedTransferDate;
@OneToMany(mappedBy = "client", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) @OneToMany(mappedBy = "client", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
private Set<ClientCollateralManagement> clientCollateralManagements = new HashSet<>(); private Set<ClientCollateralManagement> clientCollateralManagements = new HashSet<>();
@@ -304,58 +288,44 @@ public final class Client extends AbstractPersistableCustom {
this.accountNumber = accountNo; this.accountNumber = accountNo;
} }
this.submittedOnDate = Date.from(submittedOnDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.submittedOnDate = submittedOnDate;
this.submittedBy = currentUser; this.submittedBy = currentUser;
this.status = status.getValue(); this.status = status.getValue();
this.office = office; this.office = office;
if (StringUtils.isNotBlank(externalId)) { if (StringUtils.isNotBlank(externalId)) {
this.externalId = externalId.trim(); this.externalId = externalId.trim();
} else {
this.externalId = null;
} }
if (StringUtils.isNotBlank(mobileNo)) { if (StringUtils.isNotBlank(mobileNo)) {
this.mobileNo = mobileNo.trim(); this.mobileNo = mobileNo.trim();
} else {
this.mobileNo = null;
} }
if (StringUtils.isNotBlank(emailAddress)) { if (StringUtils.isNotBlank(emailAddress)) {
this.emailAddress = emailAddress.trim(); this.emailAddress = emailAddress.trim();
} else {
this.emailAddress = null;
} }
if (activationDate != null) { if (activationDate != null) {
this.activationDate = Date.from(activationDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.activationDate = activationDate;
this.activatedBy = currentUser; this.activatedBy = currentUser;
} }
if (officeJoiningDate != null) {
this.officeJoiningDate = Date.from(officeJoiningDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.officeJoiningDate = officeJoiningDate;
}
if (StringUtils.isNotBlank(firstname)) { if (StringUtils.isNotBlank(firstname)) {
this.firstname = firstname.trim(); this.firstname = firstname.trim();
} else {
this.firstname = null;
} }
if (StringUtils.isNotBlank(middlename)) { if (StringUtils.isNotBlank(middlename)) {
this.middlename = middlename.trim(); this.middlename = middlename.trim();
} else {
this.middlename = null;
} }
if (StringUtils.isNotBlank(lastname)) { if (StringUtils.isNotBlank(lastname)) {
this.lastname = lastname.trim(); this.lastname = lastname.trim();
} else {
this.lastname = null;
} }
if (StringUtils.isNotBlank(fullname)) { if (StringUtils.isNotBlank(fullname)) {
this.fullname = fullname.trim(); this.fullname = fullname.trim();
} else {
this.fullname = null;
} }
if (clientParentGroup != null) { if (clientParentGroup != null) {
@@ -370,9 +340,9 @@ public final class Client extends AbstractPersistableCustom {
if (gender != null) { if (gender != null) {
this.gender = gender; this.gender = gender;
} }
if (dateOfBirth != null) {
this.dateOfBirth = Date.from(dateOfBirth.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.dateOfBirth = dateOfBirth;
}
this.clientType = clientType; this.clientType = clientType;
this.clientClassification = clientClassification; this.clientClassification = clientClassification;
this.setLegalForm(legalForm); this.setLegalForm(legalForm);
@@ -440,7 +410,7 @@ public final class Client extends AbstractPersistableCustom {
throw new PlatformApiDataValidationException(dataValidationErrors); throw new PlatformApiDataValidationException(dataValidationErrors);
} }
this.activationDate = Date.from(activationLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.activationDate = activationLocalDate;
this.activatedBy = currentUser; this.activatedBy = currentUser;
this.officeJoiningDate = this.activationDate; this.officeJoiningDate = this.activationDate;
this.status = ClientStatus.ACTIVE.getValue(); this.status = ClientStatus.ACTIVE.getValue();
@@ -618,8 +588,7 @@ public final class Client extends AbstractPersistableCustom {
actualChanges.put(ClientApiConstants.dateFormatParamName, dateFormatAsInput); actualChanges.put(ClientApiConstants.dateFormatParamName, dateFormatAsInput);
actualChanges.put(ClientApiConstants.localeParamName, localeAsInput); actualChanges.put(ClientApiConstants.localeParamName, localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.activationDateParamName); this.activationDate = command.localDateValueOfParameterNamed(ClientApiConstants.activationDateParamName);
this.activationDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
this.officeJoiningDate = this.activationDate; this.officeJoiningDate = this.activationDate;
} }
@@ -629,8 +598,7 @@ public final class Client extends AbstractPersistableCustom {
actualChanges.put(ClientApiConstants.dateFormatParamName, dateFormatAsInput); actualChanges.put(ClientApiConstants.dateFormatParamName, dateFormatAsInput);
actualChanges.put(ClientApiConstants.localeParamName, localeAsInput); actualChanges.put(ClientApiConstants.localeParamName, localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.dateOfBirthParamName); this.dateOfBirth = command.localDateValueOfParameterNamed(ClientApiConstants.dateOfBirthParamName);
this.dateOfBirth = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (command.isChangeInLocalDateParameterNamed(ClientApiConstants.submittedOnDateParamName, getSubmittedOnDate())) { if (command.isChangeInLocalDateParameterNamed(ClientApiConstants.submittedOnDateParamName, getSubmittedOnDate())) {
@@ -639,8 +607,7 @@ public final class Client extends AbstractPersistableCustom {
actualChanges.put(ClientApiConstants.dateFormatParamName, dateFormatAsInput); actualChanges.put(ClientApiConstants.dateFormatParamName, dateFormatAsInput);
actualChanges.put(ClientApiConstants.localeParamName, localeAsInput); actualChanges.put(ClientApiConstants.localeParamName, localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.submittedOnDateParamName); this.submittedOnDate = command.localDateValueOfParameterNamed(ClientApiConstants.submittedOnDateParamName);
this.submittedOnDate = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
validateUpdate(); validateUpdate();
@@ -753,23 +720,15 @@ public final class Client extends AbstractPersistableCustom {
} }
public LocalDate getSubmittedOnDate() { public LocalDate getSubmittedOnDate() {
return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.submittedOnDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), null); return this.submittedOnDate;
} }
public LocalDate getActivationLocalDate() { public LocalDate getActivationLocalDate() {
LocalDate activationLocalDate = null; return this.activationDate;
if (this.activationDate != null) {
activationLocalDate = LocalDate.ofInstant(this.activationDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return activationLocalDate;
} }
public LocalDate getOfficeJoiningLocalDate() { public LocalDate getOfficeJoiningLocalDate() {
LocalDate officeJoiningLocalDate = null; return this.officeJoiningDate;
if (this.officeJoiningDate != null) {
officeJoiningLocalDate = LocalDate.ofInstant(this.officeJoiningDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return officeJoiningLocalDate;
} }
public boolean isOfficeIdentifiedBy(final Long officeId) { public boolean isOfficeIdentifiedBy(final Long officeId) {
@@ -840,7 +799,7 @@ public final class Client extends AbstractPersistableCustom {
this.transferToOffice = office; this.transferToOffice = office;
} }
public void updateOfficeJoiningDate(final Date date) { public void updateOfficeJoiningDate(final LocalDate date) {
this.officeJoiningDate = date; this.officeJoiningDate = date;
} }
@@ -872,7 +831,7 @@ public final class Client extends AbstractPersistableCustom {
return this.groups; return this.groups;
} }
public void close(final AppUser currentUser, final CodeValue closureReason, final Date closureDate) { public void close(final AppUser currentUser, final CodeValue closureReason, final LocalDate closureDate) {
this.closureReason = closureReason; this.closureReason = closureReason;
this.closureDate = closureDate; this.closureDate = closureDate;
this.closedBy = currentUser; this.closedBy = currentUser;
@@ -959,19 +918,19 @@ public final class Client extends AbstractPersistableCustom {
} }
public LocalDate getClosureDate() { public LocalDate getClosureDate() {
return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.closureDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), null); return this.closureDate;
} }
public LocalDate getRejectedDate() { public LocalDate getRejectedDate() {
return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.rejectionDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), null); return this.rejectionDate;
} }
public LocalDate getWithdrawalDate() { public LocalDate getWithdrawalDate() {
return ObjectUtils.defaultIfNull(LocalDate.ofInstant(this.withdrawalDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()), null); return this.withdrawalDate;
} }
public LocalDate getReopenedDate() { public LocalDate getReopenedDate() {
return this.reopenedDate == null ? null : LocalDate.ofInstant(this.reopenedDate.toInstant(), DateUtils.getDateTimeZoneOfTenant()); return this.reopenedDate;
} }
public CodeValue gender() { public CodeValue gender() {
@@ -998,19 +957,15 @@ public final class Client extends AbstractPersistableCustom {
this.gender = gender; this.gender = gender;
} }
public Date dateOfBirth() { public LocalDate dateOfBirth() {
return this.dateOfBirth; return this.dateOfBirth;
} }
public LocalDate dateOfBirthLocalDate() { public LocalDate dateOfBirthLocalDate() {
LocalDate dateOfBirth = null; return this.dateOfBirth;
if (this.dateOfBirth != null) {
dateOfBirth = LocalDate.ofInstant(this.dateOfBirth.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return dateOfBirth;
} }
public void reject(AppUser currentUser, CodeValue rejectionReason, Date rejectionDate) { public void reject(AppUser currentUser, CodeValue rejectionReason, LocalDate rejectionDate) {
this.rejectionReason = rejectionReason; this.rejectionReason = rejectionReason;
this.rejectionDate = rejectionDate; this.rejectionDate = rejectionDate;
this.rejectedBy = currentUser; this.rejectedBy = currentUser;
@@ -1020,7 +975,7 @@ public final class Client extends AbstractPersistableCustom {
} }
public void withdraw(AppUser currentUser, CodeValue withdrawalReason, Date withdrawalDate) { public void withdraw(AppUser currentUser, CodeValue withdrawalReason, LocalDate withdrawalDate) {
this.withdrawalReason = withdrawalReason; this.withdrawalReason = withdrawalReason;
this.withdrawalDate = withdrawalDate; this.withdrawalDate = withdrawalDate;
this.withdrawnBy = currentUser; this.withdrawnBy = currentUser;
@@ -1030,7 +985,7 @@ public final class Client extends AbstractPersistableCustom {
} }
public void reActivate(AppUser currentUser, Date reactivateDate) { public void reActivate(AppUser currentUser, LocalDate reactivateDate) {
this.closureDate = null; this.closureDate = null;
this.closureReason = null; this.closureReason = null;
this.reactivateDate = reactivateDate; this.reactivateDate = reactivateDate;
@@ -1041,7 +996,7 @@ public final class Client extends AbstractPersistableCustom {
} }
public void reOpened(AppUser currentUser, Date reopenedDate) { public void reOpened(AppUser currentUser, LocalDate reopenedDate) {
this.reopenedDate = reopenedDate; this.reopenedDate = reopenedDate;
this.reopenedBy = currentUser; this.reopenedBy = currentUser;
this.updatedBy = currentUser; this.updatedBy = currentUser;
@@ -1074,11 +1029,11 @@ public final class Client extends AbstractPersistableCustom {
return this.lastname; return this.lastname;
} }
public Date getProposedTransferDate() { public LocalDate getProposedTransferDate() {
return proposedTransferDate; return proposedTransferDate;
} }
public void updateProposedTransferDate(Date proposedTransferDate) { public void updateProposedTransferDate(LocalDate proposedTransferDate) {
this.proposedTransferDate = proposedTransferDate; this.proposedTransferDate = proposedTransferDate;
} }
@@ -20,19 +20,14 @@ package org.apache.fineract.portfolio.client.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import 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.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;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
import org.apache.fineract.organisation.monetary.domain.Money; import org.apache.fineract.organisation.monetary.domain.Money;
import org.apache.fineract.organisation.office.domain.OrganisationCurrency; import org.apache.fineract.organisation.office.domain.OrganisationCurrency;
@@ -56,9 +51,8 @@ public class ClientCharge extends AbstractPersistableCustom {
@Column(name = "charge_time_enum", nullable = false) @Column(name = "charge_time_enum", nullable = false)
private Integer chargeTime; private Integer chargeTime;
@Temporal(TemporalType.DATE)
@Column(name = "charge_due_date") @Column(name = "charge_due_date")
private Date dueDate; private LocalDate dueDate;
@Column(name = "charge_calculation_enum") @Column(name = "charge_calculation_enum")
private Integer chargeCalculation; private Integer chargeCalculation;
@@ -90,9 +84,8 @@ public class ClientCharge extends AbstractPersistableCustom {
@Column(name = "is_active", nullable = false) @Column(name = "is_active", nullable = false)
private boolean status = true; private boolean status = true;
@Temporal(TemporalType.DATE)
@Column(name = "inactivated_on_date") @Column(name = "inactivated_on_date")
private Date inactivationDate; private LocalDate inactivationDate;
@Transient @Transient
private OrganisationCurrency currency; private OrganisationCurrency currency;
@@ -116,7 +109,7 @@ public class ClientCharge extends AbstractPersistableCustom {
this.charge = charge; this.charge = charge;
this.penaltyCharge = charge.isPenalty(); this.penaltyCharge = charge.isPenalty();
this.chargeTime = charge.getChargeTimeType(); this.chargeTime = charge.getChargeTimeType();
this.dueDate = (dueDate == null) ? null : Date.from(dueDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.dueDate = dueDate;
this.chargeCalculation = charge.getChargeCalculation(); this.chargeCalculation = charge.getChargeCalculation();
BigDecimal chargeAmount = charge.getAmount(); BigDecimal chargeAmount = charge.getAmount();
@@ -220,11 +213,7 @@ public class ClientCharge extends AbstractPersistableCustom {
} }
public LocalDate getDueLocalDate() { public LocalDate getDueLocalDate() {
LocalDate dueDate = null; return this.dueDate;
if (this.dueDate != null) {
dueDate = LocalDate.ofInstant(this.dueDate.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return dueDate;
} }
public Client getClient() { public Client getClient() {
@@ -239,7 +228,7 @@ public class ClientCharge extends AbstractPersistableCustom {
return this.chargeTime; return this.chargeTime;
} }
public Date getDueDate() { public LocalDate getDueDate() {
return this.dueDate; return this.dueDate;
} }
@@ -267,7 +256,7 @@ public class ClientCharge extends AbstractPersistableCustom {
return !this.status; return !this.status;
} }
public Date getInactivationDate() { public LocalDate getInactivationDate() {
return this.inactivationDate; return this.inactivationDate;
} }
@@ -19,14 +19,12 @@
package org.apache.fineract.portfolio.client.domain; package org.apache.fineract.portfolio.client.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.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.codes.domain.CodeValue; import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
@@ -76,12 +74,11 @@ public class ClientFamilyMembers extends AbstractPersistableCustom {
private CodeValue profession; private CodeValue profession;
@Column(name = "date_of_birth", nullable = true) @Column(name = "date_of_birth", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate dateOfBirth;
private Date dateOfBirth;
private ClientFamilyMembers(final Client client, final String firstName, final String middleName, final String lastName, private ClientFamilyMembers(final Client client, final String firstName, final String middleName, final String lastName,
final String qualification, final String mobileNumber, final Long age, final Boolean isDependent, final CodeValue relationship, final String qualification, final String mobileNumber, final Long age, final Boolean isDependent, final CodeValue relationship,
final CodeValue maritalStatus, final CodeValue gender, final Date dateOfBirth, final CodeValue profession) { final CodeValue maritalStatus, final CodeValue gender, final LocalDate dateOfBirth, final CodeValue profession) {
this.client = client; this.client = client;
this.firstName = firstName; this.firstName = firstName;
@@ -104,7 +101,7 @@ public class ClientFamilyMembers extends AbstractPersistableCustom {
public static ClientFamilyMembers fromJson(final Client client, final String firstName, final String middleName, final String lastName, public static ClientFamilyMembers fromJson(final Client client, final String firstName, final String middleName, final String lastName,
final String qualification, final String mobileNumber, final Long age, final Boolean isDependent, final CodeValue relationship, final String qualification, final String mobileNumber, final Long age, final Boolean isDependent, final CodeValue relationship,
final CodeValue maritalStatus, final CodeValue gender, final Date dateOfBirth, final CodeValue profession) { final CodeValue maritalStatus, final CodeValue gender, final LocalDate dateOfBirth, final CodeValue profession) {
return new ClientFamilyMembers(client, firstName, middleName, lastName, qualification, mobileNumber, age, isDependent, relationship, return new ClientFamilyMembers(client, firstName, middleName, lastName, qualification, mobileNumber, age, isDependent, relationship,
maritalStatus, gender, dateOfBirth, profession); maritalStatus, gender, dateOfBirth, profession);
} }
@@ -181,11 +178,11 @@ public class ClientFamilyMembers extends AbstractPersistableCustom {
this.profession = profession; this.profession = profession;
} }
public Date getDateOfBirth() { public LocalDate getDateOfBirth() {
return this.dateOfBirth; return this.dateOfBirth;
} }
public void setDateOfBirth(Date dateOfBirth) { public void setDateOfBirth(LocalDate dateOfBirth) {
this.dateOfBirth = dateOfBirth; this.dateOfBirth = dateOfBirth;
} }
@@ -19,9 +19,7 @@
package org.apache.fineract.portfolio.client.domain; package org.apache.fineract.portfolio.client.domain;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -32,15 +30,12 @@ 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.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.fineract.infrastructure.codes.domain.CodeValue; import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.ApiParameterError; import org.apache.fineract.infrastructure.core.data.ApiParameterError;
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom; import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.client.api.ClientApiConstants; import org.apache.fineract.portfolio.client.api.ClientApiConstants;
@Entity @Entity
@@ -59,8 +54,7 @@ public class ClientNonPerson extends AbstractPersistableCustom {
private String incorpNumber; private String incorpNumber;
@Column(name = "incorp_validity_till", nullable = true) @Column(name = "incorp_validity_till", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate incorpValidityTill;
private Date incorpValidityTill;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "main_business_line_cv_id", nullable = true) @JoinColumn(name = "main_business_line_cv_id", nullable = true)
@@ -94,18 +88,12 @@ public class ClientNonPerson extends AbstractPersistableCustom {
if (StringUtils.isNotBlank(incorpNumber)) { if (StringUtils.isNotBlank(incorpNumber)) {
this.incorpNumber = incorpNumber.trim(); this.incorpNumber = incorpNumber.trim();
} else {
this.incorpNumber = null;
} }
if (incorpValidityTill != null) { this.incorpValidityTill = incorpValidityTill;
this.incorpValidityTill = Date.from(incorpValidityTill.atStartOfDay(ZoneId.systemDefault()).toInstant());
}
if (StringUtils.isNotBlank(remarks)) { if (StringUtils.isNotBlank(remarks)) {
this.remarks = remarks.trim(); this.remarks = remarks.trim();
} else {
this.remarks = null;
} }
validate(client); validate(client);
@@ -139,11 +127,7 @@ public class ClientNonPerson extends AbstractPersistableCustom {
} }
public LocalDate getIncorpValidityTillLocalDate() { public LocalDate getIncorpValidityTillLocalDate() {
LocalDate incorpValidityTillLocalDate = null; return this.incorpValidityTill;
if (this.incorpValidityTill != null) {
incorpValidityTillLocalDate = LocalDate.ofInstant(this.incorpValidityTill.toInstant(), DateUtils.getDateTimeZoneOfTenant());
}
return incorpValidityTillLocalDate;
} }
public Long constitutionId() { public Long constitutionId() {
@@ -195,8 +179,7 @@ public class ClientNonPerson extends AbstractPersistableCustom {
actualChanges.put(ClientApiConstants.dateFormatParamName, dateFormatAsInput); actualChanges.put(ClientApiConstants.dateFormatParamName, dateFormatAsInput);
actualChanges.put(ClientApiConstants.localeParamName, localeAsInput); actualChanges.put(ClientApiConstants.localeParamName, localeAsInput);
final LocalDate newValue = command.localDateValueOfParameterNamed(ClientApiConstants.incorpValidityTillParamName); this.incorpValidityTill = command.localDateValueOfParameterNamed(ClientApiConstants.incorpValidityTillParamName);
this.incorpValidityTill = Date.from(newValue.atStartOfDay(ZoneId.systemDefault()).toInstant());
} }
if (command.isChangeInLongParameterNamed(ClientApiConstants.constitutionIdParamName, constitutionId())) { if (command.isChangeInLongParameterNamed(ClientApiConstants.constitutionIdParamName, constitutionId())) {
@@ -20,9 +20,8 @@ package org.apache.fineract.portfolio.client.domain;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@@ -36,8 +35,6 @@ 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.Transient; import javax.persistence.Transient;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
import org.apache.fineract.accounting.glaccount.domain.GLAccount; import org.apache.fineract.accounting.glaccount.domain.GLAccount;
@@ -73,9 +70,8 @@ public class ClientTransaction extends AbstractPersistableCustom {
@Column(name = "transaction_type_enum", nullable = false) @Column(name = "transaction_type_enum", nullable = false)
private Integer typeOf; private Integer typeOf;
@Temporal(TemporalType.DATE)
@Column(name = "transaction_date", nullable = false) @Column(name = "transaction_date", nullable = false)
private Date dateOf; private LocalDate dateOf;
@Column(name = "amount", scale = 6, precision = 19, nullable = false) @Column(name = "amount", scale = 6, precision = 19, nullable = false)
private BigDecimal amount; private BigDecimal amount;
@@ -86,9 +82,8 @@ public class ClientTransaction extends AbstractPersistableCustom {
@Column(name = "external_id", length = 100, nullable = true, unique = true) @Column(name = "external_id", length = 100, nullable = true, unique = true)
private String externalId; private String externalId;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "created_date", nullable = false) @Column(name = "created_date", nullable = false)
private Date createdDate; private LocalDateTime createdDate;
@ManyToOne @ManyToOne
@JoinColumn(name = "appuser_id", nullable = true) @JoinColumn(name = "appuser_id", nullable = true)
@@ -107,7 +102,7 @@ public class ClientTransaction extends AbstractPersistableCustom {
final boolean isReversed = false; final boolean isReversed = false;
final String externalId = null; final String externalId = null;
return new ClientTransaction(client, office, paymentDetail, ClientTransactionType.PAY_CHARGE.getValue(), date, amount, isReversed, return new ClientTransaction(client, office, paymentDetail, ClientTransactionType.PAY_CHARGE.getValue(), date, amount, isReversed,
externalId, DateUtils.getDateOfTenant(), currencyCode, appUser); externalId, DateUtils.getLocalDateTimeOfTenant(), currencyCode, appUser);
} }
public static ClientTransaction waiver(final Client client, final Office office, final LocalDate date, final Money amount, public static ClientTransaction waiver(final Client client, final Office office, final LocalDate date, final Money amount,
@@ -116,17 +111,17 @@ public class ClientTransaction extends AbstractPersistableCustom {
final String externalId = null; final String externalId = null;
final PaymentDetail paymentDetail = null; final PaymentDetail paymentDetail = null;
return new ClientTransaction(client, office, paymentDetail, ClientTransactionType.WAIVE_CHARGE.getValue(), date, amount, isReversed, return new ClientTransaction(client, office, paymentDetail, ClientTransactionType.WAIVE_CHARGE.getValue(), date, amount, isReversed,
externalId, DateUtils.getDateOfTenant(), currencyCode, appUser); externalId, DateUtils.getLocalDateTimeOfTenant(), currencyCode, appUser);
} }
public ClientTransaction(Client client, Office office, PaymentDetail paymentDetail, Integer typeOf, LocalDate transactionLocalDate, public ClientTransaction(Client client, Office office, PaymentDetail paymentDetail, Integer typeOf, LocalDate transactionLocalDate,
Money amount, boolean reversed, String externalId, Date createdDate, String currencyCode, AppUser appUser) { Money amount, boolean reversed, String externalId, LocalDateTime createdDate, String currencyCode, AppUser appUser) {
this.client = client; this.client = client;
this.office = office; this.office = office;
this.paymentDetail = paymentDetail; this.paymentDetail = paymentDetail;
this.typeOf = typeOf; this.typeOf = typeOf;
this.dateOf = Date.from(transactionLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); this.dateOf = transactionLocalDate;
this.amount = amount.getAmount(); this.amount = amount.getAmount();
this.reversed = reversed; this.reversed = reversed;
this.externalId = externalId; this.externalId = externalId;
@@ -228,7 +223,7 @@ public class ClientTransaction extends AbstractPersistableCustom {
} }
public LocalDate getTransactionDate() { public LocalDate getTransactionDate() {
return LocalDate.ofInstant(this.dateOf.toInstant(), DateUtils.getDateTimeZoneOfTenant()); return this.dateOf;
} }
} }
@@ -19,12 +19,10 @@
package org.apache.fineract.portfolio.client.domain; package org.apache.fineract.portfolio.client.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.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;
@SuppressWarnings("serial") @SuppressWarnings("serial")
@@ -42,23 +40,21 @@ public class ClientTransferDetails extends AbstractPersistableCustom {
private Long toOfficeId; private Long toOfficeId;
@Column(name = "proposed_transfer_date", nullable = true) @Column(name = "proposed_transfer_date", nullable = true)
@Temporal(TemporalType.DATE) private LocalDate proposedTransferDate;
private Date proposedTransferDate;
@Column(name = "transfer_type", nullable = false) @Column(name = "transfer_type", nullable = false)
private Integer transferEventType; private Integer transferEventType;
@Column(name = "submitted_on", nullable = false) @Column(name = "submitted_on", nullable = false)
@Temporal(TemporalType.DATE) private LocalDate submittedOn;
private Date submittedOn;
@Column(name = "submitted_by", nullable = false) @Column(name = "submitted_by", nullable = false)
private Long submittedBy; private Long submittedBy;
protected ClientTransferDetails() {} protected ClientTransferDetails() {}
private ClientTransferDetails(final Long clientId, final Long fromOfficeId, final Long toOfficeId, final Date proposedTransferDate, private ClientTransferDetails(final Long clientId, final Long fromOfficeId, final Long toOfficeId, final LocalDate proposedTransferDate,
final Integer transferEventType, final Date submittedOn, final Long submittedBy) { final Integer transferEventType, final LocalDate submittedOn, final Long submittedBy) {
this.clientId = clientId; this.clientId = clientId;
this.fromOfficeId = fromOfficeId; this.fromOfficeId = fromOfficeId;
this.toOfficeId = toOfficeId; this.toOfficeId = toOfficeId;
@@ -69,7 +65,7 @@ public class ClientTransferDetails extends AbstractPersistableCustom {
} }
public static ClientTransferDetails instance(final Long clientId, final Long fromOfficeId, final Long toOfficeId, public static ClientTransferDetails instance(final Long clientId, final Long fromOfficeId, final Long toOfficeId,
final Date proposedTransferDate, final Integer transferEventType, final Date submittedOn, final Long submittedBy) { final LocalDate proposedTransferDate, final Integer transferEventType, final LocalDate submittedOn, final Long submittedBy) {
return new ClientTransferDetails(clientId, fromOfficeId, toOfficeId, proposedTransferDate, transferEventType, submittedOn, return new ClientTransferDetails(clientId, fromOfficeId, toOfficeId, proposedTransferDate, transferEventType, submittedOn,
submittedBy); submittedBy);
@@ -22,10 +22,10 @@ package org.apache.fineract.portfolio.client.service;
import com.google.gson.JsonArray; 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.text.DateFormat; import java.time.LocalDate;
import java.text.ParseException; import java.time.format.DateTimeFormatter;
import java.text.SimpleDateFormat; import java.time.format.DateTimeFormatterBuilder;
import java.util.Date; import java.time.format.DateTimeParseException;
import org.apache.fineract.infrastructure.codes.domain.CodeValue; import org.apache.fineract.infrastructure.codes.domain.CodeValue;
import org.apache.fineract.infrastructure.codes.domain.CodeValueRepository; import org.apache.fineract.infrastructure.codes.domain.CodeValueRepository;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -82,40 +82,19 @@ public class ClientFamilyMembersWritePlatformServiceImpl implements ClientFamily
String mobileNumber = ""; String mobileNumber = "";
Long age = null; Long age = null;
Boolean isDependent = false; Boolean isDependent = false;
Date dateOfBirth = null; LocalDate dateOfBirth = null;
this.context.authenticatedUser(); this.context.authenticatedUser();
apiJsonDeserializer.validateForCreate(clientId, command.json()); apiJsonDeserializer.validateForCreate(clientId, command.json());
Client client = clientRepositoryWrapper.findOneWithNotFoundDetection(clientId); Client client = clientRepositoryWrapper.findOneWithNotFoundDetection(clientId);
firstName = command.stringValueOfParameterNamed("firstName");
if (command.stringValueOfParameterNamed("firstName") != null) { middleName = command.stringValueOfParameterNamed("middleName");
firstName = command.stringValueOfParameterNamed("firstName"); lastName = command.stringValueOfParameterNamed("lastName");
} qualification = command.stringValueOfParameterNamed("qualification");
mobileNumber = command.stringValueOfParameterNamed("mobileNumber");
if (command.stringValueOfParameterNamed("middleName") != null) { age = command.longValueOfParameterNamed("age");
middleName = command.stringValueOfParameterNamed("middleName"); isDependent = command.booleanObjectValueOfParameterNamed("isDependent");
}
if (command.stringValueOfParameterNamed("lastName") != null) {
lastName = command.stringValueOfParameterNamed("lastName");
}
if (command.stringValueOfParameterNamed("qualification") != null) {
qualification = command.stringValueOfParameterNamed("qualification");
}
if (command.stringValueOfParameterNamed("mobileNumber") != null) {
mobileNumber = command.stringValueOfParameterNamed("mobileNumber");
}
if (command.longValueOfParameterNamed("age") != null) {
age = command.longValueOfParameterNamed("age");
}
if (command.booleanObjectValueOfParameterNamed("isDependent") != null) {
isDependent = command.booleanObjectValueOfParameterNamed("isDependent");
}
if (command.longValueOfParameterNamed("relationshipId") != null) { if (command.longValueOfParameterNamed("relationshipId") != null) {
relationshipId = command.longValueOfParameterNamed("relationshipId"); relationshipId = command.longValueOfParameterNamed("relationshipId");
@@ -137,10 +116,7 @@ public class ClientFamilyMembersWritePlatformServiceImpl implements ClientFamily
profession = this.codeValueRepository.getReferenceById(professionId); profession = this.codeValueRepository.getReferenceById(professionId);
} }
if (command.dateValueOfParameterNamed("dateOfBirth") != null) { dateOfBirth = command.localDateValueOfParameterNamed("dateOfBirth");
dateOfBirth = command.dateValueOfParameterNamed("dateOfBirth");
}
ClientFamilyMembers clientFamilyMembers = ClientFamilyMembers.fromJson(client, firstName, middleName, lastName, qualification, ClientFamilyMembers clientFamilyMembers = ClientFamilyMembers.fromJson(client, firstName, middleName, lastName, qualification,
mobileNumber, age, isDependent, relationship, maritalStatus, gender, dateOfBirth, profession); mobileNumber, age, isDependent, relationship, maritalStatus, gender, dateOfBirth, profession);
@@ -166,7 +142,7 @@ public class ClientFamilyMembersWritePlatformServiceImpl implements ClientFamily
String middleName = ""; String middleName = "";
String lastName = ""; String lastName = "";
String qualification = ""; String qualification = "";
Date dateOfBirth = null; LocalDate dateOfBirth = null;
String mobileNumber = ""; String mobileNumber = "";
Long age = null; Long age = null;
Boolean isDependent = false; Boolean isDependent = false;
@@ -238,12 +214,13 @@ public class ClientFamilyMembersWritePlatformServiceImpl implements ClientFamily
if (member.get("dateOfBirth") != null) { if (member.get("dateOfBirth") != null) {
DateFormat format = new SimpleDateFormat(member.get("dateFormat").getAsString()); DateTimeFormatter formatter = new DateTimeFormatterBuilder().appendPattern(member.get("dateFormat").getAsString())
Date date; .toFormatter();
LocalDate date;
try { try {
date = format.parse(member.get("dateOfBirth").getAsString()); date = LocalDate.parse(member.get("dateOfBirth").getAsString(), formatter);
dateOfBirth = date; dateOfBirth = date;
} catch (ParseException e) { } catch (DateTimeParseException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
LOG.error("Problem occurred in addClientFamilyMember function", e); LOG.error("Problem occurred in addClientFamilyMember function", e);
} }
@@ -280,7 +257,7 @@ public class ClientFamilyMembersWritePlatformServiceImpl implements ClientFamily
String middleName = ""; String middleName = "";
String lastName = ""; String lastName = "";
String qualification = ""; String qualification = "";
Date dateOfBirth = null; LocalDate dateOfBirth = null;
String mobileNumber = ""; String mobileNumber = "";
Long age = null; Long age = null;
Boolean isDependent = false; Boolean isDependent = false;
@@ -359,8 +336,8 @@ public class ClientFamilyMembersWritePlatformServiceImpl implements ClientFamily
clientFamilyMember.setProfession(profession); clientFamilyMember.setProfession(profession);
} }
if (command.dateValueOfParameterNamed("dateOfBirth") != null) { if (command.localDateValueOfParameterNamed("dateOfBirth") != null) {
dateOfBirth = command.dateValueOfParameterNamed("dateOfBirth"); dateOfBirth = command.localDateValueOfParameterNamed("dateOfBirth");
clientFamilyMember.setDateOfBirth(dateOfBirth); clientFamilyMember.setDateOfBirth(dateOfBirth);
} }
@@ -18,8 +18,8 @@
*/ */
package org.apache.fineract.portfolio.client.service; package org.apache.fineract.portfolio.client.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.portfolio.client.data.ClientData; import org.apache.fineract.portfolio.client.data.ClientData;
@@ -57,7 +57,7 @@ public interface ClientReadPlatformService {
*/ */
Collection<Long> retrieveUserClients(Long aUserID); Collection<Long> retrieveUserClients(Long aUserID);
Date retrieveClientTransferProposalDate(Long clientId); LocalDate retrieveClientTransferProposalDate(Long clientId);
void validateClient(Long clientId); void validateClient(Long clientId);
} }
@@ -25,7 +25,6 @@ import java.time.LocalDate;
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.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@@ -845,11 +844,11 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
} }
@Override @Override
public Date retrieveClientTransferProposalDate(Long clientId) { public LocalDate retrieveClientTransferProposalDate(Long clientId) {
validateClient(clientId); validateClient(clientId);
final String sql = "SELECT cl.proposed_transfer_date FROM m_client cl WHERE cl.id =? "; final String sql = "SELECT cl.proposed_transfer_date FROM m_client cl WHERE cl.id =? ";
try { try {
return this.jdbcTemplate.queryForObject(sql, Date.class, clientId); return this.jdbcTemplate.queryForObject(sql, LocalDate.class, clientId);
} catch (final EmptyResultDataAccessException e) { } catch (final EmptyResultDataAccessException e) {
return null; return null;
} }
@@ -20,9 +20,7 @@ package org.apache.fineract.portfolio.client.service;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@@ -748,7 +746,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
} }
} }
client.close(currentUser, closureReason, Date.from(closureDate.atStartOfDay(ZoneId.systemDefault()).toInstant())); client.close(currentUser, closureReason, closureDate);
this.clientRepository.saveAndFlush(client); this.clientRepository.saveAndFlush(client);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -842,7 +840,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
throw new InvalidClientStateTransitionException("rejection", "date.cannot.before.client.submitted.date", errorMessage, throw new InvalidClientStateTransitionException("rejection", "date.cannot.before.client.submitted.date", errorMessage,
rejectionDate, client.getSubmittedOnDate()); rejectionDate, client.getSubmittedOnDate());
} }
client.reject(currentUser, rejectionReason, Date.from(rejectionDate.atStartOfDay(ZoneId.systemDefault()).toInstant())); client.reject(currentUser, rejectionReason, rejectionDate);
clientRepository.saveAndFlush(client); clientRepository.saveAndFlush(client);
businessEventNotifierService.notifyPostBusinessEvent(new ClientRejectBusinessEvent(client)); businessEventNotifierService.notifyPostBusinessEvent(new ClientRejectBusinessEvent(client));
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -873,7 +871,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
throw new InvalidClientStateTransitionException("withdrawal", "date.cannot.before.client.submitted.date", errorMessage, throw new InvalidClientStateTransitionException("withdrawal", "date.cannot.before.client.submitted.date", errorMessage,
withdrawalDate, client.getSubmittedOnDate()); withdrawalDate, client.getSubmittedOnDate());
} }
client.withdraw(currentUser, withdrawalReason, Date.from(withdrawalDate.atStartOfDay(ZoneId.systemDefault()).toInstant())); client.withdraw(currentUser, withdrawalReason, withdrawalDate);
this.clientRepository.saveAndFlush(client); this.clientRepository.saveAndFlush(client);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -898,7 +896,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
throw new InvalidClientStateTransitionException("reactivation", "date.cannot.before.client.closed.date", errorMessage, throw new InvalidClientStateTransitionException("reactivation", "date.cannot.before.client.closed.date", errorMessage,
reactivateDate, client.getClosureDate()); reactivateDate, client.getClosureDate());
} }
client.reActivate(currentUser, Date.from(reactivateDate.atStartOfDay(ZoneId.systemDefault()).toInstant())); client.reActivate(currentUser, reactivateDate);
this.clientRepository.saveAndFlush(client); this.clientRepository.saveAndFlush(client);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) // .withCommandId(command.commandId()) //
@@ -924,7 +922,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
undoRejectDate, client.getRejectedDate()); undoRejectDate, client.getRejectedDate());
} }
client.reOpened(currentUser, Date.from(undoRejectDate.atStartOfDay(ZoneId.systemDefault()).toInstant())); client.reOpened(currentUser, undoRejectDate);
this.clientRepository.saveAndFlush(client); this.clientRepository.saveAndFlush(client);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -950,7 +948,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
throw new InvalidClientStateTransitionException("reopened", "date.cannot.before.client.withdrawal.date", errorMessage, throw new InvalidClientStateTransitionException("reopened", "date.cannot.before.client.withdrawal.date", errorMessage,
undoWithdrawalDate, client.getWithdrawalDate()); undoWithdrawalDate, client.getWithdrawalDate());
} }
client.reOpened(currentUser, Date.from(undoWithdrawalDate.atStartOfDay(ZoneId.systemDefault()).toInstant())); client.reOpened(currentUser, undoWithdrawalDate);
this.clientRepository.saveAndFlush(client); this.clientRepository.saveAndFlush(client);
return new CommandProcessingResultBuilder() // return new CommandProcessingResultBuilder() //
@@ -42,8 +42,7 @@ public class ClientAttributeIncentiveCalculation extends AttributeIncentiveCalcu
break; break;
case AGE: case AGE:
if (client.dateOfBirth() != null) { if (client.dateOfBirth() != null) {
final LocalDate dobLocalDate = LocalDate.ofInstant(client.dateOfBirth().toInstant(), final LocalDate dobLocalDate = client.dateOfBirth();
DateUtils.getDateTimeZoneOfTenant());
final int age = Math.toIntExact(ChronoUnit.YEARS.between(dobLocalDate, DateUtils.getBusinessLocalDate())); final int age = Math.toIntExact(ChronoUnit.YEARS.between(dobLocalDate, DateUtils.getBusinessLocalDate()));
applyIncentive = applyIncentive(incentivesFields.conditionType(), Long.valueOf(incentivesFields.attributeValue()), applyIncentive = applyIncentive(incentivesFields.conditionType(), Long.valueOf(incentivesFields.attributeValue()),
(long) age); (long) age);
@@ -21,9 +21,7 @@ package org.apache.fineract.portfolio.transfer.service;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.fineract.infrastructure.core.api.JsonCommand; import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
@@ -474,7 +472,7 @@ public class TransferWritePlatformServiceJpaRepositoryImpl implements TransferWr
case PROPOSAL: case PROPOSAL:
client.setStatus(ClientStatus.TRANSFER_IN_PROGRESS.getValue()); client.setStatus(ClientStatus.TRANSFER_IN_PROGRESS.getValue());
client.updateTransferToOffice(destinationOffice); client.updateTransferToOffice(destinationOffice);
client.updateProposedTransferDate(Date.from(transferDate.atStartOfDay(ZoneId.systemDefault()).toInstant())); client.updateProposedTransferDate(transferDate);
break; break;
case REJECTION: case REJECTION:
client.setStatus(ClientStatus.TRANSFER_ON_HOLD.getValue()); client.setStatus(ClientStatus.TRANSFER_ON_HOLD.getValue());
@@ -488,10 +486,9 @@ public class TransferWritePlatformServiceJpaRepositoryImpl implements TransferWr
} }
this.noteWritePlatformService.createAndPersistClientNote(client, jsonCommand); this.noteWritePlatformService.createAndPersistClientNote(client, jsonCommand);
Date proposedTransferDate = transferDate != null ? Date.from(transferDate.atStartOfDay(ZoneId.systemDefault()).toInstant()) : null; this.clientTransferDetailsRepositoryWrapper
this.clientTransferDetailsRepositoryWrapper.save( .save(ClientTransferDetails.instance(client.getId(), client.getOffice().getId(), destinationOffice.getId(), transferDate,
ClientTransferDetails.instance(client.getId(), client.getOffice().getId(), destinationOffice.getId(), proposedTransferDate, transferEventType.getValue(), DateUtils.getBusinessLocalDate(), this.context.authenticatedUser().getId()));
transferEventType.getValue(), DateUtils.getBusinessDate(), this.context.authenticatedUser().getId()));
} }
private List<Client> assembleListOfClients(final JsonCommand command) { private List<Client> assembleListOfClients(final JsonCommand command) {