remove redundant update case from deposit account for now.

This commit is contained in:
Keith Woodlock
2012-09-05 14:41:36 +01:00
parent 4a90cb091a
commit ca3d666578
5 changed files with 6 additions and 54 deletions
@@ -10,7 +10,6 @@ import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
@@ -84,19 +83,6 @@ public class DepositAccountsApiResource {
return Response.ok().entity(entityIdentifier).build(); 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 @GET
@Consumes({MediaType.APPLICATION_JSON}) @Consumes({MediaType.APPLICATION_JSON})
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
@@ -5,7 +5,6 @@ public class InvalidDepositStateTransitionException extends
public InvalidDepositStateTransitionException(final String action, String postFix, String defaultUserMessage, Object... defaultUserMessageArgs) { public InvalidDepositStateTransitionException(final String action, String postFix, String defaultUserMessage, Object... defaultUserMessageArgs) {
super("error.msg.deposit." + action + "." + postFix, defaultUserMessage, defaultUserMessageArgs); super("error.msg.deposit." + action + "." + postFix, defaultUserMessage, defaultUserMessageArgs);
// TODO Auto-generated constructor stub
} }
} }
@@ -21,7 +21,6 @@ import javax.persistence.UniqueConstraint;
import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.LazyCollectionOption;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
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;
import org.mifosng.platform.currency.domain.MonetaryCurrency; import org.mifosng.platform.currency.domain.MonetaryCurrency;
@@ -225,10 +224,6 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
this.externalId = this.getId() + "_" + this.externalId; this.externalId = this.getId() + "_" + this.externalId;
} }
public void update(final DepositAccountCommand command) {
}
public void approve( public void approve(
final LocalDate actualCommencementDate, final LocalDate actualCommencementDate,
final DepositLifecycleStateMachine depositLifecycleStateMachine, final DepositLifecycleStateMachine depositLifecycleStateMachine,
@@ -251,7 +246,10 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
} }
this.actualCommencementDate = actualCommencementDate.toDate(); 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, Money futureValueOnMaturity = calculator.calculateInterestOnMaturityFor(getDeposit(), this.tenureInMonths,
this.interestRate, this.interestCompoundedEvery, getInterestCompoundedFrequencyType()); this.interestRate, this.interestCompoundedEvery, getInterestCompoundedFrequencyType());
@@ -259,10 +257,9 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
this.interestAccrued = futureValueOnMaturity.minus(getDeposit()).getAmount(); this.interestAccrued = futureValueOnMaturity.minus(getDeposit()).getAmount();
this.total = futureValueOnMaturity.getAmount(); this.total = futureValueOnMaturity.getAmount();
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.deposit(futureValueOnMaturity,new LocalDate(this.actualCommencementDate)); DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.deposit(futureValueOnMaturity, getActualCommencementDate());
this.depositaccountTransactions.add(depositaccountTransaction);
depositaccountTransaction.updateAccount(this); depositaccountTransaction.updateAccount(this);
this.depositaccountTransactions.add(depositaccountTransaction);
LocalDate submittalDate = new LocalDate(this.projectedCommencementDate); LocalDate submittalDate = new LocalDate(this.projectedCommencementDate);
if (actualCommencementDate.isBefore(submittalDate)) { if (actualCommencementDate.isBefore(submittalDate)) {
@@ -12,9 +12,6 @@ public interface DepositAccountWritePlatformService {
@PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')")
EntityIdentifier createDepositAccount(DepositAccountCommand command); EntityIdentifier createDepositAccount(DepositAccountCommand command);
@PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')")
EntityIdentifier updateDepositAccount(DepositAccountCommand command);
@PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')") @PreAuthorize(value = "hasRole('ORGANISATION_ADMINISTRATION_SUPER_USER_ROLE')")
EntityIdentifier deleteDepositAccount(Long productId); EntityIdentifier deleteDepositAccount(Long productId);
@@ -85,33 +85,6 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
} }
} }
@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 @Transactional
@Override @Override
public EntityIdentifier deleteDepositAccount(final Long accountId) { public EntityIdentifier deleteDepositAccount(final Long accountId) {