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.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})
@@ -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
}
}
@@ -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<AppUser, Long> {
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<AppUser, Long> {
}
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<AppUser, Long> {
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();
@@ -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);
@@ -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