some formatting changes and cleanup of status for deposit accounts.
This commit is contained in:
+2
-9
@@ -68,7 +68,8 @@ public class DepositAccountsApiResource {
|
|||||||
"deposit", "maturityInterestRate", "tenureInMonths",
|
"deposit", "maturityInterestRate", "tenureInMonths",
|
||||||
"interestCompoundedEvery",
|
"interestCompoundedEvery",
|
||||||
"interestCompoundedEveryPeriodType", "renewalAllowed",
|
"interestCompoundedEveryPeriodType", "renewalAllowed",
|
||||||
"preClosureAllowed", "preClosureInterestRate", "statusEnum","withdrawnonDate","rejectedonDate","closedonDate"));
|
"preClosureAllowed", "preClosureInterestRate",
|
||||||
|
"withdrawnonDate","rejectedonDate","closedonDate"));
|
||||||
|
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@@ -188,29 +189,21 @@ public class DepositAccountsApiResource {
|
|||||||
public Response SubmitDepositApplication(@PathParam("accountId") final Long accountId,
|
public Response SubmitDepositApplication(@PathParam("accountId") final Long accountId,
|
||||||
@QueryParam("command") final String commandParam, final String jsonRequestBody) {
|
@QueryParam("command") final String commandParam, final String jsonRequestBody) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Response response=null;
|
Response response=null;
|
||||||
|
|
||||||
if (is(commandParam, "approve")) {
|
if (is(commandParam, "approve")) {
|
||||||
|
|
||||||
DepositStateTransitionApprovalCommand command=apiDataConversionService.convertJsonToDepositStateTransitionApprovalCommand(accountId, jsonRequestBody);
|
DepositStateTransitionApprovalCommand command=apiDataConversionService.convertJsonToDepositStateTransitionApprovalCommand(accountId, jsonRequestBody);
|
||||||
EntityIdentifier identifier = this.depositAccountWritePlatformService.approveDepositApplication(command);
|
EntityIdentifier identifier = this.depositAccountWritePlatformService.approveDepositApplication(command);
|
||||||
response = Response.ok().entity(identifier).build();
|
response = Response.ok().entity(identifier).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (is(commandParam, "reject")) {
|
else if (is(commandParam, "reject")) {
|
||||||
|
|
||||||
DepositStateTransitionCommand command=apiDataConversionService.convertJsonToDepositStateTransitionCommand(accountId, jsonRequestBody);
|
DepositStateTransitionCommand command=apiDataConversionService.convertJsonToDepositStateTransitionCommand(accountId, jsonRequestBody);
|
||||||
EntityIdentifier identifier = this.depositAccountWritePlatformService.rejectDepositApplication(command);
|
EntityIdentifier identifier = this.depositAccountWritePlatformService.rejectDepositApplication(command);
|
||||||
response = Response.ok().entity(identifier).build();
|
response = Response.ok().entity(identifier).build();
|
||||||
|
|
||||||
} else if (is(commandParam, "withdrewbyclient")) {
|
} else if (is(commandParam, "withdrewbyclient")) {
|
||||||
|
|
||||||
DepositStateTransitionCommand command=apiDataConversionService.convertJsonToDepositStateTransitionCommand(accountId, jsonRequestBody);
|
DepositStateTransitionCommand command=apiDataConversionService.convertJsonToDepositStateTransitionCommand(accountId, jsonRequestBody);
|
||||||
EntityIdentifier identifier = this.depositAccountWritePlatformService.withdrawDepositApplication(command);
|
EntityIdentifier identifier = this.depositAccountWritePlatformService.withdrawDepositApplication(command);
|
||||||
response = Response.ok().entity(identifier).build();
|
response = Response.ok().entity(identifier).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UndoStateTransitionCommand undoCommand = new UndoStateTransitionCommand(accountId);
|
UndoStateTransitionCommand undoCommand = new UndoStateTransitionCommand(accountId);
|
||||||
|
|||||||
+25
-25
@@ -62,7 +62,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChargeCommand convertJsonToChargeCommand(Long resourceIdentifier, String json) {
|
public ChargeCommand convertJsonToChargeCommand(final Long resourceIdentifier, final String json) {
|
||||||
if (StringUtils.isBlank(json)) {
|
if (StringUtils.isBlank(json)) {
|
||||||
throw new InvalidJsonException();
|
throw new InvalidJsonException();
|
||||||
}
|
}
|
||||||
@@ -1030,29 +1030,29 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DepositStateTransitionApprovalCommand convertJsonToDepositStateTransitionApprovalCommand(
|
public DepositStateTransitionApprovalCommand convertJsonToDepositStateTransitionApprovalCommand(
|
||||||
Long resourceIdentifier, String json) {
|
final Long resourceIdentifier, final String json) {
|
||||||
|
|
||||||
if (StringUtils.isBlank(json)) {
|
if (StringUtils.isBlank(json)) {
|
||||||
throw new InvalidJsonException();
|
throw new InvalidJsonException();
|
||||||
}
|
|
||||||
|
|
||||||
Type typeOfMap = new TypeToken<Map<String, Object>>(){}.getType();
|
|
||||||
Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
|
||||||
|
|
||||||
Set<String> supportedParams = new HashSet<String>( Arrays.asList("locale","eventDate", "dateFormat", "tenureInMonths", "depositAmount", "interestCompoundedEveryPeriodType", "productId","interestCompoundedEvery"));
|
|
||||||
|
|
||||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
|
||||||
|
|
||||||
Set<String> modifiedParameters = new HashSet<String>();
|
|
||||||
|
|
||||||
LocalDate eventDate = extractLocalDateParameter("eventDate", requestMap, modifiedParameters);
|
|
||||||
BigDecimal depositAmount=extractBigDecimalParameter("depositAmount", requestMap, modifiedParameters);
|
|
||||||
Integer tenureInMonths = extractIntegerParameter("tenureInMonths", requestMap, modifiedParameters);
|
|
||||||
Integer interestCompoundedEveryPeriodType = extractIntegerParameter("interestCompoundedEveryPeriodType", requestMap, modifiedParameters);
|
|
||||||
Integer interestCompoundedEvery = extractIntegerParameter("interestCompoundedEvery", requestMap, modifiedParameters);
|
|
||||||
Long productId = extractLongParameter("productId", requestMap, modifiedParameters);
|
|
||||||
|
|
||||||
return new DepositStateTransitionApprovalCommand(resourceIdentifier, productId, eventDate, tenureInMonths, depositAmount, interestCompoundedEveryPeriodType,interestCompoundedEvery);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Type typeOfMap = new TypeToken<Map<String, String>>(){}.getType();
|
||||||
|
Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||||
|
|
||||||
|
Set<String> supportedParams = new HashSet<String>(Arrays.asList("locale","eventDate", "dateFormat", "tenureInMonths", "depositAmount", "interestCompoundedEveryPeriodType", "productId","interestCompoundedEvery"));
|
||||||
|
|
||||||
|
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||||
|
|
||||||
|
Set<String> modifiedParameters = new HashSet<String>();
|
||||||
|
|
||||||
|
LocalDate eventDate = extractLocalDateParameter("eventDate", requestMap, modifiedParameters);
|
||||||
|
BigDecimal depositAmount=extractBigDecimalParameter("depositAmount", requestMap, modifiedParameters);
|
||||||
|
Integer tenureInMonths = extractIntegerParameter("tenureInMonths", requestMap, modifiedParameters);
|
||||||
|
Integer interestCompoundedEveryPeriodType = extractIntegerParameter("interestCompoundedEveryPeriodType", requestMap, modifiedParameters);
|
||||||
|
Integer interestCompoundedEvery = extractIntegerParameter("interestCompoundedEvery", requestMap, modifiedParameters);
|
||||||
|
Long productId = extractLongParameter("productId", requestMap, modifiedParameters);
|
||||||
|
|
||||||
|
return new DepositStateTransitionApprovalCommand(resourceIdentifier, productId, eventDate, tenureInMonths, depositAmount, interestCompoundedEveryPeriodType,interestCompoundedEvery);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+104
-72
@@ -6,8 +6,6 @@ import java.util.Date;
|
|||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Embedded;
|
import javax.persistence.Embedded;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EnumType;
|
|
||||||
import javax.persistence.Enumerated;
|
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
@@ -30,10 +28,12 @@ import org.mifosng.platform.user.domain.AppUser;
|
|||||||
@Table(name = "m_deposit_account", uniqueConstraints = @UniqueConstraint(name="deposit_acc_external_id", columnNames = { "external_id" }))
|
@Table(name = "m_deposit_account", uniqueConstraints = @UniqueConstraint(name="deposit_acc_external_id", columnNames = { "external_id" }))
|
||||||
public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "client_id", nullable = false)
|
@JoinColumn(name = "client_id", nullable = false)
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "product_id")
|
@JoinColumn(name = "product_id")
|
||||||
private final DepositProduct product;
|
private final DepositProduct product;
|
||||||
@@ -41,24 +41,27 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
@Column(name = "external_id")
|
@Column(name = "external_id")
|
||||||
private String externalId;
|
private String externalId;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Embedded
|
@Embedded
|
||||||
private MonetaryCurrency currency;
|
private MonetaryCurrency currency;
|
||||||
|
|
||||||
@Column(name = "deposit_amount", scale = 6, precision = 19, nullable = false)
|
@Column(name = "deposit_amount", scale = 6, precision = 19, nullable = false)
|
||||||
private BigDecimal depositAmount;
|
private BigDecimal depositAmount;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "maturity_nominal_interest_rate", scale = 6, precision = 19, nullable = false)
|
@Column(name = "maturity_nominal_interest_rate", scale = 6, precision = 19, nullable = false)
|
||||||
private BigDecimal interestRate;
|
private BigDecimal interestRate;
|
||||||
|
|
||||||
@Column(name = "tenure_months", nullable=false)
|
@Column(name = "tenure_months", nullable=false)
|
||||||
private Integer tenureInMonths;
|
private Integer tenureInMonths;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "interest_compounded_every", nullable = false)
|
@Column(name = "interest_compounded_every", nullable = false)
|
||||||
private Integer interestCompoundedEvery;
|
private Integer interestCompoundedEvery;
|
||||||
|
|
||||||
@Enumerated(EnumType.ORDINAL)
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "interest_compounded_every_period_enum", nullable = false)
|
@Column(name = "interest_compounded_every_period_enum", nullable = false)
|
||||||
private PeriodFrequencyType interestCompoundedFrequencyType;
|
private Integer interestCompoundedFrequencyType;
|
||||||
|
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
@Column(name = "projected_commencement_date")
|
@Column(name = "projected_commencement_date")
|
||||||
@@ -68,32 +71,41 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
@Column(name = "actual_commencement_date")
|
@Column(name = "actual_commencement_date")
|
||||||
private Date actualCommencementDate;
|
private Date actualCommencementDate;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
@Column(name = "projected_maturity_date")
|
@Column(name = "projected_maturity_date")
|
||||||
private Date projectedMaturityDate;
|
private Date projectedMaturityDate;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
@Column(name = "actual_maturity_date")
|
@Column(name = "actual_maturity_date")
|
||||||
private Date actualMaturityDate;
|
private Date actualMaturityDate;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "projected_interest_accrued_on_maturity", scale = 6, precision = 19, nullable = false)
|
@Column(name = "projected_interest_accrued_on_maturity", scale = 6, precision = 19, nullable = false)
|
||||||
private BigDecimal projectedInterestAccruedOnMaturity;
|
private BigDecimal projectedInterestAccruedOnMaturity;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "actual_interest_accrued", scale = 6, precision = 19, nullable = false)
|
@Column(name = "actual_interest_accrued", scale = 6, precision = 19, nullable = false)
|
||||||
private BigDecimal interestAccrued;
|
private BigDecimal interestAccrued;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "projected_total_maturity_amount", scale = 6, precision = 19, nullable = false)
|
@Column(name = "projected_total_maturity_amount", scale = 6, precision = 19, nullable = false)
|
||||||
private BigDecimal projectedTotalOnMaturity;
|
private BigDecimal projectedTotalOnMaturity;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "actual_total_amount", scale = 6, precision = 19, nullable = false)
|
@Column(name = "actual_total_amount", scale = 6, precision = 19, nullable = false)
|
||||||
private BigDecimal total;
|
private BigDecimal total;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "pre_closure_interest_rate", scale = 6, precision = 19, nullable = false)
|
@Column(name = "pre_closure_interest_rate", scale = 6, precision = 19, nullable = false)
|
||||||
private BigDecimal preClosureInterestRate;
|
private BigDecimal preClosureInterestRate;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "is_renewal_allowed", nullable = false)
|
@Column(name = "is_renewal_allowed", nullable = false)
|
||||||
private boolean renewalAllowed = false;
|
private boolean renewalAllowed = false;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Column(name = "is_preclosure_allowed", nullable = false)
|
@Column(name = "is_preclosure_allowed", nullable = false)
|
||||||
private boolean preClosureAllowed = false;
|
private boolean preClosureAllowed = false;
|
||||||
|
|
||||||
@@ -103,14 +115,17 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
@Column(name = "status_enum", nullable = false)
|
@Column(name = "status_enum", nullable = false)
|
||||||
private Integer depositStatus;
|
private Integer depositStatus;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
@Column(name = "closedon_date")
|
@Column(name = "closedon_date")
|
||||||
private Date closedOnDate;
|
private Date closedOnDate;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
@Column(name = "rejectedon_date")
|
@Column(name = "rejectedon_date")
|
||||||
private Date rejectedOnDate;
|
private Date rejectedOnDate;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
@Column(name = "withdrawnon_date")
|
@Column(name = "withdrawnon_date")
|
||||||
private Date withdrawnOnDate;
|
private Date withdrawnOnDate;
|
||||||
@@ -167,7 +182,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
this.tenureInMonths = termInMonths;
|
this.tenureInMonths = termInMonths;
|
||||||
|
|
||||||
this.interestCompoundedEvery = interestCompoundedEvery;
|
this.interestCompoundedEvery = interestCompoundedEvery;
|
||||||
this.interestCompoundedFrequencyType = interestCompoundedFrequencyPeriodType;
|
this.interestCompoundedFrequencyType = interestCompoundedFrequencyPeriodType.getValue();
|
||||||
if (commencementDate != null) {
|
if (commencementDate != null) {
|
||||||
this.projectedCommencementDate = commencementDate.toDate();
|
this.projectedCommencementDate = commencementDate.toDate();
|
||||||
this.projectedMaturityDate = commencementDate.plusMonths(this.tenureInMonths).toDate();
|
this.projectedMaturityDate = commencementDate.plusMonths(this.tenureInMonths).toDate();
|
||||||
@@ -202,14 +217,18 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void approve(final LocalDate actualCommencementDate, DepositLifecycleStateMachine depositLifecycleStateMachine, DepositApprovalData depositApprovalData, BigDecimal depositAmount) {
|
public void approve(
|
||||||
|
final LocalDate actualCommencementDate,
|
||||||
|
final DepositLifecycleStateMachine depositLifecycleStateMachine,
|
||||||
|
final DepositApprovalData depositApprovalData,
|
||||||
|
final BigDecimal depositAmount) {
|
||||||
|
|
||||||
DepositStatus statusEnum = depositLifecycleStateMachine.transition(DepositEvent.DEPOSIT_APPROVED, DepositStatus.fromInt(this.depositStatus));
|
DepositStatus statusEnum = depositLifecycleStateMachine.transition(DepositEvent.DEPOSIT_APPROVED, DepositStatus.fromInt(this.depositStatus));
|
||||||
this.depositStatus = statusEnum.getValue();
|
this.depositStatus = statusEnum.getValue();
|
||||||
|
|
||||||
this.tenureInMonths = depositApprovalData.getTenureInMonths();
|
this.tenureInMonths = depositApprovalData.getTenureInMonths();
|
||||||
this.depositAmount = depositAmount;
|
this.depositAmount = depositAmount;
|
||||||
this.interestCompoundedFrequencyType = depositApprovalData.getInterestCompoundedEveryPeriodType();
|
this.interestCompoundedFrequencyType = depositApprovalData.getInterestCompoundedEveryPeriodType().getValue();
|
||||||
|
|
||||||
this.actualCommencementDate = actualCommencementDate.toDateTimeAtCurrentTime().toDate();
|
this.actualCommencementDate = actualCommencementDate.toDateTimeAtCurrentTime().toDate();
|
||||||
|
|
||||||
@@ -236,75 +255,88 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getActualCommencementDate() {
|
public LocalDate getActualCommencementDate() {
|
||||||
LocalDate date=null;
|
LocalDate date = null;
|
||||||
if(this.actualCommencementDate!=null){
|
if (this.actualCommencementDate != null) {
|
||||||
date = new LocalDate(this.actualCommencementDate);
|
date = new LocalDate(this.actualCommencementDate);
|
||||||
}
|
}
|
||||||
return date;
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDate getProjectedCommencementDate() {
|
||||||
|
LocalDate date = null;
|
||||||
|
if (this.projectedCommencementDate != null) {
|
||||||
|
date = new LocalDate(this.projectedCommencementDate);
|
||||||
|
}
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reject(final LocalDate rejectedOn,
|
||||||
|
final DepositLifecycleStateMachine depositLifecycleStateMachine) {
|
||||||
|
|
||||||
|
DepositStatus statusEnum = depositLifecycleStateMachine.transition(
|
||||||
|
DepositEvent.DEPOSIT_REJECTED,
|
||||||
|
DepositStatus.fromInt(this.depositStatus));
|
||||||
|
this.depositStatus = statusEnum.getValue();
|
||||||
|
|
||||||
|
this.rejectedOnDate = rejectedOn.toDateTimeAtCurrentTime().toDate();
|
||||||
|
this.closedOnDate = rejectedOn.toDateTimeAtCurrentTime().toDate();
|
||||||
|
|
||||||
|
if (rejectedOn.isBefore(getProjectedCommencementDate())) {
|
||||||
|
|
||||||
|
final String errorMessage = "The date on which a deposit is rejected cannot be before its submittal date: "
|
||||||
|
+ getProjectedCommencementDate().toString();
|
||||||
|
throw new InvalidDepositStateTransitionException("reject",
|
||||||
|
"cannot.be.before.submittal.date", errorMessage,
|
||||||
|
rejectedOn, getProjectedCommencementDate());
|
||||||
|
|
||||||
|
}
|
||||||
|
if (rejectedOn.isAfter(new LocalDate())) {
|
||||||
|
|
||||||
|
final String errorMessage = "The date on which a deposit is rejected cannot be in the future.";
|
||||||
|
throw new InvalidDepositStateTransitionException("reject",
|
||||||
|
"cannot.be.a.future.date", errorMessage, rejectedOn);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void withdrawnByApplicant(final LocalDate withdrawnOn,
|
||||||
|
final DepositLifecycleStateMachine depositLifecycleStateMachine) {
|
||||||
|
|
||||||
|
DepositStatus statusEnum = depositLifecycleStateMachine.transition(
|
||||||
|
DepositEvent.DEPOSIT_WITHDRAWN,
|
||||||
|
DepositStatus.fromInt(this.depositStatus));
|
||||||
|
this.depositStatus = statusEnum.getValue();
|
||||||
|
|
||||||
|
this.withdrawnOnDate = withdrawnOn.toDateTimeAtCurrentTime().toDate();
|
||||||
|
this.closedOnDate = withdrawnOn.toDateTimeAtCurrentTime().toDate();
|
||||||
|
|
||||||
|
if (withdrawnOn.isBefore(getProjectedCommencementDate())) {
|
||||||
|
|
||||||
|
final String errorMessage = "The date on which a deposit is rejected cannot be before its submittal date: "
|
||||||
|
+ getProjectedCommencementDate().toString();
|
||||||
|
throw new InvalidDepositStateTransitionException("reject",
|
||||||
|
"cannot.be.before.submittal.date", errorMessage,
|
||||||
|
withdrawnOn, getProjectedCommencementDate());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getProjectedCommencementDate() {
|
if (withdrawnOn.isAfter(new LocalDate())) {
|
||||||
LocalDate date=null;
|
final String errorMessage = "The date on which a deposit is rejected cannot be in the future.";
|
||||||
if(this.projectedCommencementDate!=null){
|
throw new InvalidDepositStateTransitionException("reject",
|
||||||
date = new LocalDate(this.projectedCommencementDate);
|
"cannot.be.a.future.date", errorMessage, withdrawnOn);
|
||||||
}
|
|
||||||
return date;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void reject(LocalDate rejectedOn, DepositLifecycleStateMachine depositLifecycleStateMachine) {
|
public void undoDepositApproval(final DepositLifecycleStateMachine depositLifecycleStateMachine) {
|
||||||
|
|
||||||
DepositStatus statusEnum = depositLifecycleStateMachine.transition(DepositEvent.DEPOSIT_REJECTED, DepositStatus.fromInt(this.depositStatus));
|
|
||||||
this.depositStatus = statusEnum.getValue();
|
|
||||||
|
|
||||||
this.rejectedOnDate = rejectedOn.toDateTimeAtCurrentTime().toDate();
|
|
||||||
this.closedOnDate = rejectedOn.toDateTimeAtCurrentTime().toDate();
|
|
||||||
|
|
||||||
if (rejectedOn.isBefore(getProjectedCommencementDate())) {
|
|
||||||
|
|
||||||
final String errorMessage = "The date on which a deposit is rejected cannot be before its submittal date: " + getProjectedCommencementDate().toString();
|
|
||||||
throw new InvalidDepositStateTransitionException("reject", "cannot.be.before.submittal.date", errorMessage, rejectedOn, getProjectedCommencementDate());
|
|
||||||
|
|
||||||
}
|
|
||||||
if (rejectedOn.isAfter(new LocalDate())) {
|
|
||||||
|
|
||||||
final String errorMessage = "The date on which a deposit is rejected cannot be in the future.";
|
|
||||||
throw new InvalidDepositStateTransitionException("reject", "cannot.be.a.future.date", errorMessage, rejectedOn);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
DepositStatus statusEnum = depositLifecycleStateMachine.transition(
|
||||||
|
DepositEvent.DEPOSIT_APPROVAL_UNDO,
|
||||||
|
DepositStatus.fromInt(this.depositStatus));
|
||||||
|
this.depositStatus = statusEnum.getValue();
|
||||||
|
|
||||||
public void withdraw(LocalDate withdrawnOn, DepositLifecycleStateMachine depositLifecycleStateMachine) {
|
this.actualCommencementDate = null;
|
||||||
|
this.actualMaturityDate = null;
|
||||||
DepositStatus statusEnum = depositLifecycleStateMachine.transition(DepositEvent.DEPOSIT_WITHDRAWN, DepositStatus.fromInt(this.depositStatus));
|
}
|
||||||
this.depositStatus = statusEnum.getValue();
|
|
||||||
|
|
||||||
this.withdrawnOnDate = withdrawnOn.toDateTimeAtCurrentTime().toDate();
|
|
||||||
this.closedOnDate = withdrawnOn.toDateTimeAtCurrentTime().toDate();
|
|
||||||
|
|
||||||
if (withdrawnOn.isBefore(getProjectedCommencementDate())) {
|
|
||||||
|
|
||||||
final String errorMessage = "The date on which a deposit is rejected cannot be before its submittal date: " + getProjectedCommencementDate().toString();
|
|
||||||
throw new InvalidDepositStateTransitionException("reject", "cannot.be.before.submittal.date", errorMessage, withdrawnOn, getProjectedCommencementDate());
|
|
||||||
|
|
||||||
}
|
|
||||||
if (withdrawnOn.isAfter(new LocalDate())) {
|
|
||||||
|
|
||||||
final String errorMessage = "The date on which a deposit is rejected cannot be in the future.";
|
|
||||||
throw new InvalidDepositStateTransitionException("reject", "cannot.be.a.future.date", errorMessage, withdrawnOn);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void undoDepositApproval(DepositLifecycleStateMachine depositLifecycleStateMachine) {
|
|
||||||
|
|
||||||
DepositStatus statusEnum = depositLifecycleStateMachine.transition(DepositEvent.DEPOSIT_APPROVAL_UNDO, DepositStatus.fromInt(this.depositStatus));
|
|
||||||
this.depositStatus = statusEnum.getValue();
|
|
||||||
|
|
||||||
this.actualCommencementDate = null;
|
|
||||||
this.actualMaturityDate=null;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+22
-14
@@ -6,42 +6,50 @@ import org.mifosng.platform.currency.domain.Money;
|
|||||||
import org.mifosng.platform.loan.domain.PeriodFrequencyType;
|
import org.mifosng.platform.loan.domain.PeriodFrequencyType;
|
||||||
|
|
||||||
public class DepositApprovalData {
|
public class DepositApprovalData {
|
||||||
|
|
||||||
private final Integer tenureInMonths;
|
private final Integer tenureInMonths;
|
||||||
private final Money deposit;
|
private final Money deposit;
|
||||||
private final BigDecimal maturityInterestRate;
|
private final BigDecimal maturityInterestRate;
|
||||||
private final Integer interestCompoundedEvery;
|
private final Integer interestCompoundedEvery;
|
||||||
private final PeriodFrequencyType interestCompoundedEveryPeriodType;
|
private final PeriodFrequencyType interestCompoundedEveryPeriodType;
|
||||||
private final FixedTermDepositInterestCalculator fixedTermDepositInterestCalculator;
|
private final FixedTermDepositInterestCalculator fixedTermDepositInterestCalculator;
|
||||||
|
|
||||||
|
public DepositApprovalData(
|
||||||
public DepositApprovalData(final Integer tenureInMonths,final Money deposit,final BigDecimal maturityInterestRate,final Integer interestCompoundedEvery,final PeriodFrequencyType interestCompoundedEveryPeriodType,final FixedTermDepositInterestCalculator fixedTermDepositInterestCalculator) {
|
final Integer tenureInMonths,
|
||||||
this.tenureInMonths=tenureInMonths;
|
final Money deposit,
|
||||||
this.deposit=deposit;
|
final BigDecimal maturityInterestRate,
|
||||||
this.maturityInterestRate=maturityInterestRate;
|
final Integer interestCompoundedEvery,
|
||||||
this.interestCompoundedEvery=interestCompoundedEvery;
|
final PeriodFrequencyType interestCompoundedEveryPeriodType,
|
||||||
this.interestCompoundedEveryPeriodType=interestCompoundedEveryPeriodType;
|
final FixedTermDepositInterestCalculator fixedTermDepositInterestCalculator) {
|
||||||
this.fixedTermDepositInterestCalculator=fixedTermDepositInterestCalculator;
|
this.tenureInMonths = tenureInMonths;
|
||||||
|
this.deposit = deposit;
|
||||||
|
this.maturityInterestRate = maturityInterestRate;
|
||||||
|
this.interestCompoundedEvery = interestCompoundedEvery;
|
||||||
|
this.interestCompoundedEveryPeriodType = interestCompoundedEveryPeriodType;
|
||||||
|
this.fixedTermDepositInterestCalculator = fixedTermDepositInterestCalculator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Integer getTenureInMonths() {
|
public Integer getTenureInMonths() {
|
||||||
return tenureInMonths;
|
return tenureInMonths;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Money getDeposit() {
|
public Money getDeposit() {
|
||||||
return deposit;
|
return deposit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal getMaturityInterestRate() {
|
public BigDecimal getMaturityInterestRate() {
|
||||||
return maturityInterestRate;
|
return maturityInterestRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getInterestCompoundedEvery() {
|
public Integer getInterestCompoundedEvery() {
|
||||||
return interestCompoundedEvery;
|
return interestCompoundedEvery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PeriodFrequencyType getInterestCompoundedEveryPeriodType() {
|
public PeriodFrequencyType getInterestCompoundedEveryPeriodType() {
|
||||||
return interestCompoundedEveryPeriodType;
|
return interestCompoundedEveryPeriodType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FixedTermDepositInterestCalculator getFixedTermDepositInterestCalculator() {
|
public FixedTermDepositInterestCalculator getFixedTermDepositInterestCalculator() {
|
||||||
return fixedTermDepositInterestCalculator;
|
return fixedTermDepositInterestCalculator;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
-2
@@ -4,7 +4,6 @@ import java.math.BigDecimal;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
|
||||||
import org.mifosng.platform.api.commands.DepositAccountCommand;
|
import org.mifosng.platform.api.commands.DepositAccountCommand;
|
||||||
import org.mifosng.platform.api.commands.DepositStateTransitionApprovalCommand;
|
import org.mifosng.platform.api.commands.DepositStateTransitionApprovalCommand;
|
||||||
import org.mifosng.platform.client.domain.Client;
|
import org.mifosng.platform.client.domain.Client;
|
||||||
@@ -12,7 +11,6 @@ import org.mifosng.platform.client.domain.ClientRepository;
|
|||||||
import org.mifosng.platform.currency.domain.Money;
|
import org.mifosng.platform.currency.domain.Money;
|
||||||
import org.mifosng.platform.exceptions.ClientNotFoundException;
|
import org.mifosng.platform.exceptions.ClientNotFoundException;
|
||||||
import org.mifosng.platform.exceptions.DepositProductNotFoundException;
|
import org.mifosng.platform.exceptions.DepositProductNotFoundException;
|
||||||
import org.mifosng.platform.exceptions.NoAuthorizationException;
|
|
||||||
import org.mifosng.platform.loan.domain.PeriodFrequencyType;
|
import org.mifosng.platform.loan.domain.PeriodFrequencyType;
|
||||||
import org.mifosng.platform.saving.domain.DepositAccount;
|
import org.mifosng.platform.saving.domain.DepositAccount;
|
||||||
import org.mifosng.platform.saving.domain.DepositApprovalData;
|
import org.mifosng.platform.saving.domain.DepositApprovalData;
|
||||||
|
|||||||
+4
-3
@@ -129,7 +129,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public EntityIdentifier approveDepositApplication(DepositStateTransitionApprovalCommand command) {
|
public EntityIdentifier approveDepositApplication(final DepositStateTransitionApprovalCommand command) {
|
||||||
|
|
||||||
AppUser currentUser = context.authenticatedUser();
|
AppUser currentUser = context.authenticatedUser();
|
||||||
|
|
||||||
@@ -144,6 +144,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
|
|
||||||
DepositApprovalData depositApprovalData=this.depositAccountAssembler.assembleFrom(command);
|
DepositApprovalData depositApprovalData=this.depositAccountAssembler.assembleFrom(command);
|
||||||
|
|
||||||
|
// FIXME - madhukar - you are checking for loan permission here instead of some specific deposit account permission.
|
||||||
LocalDate eventDate = command.getEventDate();
|
LocalDate eventDate = command.getEventDate();
|
||||||
if (this.isBeforeToday(eventDate) && currentUser.canNotApproveLoanInPast()) {
|
if (this.isBeforeToday(eventDate) && currentUser.canNotApproveLoanInPast()) {
|
||||||
throw new NoAuthorizationException("User has no authority to approve deposit with a date in the past.");
|
throw new NoAuthorizationException("User has no authority to approve deposit with a date in the past.");
|
||||||
@@ -151,7 +152,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
|
|
||||||
BigDecimal depositAmount = command.getDepositAmount();
|
BigDecimal depositAmount = command.getDepositAmount();
|
||||||
|
|
||||||
account.approve(eventDate, defaultDepositLifecycleStateMachine(), depositApprovalData,depositAmount);
|
account.approve(eventDate, defaultDepositLifecycleStateMachine(), depositApprovalData, depositAmount);
|
||||||
this.depositAccountRepository.save(account);
|
this.depositAccountRepository.save(account);
|
||||||
|
|
||||||
return new EntityIdentifier(account.getId());
|
return new EntityIdentifier(account.getId());
|
||||||
@@ -210,7 +211,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
throw new NoAuthorizationException("User has no authority to approve deposit with a date in the past.");
|
throw new NoAuthorizationException("User has no authority to approve deposit with a date in the past.");
|
||||||
}
|
}
|
||||||
|
|
||||||
account.withdraw(eventDate, defaultDepositLifecycleStateMachine());
|
account.withdrawnByApplicant(eventDate, defaultDepositLifecycleStateMachine());
|
||||||
return new EntityIdentifier(account.getId());
|
return new EntityIdentifier(account.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user