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