You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fineract.apache.org by nikpawar89 <gi...@git.apache.org> on 2016/08/01 07:08:30 UTC

[GitHub] incubator-fineract pull request #189: address_module

GitHub user nikpawar89 opened a pull request:

    https://github.com/apache/incubator-fineract/pull/189

    address_module

    Squashed multiple commits to single commit.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/nikpawar89/incubator-fineract address

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-fineract/pull/189.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #189
    
----
commit 260b5ed38fecec4ec07dc8a6c1ae8e546ce45fce
Author: nikpawar89 <ni...@yahoo.in>
Date:   2016-07-19T06:08:06Z

    address_module

----


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72944777
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/address/domain/Address.java ---
    @@ -0,0 +1,343 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.portfolio.address.domain;
    +
    +import java.math.BigDecimal;
    +import java.util.ArrayList;
    +import java.util.Date;
    +import java.util.List;
    +
    +import javax.persistence.CascadeType;
    +import javax.persistence.Entity;
    +import javax.persistence.ManyToOne;
    +import javax.persistence.OneToMany;
    +import javax.persistence.Table;
    +
    +import org.apache.fineract.infrastructure.codes.domain.CodeValue;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.portfolio.client.domain.ClientAddress;
    +import org.springframework.data.jpa.domain.AbstractPersistable;
    +
    +import com.google.gson.JsonObject;
    +
    +@Entity
    +@Table(name = "m_address")
    +public class Address extends AbstractPersistable<Long> {
    +
    +	@OneToMany(mappedBy = "address", cascade = CascadeType.ALL)
    +	private List<ClientAddress> clientaddress = new ArrayList<>();
    --- End diff --
    
    Collection child entities should be of type Set. 
    Reason: The moment we add more child collections, we end up having lot of issues like Multiple param bags, duplicate entries in list child entity. 


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72968902
  
    --- 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;
    --- End diff --
    
    I am giving insert for this specific configuration and hence I have hardcoded it.



---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72954617
  
    --- 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;
    --- End diff --
    
    Why this config is hard coded here?


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72955848
  
    --- Diff: fineract-provider/src/main/resources/sql/migrations/core_db/v312_address_module_tables_metadat.sql ---
    @@ -0,0 +1,127 @@
    +--
    +-- Licensed to the Apache Software Foundation (ASF) under one
    +-- or more contributor license agreements. See the NOTICE file
    +-- distributed with this work for additional information
    +-- regarding copyright ownership. The ASF licenses this file
    +-- to you under the Apache License, Version 2.0 (the
    +-- "License"); you may not use this file except in compliance
    +-- with the License. You may obtain a copy of the License at
    +--
    +-- http://www.apache.org/licenses/LICENSE-2.0
    +--
    +-- Unless required by applicable law or agreed to in writing,
    +-- software distributed under the License is distributed on an
    +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +-- KIND, either express or implied. See the License for the
    +-- specific language governing permissions and limitations
    +-- under the License.
    +--
    +
    +--code inserts
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (150, 'INDIAN STATES', 0);
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (151, 'COUNTRY ID', 0);
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (152, 'ADDRESS TYPE ID', 0);
    +
    +--add new column in portfolio
    +alter table `m_portfolio_command_source` add column `status` TINYINT(4) NULL DEFAULT NULL;
    +
    +--configuration
    +INSERT INTO `c_configuration` (`id`, `name`, `value`, `date_value`, `enabled`, `is_trap_door`, `description`) VALUES (29, 'Enable-Address', NULL, NULL, 1, 0, NULL);
    +
    +--add address table
    +CREATE TABLE `m_address` (
    +	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    +	`street` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_1` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_2` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_3` VARCHAR(100) NULL DEFAULT NULL,
    +	`town_village` VARCHAR(100) NULL DEFAULT NULL,
    +	`city` VARCHAR(100) NULL DEFAULT NULL,
    +	`county_district` VARCHAR(100) NULL DEFAULT NULL,
    +	`state_province_id` INT(11) NULL DEFAULT NULL,
    +	`country_id` INT(11) NULL DEFAULT NULL,
    +	`postal_code` VARCHAR(10) NULL DEFAULT NULL,
    +	`latitude` DECIMAL(10,8) UNSIGNED NULL DEFAULT '0.00000000',
    +	`longitude` DECIMAL(10,8) UNSIGNED NULL DEFAULT '0.00000000',
    +	`created_by` VARCHAR(100) NULL DEFAULT NULL,
    +	`created_on` DATE NULL DEFAULT NULL,
    +	`updated_by` VARCHAR(100) NULL DEFAULT NULL,
    +	`updated_on` DATE NULL DEFAULT NULL,
    +	PRIMARY KEY (`id`),
    +	INDEX `address_fields_codefk1` (`state_province_id`),
    +	INDEX `address_fields_codefk2` (`country_id`),
    +	CONSTRAINT `address_fields_codefk1` FOREIGN KEY (`state_province_id`) REFERENCES `m_code_value` (`id`),
    +	CONSTRAINT `address_fields_codefk2` FOREIGN KEY (`country_id`) REFERENCES `m_code_value` (`id`)
    +)
    +COLLATE='utf8_general_ci'
    +ENGINE=InnoDB
    +AUTO_INCREMENT=20
    +;
    +
    +
    +--entity address table
    +CREATE TABLE `m_client_address` (
    +	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    +	`client_id` BIGINT(20) NOT NULL DEFAULT '0',
    +	`address_id` BIGINT(20) NOT NULL DEFAULT '0',
    +	`address_type_id` INT(11) NOT NULL DEFAULT '0',
    +	`is_active` TINYINT(4) NOT NULL DEFAULT '0',
    +	PRIMARY KEY (`id`),
    +	INDEX `addressIdFk` (`address_id`),
    +	INDEX `address_codefk` (`address_type_id`),
    +	INDEX `clientaddressfk` (`client_id`),
    +	CONSTRAINT `address_codefk` FOREIGN KEY (`address_type_id`) REFERENCES `m_code_value` (`id`),
    +	CONSTRAINT `clientaddressfk` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
    +)
    +COLLATE='utf8_general_ci'
    +ENGINE=InnoDB
    +AUTO_INCREMENT=28
    --- End diff --
    
    why AUTO_INCREMENT=28 ?


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72955812
  
    --- Diff: fineract-provider/src/main/resources/sql/migrations/core_db/v312_address_module_tables_metadat.sql ---
    @@ -0,0 +1,127 @@
    +--
    +-- Licensed to the Apache Software Foundation (ASF) under one
    +-- or more contributor license agreements. See the NOTICE file
    +-- distributed with this work for additional information
    +-- regarding copyright ownership. The ASF licenses this file
    +-- to you under the Apache License, Version 2.0 (the
    +-- "License"); you may not use this file except in compliance
    +-- with the License. You may obtain a copy of the License at
    +--
    +-- http://www.apache.org/licenses/LICENSE-2.0
    +--
    +-- Unless required by applicable law or agreed to in writing,
    +-- software distributed under the License is distributed on an
    +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +-- KIND, either express or implied. See the License for the
    +-- specific language governing permissions and limitations
    +-- under the License.
    +--
    +
    +--code inserts
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (150, 'INDIAN STATES', 0);
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (151, 'COUNTRY ID', 0);
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (152, 'ADDRESS TYPE ID', 0);
    +
    +--add new column in portfolio
    +alter table `m_portfolio_command_source` add column `status` TINYINT(4) NULL DEFAULT NULL;
    +
    +--configuration
    +INSERT INTO `c_configuration` (`id`, `name`, `value`, `date_value`, `enabled`, `is_trap_door`, `description`) VALUES (29, 'Enable-Address', NULL, NULL, 1, 0, NULL);
    +
    +--add address table
    +CREATE TABLE `m_address` (
    +	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    +	`street` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_1` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_2` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_3` VARCHAR(100) NULL DEFAULT NULL,
    +	`town_village` VARCHAR(100) NULL DEFAULT NULL,
    +	`city` VARCHAR(100) NULL DEFAULT NULL,
    +	`county_district` VARCHAR(100) NULL DEFAULT NULL,
    +	`state_province_id` INT(11) NULL DEFAULT NULL,
    +	`country_id` INT(11) NULL DEFAULT NULL,
    +	`postal_code` VARCHAR(10) NULL DEFAULT NULL,
    +	`latitude` DECIMAL(10,8) UNSIGNED NULL DEFAULT '0.00000000',
    +	`longitude` DECIMAL(10,8) UNSIGNED NULL DEFAULT '0.00000000',
    +	`created_by` VARCHAR(100) NULL DEFAULT NULL,
    +	`created_on` DATE NULL DEFAULT NULL,
    +	`updated_by` VARCHAR(100) NULL DEFAULT NULL,
    +	`updated_on` DATE NULL DEFAULT NULL,
    +	PRIMARY KEY (`id`),
    +	INDEX `address_fields_codefk1` (`state_province_id`),
    +	INDEX `address_fields_codefk2` (`country_id`),
    +	CONSTRAINT `address_fields_codefk1` FOREIGN KEY (`state_province_id`) REFERENCES `m_code_value` (`id`),
    +	CONSTRAINT `address_fields_codefk2` FOREIGN KEY (`country_id`) REFERENCES `m_code_value` (`id`)
    +)
    +COLLATE='utf8_general_ci'
    +ENGINE=InnoDB
    +AUTO_INCREMENT=20
    --- End diff --
    
    AUTO_INCREMENT=20 ?


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72937829
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/commands/domain/CommandSource.java ---
    @@ -95,6 +95,7 @@
         
    --- End diff --
    
    removed the file from commit


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72942209
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java ---
    @@ -41,10 +41,39 @@
         private String transactionId;
         private Long productId;
         private Long templateId;
    +    private Boolean status;
     
         public CommandWrapper build() {
             return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId, this.actionName,
    -                this.entityName, this.entityId, this.subentityId, this.href, this.json, this.transactionId, this.productId, this.templateId);
    +                this.entityName, this.entityId, this.subentityId, this.href, this.json, this.transactionId, this.productId, this.templateId
    +                ,this.status);
    +    }
    +    
    +    public CommandWrapperBuilder addClientAddress(final long clientId,final long addressTypeId) {
    +        this.actionName = "CREATE";
    +        this.entityName = "ADDRESS";
    +        this.entityId = addressTypeId;
    +        this.href = "/Address/template";
    +        this.clientId=clientId;
    +        return this;
    +    }
    +    
    +    public CommandWrapperBuilder updateClientAddress(final long clientId,final long addressTypeID,final boolean status) {
    +        this.actionName = "UPDATE";
    +        this.entityName = "ADDRESS";
    +        this.entityId = addressTypeID;
    +        this.href = "/Address/template";
    --- End diff --
    
    href value should reflect actual path url


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72952811
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/address/service/AddressWritePlatformServiceImpl.java ---
    @@ -0,0 +1,317 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.portfolio.address.service;
    +
    +import java.math.BigDecimal;
    +
    +import org.apache.fineract.infrastructure.codes.domain.CodeValue;
    +import org.apache.fineract.infrastructure.codes.domain.CodeValueRepository;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
    +import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
    +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
    +import org.apache.fineract.portfolio.address.domain.Address;
    +import org.apache.fineract.portfolio.address.domain.AddressRepository;
    +import org.apache.fineract.portfolio.address.serialization.AddAddressCommandFromApiJsonDeserializer;
    +import org.apache.fineract.portfolio.client.domain.Client;
    +import org.apache.fineract.portfolio.client.domain.ClientAddress;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepository;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepositoryWrapper;
    +import org.apache.fineract.portfolio.client.domain.ClientRepository;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +import com.google.gson.JsonArray;
    +import com.google.gson.JsonObject;
    +
    +@Service
    +public class AddressWritePlatformServiceImpl implements AddressWritePlatformService {
    +	private final PlatformSecurityContext context;
    +	private final CodeValueRepository codeValueRepository;
    +	private final ClientAddressRepository clientAddressRepository;
    +	private final ClientRepository clientRepository;
    +	private final AddressRepository addressRepository;
    +	private final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper;
    +	private final AddAddressCommandFromApiJsonDeserializer fromApiJsonDeserializer;
    +	private final static Logger logger = LoggerFactory.getLogger(AddressWritePlatformServiceImpl.class);
    +
    +	@Autowired
    +	public AddressWritePlatformServiceImpl(final PlatformSecurityContext context,
    +			final CodeValueRepository codeValueRepository, final ClientAddressRepository clientAddressRepository,
    +			final ClientRepository clientRepository, final AddressRepository addressRepository,
    +			final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper,
    +			final AddAddressCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
    +		this.context = context;
    +		this.codeValueRepository = codeValueRepository;
    +		this.clientAddressRepository = clientAddressRepository;
    +		this.clientRepository = clientRepository;
    +		this.addressRepository = addressRepository;
    +		this.clientAddressRepositoryWrapper = clientAddressRepositoryWrapper;
    +		this.fromApiJsonDeserializer = fromApiJsonDeserializer;
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addClientAddress(final Long clientId, final Long addressTypeId,
    +			final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		this.context.authenticatedUser();
    +		this.fromApiJsonDeserializer.validateForCreate(command.json(), false);
    +
    +		if (command.longValueOfParameterNamed("state_province_id") != null) {
    +			stateId = command.longValueOfParameterNamed("state_province_id");
    +			stateIdobj = this.codeValueRepository.getOne(stateId);
    +		}
    +
    +		if (command.longValueOfParameterNamed("country_id") != null) {
    +			countryId = command.longValueOfParameterNamed("country_id");
    +			countryIdObj = this.codeValueRepository.getOne(countryId);
    +		}
    +
    +		final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +		final Address add = Address.fromJson(command, stateIdobj, countryIdObj);
    +		this.addressRepository.save(add);
    +		final Long addressid = add.getId();
    +		final Address addobj = this.addressRepository.getOne(addressid);
    +
    +		final Client client = this.clientRepository.getOne(clientId);
    +
    +		final ClientAddress clientAddressobj = ClientAddress.fromJson(command, client, addobj, addressTypeIdObj);
    +		this.clientAddressRepository.save(clientAddressobj);
    +
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId())
    +				.withEntityId(clientAddressobj.getId()).build();
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addNewClientAddress(final Client client, final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		final JsonArray addressArray = command.arrayOfParameterNamed("address");
    +
    +		for (int i = 0; i < addressArray.size(); i++) {
    +			final JsonObject jsonObject = addressArray.get(i).getAsJsonObject();
    +			this.fromApiJsonDeserializer.validateForCreate(jsonObject.toString(), true);
    +
    +			if (command.longValueOfParameterNamed("state_province_id") != null) {
    +				stateId = command.longValueOfParameterNamed("state_province_id");
    +				stateIdobj = this.codeValueRepository.getOne(stateId);
    +			}
    +
    +			if (command.longValueOfParameterNamed("country_id") != null) {
    +				countryId = command.longValueOfParameterNamed("country_id");
    +				countryIdObj = this.codeValueRepository.getOne(countryId);
    +			}
    +
    +			final long addressTypeId = jsonObject.get("addressTypeId").getAsLong();
    +			final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +			final Address add = Address.fromJsonObject(jsonObject, stateIdobj, countryIdObj);
    +			this.addressRepository.save(add);
    +			final Long addressid = add.getId();
    +			final Address addobj = this.addressRepository.getOne(addressid);
    +
    +			final ClientAddress clientAddressobj = ClientAddress.fromJson(command, client, addobj, addressTypeIdObj);
    +			this.clientAddressRepository.save(clientAddressobj);
    +
    +		}
    +		final long typ = 1;
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(typ).build();
    +	}
    +
    +	@Override
    +	public CommandProcessingResult updateClientAddress(final Long clientId, final Long addressTypeId,
    +			final Boolean status, final JsonCommand command) {
    +		this.context.authenticatedUser();
    +
    +		long stateId;
    +
    +		long countryId;
    +
    +		CodeValue stateIdobj;
    +
    +		CodeValue countryIdObj;
    +
    +		boolean is_address_update = false;
    +
    +		boolean is_address_config_update = false;
    +
    +		final CodeValue addresstyp = this.codeValueRepository.getOne(addressTypeId);
    +		
    +		
    +		System.out.println("clientId is"+ clientId);
    --- End diff --
    
    Remove sysouts.


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by Nayan <gi...@git.apache.org>.
Github user Nayan commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72932502
  
    --- Diff: fineract-provider/src/main/resources/sql/migrations/core_db/v312_address_module_tables_metadat.sql.bak ---
    @@ -0,0 +1,96 @@
    +--
    --- End diff --
    
    @nikpawar89 why back file is part of this commit \U0001f44e 


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72969772
  
    --- 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;
    --- End diff --
    
    What happens if c_configuration already having a row with id 29?


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72952895
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/address/service/AddressWritePlatformServiceImpl.java ---
    @@ -0,0 +1,317 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.portfolio.address.service;
    +
    +import java.math.BigDecimal;
    +
    +import org.apache.fineract.infrastructure.codes.domain.CodeValue;
    +import org.apache.fineract.infrastructure.codes.domain.CodeValueRepository;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
    +import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
    +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
    +import org.apache.fineract.portfolio.address.domain.Address;
    +import org.apache.fineract.portfolio.address.domain.AddressRepository;
    +import org.apache.fineract.portfolio.address.serialization.AddAddressCommandFromApiJsonDeserializer;
    +import org.apache.fineract.portfolio.client.domain.Client;
    +import org.apache.fineract.portfolio.client.domain.ClientAddress;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepository;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepositoryWrapper;
    +import org.apache.fineract.portfolio.client.domain.ClientRepository;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +import com.google.gson.JsonArray;
    +import com.google.gson.JsonObject;
    +
    +@Service
    +public class AddressWritePlatformServiceImpl implements AddressWritePlatformService {
    +	private final PlatformSecurityContext context;
    +	private final CodeValueRepository codeValueRepository;
    +	private final ClientAddressRepository clientAddressRepository;
    +	private final ClientRepository clientRepository;
    +	private final AddressRepository addressRepository;
    +	private final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper;
    +	private final AddAddressCommandFromApiJsonDeserializer fromApiJsonDeserializer;
    +	private final static Logger logger = LoggerFactory.getLogger(AddressWritePlatformServiceImpl.class);
    +
    +	@Autowired
    +	public AddressWritePlatformServiceImpl(final PlatformSecurityContext context,
    +			final CodeValueRepository codeValueRepository, final ClientAddressRepository clientAddressRepository,
    +			final ClientRepository clientRepository, final AddressRepository addressRepository,
    +			final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper,
    +			final AddAddressCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
    +		this.context = context;
    +		this.codeValueRepository = codeValueRepository;
    +		this.clientAddressRepository = clientAddressRepository;
    +		this.clientRepository = clientRepository;
    +		this.addressRepository = addressRepository;
    +		this.clientAddressRepositoryWrapper = clientAddressRepositoryWrapper;
    +		this.fromApiJsonDeserializer = fromApiJsonDeserializer;
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addClientAddress(final Long clientId, final Long addressTypeId,
    +			final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		this.context.authenticatedUser();
    +		this.fromApiJsonDeserializer.validateForCreate(command.json(), false);
    +
    +		if (command.longValueOfParameterNamed("state_province_id") != null) {
    +			stateId = command.longValueOfParameterNamed("state_province_id");
    +			stateIdobj = this.codeValueRepository.getOne(stateId);
    +		}
    +
    +		if (command.longValueOfParameterNamed("country_id") != null) {
    +			countryId = command.longValueOfParameterNamed("country_id");
    +			countryIdObj = this.codeValueRepository.getOne(countryId);
    +		}
    +
    +		final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +		final Address add = Address.fromJson(command, stateIdobj, countryIdObj);
    +		this.addressRepository.save(add);
    +		final Long addressid = add.getId();
    +		final Address addobj = this.addressRepository.getOne(addressid);
    +
    +		final Client client = this.clientRepository.getOne(clientId);
    +
    +		final ClientAddress clientAddressobj = ClientAddress.fromJson(command, client, addobj, addressTypeIdObj);
    +		this.clientAddressRepository.save(clientAddressobj);
    +
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId())
    +				.withEntityId(clientAddressobj.getId()).build();
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addNewClientAddress(final Client client, final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		final JsonArray addressArray = command.arrayOfParameterNamed("address");
    +
    +		for (int i = 0; i < addressArray.size(); i++) {
    +			final JsonObject jsonObject = addressArray.get(i).getAsJsonObject();
    +			this.fromApiJsonDeserializer.validateForCreate(jsonObject.toString(), true);
    +
    +			if (command.longValueOfParameterNamed("state_province_id") != null) {
    +				stateId = command.longValueOfParameterNamed("state_province_id");
    +				stateIdobj = this.codeValueRepository.getOne(stateId);
    +			}
    +
    +			if (command.longValueOfParameterNamed("country_id") != null) {
    +				countryId = command.longValueOfParameterNamed("country_id");
    +				countryIdObj = this.codeValueRepository.getOne(countryId);
    +			}
    +
    +			final long addressTypeId = jsonObject.get("addressTypeId").getAsLong();
    +			final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +			final Address add = Address.fromJsonObject(jsonObject, stateIdobj, countryIdObj);
    +			this.addressRepository.save(add);
    +			final Long addressid = add.getId();
    +			final Address addobj = this.addressRepository.getOne(addressid);
    +
    +			final ClientAddress clientAddressobj = ClientAddress.fromJson(command, client, addobj, addressTypeIdObj);
    +			this.clientAddressRepository.save(clientAddressobj);
    +
    +		}
    +		final long typ = 1;
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(typ).build();
    +	}
    +
    +	@Override
    +	public CommandProcessingResult updateClientAddress(final Long clientId, final Long addressTypeId,
    +			final Boolean status, final JsonCommand command) {
    +		this.context.authenticatedUser();
    +
    +		long stateId;
    +
    +		long countryId;
    +
    +		CodeValue stateIdobj;
    +
    +		CodeValue countryIdObj;
    +
    +		boolean is_address_update = false;
    +
    +		boolean is_address_config_update = false;
    +
    +		final CodeValue addresstyp = this.codeValueRepository.getOne(addressTypeId);
    +		
    +		
    +		System.out.println("clientId is"+ clientId);
    +		System.out.println("addresstyp:" +addresstyp);
    +		System.out.println("status:" +status);
    +
    +		final ClientAddress clientAddressObj = this.clientAddressRepositoryWrapper
    +				.findOneByClientIdAndAddressTypeAndIsActive(clientId, addresstyp, status);
    +		System.out.println(clientAddressObj);
    --- End diff --
    
    Remove sysout


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72975292
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/address/service/AddressWritePlatformServiceImpl.java ---
    @@ -0,0 +1,317 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.portfolio.address.service;
    +
    +import java.math.BigDecimal;
    +
    +import org.apache.fineract.infrastructure.codes.domain.CodeValue;
    +import org.apache.fineract.infrastructure.codes.domain.CodeValueRepository;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
    +import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
    +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
    +import org.apache.fineract.portfolio.address.domain.Address;
    +import org.apache.fineract.portfolio.address.domain.AddressRepository;
    +import org.apache.fineract.portfolio.address.serialization.AddAddressCommandFromApiJsonDeserializer;
    +import org.apache.fineract.portfolio.client.domain.Client;
    +import org.apache.fineract.portfolio.client.domain.ClientAddress;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepository;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepositoryWrapper;
    +import org.apache.fineract.portfolio.client.domain.ClientRepository;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +import com.google.gson.JsonArray;
    +import com.google.gson.JsonObject;
    +
    +@Service
    +public class AddressWritePlatformServiceImpl implements AddressWritePlatformService {
    +	private final PlatformSecurityContext context;
    +	private final CodeValueRepository codeValueRepository;
    +	private final ClientAddressRepository clientAddressRepository;
    +	private final ClientRepository clientRepository;
    +	private final AddressRepository addressRepository;
    +	private final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper;
    +	private final AddAddressCommandFromApiJsonDeserializer fromApiJsonDeserializer;
    +	private final static Logger logger = LoggerFactory.getLogger(AddressWritePlatformServiceImpl.class);
    +
    +	@Autowired
    +	public AddressWritePlatformServiceImpl(final PlatformSecurityContext context,
    +			final CodeValueRepository codeValueRepository, final ClientAddressRepository clientAddressRepository,
    +			final ClientRepository clientRepository, final AddressRepository addressRepository,
    +			final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper,
    +			final AddAddressCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
    +		this.context = context;
    +		this.codeValueRepository = codeValueRepository;
    +		this.clientAddressRepository = clientAddressRepository;
    +		this.clientRepository = clientRepository;
    +		this.addressRepository = addressRepository;
    +		this.clientAddressRepositoryWrapper = clientAddressRepositoryWrapper;
    +		this.fromApiJsonDeserializer = fromApiJsonDeserializer;
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addClientAddress(final Long clientId, final Long addressTypeId,
    +			final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		this.context.authenticatedUser();
    +		this.fromApiJsonDeserializer.validateForCreate(command.json(), false);
    +
    +		if (command.longValueOfParameterNamed("state_province_id") != null) {
    +			stateId = command.longValueOfParameterNamed("state_province_id");
    +			stateIdobj = this.codeValueRepository.getOne(stateId);
    +		}
    +
    +		if (command.longValueOfParameterNamed("country_id") != null) {
    +			countryId = command.longValueOfParameterNamed("country_id");
    +			countryIdObj = this.codeValueRepository.getOne(countryId);
    +		}
    +
    +		final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +		final Address add = Address.fromJson(command, stateIdobj, countryIdObj);
    +		this.addressRepository.save(add);
    +		final Long addressid = add.getId();
    +		final Address addobj = this.addressRepository.getOne(addressid);
    +
    +		final Client client = this.clientRepository.getOne(clientId);
    +
    +		final ClientAddress clientAddressobj = ClientAddress.fromJson(command, client, addobj, addressTypeIdObj);
    +		this.clientAddressRepository.save(clientAddressobj);
    +
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId())
    +				.withEntityId(clientAddressobj.getId()).build();
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addNewClientAddress(final Client client, final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		final JsonArray addressArray = command.arrayOfParameterNamed("address");
    +
    +		for (int i = 0; i < addressArray.size(); i++) {
    +			final JsonObject jsonObject = addressArray.get(i).getAsJsonObject();
    +			this.fromApiJsonDeserializer.validateForCreate(jsonObject.toString(), true);
    +
    +			if (command.longValueOfParameterNamed("state_province_id") != null) {
    +				stateId = command.longValueOfParameterNamed("state_province_id");
    +				stateIdobj = this.codeValueRepository.getOne(stateId);
    +			}
    +
    +			if (command.longValueOfParameterNamed("country_id") != null) {
    +				countryId = command.longValueOfParameterNamed("country_id");
    +				countryIdObj = this.codeValueRepository.getOne(countryId);
    +			}
    +
    +			final long addressTypeId = jsonObject.get("addressTypeId").getAsLong();
    +			final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +			final Address add = Address.fromJsonObject(jsonObject, stateIdobj, countryIdObj);
    +			this.addressRepository.save(add);
    +			final Long addressid = add.getId();
    +			final Address addobj = this.addressRepository.getOne(addressid);
    +
    +			final ClientAddress clientAddressobj = ClientAddress.fromJson(command, client, addobj, addressTypeIdObj);
    +			this.clientAddressRepository.save(clientAddressobj);
    +
    +		}
    +		final long typ = 1;
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(typ).build();
    +	}
    +
    +	@Override
    +	public CommandProcessingResult updateClientAddress(final Long clientId, final Long addressTypeId,
    +			final Boolean status, final JsonCommand command) {
    +		this.context.authenticatedUser();
    +
    +		long stateId;
    +
    +		long countryId;
    +
    +		CodeValue stateIdobj;
    +
    +		CodeValue countryIdObj;
    +
    +		boolean is_address_update = false;
    +
    +		boolean is_address_config_update = false;
    +
    +		final CodeValue addresstyp = this.codeValueRepository.getOne(addressTypeId);
    +		
    +		
    +		System.out.println("clientId is"+ clientId);
    --- End diff --
    
    done


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72953812
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/address/service/AddressWritePlatformServiceImpl.java ---
    @@ -0,0 +1,317 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.portfolio.address.service;
    +
    +import java.math.BigDecimal;
    +
    +import org.apache.fineract.infrastructure.codes.domain.CodeValue;
    +import org.apache.fineract.infrastructure.codes.domain.CodeValueRepository;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
    +import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
    +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
    +import org.apache.fineract.portfolio.address.domain.Address;
    +import org.apache.fineract.portfolio.address.domain.AddressRepository;
    +import org.apache.fineract.portfolio.address.serialization.AddAddressCommandFromApiJsonDeserializer;
    +import org.apache.fineract.portfolio.client.domain.Client;
    +import org.apache.fineract.portfolio.client.domain.ClientAddress;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepository;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepositoryWrapper;
    +import org.apache.fineract.portfolio.client.domain.ClientRepository;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +import com.google.gson.JsonArray;
    +import com.google.gson.JsonObject;
    +
    +@Service
    +public class AddressWritePlatformServiceImpl implements AddressWritePlatformService {
    +	private final PlatformSecurityContext context;
    +	private final CodeValueRepository codeValueRepository;
    +	private final ClientAddressRepository clientAddressRepository;
    +	private final ClientRepository clientRepository;
    +	private final AddressRepository addressRepository;
    +	private final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper;
    +	private final AddAddressCommandFromApiJsonDeserializer fromApiJsonDeserializer;
    +	private final static Logger logger = LoggerFactory.getLogger(AddressWritePlatformServiceImpl.class);
    +
    +	@Autowired
    +	public AddressWritePlatformServiceImpl(final PlatformSecurityContext context,
    +			final CodeValueRepository codeValueRepository, final ClientAddressRepository clientAddressRepository,
    +			final ClientRepository clientRepository, final AddressRepository addressRepository,
    +			final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper,
    +			final AddAddressCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
    +		this.context = context;
    +		this.codeValueRepository = codeValueRepository;
    +		this.clientAddressRepository = clientAddressRepository;
    +		this.clientRepository = clientRepository;
    +		this.addressRepository = addressRepository;
    +		this.clientAddressRepositoryWrapper = clientAddressRepositoryWrapper;
    +		this.fromApiJsonDeserializer = fromApiJsonDeserializer;
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addClientAddress(final Long clientId, final Long addressTypeId,
    +			final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		this.context.authenticatedUser();
    +		this.fromApiJsonDeserializer.validateForCreate(command.json(), false);
    +
    +		if (command.longValueOfParameterNamed("state_province_id") != null) {
    +			stateId = command.longValueOfParameterNamed("state_province_id");
    +			stateIdobj = this.codeValueRepository.getOne(stateId);
    +		}
    +
    +		if (command.longValueOfParameterNamed("country_id") != null) {
    +			countryId = command.longValueOfParameterNamed("country_id");
    +			countryIdObj = this.codeValueRepository.getOne(countryId);
    +		}
    +
    +		final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +		final Address add = Address.fromJson(command, stateIdobj, countryIdObj);
    +		this.addressRepository.save(add);
    +		final Long addressid = add.getId();
    +		final Address addobj = this.addressRepository.getOne(addressid);
    +
    +		final Client client = this.clientRepository.getOne(clientId);
    +
    +		final ClientAddress clientAddressobj = ClientAddress.fromJson(command, client, addobj, addressTypeIdObj);
    +		this.clientAddressRepository.save(clientAddressobj);
    +
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId())
    +				.withEntityId(clientAddressobj.getId()).build();
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addNewClientAddress(final Client client, final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		final JsonArray addressArray = command.arrayOfParameterNamed("address");
    +
    +		for (int i = 0; i < addressArray.size(); i++) {
    +			final JsonObject jsonObject = addressArray.get(i).getAsJsonObject();
    +			this.fromApiJsonDeserializer.validateForCreate(jsonObject.toString(), true);
    +
    +			if (command.longValueOfParameterNamed("state_province_id") != null) {
    +				stateId = command.longValueOfParameterNamed("state_province_id");
    +				stateIdobj = this.codeValueRepository.getOne(stateId);
    +			}
    +
    +			if (command.longValueOfParameterNamed("country_id") != null) {
    +				countryId = command.longValueOfParameterNamed("country_id");
    +				countryIdObj = this.codeValueRepository.getOne(countryId);
    +			}
    +
    +			final long addressTypeId = jsonObject.get("addressTypeId").getAsLong();
    +			final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +			final Address add = Address.fromJsonObject(jsonObject, stateIdobj, countryIdObj);
    +			this.addressRepository.save(add);
    +			final Long addressid = add.getId();
    +			final Address addobj = this.addressRepository.getOne(addressid);
    +
    +			final ClientAddress clientAddressobj = ClientAddress.fromJson(command, client, addobj, addressTypeIdObj);
    +			this.clientAddressRepository.save(clientAddressobj);
    +
    +		}
    +		final long typ = 1;
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(typ).build();
    +	}
    +
    +	@Override
    +	public CommandProcessingResult updateClientAddress(final Long clientId, final Long addressTypeId,
    +			final Boolean status, final JsonCommand command) {
    +		this.context.authenticatedUser();
    +
    +		long stateId;
    +
    +		long countryId;
    +
    +		CodeValue stateIdobj;
    +
    +		CodeValue countryIdObj;
    +
    +		boolean is_address_update = false;
    +
    +		boolean is_address_config_update = false;
    +
    +		final CodeValue addresstyp = this.codeValueRepository.getOne(addressTypeId);
    +		
    +		
    +		System.out.println("clientId is"+ clientId);
    +		System.out.println("addresstyp:" +addresstyp);
    +		System.out.println("status:" +status);
    +
    +		final ClientAddress clientAddressObj = this.clientAddressRepositoryWrapper
    --- End diff --
    
    Why this method is required to pass status? Any how you are always retrieving active client address right? 


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72934157
  
    --- Diff: fineract-provider/src/main/resources/sql/migrations/core_db/v312_address_module_tables_metadat.sql.bak ---
    @@ -0,0 +1,96 @@
    +--
    --- End diff --
    
    would remove that



---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72954771
  
    --- 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 --
    
    remove sysout


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72975283
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/address/service/AddressWritePlatformServiceImpl.java ---
    @@ -0,0 +1,317 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.portfolio.address.service;
    +
    +import java.math.BigDecimal;
    +
    +import org.apache.fineract.infrastructure.codes.domain.CodeValue;
    +import org.apache.fineract.infrastructure.codes.domain.CodeValueRepository;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
    +import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
    +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
    +import org.apache.fineract.portfolio.address.domain.Address;
    +import org.apache.fineract.portfolio.address.domain.AddressRepository;
    +import org.apache.fineract.portfolio.address.serialization.AddAddressCommandFromApiJsonDeserializer;
    +import org.apache.fineract.portfolio.client.domain.Client;
    +import org.apache.fineract.portfolio.client.domain.ClientAddress;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepository;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepositoryWrapper;
    +import org.apache.fineract.portfolio.client.domain.ClientRepository;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +import com.google.gson.JsonArray;
    +import com.google.gson.JsonObject;
    +
    +@Service
    +public class AddressWritePlatformServiceImpl implements AddressWritePlatformService {
    +	private final PlatformSecurityContext context;
    +	private final CodeValueRepository codeValueRepository;
    +	private final ClientAddressRepository clientAddressRepository;
    +	private final ClientRepository clientRepository;
    +	private final AddressRepository addressRepository;
    +	private final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper;
    +	private final AddAddressCommandFromApiJsonDeserializer fromApiJsonDeserializer;
    +	private final static Logger logger = LoggerFactory.getLogger(AddressWritePlatformServiceImpl.class);
    +
    +	@Autowired
    +	public AddressWritePlatformServiceImpl(final PlatformSecurityContext context,
    +			final CodeValueRepository codeValueRepository, final ClientAddressRepository clientAddressRepository,
    +			final ClientRepository clientRepository, final AddressRepository addressRepository,
    +			final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper,
    +			final AddAddressCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
    +		this.context = context;
    +		this.codeValueRepository = codeValueRepository;
    +		this.clientAddressRepository = clientAddressRepository;
    +		this.clientRepository = clientRepository;
    +		this.addressRepository = addressRepository;
    +		this.clientAddressRepositoryWrapper = clientAddressRepositoryWrapper;
    +		this.fromApiJsonDeserializer = fromApiJsonDeserializer;
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addClientAddress(final Long clientId, final Long addressTypeId,
    +			final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		this.context.authenticatedUser();
    +		this.fromApiJsonDeserializer.validateForCreate(command.json(), false);
    +
    +		if (command.longValueOfParameterNamed("state_province_id") != null) {
    +			stateId = command.longValueOfParameterNamed("state_province_id");
    +			stateIdobj = this.codeValueRepository.getOne(stateId);
    +		}
    +
    +		if (command.longValueOfParameterNamed("country_id") != null) {
    +			countryId = command.longValueOfParameterNamed("country_id");
    +			countryIdObj = this.codeValueRepository.getOne(countryId);
    +		}
    +
    +		final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +		final Address add = Address.fromJson(command, stateIdobj, countryIdObj);
    +		this.addressRepository.save(add);
    +		final Long addressid = add.getId();
    +		final Address addobj = this.addressRepository.getOne(addressid);
    +
    +		final Client client = this.clientRepository.getOne(clientId);
    +
    +		final ClientAddress clientAddressobj = ClientAddress.fromJson(command, client, addobj, addressTypeIdObj);
    +		this.clientAddressRepository.save(clientAddressobj);
    +
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId())
    +				.withEntityId(clientAddressobj.getId()).build();
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addNewClientAddress(final Client client, final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		final JsonArray addressArray = command.arrayOfParameterNamed("address");
    +
    +		for (int i = 0; i < addressArray.size(); i++) {
    +			final JsonObject jsonObject = addressArray.get(i).getAsJsonObject();
    +			this.fromApiJsonDeserializer.validateForCreate(jsonObject.toString(), true);
    +
    +			if (command.longValueOfParameterNamed("state_province_id") != null) {
    +				stateId = command.longValueOfParameterNamed("state_province_id");
    +				stateIdobj = this.codeValueRepository.getOne(stateId);
    +			}
    +
    +			if (command.longValueOfParameterNamed("country_id") != null) {
    +				countryId = command.longValueOfParameterNamed("country_id");
    +				countryIdObj = this.codeValueRepository.getOne(countryId);
    +			}
    +
    +			final long addressTypeId = jsonObject.get("addressTypeId").getAsLong();
    +			final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +			final Address add = Address.fromJsonObject(jsonObject, stateIdobj, countryIdObj);
    +			this.addressRepository.save(add);
    +			final Long addressid = add.getId();
    +			final Address addobj = this.addressRepository.getOne(addressid);
    +
    +			final ClientAddress clientAddressobj = ClientAddress.fromJson(command, client, addobj, addressTypeIdObj);
    +			this.clientAddressRepository.save(clientAddressobj);
    +
    +		}
    +		final long typ = 1;
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(typ).build();
    +	}
    +
    +	@Override
    +	public CommandProcessingResult updateClientAddress(final Long clientId, final Long addressTypeId,
    +			final Boolean status, final JsonCommand command) {
    +		this.context.authenticatedUser();
    +
    +		long stateId;
    +
    +		long countryId;
    +
    +		CodeValue stateIdobj;
    +
    +		CodeValue countryIdObj;
    +
    +		boolean is_address_update = false;
    +
    +		boolean is_address_config_update = false;
    +
    +		final CodeValue addresstyp = this.codeValueRepository.getOne(addressTypeId);
    +		
    +		
    +		System.out.println("clientId is"+ clientId);
    +		System.out.println("addresstyp:" +addresstyp);
    +		System.out.println("status:" +status);
    +
    +		final ClientAddress clientAddressObj = this.clientAddressRepositoryWrapper
    +				.findOneByClientIdAndAddressTypeAndIsActive(clientId, addresstyp, status);
    +		System.out.println(clientAddressObj);
    --- End diff --
    
    done


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72992013
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductCommandsServiceImpl.java ---
    @@ -47,7 +47,7 @@ public CommandProcessingResult postDividends(Long productId, JsonCommand jsonCom
         public Object handleCommand(Long productId, String command, String jsonBody) {
             final JsonElement parsedCommand = this.fromApiJsonHelper.parse(jsonBody);
             final JsonCommand jsonCommand = JsonCommand.from(jsonBody, parsedCommand, this.fromApiJsonHelper, null, null, null, null, null,
    -                null, null, null, null, null);
    +                null, null, null, null, null,null);
    --- End diff --
    
    from static method of JsonCommand class has to be chaned in order to get status value from the JSONCommand.  The change in the signature results in addition of one more parameter value in this class.


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 closed the pull request at:

    https://github.com/apache/incubator-fineract/pull/189


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72975231
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java ---
    @@ -41,10 +41,39 @@
         private String transactionId;
         private Long productId;
         private Long templateId;
    +    private Boolean status;
     
         public CommandWrapper build() {
             return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId, this.actionName,
    -                this.entityName, this.entityId, this.subentityId, this.href, this.json, this.transactionId, this.productId, this.templateId);
    +                this.entityName, this.entityId, this.subentityId, this.href, this.json, this.transactionId, this.productId, this.templateId
    +                ,this.status);
    +    }
    +    
    +    public CommandWrapperBuilder addClientAddress(final long clientId,final long addressTypeId) {
    +        this.actionName = "CREATE";
    +        this.entityName = "ADDRESS";
    +        this.entityId = addressTypeId;
    +        this.href = "/Address/template";
    +        this.clientId=clientId;
    +        return this;
    +    }
    +    
    +    public CommandWrapperBuilder updateClientAddress(final long clientId,final long addressTypeID,final boolean status) {
    +        this.actionName = "UPDATE";
    +        this.entityName = "ADDRESS";
    +        this.entityId = addressTypeID;
    +        this.href = "/Address/template";
    --- End diff --
    
    I actually don't require them. Can I omit these entries?


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72942184
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java ---
    @@ -41,10 +41,39 @@
         private String transactionId;
         private Long productId;
         private Long templateId;
    +    private Boolean status;
     
         public CommandWrapper build() {
             return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId, this.actionName,
    -                this.entityName, this.entityId, this.subentityId, this.href, this.json, this.transactionId, this.productId, this.templateId);
    +                this.entityName, this.entityId, this.subentityId, this.href, this.json, this.transactionId, this.productId, this.templateId
    +                ,this.status);
    +    }
    +    
    +    public CommandWrapperBuilder addClientAddress(final long clientId,final long addressTypeId) {
    +        this.actionName = "CREATE";
    +        this.entityName = "ADDRESS";
    +        this.entityId = addressTypeId;
    +        this.href = "/Address/template";
    --- End diff --
    
    href value should reflect actual path url


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72992036
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/service/ShareAccountCommandsServiceImpl.java ---
    @@ -47,7 +47,7 @@ public ShareAccountCommandsServiceImpl(final FromJsonHelper fromApiJsonHelper,
         public Object handleCommand(Long accountId, String command, String jsonBody) {
             final JsonElement parsedCommand = this.fromApiJsonHelper.parse(jsonBody);
             final JsonCommand jsonCommand = JsonCommand.from(jsonBody, parsedCommand, this.fromApiJsonHelper, null, null, null, null, null,
    -                null, null, null, null, null);
    +                null, null, null, null, null,null);
    --- End diff --
    
    from static method of JsonCommand class has to be chaned in order to get status value from the JSONCommand.  The change in the signature results in addition of one more parameter value in this class.


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72965434
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/address/api/AddressConfigurationApiResources.java ---
    @@ -0,0 +1,112 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.portfolio.address.api;
    +
    +import java.util.Arrays;
    +import java.util.Collection;
    +import java.util.HashSet;
    +import java.util.Set;
    +
    +import javax.ws.rs.Consumes;
    +import javax.ws.rs.GET;
    +import javax.ws.rs.Path;
    +import javax.ws.rs.PathParam;
    +import javax.ws.rs.Produces;
    +import javax.ws.rs.core.Context;
    +import javax.ws.rs.core.MediaType;
    +import javax.ws.rs.core.UriInfo;
    +
    +import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
    +import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
    +import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
    +import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
    +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
    +import org.apache.fineract.portfolio.address.data.AddressData;
    +import org.apache.fineract.portfolio.address.data.FieldConfigurationData;
    +import org.apache.fineract.portfolio.address.service.AddressReadPlatformServiceImpl;
    +import org.apache.fineract.portfolio.address.service.FieldConfigurationReadPlatformService;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.context.annotation.Scope;
    +import org.springframework.stereotype.Component;
    +
    +@Path("/clients/addresses")
    +@Component
    +@Scope("singleton")
    +public class AddressConfigurationApiResources {
    +	private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("clientAddressId", "client_id",
    +			"address_id", "address_type_id", "is_active", "fieldConfigurationId", "entity", "table", "field",
    +			"is_enabled", "is_mandatory", "validation_regex"));
    +	private final String resourceNameForPermissions = "Address";
    +	private final PlatformSecurityContext context;
    +	private final AddressReadPlatformServiceImpl readPlatformService;
    +	private final DefaultToApiJsonSerializer<AddressData> toApiJsonSerializer;
    +	private final FieldConfigurationReadPlatformService readPlatformServicefld;
    +	private final DefaultToApiJsonSerializer<FieldConfigurationData> toApiJsonSerializerfld;
    +	private final ApiRequestParameterHelper apiRequestParameterHelper;
    +	private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
    +
    +	@Autowired
    +	public AddressConfigurationApiResources(final PlatformSecurityContext context,
    +			final AddressReadPlatformServiceImpl readPlatformService,
    +			final DefaultToApiJsonSerializer<AddressData> toApiJsonSerializer,
    +			final FieldConfigurationReadPlatformService readPlatformServicefld,
    +			final DefaultToApiJsonSerializer<FieldConfigurationData> toApiJsonSerializerfld,
    +			final ApiRequestParameterHelper apiRequestParameterHelper,
    +			final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
    +		this.context = context;
    +		this.readPlatformService = readPlatformService;
    +		this.toApiJsonSerializer = toApiJsonSerializer;
    +		this.readPlatformServicefld = readPlatformServicefld;
    +		this.toApiJsonSerializerfld = toApiJsonSerializerfld;
    +		this.apiRequestParameterHelper = apiRequestParameterHelper;
    +		this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
    +	}
    +
    +	@GET
    +	@Path("/fieldconfiguration/{entity}")
    +	@Consumes({ MediaType.APPLICATION_JSON })
    +	@Produces({ MediaType.APPLICATION_JSON })
    +	public String getAddresses(@PathParam("entity") final String entityname, @Context final UriInfo uriInfo) {
    --- End diff --
    
    removed the redundant method from AddressConfigurationApiResources.java



---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by Nayan <gi...@git.apache.org>.
Github user Nayan commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r73134464
  
    --- Diff: fineract-provider/src/main/resources/sql/migrations/core_db/v312_address_module_tables_metadat.sql ---
    @@ -0,0 +1,127 @@
    +--
    +-- Licensed to the Apache Software Foundation (ASF) under one
    +-- or more contributor license agreements. See the NOTICE file
    +-- distributed with this work for additional information
    +-- regarding copyright ownership. The ASF licenses this file
    +-- to you under the Apache License, Version 2.0 (the
    +-- "License"); you may not use this file except in compliance
    +-- with the License. You may obtain a copy of the License at
    +--
    +-- http://www.apache.org/licenses/LICENSE-2.0
    +--
    +-- Unless required by applicable law or agreed to in writing,
    +-- software distributed under the License is distributed on an
    +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +-- KIND, either express or implied. See the License for the
    +-- specific language governing permissions and limitations
    +-- under the License.
    +--
    +
    +--code inserts
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (150, 'INDIAN STATES', 0);
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (151, 'COUNTRY ID', 0);
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (152, 'ADDRESS TYPE ID', 0);
    +
    +--add new column in portfolio
    +alter table `m_portfolio_command_source` add column `status` TINYINT(4) NULL DEFAULT NULL;
    +
    +--configuration
    +INSERT INTO `c_configuration` (`id`, `name`, `value`, `date_value`, `enabled`, `is_trap_door`, `description`) VALUES (29, 'Enable-Address', NULL, NULL, 1, 0, NULL);
    +
    +--add address table
    +CREATE TABLE `m_address` (
    +	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    +	`street` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_1` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_2` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_3` VARCHAR(100) NULL DEFAULT NULL,
    +	`town_village` VARCHAR(100) NULL DEFAULT NULL,
    +	`city` VARCHAR(100) NULL DEFAULT NULL,
    +	`county_district` VARCHAR(100) NULL DEFAULT NULL,
    +	`state_province_id` INT(11) NULL DEFAULT NULL,
    +	`country_id` INT(11) NULL DEFAULT NULL,
    +	`postal_code` VARCHAR(10) NULL DEFAULT NULL,
    +	`latitude` DECIMAL(10,8) UNSIGNED NULL DEFAULT '0.00000000',
    +	`longitude` DECIMAL(10,8) UNSIGNED NULL DEFAULT '0.00000000',
    +	`created_by` VARCHAR(100) NULL DEFAULT NULL,
    +	`created_on` DATE NULL DEFAULT NULL,
    +	`updated_by` VARCHAR(100) NULL DEFAULT NULL,
    +	`updated_on` DATE NULL DEFAULT NULL,
    +	PRIMARY KEY (`id`),
    +	INDEX `address_fields_codefk1` (`state_province_id`),
    +	INDEX `address_fields_codefk2` (`country_id`),
    +	CONSTRAINT `address_fields_codefk1` FOREIGN KEY (`state_province_id`) REFERENCES `m_code_value` (`id`),
    +	CONSTRAINT `address_fields_codefk2` FOREIGN KEY (`country_id`) REFERENCES `m_code_value` (`id`)
    +)
    +COLLATE='utf8_general_ci'
    +ENGINE=InnoDB
    +AUTO_INCREMENT=1
    +;
    +
    +
    +--entity address table
    +CREATE TABLE `m_client_address` (
    +	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    +	`client_id` BIGINT(20) NOT NULL DEFAULT '0',
    +	`address_id` BIGINT(20) NOT NULL DEFAULT '0',
    +	`address_type_id` INT(11) NOT NULL DEFAULT '0',
    +	`is_active` TINYINT(4) NOT NULL DEFAULT '0',
    +	PRIMARY KEY (`id`),
    +	INDEX `addressIdFk` (`address_id`),
    +	INDEX `address_codefk` (`address_type_id`),
    +	INDEX `clientaddressfk` (`client_id`),
    +	CONSTRAINT `address_codefk` FOREIGN KEY (`address_type_id`) REFERENCES `m_code_value` (`id`),
    +	CONSTRAINT `clientaddressfk` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
    +)
    +COLLATE='utf8_general_ci'
    +ENGINE=InnoDB
    +AUTO_INCREMENT=1
    +;
    +
    +
    +--field configuration
    +CREATE TABLE `m_field_configuration` (
    +	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    +	`entity` VARCHAR(100) NOT NULL,
    +	`table` VARCHAR(100) NOT NULL,
    +	`field` VARCHAR(100) NOT NULL,
    +	`is_enabled` TINYINT(4) NOT NULL,
    +	`is_mandatory` TINYINT(4) NOT NULL,
    +	`validation_regex` VARCHAR(50) NULL DEFAULT NULL,
    +	PRIMARY KEY (`id`)
    +)
    +COLLATE='utf8_general_ci'
    +ENGINE=InnoDB
    +AUTO_INCREMENT=1
    +;
    +
    +
    +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
    +/*!40101 SET NAMES utf8mb4 */;
    +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
    +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
    +-- Dumping data for table mifostenant-default.m_field_configuration: ~18 rows (approximately)
    +/*!40000 ALTER TABLE `m_field_configuration` DISABLE KEYS */;
    +INSERT INTO `m_field_configuration` (`id`, `entity`, `table`, `field`, `is_enabled`, `is_mandatory`, `validation_regex`) VALUES
    --- End diff --
    
    @nikpawar89 primary key should be auto generated


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72954135
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientAddressRepositoryWrapper.java ---
    @@ -0,0 +1,43 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.portfolio.client.domain;
    +
    +import org.apache.fineract.infrastructure.codes.domain.CodeValue;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +@Service
    +public class ClientAddressRepositoryWrapper {
    +	private final ClientAddressRepository clientAddressRepository;
    +
    +	@Autowired
    +	public ClientAddressRepositoryWrapper(final ClientAddressRepository clientAddressRepository) {
    +		this.clientAddressRepository = clientAddressRepository;
    +	}
    +
    +	public ClientAddress findOneByClientIdAndAddressTypeAndIsActive(final long clientId, final CodeValue addressType,
    --- End diff --
    
    This method returns active client addresses. is it required to have isActive as param?


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72956196
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/client/handler/UpdateClientAddressCommandHandler.java ---
    @@ -0,0 +1,47 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.portfolio.client.handler;
    +
    +import org.apache.fineract.commands.annotation.CommandType;
    +import org.apache.fineract.commands.handler.NewCommandSourceHandler;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
    +import org.apache.fineract.portfolio.address.service.AddressWritePlatformService;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +@Service
    +@CommandType(entity = "ADDRESS", action = "UPDATE")
    +public class UpdateClientAddressCommandHandler implements NewCommandSourceHandler {
    +
    +	private final AddressWritePlatformService writePlatformService;
    +
    +	@Autowired
    +	public UpdateClientAddressCommandHandler(final AddressWritePlatformService writePlatformService) {
    +		this.writePlatformService = writePlatformService;
    +	}
    +
    +	@Override
    +	public CommandProcessingResult processCommand(final JsonCommand command) {
    +		return this.writePlatformService.updateClientAddress(command.getClientId(), command.entityId(),
    +				command.getStatus(), command);
    --- End diff --
    
    status is not required to pass


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by Nayan <gi...@git.apache.org>.
Github user Nayan commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72932323
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/commands/domain/CommandSource.java ---
    @@ -95,6 +95,7 @@
         
    --- End diff --
    
    @nikpawar89  this file should be ignored, has only formatting changes 


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72992059
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java ---
    @@ -2292,7 +2292,7 @@ public void applyOverdueChargesForLoan(final Long loanId, Collection<OverdueLoan
     
                 final JsonElement parsedCommand = this.fromApiJsonHelper.parse(overdueInstallment.toString());
                 final JsonCommand command = JsonCommand.from(overdueInstallment.toString(), parsedCommand, this.fromApiJsonHelper, null, null,
    -                    null, null, null, loanId, null, null, null, null);
    +                    null, null, null, loanId, null, null, null, null,null);
    --- End diff --
    
    from static method of JsonCommand class has to be chaned in order to get status value from the JSONCommand.  The change in the signature results in addition of one more parameter value in this class.


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72944048
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/address/api/AddressConfigurationApiResources.java ---
    @@ -0,0 +1,112 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.portfolio.address.api;
    +
    +import java.util.Arrays;
    +import java.util.Collection;
    +import java.util.HashSet;
    +import java.util.Set;
    +
    +import javax.ws.rs.Consumes;
    +import javax.ws.rs.GET;
    +import javax.ws.rs.Path;
    +import javax.ws.rs.PathParam;
    +import javax.ws.rs.Produces;
    +import javax.ws.rs.core.Context;
    +import javax.ws.rs.core.MediaType;
    +import javax.ws.rs.core.UriInfo;
    +
    +import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
    +import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
    +import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
    +import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
    +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
    +import org.apache.fineract.portfolio.address.data.AddressData;
    +import org.apache.fineract.portfolio.address.data.FieldConfigurationData;
    +import org.apache.fineract.portfolio.address.service.AddressReadPlatformServiceImpl;
    +import org.apache.fineract.portfolio.address.service.FieldConfigurationReadPlatformService;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.context.annotation.Scope;
    +import org.springframework.stereotype.Component;
    +
    +@Path("/clients/addresses")
    +@Component
    +@Scope("singleton")
    +public class AddressConfigurationApiResources {
    +	private final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("clientAddressId", "client_id",
    +			"address_id", "address_type_id", "is_active", "fieldConfigurationId", "entity", "table", "field",
    +			"is_enabled", "is_mandatory", "validation_regex"));
    +	private final String resourceNameForPermissions = "Address";
    +	private final PlatformSecurityContext context;
    +	private final AddressReadPlatformServiceImpl readPlatformService;
    +	private final DefaultToApiJsonSerializer<AddressData> toApiJsonSerializer;
    +	private final FieldConfigurationReadPlatformService readPlatformServicefld;
    +	private final DefaultToApiJsonSerializer<FieldConfigurationData> toApiJsonSerializerfld;
    +	private final ApiRequestParameterHelper apiRequestParameterHelper;
    +	private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
    +
    +	@Autowired
    +	public AddressConfigurationApiResources(final PlatformSecurityContext context,
    +			final AddressReadPlatformServiceImpl readPlatformService,
    +			final DefaultToApiJsonSerializer<AddressData> toApiJsonSerializer,
    +			final FieldConfigurationReadPlatformService readPlatformServicefld,
    +			final DefaultToApiJsonSerializer<FieldConfigurationData> toApiJsonSerializerfld,
    +			final ApiRequestParameterHelper apiRequestParameterHelper,
    +			final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
    +		this.context = context;
    +		this.readPlatformService = readPlatformService;
    +		this.toApiJsonSerializer = toApiJsonSerializer;
    +		this.readPlatformServicefld = readPlatformServicefld;
    +		this.toApiJsonSerializerfld = toApiJsonSerializerfld;
    +		this.apiRequestParameterHelper = apiRequestParameterHelper;
    +		this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
    +	}
    +
    +	@GET
    +	@Path("/fieldconfiguration/{entity}")
    +	@Consumes({ MediaType.APPLICATION_JSON })
    +	@Produces({ MediaType.APPLICATION_JSON })
    +	public String getAddresses(@PathParam("entity") final String entityname, @Context final UriInfo uriInfo) {
    --- End diff --
    
    Already EntityFieldConfigurationApiResources.getAddresses(...) API is returning same Data. Why this API is required in this class?


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72934116
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/commands/domain/CommandWrapper.java ---
    @@ -38,6 +38,8 @@
         private final String json;
         private final String transactionId;
         private final Long productId;
    +    private final Boolean status;
    --- End diff --
    
    THe status field is basically, the status of the address. 
    I could not find any better way to pass the field( which is a command) from API resource to command handler.


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by Nayan <gi...@git.apache.org>.
Github user Nayan commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72932666
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/commands/domain/CommandWrapper.java ---
    @@ -38,6 +38,8 @@
         private final String json;
         private final String transactionId;
         private final Long productId;
    +    private final Boolean status;
    --- End diff --
    
    @nikpawar89  what is the use this status field? avoid modifying command handler infrastructure code 


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72954491
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java ---
    @@ -2292,7 +2292,7 @@ public void applyOverdueChargesForLoan(final Long loanId, Collection<OverdueLoan
     
                 final JsonElement parsedCommand = this.fromApiJsonHelper.parse(overdueInstallment.toString());
                 final JsonCommand command = JsonCommand.from(overdueInstallment.toString(), parsedCommand, this.fromApiJsonHelper, null, null,
    -                    null, null, null, loanId, null, null, null, null);
    +                    null, null, null, loanId, null, null, null, null,null);
    --- End diff --
    
    No change is required in this class


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by Nayan <gi...@git.apache.org>.
Github user Nayan commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r73134256
  
    --- Diff: fineract-provider/src/main/resources/sql/migrations/core_db/v312_address_module_tables_metadat.sql ---
    @@ -0,0 +1,127 @@
    +--
    +-- Licensed to the Apache Software Foundation (ASF) under one
    +-- or more contributor license agreements. See the NOTICE file
    +-- distributed with this work for additional information
    +-- regarding copyright ownership. The ASF licenses this file
    +-- to you under the Apache License, Version 2.0 (the
    +-- "License"); you may not use this file except in compliance
    +-- with the License. You may obtain a copy of the License at
    +--
    +-- http://www.apache.org/licenses/LICENSE-2.0
    +--
    +-- Unless required by applicable law or agreed to in writing,
    +-- software distributed under the License is distributed on an
    +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +-- KIND, either express or implied. See the License for the
    +-- specific language governing permissions and limitations
    +-- under the License.
    +--
    +
    +--code inserts
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (150, 'INDIAN STATES', 0);
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (151, 'COUNTRY ID', 0);
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (152, 'ADDRESS TYPE ID', 0);
    +
    +--add new column in portfolio
    +alter table `m_portfolio_command_source` add column `status` TINYINT(4) NULL DEFAULT NULL;
    +
    +--configuration
    +INSERT INTO `c_configuration` (`id`, `name`, `value`, `date_value`, `enabled`, `is_trap_door`, `description`) VALUES (29, 'Enable-Address', NULL, NULL, 1, 0, NULL);
    --- End diff --
    
    @nikpawar89 primary key should be auto generated


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72954375
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/commands/domain/CommandWrapper.java ---
    @@ -38,6 +38,8 @@
         private final String json;
         private final String transactionId;
         private final Long productId;
    +    private final Boolean status;
    --- End diff --
    
    No need to add status variable


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72970984
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/ClientAddressRepositoryWrapper.java ---
    @@ -0,0 +1,43 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.portfolio.client.domain;
    +
    +import org.apache.fineract.infrastructure.codes.domain.CodeValue;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +@Service
    +public class ClientAddressRepositoryWrapper {
    +	private final ClientAddressRepository clientAddressRepository;
    +
    +	@Autowired
    +	public ClientAddressRepositoryWrapper(final ClientAddressRepository clientAddressRepository) {
    +		this.clientAddressRepository = clientAddressRepository;
    +	}
    +
    +	public ClientAddress findOneByClientIdAndAddressTypeAndIsActive(final long clientId, final CodeValue addressType,
    --- End diff --
    
    isActive is a parameter which helps retrieving both active and inactive address.


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72967384
  
    --- Diff: fineract-provider/src/main/resources/sql/migrations/core_db/v312_address_module_tables_metadat.sql ---
    @@ -0,0 +1,127 @@
    +--
    +-- Licensed to the Apache Software Foundation (ASF) under one
    +-- or more contributor license agreements. See the NOTICE file
    +-- distributed with this work for additional information
    +-- regarding copyright ownership. The ASF licenses this file
    +-- to you under the Apache License, Version 2.0 (the
    +-- "License"); you may not use this file except in compliance
    +-- with the License. You may obtain a copy of the License at
    +--
    +-- http://www.apache.org/licenses/LICENSE-2.0
    +--
    +-- Unless required by applicable law or agreed to in writing,
    +-- software distributed under the License is distributed on an
    +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +-- KIND, either express or implied. See the License for the
    +-- specific language governing permissions and limitations
    +-- under the License.
    +--
    +
    +--code inserts
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (150, 'INDIAN STATES', 0);
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (151, 'COUNTRY ID', 0);
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (152, 'ADDRESS TYPE ID', 0);
    +
    +--add new column in portfolio
    +alter table `m_portfolio_command_source` add column `status` TINYINT(4) NULL DEFAULT NULL;
    +
    +--configuration
    +INSERT INTO `c_configuration` (`id`, `name`, `value`, `date_value`, `enabled`, `is_trap_door`, `description`) VALUES (29, 'Enable-Address', NULL, NULL, 1, 0, NULL);
    +
    +--add address table
    +CREATE TABLE `m_address` (
    +	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    +	`street` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_1` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_2` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_3` VARCHAR(100) NULL DEFAULT NULL,
    +	`town_village` VARCHAR(100) NULL DEFAULT NULL,
    +	`city` VARCHAR(100) NULL DEFAULT NULL,
    +	`county_district` VARCHAR(100) NULL DEFAULT NULL,
    +	`state_province_id` INT(11) NULL DEFAULT NULL,
    +	`country_id` INT(11) NULL DEFAULT NULL,
    +	`postal_code` VARCHAR(10) NULL DEFAULT NULL,
    +	`latitude` DECIMAL(10,8) UNSIGNED NULL DEFAULT '0.00000000',
    +	`longitude` DECIMAL(10,8) UNSIGNED NULL DEFAULT '0.00000000',
    +	`created_by` VARCHAR(100) NULL DEFAULT NULL,
    +	`created_on` DATE NULL DEFAULT NULL,
    +	`updated_by` VARCHAR(100) NULL DEFAULT NULL,
    +	`updated_on` DATE NULL DEFAULT NULL,
    +	PRIMARY KEY (`id`),
    +	INDEX `address_fields_codefk1` (`state_province_id`),
    +	INDEX `address_fields_codefk2` (`country_id`),
    +	CONSTRAINT `address_fields_codefk1` FOREIGN KEY (`state_province_id`) REFERENCES `m_code_value` (`id`),
    +	CONSTRAINT `address_fields_codefk2` FOREIGN KEY (`country_id`) REFERENCES `m_code_value` (`id`)
    +)
    +COLLATE='utf8_general_ci'
    +ENGINE=InnoDB
    +AUTO_INCREMENT=20
    --- End diff --
    
    changed to 1


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72975216
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/commands/service/CommandWrapperBuilder.java ---
    @@ -41,10 +41,39 @@
         private String transactionId;
         private Long productId;
         private Long templateId;
    +    private Boolean status;
     
         public CommandWrapper build() {
             return new CommandWrapper(this.officeId, this.groupId, this.clientId, this.loanId, this.savingsId, this.actionName,
    -                this.entityName, this.entityId, this.subentityId, this.href, this.json, this.transactionId, this.productId, this.templateId);
    +                this.entityName, this.entityId, this.subentityId, this.href, this.json, this.transactionId, this.productId, this.templateId
    +                ,this.status);
    +    }
    +    
    +    public CommandWrapperBuilder addClientAddress(final long clientId,final long addressTypeId) {
    +        this.actionName = "CREATE";
    +        this.entityName = "ADDRESS";
    +        this.entityId = addressTypeId;
    +        this.href = "/Address/template";
    --- End diff --
    
    I actually don't require them. Can I omit these entries?


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72954441
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/service/ShareProductCommandsServiceImpl.java ---
    @@ -47,7 +47,7 @@ public CommandProcessingResult postDividends(Long productId, JsonCommand jsonCom
         public Object handleCommand(Long productId, String command, String jsonBody) {
             final JsonElement parsedCommand = this.fromApiJsonHelper.parse(jsonBody);
             final JsonCommand jsonCommand = JsonCommand.from(jsonBody, parsedCommand, this.fromApiJsonHelper, null, null, null, null, null,
    -                null, null, null, null, null);
    +                null, null, null, null, null,null);
    --- End diff --
    
    No change is required in this class.


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72967370
  
    --- Diff: fineract-provider/src/main/resources/sql/migrations/core_db/v312_address_module_tables_metadat.sql ---
    @@ -0,0 +1,127 @@
    +--
    +-- Licensed to the Apache Software Foundation (ASF) under one
    +-- or more contributor license agreements. See the NOTICE file
    +-- distributed with this work for additional information
    +-- regarding copyright ownership. The ASF licenses this file
    +-- to you under the Apache License, Version 2.0 (the
    +-- "License"); you may not use this file except in compliance
    +-- with the License. You may obtain a copy of the License at
    +--
    +-- http://www.apache.org/licenses/LICENSE-2.0
    +--
    +-- Unless required by applicable law or agreed to in writing,
    +-- software distributed under the License is distributed on an
    +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    +-- KIND, either express or implied. See the License for the
    +-- specific language governing permissions and limitations
    +-- under the License.
    +--
    +
    +--code inserts
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (150, 'INDIAN STATES', 0);
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (151, 'COUNTRY ID', 0);
    +INSERT INTO `m_code` (`id`, `code_name`, `is_system_defined`) VALUES (152, 'ADDRESS TYPE ID', 0);
    +
    +--add new column in portfolio
    +alter table `m_portfolio_command_source` add column `status` TINYINT(4) NULL DEFAULT NULL;
    +
    +--configuration
    +INSERT INTO `c_configuration` (`id`, `name`, `value`, `date_value`, `enabled`, `is_trap_door`, `description`) VALUES (29, 'Enable-Address', NULL, NULL, 1, 0, NULL);
    +
    +--add address table
    +CREATE TABLE `m_address` (
    +	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    +	`street` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_1` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_2` VARCHAR(100) NULL DEFAULT NULL,
    +	`address_line_3` VARCHAR(100) NULL DEFAULT NULL,
    +	`town_village` VARCHAR(100) NULL DEFAULT NULL,
    +	`city` VARCHAR(100) NULL DEFAULT NULL,
    +	`county_district` VARCHAR(100) NULL DEFAULT NULL,
    +	`state_province_id` INT(11) NULL DEFAULT NULL,
    +	`country_id` INT(11) NULL DEFAULT NULL,
    +	`postal_code` VARCHAR(10) NULL DEFAULT NULL,
    +	`latitude` DECIMAL(10,8) UNSIGNED NULL DEFAULT '0.00000000',
    +	`longitude` DECIMAL(10,8) UNSIGNED NULL DEFAULT '0.00000000',
    +	`created_by` VARCHAR(100) NULL DEFAULT NULL,
    +	`created_on` DATE NULL DEFAULT NULL,
    +	`updated_by` VARCHAR(100) NULL DEFAULT NULL,
    +	`updated_on` DATE NULL DEFAULT NULL,
    +	PRIMARY KEY (`id`),
    +	INDEX `address_fields_codefk1` (`state_province_id`),
    +	INDEX `address_fields_codefk2` (`country_id`),
    +	CONSTRAINT `address_fields_codefk1` FOREIGN KEY (`state_province_id`) REFERENCES `m_code_value` (`id`),
    +	CONSTRAINT `address_fields_codefk2` FOREIGN KEY (`country_id`) REFERENCES `m_code_value` (`id`)
    +)
    +COLLATE='utf8_general_ci'
    +ENGINE=InnoDB
    +AUTO_INCREMENT=20
    +;
    +
    +
    +--entity address table
    +CREATE TABLE `m_client_address` (
    +	`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
    +	`client_id` BIGINT(20) NOT NULL DEFAULT '0',
    +	`address_id` BIGINT(20) NOT NULL DEFAULT '0',
    +	`address_type_id` INT(11) NOT NULL DEFAULT '0',
    +	`is_active` TINYINT(4) NOT NULL DEFAULT '0',
    +	PRIMARY KEY (`id`),
    +	INDEX `addressIdFk` (`address_id`),
    +	INDEX `address_codefk` (`address_type_id`),
    +	INDEX `clientaddressfk` (`client_id`),
    +	CONSTRAINT `address_codefk` FOREIGN KEY (`address_type_id`) REFERENCES `m_code_value` (`id`),
    +	CONSTRAINT `clientaddressfk` FOREIGN KEY (`client_id`) REFERENCES `m_client` (`id`)
    +)
    +COLLATE='utf8_general_ci'
    +ENGINE=InnoDB
    +AUTO_INCREMENT=28
    --- End diff --
    
    changed to 1


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nikpawar89 <gi...@git.apache.org>.
Github user nikpawar89 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72987749
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/address/service/AddressWritePlatformServiceImpl.java ---
    @@ -0,0 +1,317 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements. See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership. The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License. You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied. See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.fineract.portfolio.address.service;
    +
    +import java.math.BigDecimal;
    +
    +import org.apache.fineract.infrastructure.codes.domain.CodeValue;
    +import org.apache.fineract.infrastructure.codes.domain.CodeValueRepository;
    +import org.apache.fineract.infrastructure.core.api.JsonCommand;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
    +import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
    +import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
    +import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
    +import org.apache.fineract.portfolio.address.domain.Address;
    +import org.apache.fineract.portfolio.address.domain.AddressRepository;
    +import org.apache.fineract.portfolio.address.serialization.AddAddressCommandFromApiJsonDeserializer;
    +import org.apache.fineract.portfolio.client.domain.Client;
    +import org.apache.fineract.portfolio.client.domain.ClientAddress;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepository;
    +import org.apache.fineract.portfolio.client.domain.ClientAddressRepositoryWrapper;
    +import org.apache.fineract.portfolio.client.domain.ClientRepository;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.springframework.stereotype.Service;
    +
    +import com.google.gson.JsonArray;
    +import com.google.gson.JsonObject;
    +
    +@Service
    +public class AddressWritePlatformServiceImpl implements AddressWritePlatformService {
    +	private final PlatformSecurityContext context;
    +	private final CodeValueRepository codeValueRepository;
    +	private final ClientAddressRepository clientAddressRepository;
    +	private final ClientRepository clientRepository;
    +	private final AddressRepository addressRepository;
    +	private final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper;
    +	private final AddAddressCommandFromApiJsonDeserializer fromApiJsonDeserializer;
    +	private final static Logger logger = LoggerFactory.getLogger(AddressWritePlatformServiceImpl.class);
    +
    +	@Autowired
    +	public AddressWritePlatformServiceImpl(final PlatformSecurityContext context,
    +			final CodeValueRepository codeValueRepository, final ClientAddressRepository clientAddressRepository,
    +			final ClientRepository clientRepository, final AddressRepository addressRepository,
    +			final ClientAddressRepositoryWrapper clientAddressRepositoryWrapper,
    +			final AddAddressCommandFromApiJsonDeserializer fromApiJsonDeserializer) {
    +		this.context = context;
    +		this.codeValueRepository = codeValueRepository;
    +		this.clientAddressRepository = clientAddressRepository;
    +		this.clientRepository = clientRepository;
    +		this.addressRepository = addressRepository;
    +		this.clientAddressRepositoryWrapper = clientAddressRepositoryWrapper;
    +		this.fromApiJsonDeserializer = fromApiJsonDeserializer;
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addClientAddress(final Long clientId, final Long addressTypeId,
    +			final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		this.context.authenticatedUser();
    +		this.fromApiJsonDeserializer.validateForCreate(command.json(), false);
    +
    +		if (command.longValueOfParameterNamed("state_province_id") != null) {
    +			stateId = command.longValueOfParameterNamed("state_province_id");
    +			stateIdobj = this.codeValueRepository.getOne(stateId);
    +		}
    +
    +		if (command.longValueOfParameterNamed("country_id") != null) {
    +			countryId = command.longValueOfParameterNamed("country_id");
    +			countryIdObj = this.codeValueRepository.getOne(countryId);
    +		}
    +
    +		final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +		final Address add = Address.fromJson(command, stateIdobj, countryIdObj);
    +		this.addressRepository.save(add);
    +		final Long addressid = add.getId();
    +		final Address addobj = this.addressRepository.getOne(addressid);
    +
    +		final Client client = this.clientRepository.getOne(clientId);
    +
    +		final ClientAddress clientAddressobj = ClientAddress.fromJson(command, client, addobj, addressTypeIdObj);
    +		this.clientAddressRepository.save(clientAddressobj);
    +
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId())
    +				.withEntityId(clientAddressobj.getId()).build();
    +	}
    +
    +	@Override
    +	public CommandProcessingResult addNewClientAddress(final Client client, final JsonCommand command) {
    +		CodeValue stateIdobj = null;
    +		CodeValue countryIdObj = null;
    +		long stateId;
    +		long countryId;
    +
    +		final JsonArray addressArray = command.arrayOfParameterNamed("address");
    +
    +		for (int i = 0; i < addressArray.size(); i++) {
    +			final JsonObject jsonObject = addressArray.get(i).getAsJsonObject();
    +			this.fromApiJsonDeserializer.validateForCreate(jsonObject.toString(), true);
    +
    +			if (command.longValueOfParameterNamed("state_province_id") != null) {
    +				stateId = command.longValueOfParameterNamed("state_province_id");
    +				stateIdobj = this.codeValueRepository.getOne(stateId);
    +			}
    +
    +			if (command.longValueOfParameterNamed("country_id") != null) {
    +				countryId = command.longValueOfParameterNamed("country_id");
    +				countryIdObj = this.codeValueRepository.getOne(countryId);
    +			}
    +
    +			final long addressTypeId = jsonObject.get("addressTypeId").getAsLong();
    +			final CodeValue addressTypeIdObj = this.codeValueRepository.getOne(addressTypeId);
    +
    +			final Address add = Address.fromJsonObject(jsonObject, stateIdobj, countryIdObj);
    +			this.addressRepository.save(add);
    +			final Long addressid = add.getId();
    +			final Address addobj = this.addressRepository.getOne(addressid);
    +
    +			final ClientAddress clientAddressobj = ClientAddress.fromJson(command, client, addobj, addressTypeIdObj);
    +			this.clientAddressRepository.save(clientAddressobj);
    +
    +		}
    +		final long typ = 1;
    +		return new CommandProcessingResultBuilder().withCommandId(command.commandId()).withEntityId(typ).build();
    +	}
    +
    +	@Override
    +	public CommandProcessingResult updateClientAddress(final Long clientId, final Long addressTypeId,
    +			final Boolean status, final JsonCommand command) {
    +		this.context.authenticatedUser();
    +
    +		long stateId;
    +
    +		long countryId;
    +
    +		CodeValue stateIdobj;
    +
    +		CodeValue countryIdObj;
    +
    +		boolean is_address_update = false;
    +
    +		boolean is_address_config_update = false;
    +
    +		final CodeValue addresstyp = this.codeValueRepository.getOne(addressTypeId);
    +		
    +		
    +		System.out.println("clientId is"+ clientId);
    +		System.out.println("addresstyp:" +addresstyp);
    +		System.out.println("status:" +status);
    +
    +		final ClientAddress clientAddressObj = this.clientAddressRepositoryWrapper
    --- End diff --
    
    we are retrieving both active and non-active address, hence a filter parameter is required.


---
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.
---

[GitHub] incubator-fineract pull request #189: address_module

Posted by nazeer1100126 <gi...@git.apache.org>.
Github user nazeer1100126 commented on a diff in the pull request:

    https://github.com/apache/incubator-fineract/pull/189#discussion_r72954461
  
    --- Diff: fineract-provider/src/main/java/org/apache/fineract/portfolio/shareaccounts/service/ShareAccountCommandsServiceImpl.java ---
    @@ -47,7 +47,7 @@ public ShareAccountCommandsServiceImpl(final FromJsonHelper fromApiJsonHelper,
         public Object handleCommand(Long accountId, String command, String jsonBody) {
             final JsonElement parsedCommand = this.fromApiJsonHelper.parse(jsonBody);
             final JsonCommand jsonCommand = JsonCommand.from(jsonBody, parsedCommand, this.fromApiJsonHelper, null, null, null, null, null,
    -                null, null, null, null, null);
    +                null, null, null, null, null,null);
    --- End diff --
    
    No change is required in this class


---
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.
---