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 7aec2bb40..3701864ca 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 @@ -10,7 +10,6 @@ import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; -import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; @@ -84,19 +83,6 @@ public class DepositAccountsApiResource { return Response.ok().entity(entityIdentifier).build(); } - @PUT - @Path("{accountId}") - @Consumes({MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_JSON}) - public Response updateSavingProduct(@PathParam("accountId") final Long accountId, final String jsonRequestBody){ - - final DepositAccountCommand command = this.apiDataConversionService.convertJsonToDepositAccountCommand(accountId, jsonRequestBody); - - EntityIdentifier entityIdentifier = this.depositAccountWritePlatformService.updateDepositAccount(command); - - return Response.ok().entity(entityIdentifier).build(); - } - @GET @Consumes({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON}) diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidDepositStateTransitionException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidDepositStateTransitionException.java index bb07baf0b..6c7cda035 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidDepositStateTransitionException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/InvalidDepositStateTransitionException.java @@ -5,7 +5,6 @@ public class InvalidDepositStateTransitionException extends public InvalidDepositStateTransitionException(final String action, String postFix, String defaultUserMessage, Object... defaultUserMessageArgs) { super("error.msg.deposit." + action + "." + postFix, defaultUserMessage, defaultUserMessageArgs); - // TODO Auto-generated constructor stub } } 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 774a84168..0d76da470 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 @@ -21,7 +21,6 @@ import javax.persistence.UniqueConstraint; import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollectionOption; import org.joda.time.LocalDate; -import org.mifosng.platform.api.commands.DepositAccountCommand; import org.mifosng.platform.api.commands.DepositStateTransitionApprovalCommand; import org.mifosng.platform.client.domain.Client; import org.mifosng.platform.currency.domain.MonetaryCurrency; @@ -225,10 +224,6 @@ public class DepositAccount extends AbstractAuditableCustom { this.externalId = this.getId() + "_" + this.externalId; } - public void update(final DepositAccountCommand command) { - - } - public void approve( final LocalDate actualCommencementDate, final DepositLifecycleStateMachine depositLifecycleStateMachine, @@ -251,7 +246,10 @@ public class DepositAccount extends AbstractAuditableCustom { } this.actualCommencementDate = actualCommencementDate.toDate(); - this.actualMaturityDate = new LocalDate(this.actualCommencementDate).plusMonths(this.tenureInMonths).toDate(); + + // TODO - KW - there was probably no need for 'projected' and 'actual' maturity dates - a single 'matures_on' attribute is sufficient + this.projectedMaturityDate = getActualCommencementDate().plusMonths(this.tenureInMonths).toDate(); + this.actualMaturityDate = getActualCommencementDate().plusMonths(this.tenureInMonths).toDate(); Money futureValueOnMaturity = calculator.calculateInterestOnMaturityFor(getDeposit(), this.tenureInMonths, this.interestRate, this.interestCompoundedEvery, getInterestCompoundedFrequencyType()); @@ -259,11 +257,10 @@ public class DepositAccount extends AbstractAuditableCustom { this.interestAccrued = futureValueOnMaturity.minus(getDeposit()).getAmount(); this.total = futureValueOnMaturity.getAmount(); - DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.deposit(futureValueOnMaturity,new LocalDate(this.actualCommencementDate)); + DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.deposit(futureValueOnMaturity, getActualCommencementDate()); + depositaccountTransaction.updateAccount(this); this.depositaccountTransactions.add(depositaccountTransaction); - depositaccountTransaction.updateAccount(this); - LocalDate submittalDate = new LocalDate(this.projectedCommencementDate); if (actualCommencementDate.isBefore(submittalDate)) { final String errorMessage = "The date on which a deposit is approved cannot be before its submittal date: " + submittalDate.toString(); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformService.java index e99a1673b..3d9a96921 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformService.java @@ -12,9 +12,6 @@ public interface DepositAccountWritePlatformService { @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") EntityIdentifier createDepositAccount(DepositAccountCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") - EntityIdentifier updateDepositAccount(DepositAccountCommand command); - @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") EntityIdentifier deleteDepositAccount(Long productId); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java index b2995deef..36ae029ab 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java @@ -84,33 +84,6 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo return new EntityIdentifier(Long.valueOf(-1)); } } - - @Transactional - @Override - public EntityIdentifier updateDepositAccount(final DepositAccountCommand command) { - - try { - - this.context.authenticatedUser(); - - DepositAccountCommandValidator validator = new DepositAccountCommandValidator(command); - validator.validateForUpdate(); - - // FIXME - update scenarios to be completely done - final DepositAccount account = this.depositAccountAssembler.assembleFrom(command); - if (account == null || account.isDeleted()) { - throw new DepositAccountNotFoundException(command.getId()); - } - - account.update(command); - this.depositAccountRepository.save(account); - - return new EntityIdentifier(account.getId()); - } catch (DataIntegrityViolationException dve) { - handleDataIntegrityIssues(command, dve); - return new EntityIdentifier(Long.valueOf(-1)); - } - } @Transactional @Override