clean up for close client
This commit is contained in:
+9
-7
@@ -15,6 +15,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.JoinTable;
|
import javax.persistence.JoinTable;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
@@ -29,6 +30,7 @@ import javax.persistence.UniqueConstraint;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
|
import org.mifosplatform.infrastructure.codes.domain.CodeValue;
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
|
||||||
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
|
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
|
||||||
@@ -96,8 +98,9 @@ public final class Client extends AbstractPersistable<Long> {
|
|||||||
@Transient
|
@Transient
|
||||||
private boolean accountNumberRequiresAutoGeneration = false;
|
private boolean accountNumberRequiresAutoGeneration = false;
|
||||||
|
|
||||||
@Column(name = "closure_reason_cv_id", nullable = true)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
private Long closureReasonId;
|
@JoinColumn(name = "closure_reason_cv_id", nullable = true)
|
||||||
|
private CodeValue closureReason;
|
||||||
|
|
||||||
@Column(name = "closedon_date", nullable = true)
|
@Column(name = "closedon_date", nullable = true)
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
@@ -253,7 +256,7 @@ public final class Client extends AbstractPersistable<Long> {
|
|||||||
return ClientStatus.fromInt(this.status).isActive();
|
return ClientStatus.fromInt(this.status).isActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTransferInProgress () {
|
public boolean isTransferInProgress() {
|
||||||
return ClientStatus.fromInt(this.status).isTransferInProgress();
|
return ClientStatus.fromInt(this.status).isTransferInProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,13 +465,12 @@ public final class Client extends AbstractPersistable<Long> {
|
|||||||
this.staff = staff;
|
this.staff = staff;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Group> getGroups(){
|
public Set<Group> getGroups() {
|
||||||
return this.groups;
|
return this.groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void close(final CodeValue closureReason, final Date closureDate) {
|
||||||
public void close(final Long closureReasonId, final Date closureDate) {
|
this.closureReason = closureReason;
|
||||||
this.closureReasonId = closureReasonId;
|
|
||||||
this.closureDate = closureDate;
|
this.closureDate = closureDate;
|
||||||
this.status = ClientStatus.CLOSED.getValue();
|
this.status = ClientStatus.CLOSED.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -13,6 +13,7 @@ import java.util.Map;
|
|||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.joda.time.format.DateTimeFormat;
|
import org.joda.time.format.DateTimeFormat;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
|
import org.mifosplatform.infrastructure.codes.domain.CodeValue;
|
||||||
import org.mifosplatform.infrastructure.codes.domain.CodeValueRepositoryWrapper;
|
import org.mifosplatform.infrastructure.codes.domain.CodeValueRepositoryWrapper;
|
||||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||||
@@ -337,7 +338,8 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
|||||||
final LocalDate closureDate = command.localDateValueOfParameterNamed(ClientApiConstants.closureDateParamName);
|
final LocalDate closureDate = command.localDateValueOfParameterNamed(ClientApiConstants.closureDateParamName);
|
||||||
final Long closureReasonId = command.longValueOfParameterNamed(ClientApiConstants.closureReasonIdParamName);
|
final Long closureReasonId = command.longValueOfParameterNamed(ClientApiConstants.closureReasonIdParamName);
|
||||||
|
|
||||||
this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(ClientApiConstants.CLIENT_CLOSURE_REASON, closureReasonId);
|
CodeValue closureReason = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(
|
||||||
|
ClientApiConstants.CLIENT_CLOSURE_REASON, closureReasonId);
|
||||||
|
|
||||||
if (ClientStatus.fromInt(client.getStatus()).isClosed()) {
|
if (ClientStatus.fromInt(client.getStatus()).isClosed()) {
|
||||||
final String errorMessage = "Client is alread closed.";
|
final String errorMessage = "Client is alread closed.";
|
||||||
@@ -384,7 +386,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client.close(closureReasonId, closureDate.toDate());
|
client.close(closureReason, closureDate.toDate());
|
||||||
this.clientRepository.saveAndFlush(client);
|
this.clientRepository.saveAndFlush(client);
|
||||||
|
|
||||||
return new CommandProcessingResultBuilder() //
|
return new CommandProcessingResultBuilder() //
|
||||||
|
|||||||
Reference in New Issue
Block a user