Merge pull request #649 from Musoni/MIFOSX-762

MIFOS-762 - Fixed SubmittedBy userID for creating new savings
This commit is contained in:
Keith Woodlock
2013-10-30 03:20:42 -07:00
3 changed files with 12 additions and 8 deletions
@@ -244,7 +244,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
public static SavingsAccount createNewApplicationForSubmittal(final Client client, final Group group, final SavingsProduct product,
final Staff fieldOfficer, final String accountNo, final String externalId, final AccountType accountType,
final LocalDate submittedOnDate, final BigDecimal interestRate,
final LocalDate submittedOnDate, final AppUser submittedBy, final BigDecimal interestRate,
final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType,
final SavingsPostingInterestPeriodType interestPostingPeriodType, final SavingsInterestCalculationType interestCalculationType,
final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final BigDecimal minRequiredOpeningBalance,
@@ -252,7 +252,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
final boolean withdrawalFeeApplicableForTransfer, final Set<SavingsAccountCharge> savingsAccountCharges) {
final SavingsAccountStatusType status = SavingsAccountStatusType.SUBMITTED_AND_PENDING_APPROVAL;
return new SavingsAccount(client, group, product, fieldOfficer, accountNo, externalId, status, accountType, submittedOnDate,
return new SavingsAccount(client, group, product, fieldOfficer, accountNo, externalId, status, accountType, submittedOnDate, submittedBy,
interestRate, interestCompoundingPeriodType, interestPostingPeriodType, interestCalculationType,
interestCalculationDaysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType,
withdrawalFeeApplicableForTransfer, savingsAccountCharges);
@@ -260,7 +260,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
private SavingsAccount(final Client client, final Group group, final SavingsProduct product, final Staff fieldOfficer,
final String accountNo, final String externalId, final SavingsAccountStatusType status, final AccountType accountType,
final LocalDate submittedOnDate, final BigDecimal nominalAnnualInterestRate,
final LocalDate submittedOnDate, final AppUser submittedBy, final BigDecimal nominalAnnualInterestRate,
final SavingsCompoundingInterestPeriodType interestCompoundingPeriodType,
final SavingsPostingInterestPeriodType interestPostingPeriodType, final SavingsInterestCalculationType interestCalculationType,
final SavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType, final BigDecimal minRequiredOpeningBalance,
@@ -276,11 +276,13 @@ public class SavingsAccount extends AbstractPersistable<Long> {
} else {
this.accountNumber = accountNo;
}
this.currency = product.currency();
this.externalId = externalId;
this.status = status.getValue();
this.accountType = accountType.getValue();
this.submittedOnDate = submittedOnDate.toDate();
this.submittedBy = submittedBy;
this.nominalAnnualInterestRate = nominalAnnualInterestRate;
this.interestCompoundingPeriodType = interestCompoundingPeriodType.getValue();
this.interestPostingPeriodType = interestPostingPeriodType.getValue();
@@ -50,6 +50,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.google.gson.JsonElement;
import org.mifosplatform.useradministration.domain.AppUser;
@Service
public class SavingsAccountAssembler {
@@ -85,10 +86,10 @@ public class SavingsAccountAssembler {
* request inheriting details where relevant from chosen
* {@link SavingsProduct}.
*/
public SavingsAccount assembleFrom(final JsonCommand command) {
public SavingsAccount assembleFrom(final JsonCommand command, final AppUser submittedBy) {
final JsonElement element = command.parsedJson();
final String accountNo = this.fromApiJsonHelper.extractStringNamed(accountNoParamName, element);
final String externalId = this.fromApiJsonHelper.extractStringNamed(externalIdParamName, element);
final Long productId = this.fromApiJsonHelper.extractLongNamed(productIdParamName, element);
@@ -200,9 +201,9 @@ public class SavingsAccountAssembler {
final Set<SavingsAccountCharge> charges = this.savingsAccountChargeAssembler.fromParsedJson(element, product.currency().getCode());
final SavingsAccount account = SavingsAccount.createNewApplicationForSubmittal(client, group, product, fieldOfficer, accountNo,
externalId, accountType, submittedOnDate, interestRate, interestCompoundingPeriodType, interestPostingPeriodType,
externalId, accountType, submittedOnDate, submittedBy, interestRate, interestCompoundingPeriodType, interestPostingPeriodType,
interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency,
lockinPeriodFrequencyType, iswithdrawalFeeApplicableForTransfer, charges);
account.setHelpers(this.savingsAccountTransactionSummaryWrapper, this.savingsHelper);
@@ -129,8 +129,9 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
public CommandProcessingResult submitApplication(final JsonCommand command) {
try {
this.savingsAccountDataValidator.validateForSubmit(command.json());
final AppUser submittedBy = this.context.authenticatedUser();
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(command);
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(command, submittedBy);
this.savingAccountRepository.save(account);
if (account.isAccountNumberRequiresAutoGeneration()) {