fineract-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nikpawar89 <...@git.apache.org>
Subject [GitHub] incubator-fineract pull request #189: address_module
Date Mon, 01 Aug 2016 12:11:55 GMT
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72967402
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java
---
    @@ -195,8 +203,138 @@ private void handleDataIntegrityIssues(final JsonCommand command,
final DataInte
         @Transactional
         @Override
         public CommandProcessingResult createClient(final JsonCommand command) {
    -
    -        try {
    +    	 try {
    +             final AppUser currentUser = this.context.authenticatedUser();
    +             
    +             final long configId=29;
    +             
    +             final GlobalConfigurationPropertyData configuration=this.configurationReadPlatformService.retrieveGlobalConfiguration(configId);
    +             
    +             final Boolean isAddressEnabled=configuration.isEnabled(); 
    +
    +            // this.fromApiJsonDeserializer.validateForCreate(command.json());
    +             
    +             
    +             
    +
    +             final Long officeId = command.longValueOfParameterNamed(ClientApiConstants.officeIdParamName);
    +
    +             final Office clientOffice = this.officeRepository.findOne(officeId);
    +             if (clientOffice == null) { throw new OfficeNotFoundException(officeId);
}
    +
    +             final Long groupId = command.longValueOfParameterNamed(ClientApiConstants.groupIdParamName);
    +
    +             Group clientParentGroup = null;
    +             if (groupId != null) {
    +                 clientParentGroup = this.groupRepository.findOne(groupId);
    +                 if (clientParentGroup == null) { throw new GroupNotFoundException(groupId);
}
    +             }
    +
    +             Staff staff = null;
    +             final Long staffId = command.longValueOfParameterNamed(ClientApiConstants.staffIdParamName);
    +             if (staffId != null) {
    +                 staff = this.staffRepository.findByOfficeHierarchyWithNotFoundDetection(staffId,
clientOffice.getHierarchy());
    +             }
    +
    +             CodeValue gender = null;
    +             final Long genderId = command.longValueOfParameterNamed(ClientApiConstants.genderIdParamName);
    +             if (genderId != null) {
    +                 gender = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(ClientApiConstants.GENDER,
genderId);
    +             }
    +
    +             CodeValue clientType = null;
    +             final Long clientTypeId = command.longValueOfParameterNamed(ClientApiConstants.clientTypeIdParamName);
    +             if (clientTypeId != null) {
    +                 clientType = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(ClientApiConstants.CLIENT_TYPE,
    +                         clientTypeId);
    +             }
    +
    +             CodeValue clientClassification = null;
    +             final Long clientClassificationId = command.longValueOfParameterNamed(ClientApiConstants.clientClassificationIdParamName);
    +             if (clientClassificationId != null) {
    +                 clientClassification = this.codeValueRepository.findOneByCodeNameAndIdWithNotFoundDetection(
    +                         ClientApiConstants.CLIENT_CLASSIFICATION, clientClassificationId);
    +             }
    +
    +             SavingsProduct savingsProduct = null;
    +             final Long savingsProductId = command.longValueOfParameterNamed(ClientApiConstants.savingsProductIdParamName);
    +             if (savingsProductId != null) {
    +                 savingsProduct = this.savingsProductRepository.findOne(savingsProductId);
    +                 if (savingsProduct == null) { throw new SavingsProductNotFoundException(savingsProductId);
}
    +
    +             }
    +             
    +             final Integer legalFormParamValue = command.integerValueOfParameterNamed(ClientApiConstants.legalFormIdParamName);
    +             boolean isEntity = false;
    +             Integer legalFormValue = null;
    +             if(legalFormParamValue != null)
    +             {
    +             	LegalForm legalForm = LegalForm.fromInt(legalFormParamValue);
    +             	if(legalForm != null)
    +                 {
    +                 	legalFormValue = legalForm.getValue();
    +                 	isEntity = legalForm.isEntity();
    +                 }
    +             }
    +             
    +             final Client newClient = Client.createNew(currentUser, clientOffice, clientParentGroup,
staff, savingsProduct, gender,
    +                     clientType, clientClassification, legalFormValue, command);
    +             boolean rollbackTransaction = false;
    +             if (newClient.isActive()) {
    +                 validateParentGroupRulesBeforeClientActivation(newClient);
    +                 final CommandWrapper commandWrapper = new CommandWrapperBuilder().activateClient(null).build();
    +                 rollbackTransaction = this.commandProcessingService.validateCommand(commandWrapper,
currentUser);
    +             }
    +
    +             this.clientRepository.save(newClient);
    +
    +             if (newClient.isAccountNumberRequiresAutoGeneration()) {
    +                 AccountNumberFormat accountNumberFormat = this.accountNumberFormatRepository.findByAccountType(EntityAccountType.CLIENT);
    +                 newClient.updateAccountNo(accountNumberGenerator.generate(newClient,
accountNumberFormat));
    +                 this.clientRepository.save(newClient);
    +             }
    +                         
    +             final Locale locale = command.extractLocale();
    +             final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
    +             CommandProcessingResult result = openSavingsAccount(newClient, fmt);
    +             if (result.getSavingsId() != null) {
    +                 this.clientRepository.save(newClient);
    +             }
    +             
    +             if(isEntity)            
    +             	extractAndCreateClientNonPerson(newClient, command);
    +             
    +             final long clientId=newClient.getId();
    +             System.out.println("client with client ID created:"+clientId);
    --- End diff --
    
    removed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message