From 16da04f08962353b812cd2f0f1195dc147092f74 Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Thu, 13 Sep 2012 17:10:25 +0100 Subject: [PATCH] small bit of tidy up. --- .../api/DepositAccountsApiResource.java | 40 +++++++++---------- .../saving/domain/DepositAccount.java | 5 +-- .../DepositAccountCommandValidator.java | 2 +- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositAccountsApiResource.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositAccountsApiResource.java index 177195f92..26bfc27f3 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositAccountsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/DepositAccountsApiResource.java @@ -196,27 +196,27 @@ public class DepositAccountsApiResource { DepositStateTransitionApprovalCommand command=apiDataConversionService.convertJsonToDepositStateTransitionApprovalCommand(accountId, jsonRequestBody); EntityIdentifier identifier = this.depositAccountWritePlatformService.approveDepositApplication(command); response = Response.ok().entity(identifier).build(); - } - else{ - DepositStateTransitionCommand command=apiDataConversionService.convertJsonToDepositStateTransitionCommand(accountId, jsonRequestBody); - if (is(commandParam, "reject")) { - EntityIdentifier identifier = this.depositAccountWritePlatformService.rejectDepositApplication(command); - response = Response.ok().entity(identifier).build(); - } else if (is(commandParam, "withdrewbyclient")) { - EntityIdentifier identifier = this.depositAccountWritePlatformService.withdrawDepositApplication(command); - response = Response.ok().entity(identifier).build(); - } else if (is(commandParam, "mature")){ - EntityIdentifier identifier = this.depositAccountWritePlatformService.matureDepositApplication(command); - response = Response.ok().entity(identifier).build(); - } - - UndoStateTransitionCommand undoCommand = new UndoStateTransitionCommand(accountId, command.getNote()); - - if (is(commandParam, "undoapproval")) { - EntityIdentifier identifier = this.depositAccountWritePlatformService.undoDepositApproval(undoCommand); - response = Response.ok().entity(identifier).build(); - } + } else { + DepositStateTransitionCommand command=apiDataConversionService.convertJsonToDepositStateTransitionCommand(accountId, jsonRequestBody); + if (is(commandParam, "reject")) { + EntityIdentifier identifier = this.depositAccountWritePlatformService.rejectDepositApplication(command); + response = Response.ok().entity(identifier).build(); + } else if (is(commandParam, "withdrewbyclient")) { + EntityIdentifier identifier = this.depositAccountWritePlatformService.withdrawDepositApplication(command); + response = Response.ok().entity(identifier).build(); + } else if (is(commandParam, "mature")){ + EntityIdentifier identifier = this.depositAccountWritePlatformService.matureDepositApplication(command); + response = Response.ok().entity(identifier).build(); } + + UndoStateTransitionCommand undoCommand = new UndoStateTransitionCommand(accountId, command.getNote()); + + if (is(commandParam, "undoapproval")) { + EntityIdentifier identifier = this.depositAccountWritePlatformService.undoDepositApproval(undoCommand); + response = Response.ok().entity(identifier).build(); + } + } + if (response == null) { throw new UnrecognizedQueryParamException("command", commandParam); } diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java index 943b8db56..ac52eb3a4 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java @@ -41,7 +41,6 @@ public class DepositAccount extends AbstractAuditableCustom { @JoinColumn(name = "client_id", nullable = false) private Client client; - @SuppressWarnings("unused") @ManyToOne @JoinColumn(name = "product_id") private final DepositProduct product; @@ -75,7 +74,6 @@ public class DepositAccount extends AbstractAuditableCustom { @Column(name = "actual_commencement_date") private Date actualCommencementDate; - @SuppressWarnings("unused") @Temporal(TemporalType.DATE) @Column(name = "matures_on_date") private Date maturesOnDate; @@ -92,7 +90,6 @@ public class DepositAccount extends AbstractAuditableCustom { @Column(name = "projected_total_maturity_amount", scale = 6, precision = 19, nullable = false) private BigDecimal projectedTotalOnMaturity; - @SuppressWarnings("unused") @Column(name = "actual_total_amount", scale = 6, precision = 19, nullable = false) private BigDecimal total; @@ -100,7 +97,6 @@ public class DepositAccount extends AbstractAuditableCustom { @Column(name = "pre_closure_interest_rate", scale = 6, precision = 19, nullable = false) private BigDecimal preClosureInterestRate; - @SuppressWarnings("unused") @Column(name = "is_renewal_allowed", nullable = false) private boolean renewalAllowed = false; @@ -137,6 +133,7 @@ public class DepositAccount extends AbstractAuditableCustom { @OneToMany(cascade = CascadeType.ALL, mappedBy = "depositAccount", orphanRemoval = true) private final List depositaccountTransactions = new ArrayList(); + @SuppressWarnings("unused") @OneToOne(optional=true, cascade={CascadeType.PERSIST}) @JoinColumn(name = "renewed_account_id") private DepositAccount renewdAccount; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountCommandValidator.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountCommandValidator.java index 7abe2027e..d19f9111b 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountCommandValidator.java @@ -57,7 +57,7 @@ public class DepositAccountCommandValidator { baseDataValidator.reset().parameter("productId").value(command.getProductId()).notNull(); baseDataValidator.reset().parameter("externalId").value(command.getExternalId()).ignoreIfNull().notExceedingLengthOf(100); - baseDataValidator.reset().parameter("depositAmount").value(command.getDepositAmount()).notNull().zeroOrPositiveAmount(); + baseDataValidator.reset().parameter("deposit").value(command.getDepositAmount()).notNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("maturityInterestRate").value(command.getMaturityInterestRate()).ignoreIfNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("preClosureInterestRate").value(command.getPreClosureInterestRate()).ignoreIfNull().zeroOrPositiveAmount(); baseDataValidator.reset().parameter("tenureInMonths").value(command.getTenureInMonths()).ignoreIfNull().integerGreaterThanZero();