@Transactional @Override 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, submittedBy); this.savingAccountRepository.save(account); if (account.isAccountNumberRequiresAutoGeneration()) { final AccountNumberGenerator accountNoGenerator = this.accountIdentifierGeneratorFactory.determineSavingsAccountNoGenerator( account.getId()); account.updateAccountNo(accountNoGenerator.generate()); this.savingAccountRepository.save(account); } final Long savingsId = account.getId(); return new CommandProcessingResultBuilder() // .withCommandId(command.commandId()) // .withEntityId(savingsId) // .withOfficeId(account.officeId()) // .withClientId(account.clientId()) // .withGroupId(account.groupId()) // .withSavingsId(savingsId) // .build(); } catch (final DataAccessException dve) { handleDataIntegrityIssues(command, dve); return CommandProcessingResult.empty(); } }
@Override public CommandProcessingResult createActiveApplication( final SavingsAccountDataDTO savingsAccountDataDTO) { final CommandWrapper commandWrapper = new CommandWrapperBuilder().savingsAccountActivation(null).build(); boolean rollbackTransaction = this.commandProcessingService.validateCommand( commandWrapper, savingsAccountDataDTO.getAppliedBy()); final SavingsAccount account = this.savingAccountAssembler.assembleFrom( savingsAccountDataDTO.getClient(), savingsAccountDataDTO.getGroup(), savingsAccountDataDTO.getSavingsProduct(), savingsAccountDataDTO.getApplicationDate(), savingsAccountDataDTO.getAppliedBy()); account.approveAndActivateApplication( savingsAccountDataDTO.getApplicationDate().toDate(), savingsAccountDataDTO.getAppliedBy(), savingsAccountDataDTO.getFmt()); this.savingAccountRepository.save(account); if (account.isAccountNumberRequiresAutoGeneration()) { final AccountNumberGenerator accountNoGenerator = this.accountIdentifierGeneratorFactory.determineSavingsAccountNoGenerator( account.getId()); account.updateAccountNo(accountNoGenerator.generate()); this.savingAccountRepository.save(account); } return new CommandProcessingResultBuilder() // .withSavingsId(account.getId()) // .setRollbackTransaction(rollbackTransaction) // .build(); }
@Transactional @Override public CommandProcessingResult createSavingAccount(final JsonCommand command) { try { this.context.authenticatedUser(); this.savingsAccountDataValidator.validateForCreate(command.json()); final List<Long> existingTransactionIds = new ArrayList<Long>(); final List<Long> existingReversedTransactionIds = new ArrayList<Long>(); final SavingsAccount account = this.savingAccountAssembler.assembleFrom( command, existingTransactionIds, existingReversedTransactionIds); this.savingAccountRepository.save(account); if (account.isAccountNumberRequiresAutoGeneration()) { final AccountNumberGenerator accountNoGenerator = this.accountIdentifierGeneratorFactory.determineLoanAccountNoGenerator(account.getId()); account.updateAccountNo(accountNoGenerator.generate()); this.savingAccountRepository.save(account); } postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds); final Long savingsId = account.getId(); return new CommandProcessingResultBuilder() // .withCommandId(command.commandId()) // .withEntityId(savingsId) // .withOfficeId(account.officeId()) // .withClientId(account.clientId()) // .withGroupId(account.groupId()) // .withSavingsId(savingsId) // .build(); } catch (DataAccessException dve) { handleDataIntegrityIssues(command, dve); return CommandProcessingResult.empty(); } }