fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From av...@apache.org
Subject [03/19] fineract git commit: all modules populate & import
Date Wed, 13 Dec 2017 09:03:16 GMT
http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/api/AccountsApiResource.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/api/AccountsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/api/AccountsApiResource.java
index f627c89..9e72b0b 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/api/AccountsApiResource.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/api/AccountsApiResource.java
@@ -28,11 +28,17 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
+import com.sun.jersey.core.header.FormDataContentDisposition;
+import com.sun.jersey.multipart.FormDataParam;
 import org.apache.fineract.commands.domain.CommandWrapper;
 import org.apache.fineract.commands.service.CommandWrapperBuilder;
 import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
+import org.apache.fineract.infrastructure.bulkimport.data.GlobalEntityType;
+import org.apache.fineract.infrastructure.bulkimport.service.BulkImportWorkbookPopulatorService;
+import org.apache.fineract.infrastructure.bulkimport.service.BulkImportWorkbookService;
 import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
 import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
 import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
@@ -40,6 +46,7 @@ import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSer
 import org.apache.fineract.infrastructure.core.service.Page;
 import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
 import org.apache.fineract.portfolio.accounts.constants.AccountsApiConstants;
+import org.apache.fineract.portfolio.accounts.constants.ShareAccountApiConstants;
 import org.apache.fineract.portfolio.accounts.data.AccountData;
 import org.apache.fineract.portfolio.accounts.service.AccountReadPlatformService;
 import org.apache.fineract.portfolio.products.exception.ResourceNotFoundException;
@@ -49,6 +56,8 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 
+import java.io.InputStream;
+
 
 @Path("/accounts/{type}")
 @Component
@@ -60,18 +69,24 @@ public class AccountsApiResource {
     private final DefaultToApiJsonSerializer<AccountData> toApiJsonSerializer;
     private final PlatformSecurityContext platformSecurityContext;
     private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
+    private final BulkImportWorkbookService bulkImportWorkbookService;
+    private final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService;
     
     @Autowired
     public AccountsApiResource(final ApplicationContext applicationContext,
             final ApiRequestParameterHelper apiRequestParameterHelper,
             final DefaultToApiJsonSerializer<AccountData> toApiJsonSerializer,
             final PlatformSecurityContext platformSecurityContext,
-            final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService) {
+            final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
+            final BulkImportWorkbookService bulkImportWorkbookService,
+            final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService) {
         this.applicationContext = applicationContext ;
         this.apiRequestParameterHelper = apiRequestParameterHelper ;
         this.toApiJsonSerializer = toApiJsonSerializer ;
         this.platformSecurityContext = platformSecurityContext ; 
         this.commandsSourceWritePlatformService = commandsSourceWritePlatformService ;
+        this.bulkImportWorkbookService=bulkImportWorkbookService;
+        this.bulkImportWorkbookPopulatorService=bulkImportWorkbookPopulatorService;
     }
     
     @GET
@@ -160,4 +175,22 @@ public class AccountsApiResource {
         final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
         return this.toApiJsonSerializer.serialize(result);
     }
+
+    @GET
+    @Path("downloadtemplate")
+    @Produces("application/vnd.ms-excel")
+    public Response getSharedAccountsTemplate(@QueryParam("officeId") final Long officeId,
+            @QueryParam("dateFormat") final String dateFormat) {
+        return bulkImportWorkbookPopulatorService.getTemplate(GlobalEntityType.SHARE_ACCOUNTS.toString(),officeId, null,dateFormat);
+    }
+    @POST
+    @Path("uploadtemplate")
+    @Consumes(MediaType.MULTIPART_FORM_DATA)
+    public String postSharedAccountsTemplate(@FormDataParam("file") InputStream uploadedInputStream,
+            @FormDataParam("file") FormDataContentDisposition fileDetail,
+            @FormDataParam("locale") final String locale, @FormDataParam("dateFormat") final String dateFormat){
+        final Long importDocumentId = this. bulkImportWorkbookService.importWorkbook(GlobalEntityType.SHARE_ACCOUNTS.toString(), uploadedInputStream,
+                fileDetail,locale,dateFormat);
+        return this.toApiJsonSerializer.serialize(importDocumentId);
+    }
 }

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/address/data/AddressData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/address/data/AddressData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/address/data/AddressData.java
index 8601b46..61bd889 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/address/data/AddressData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/address/data/AddressData.java
@@ -76,6 +76,38 @@ public class AddressData {
 	private final Collection<CodeValueData> stateProvinceIdOptions;
 	private final Collection<CodeValueData> addressTypeIdOptions;
 
+	public AddressData(Long addressTypeId,String street, String addressLine1, String addressLine2, String addressLine3,
+			String city,String postalCode, Boolean isActive,Long stateProvinceId,Long countryId) {
+
+		this.addressTypeId = addressTypeId;
+		this.isActive = isActive;
+		this.street = street;
+		this.addressLine1 = addressLine1;
+		this.addressLine2 = addressLine2;
+		this.addressLine3 = addressLine3;
+		this.countryId = countryId;
+		this.postalCode = postalCode;
+		this.stateProvinceId = stateProvinceId;
+		this.city = city;
+		this.townVillage = null;
+		this.client_id = null;
+		this.addressType = null;
+		this.addressId = null;
+		this.countyDistrict = null;
+		this.countryName = null;
+		this.stateName = null;
+		this.latitude = null;
+		this.longitude = null;
+		this.createdBy = null;
+		this.createdOn = null;
+		this.updatedBy = null;
+		this.updatedOn = null;
+		this.countryIdOptions = null;
+		this.stateProvinceIdOptions = null;
+		this.addressTypeIdOptions = null;
+	}
+
+
 	private AddressData(final String addressType, final Long client_id, final Long addressId, final Long addressTypeId,
 			final Boolean is_active, final String street, final String addressLine1, final String addressLine2,
 			final String addressLine3, final String townVillage, final String city, final String countyDistrict,

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/data/CalendarData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/data/CalendarData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/data/CalendarData.java
index 2c6513a..12fa064 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/data/CalendarData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/calendar/data/CalendarData.java
@@ -21,6 +21,7 @@ package org.apache.fineract.portfolio.calendar.data;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
 import org.apache.fineract.infrastructure.core.data.EnumOptionData;
 import org.apache.fineract.portfolio.calendar.domain.CalendarFrequencyType;
 import org.apache.fineract.portfolio.calendar.domain.CalendarRemindBy;
@@ -41,7 +42,7 @@ public class CalendarData {
     private final Long calendarInstanceId;
     private final Long entityId;
     private final EnumOptionData entityType;
-    private final String title;
+    private String title;
     private final String description;
     private final String location;
     private final LocalDate startDate;
@@ -78,7 +79,123 @@ public class CalendarData {
     final List<EnumOptionData> frequencyOptions;
     final List<EnumOptionData> repeatsOnDayOptions;
     final List<EnumOptionData> frequencyNthDayTypeOptions;
- 
+
+    //import fields
+    private transient Integer rowIndex;
+    private  String dateFormat;
+    private  String locale;
+    private  String centerId;
+    private String typeId;
+
+    public static CalendarData importInstanceNoRepeatsOnDay(LocalDate startDate, boolean repeating,
+            EnumOptionData frequency, Integer interval,Integer rowIndex,String locale,String dateFormat){
+       return  new CalendarData(startDate, repeating, frequency, interval, rowIndex,locale,dateFormat);
+
+    }
+    public static CalendarData importInstanceWithRepeatsOnDay(LocalDate startDate, boolean repeating,
+            EnumOptionData frequency,Integer interval,EnumOptionData repeatsOnDay,Integer rowIndex,
+            String locale,String dateFormat){
+        return new CalendarData(startDate, repeating, frequency, interval, repeatsOnDay, rowIndex,locale,dateFormat);
+    }
+    private CalendarData(LocalDate startDate, boolean repeating,EnumOptionData frequency,Integer interval,
+            Integer rowIndex,String locale,String dateFormat) {
+        this.startDate = startDate;
+        this.repeating = repeating;
+        this.frequency = frequency;
+        this.interval = interval;
+        this.rowIndex=rowIndex;
+        this.dateFormat= dateFormat;
+        this.locale= locale;
+        this.description = "";
+        this.typeId = "1";
+        this.id = null;
+        this.calendarInstanceId = null;
+        this.entityId = null;
+        this.entityType = null;
+        this.title = null;
+        this.location = null;
+        this.endDate = null;
+        this.meetingTime = null;
+        this.type = null;
+        this.recurrence = null;
+        this.repeatsOnDay = null;
+        this.repeatsOnNthDayOfMonth = null;
+        this.remindBy = null;
+        this.firstReminder = null;
+        this.secondReminder = null;
+        this.recurringDates = null;
+        this.nextTenRecurringDates = null;
+        this.humanReadable = null;
+        this.recentEligibleMeetingDate =null;
+        this.createdDate = null;
+        this.lastUpdatedDate = null;
+        this.createdByUserId = null;
+        this.createdByUsername = null;
+        this.lastUpdatedByUserId = null;
+        this.lastUpdatedByUsername = null;
+        this.repeatsOnDayOfMonth = null;
+        this.entityTypeOptions = null;
+        this.calendarTypeOptions = null;
+        this.remindByOptions = null;
+        this.frequencyOptions = null;
+        this.repeatsOnDayOptions = null;
+        this.frequencyNthDayTypeOptions = null;
+        this.duration=null;
+    }
+
+    private CalendarData(LocalDate startDate, boolean repeating,EnumOptionData frequency,Integer interval,
+            EnumOptionData repeatsOnDay,Integer rowIndex,String locale,String dateFormat) {
+        this.startDate = startDate;
+        this.repeating = repeating;
+        this.frequency = frequency;
+        this.interval = interval;
+        this.repeatsOnDay = repeatsOnDay;
+        this.rowIndex=rowIndex;
+        this.dateFormat= dateFormat;
+        this.locale= locale;
+        this.description = "";
+        this.typeId = "1";
+        this.id = null;
+        this.calendarInstanceId = null;
+        this.entityId = null;
+        this.entityType = null;
+        this.title = null;
+        this.location = null;
+        this.endDate = null;
+        this.meetingTime = null;
+        this.type = null;
+        this.recurrence = null;
+        this.repeatsOnNthDayOfMonth = null;
+        this.remindBy = null;
+        this.firstReminder = null;
+        this.secondReminder = null;
+        this.recurringDates = null;
+        this.nextTenRecurringDates = null;
+        this.humanReadable = null;
+        this.recentEligibleMeetingDate =null;
+        this.createdDate = null;
+        this.lastUpdatedDate = null;
+        this.createdByUserId = null;
+        this.createdByUsername = null;
+        this.lastUpdatedByUserId = null;
+        this.lastUpdatedByUsername = null;
+        this.repeatsOnDayOfMonth = null;
+        this.entityTypeOptions = null;
+        this.calendarTypeOptions = null;
+        this.remindByOptions = null;
+        this.frequencyOptions = null;
+        this.repeatsOnDayOptions = null;
+        this.frequencyNthDayTypeOptions = null;
+        this.duration=null;
+    }
+    public void setCenterId(String centerId) {
+        this.centerId = centerId;
+    }
+
+    public void setTitle(String title){
+        this.title=title;
+    }
+
     public static CalendarData instance(final Long id, final Long calendarInstanceId, final Long entityId, final EnumOptionData entityType,
             final String title, final String description, final String location, final LocalDate startDate, final LocalDate endDate,
             final Integer duration, final EnumOptionData type, final boolean repeating, final String recurrence,

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/data/ChargeData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/data/ChargeData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/data/ChargeData.java
index 9828962..179f245 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/data/ChargeData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/data/ChargeData.java
@@ -308,4 +308,16 @@ public class ChargeData implements Comparable<ChargeData>, Serializable {
         }
         return isOverdueInstallmentCharge;
     }
+
+    public Long getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public CurrencyData getCurrency() {
+        return currency;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientApiConstants.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientApiConstants.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientApiConstants.java
index 090cc0a..a0c9d98 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientApiConstants.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientApiConstants.java
@@ -29,6 +29,7 @@ public class ClientApiConstants {
     public static final String CLIENT_RESOURCE_NAME = "client";
     public static final String CLIENT_CHARGES_RESOURCE_NAME = "CLIENTCHARGE";
 
+
     // Client Charge Action Names
     public static final String CLIENT_CHARGE_ACTION_CREATE = "CREATE";
     public static final String CLIENT_CHARGE_ACTION_DELETE = "DELETE";

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java
index f8bf7a8..d0e0af3 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java
@@ -18,6 +18,7 @@
  */
 package org.apache.fineract.portfolio.client.api;
 
+import java.io.InputStream;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
@@ -35,12 +36,17 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
+import com.sun.jersey.core.header.FormDataContentDisposition;
+import com.sun.jersey.multipart.FormDataParam;
 import org.apache.commons.lang.StringUtils;
 import org.apache.fineract.commands.domain.CommandWrapper;
 import org.apache.fineract.commands.service.CommandWrapperBuilder;
 import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
+import org.apache.fineract.infrastructure.bulkimport.service.BulkImportWorkbookPopulatorService;
+import org.apache.fineract.infrastructure.bulkimport.service.BulkImportWorkbookService;
 import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
 import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
 import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException;
@@ -72,6 +78,8 @@ public class ClientsApiResource {
     private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
     private final AccountDetailsReadPlatformService accountDetailsReadPlatformService;
     private final SavingsAccountReadPlatformService savingsAccountReadPlatformService;
+    private final BulkImportWorkbookService bulkImportWorkbookService;
+    private final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService;
 
     @Autowired
     public ClientsApiResource(final PlatformSecurityContext context, final ClientReadPlatformService readPlatformService,
@@ -80,7 +88,9 @@ public class ClientsApiResource {
             final ApiRequestParameterHelper apiRequestParameterHelper,
             final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService,
             final AccountDetailsReadPlatformService accountDetailsReadPlatformService,
-            final SavingsAccountReadPlatformService savingsAccountReadPlatformService) {
+            final SavingsAccountReadPlatformService savingsAccountReadPlatformService,
+            final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService,
+            final BulkImportWorkbookService bulkImportWorkbookService) {
         this.context = context;
         this.clientReadPlatformService = readPlatformService;
         this.toApiJsonSerializer = toApiJsonSerializer;
@@ -89,6 +99,8 @@ public class ClientsApiResource {
         this.commandsSourceWritePlatformService = commandsSourceWritePlatformService;
         this.accountDetailsReadPlatformService = accountDetailsReadPlatformService;
         this.savingsAccountReadPlatformService = savingsAccountReadPlatformService;
+        this.bulkImportWorkbookPopulatorService=bulkImportWorkbookPopulatorService;
+        this.bulkImportWorkbookService=bulkImportWorkbookService;
     }
 
     @GET
@@ -310,4 +322,23 @@ public class ClientsApiResource {
         final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
         return this.clientAccountSummaryToApiJsonSerializer.serialize(settings, clientAccount, CLIENT_ACCOUNTS_DATA_PARAMETERS);
     }
+
+    @GET
+    @Path("downloadtemplate")
+    @Produces("application/vnd.ms-excel")
+    public Response getClientTemplate(@QueryParam("legalFormType")final String legalFormType,
+            @QueryParam("officeId")final Long officeId,@QueryParam("staffId")final Long staffId,
+            @QueryParam("dateFormat") final String dateFormat) {
+        return bulkImportWorkbookPopulatorService.getTemplate(legalFormType, officeId, staffId,dateFormat);
+    }
+
+    @POST
+    @Path("uploadtemplate")
+    @Consumes(MediaType.MULTIPART_FORM_DATA)
+    public String postClientTemplate(@QueryParam("legalFormType")final String legalFormType,@FormDataParam("file") InputStream uploadedInputStream,
+            @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("locale") final String locale,
+            @FormDataParam("dateFormat") final String dateFormat){
+        final Long importDocumentId = bulkImportWorkbookService.importWorkbook(legalFormType, uploadedInputStream,fileDetail,locale,dateFormat);
+        return this.toApiJsonSerializer.serialize(importDocumentId);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientData.java
index 3827307..680e037 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientData.java
@@ -21,10 +21,12 @@ package org.apache.fineract.portfolio.client.data;
 import java.util.Collection;
 import java.util.List;
 
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.builder.CompareToBuilder;
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
 import org.apache.fineract.infrastructure.codes.data.CodeValueData;
 import org.apache.fineract.infrastructure.core.data.EnumOptionData;
 import org.apache.fineract.infrastructure.dataqueries.data.DatatableData;
@@ -106,6 +108,223 @@ final public class ClientData implements Comparable<ClientData> {
 
     private final List<DatatableData> datatables;
 
+    //import fields
+    private transient Integer rowIndex;
+    private String dateFormat;
+    private String locale;
+    private Long clientTypeId;
+    private Long genderId;
+    private Long clientClassificationId;
+    private Long legalFormId;
+    private LocalDate submittedOnDate;
+
+    public static ClientData importClientEntityInstance(Long legalFormId,Integer rowIndex,String fullname,Long officeId, Long clientTypeId,
+            Long clientClassificationId,Long staffId,Boolean active,LocalDate activationDate,LocalDate submittedOnDate,
+            String externalId,LocalDate dateOfBirth,String mobileNo,ClientNonPersonData clientNonPersonDetails,
+            AddressData address,String locale,String dateFormat){
+        return  new ClientData(legalFormId,rowIndex,fullname,officeId,clientTypeId,clientClassificationId,
+                staffId,active,activationDate,submittedOnDate, externalId,dateOfBirth,mobileNo,clientNonPersonDetails,address,
+                locale,dateFormat);
+    }
+
+    public static ClientData importClientPersonInstance(Long legalFormId,Integer rowIndex,String firstName,String lastName,String middleName,
+            LocalDate submittedOn,LocalDate activationDate,Boolean active,String externalId,Long officeId,
+            Long staffId,String mobileNo, LocalDate dob,Long clientTypeId,Long genderId,
+            Long clientClassificationId,Boolean isStaff,AddressData address,String locale,String dateFormat){
+
+        return new ClientData(legalFormId,rowIndex,firstName,lastName,middleName,submittedOn,activationDate,active,externalId,
+                officeId,staffId,mobileNo,dob,clientTypeId,genderId,clientClassificationId,isStaff,address,locale,dateFormat);
+    }
+
+    private ClientData(Long legalFormId,Integer rowIndex,String firstname,String lastname,String middlename,
+            LocalDate submittedOn,LocalDate activationDate,Boolean active,String externalId,Long officeId,
+            Long staffId,String mobileNo, LocalDate dob,Long clientTypeId,Long genderId,
+            Long clientClassificationId,Boolean isStaff,AddressData address,String locale,String dateFormat ) {
+        this.rowIndex=rowIndex;
+        this.dateFormat=dateFormat;
+        this.locale= locale;
+        this.firstname = firstname;
+        this.lastname = lastname;
+        this.middlename = middlename;
+        this.activationDate=activationDate;
+        this.submittedOnDate=submittedOn;
+        this.active=active;
+        this.externalId=externalId;
+        this.officeId=officeId;
+        this.staffId=staffId;
+        this.legalFormId=legalFormId;
+        this.mobileNo=mobileNo;
+        this.dateOfBirth=dob;
+        this.clientTypeId=clientTypeId;
+        this.genderId=genderId;
+        this.clientClassificationId=clientClassificationId;
+        this.isStaff=isStaff;
+        this.address=address;
+        this.id = null;
+        this.accountNo = null;
+        this.status = null;
+        this.subStatus = null;
+        this.fullname = null;
+        this.displayName = null;
+        this.gender = null;
+        this.clientType = null;
+        this.clientClassification = null;
+        this.officeName = null;
+        this.transferToOfficeId = null;
+        this.transferToOfficeName =null;
+        this.imageId = null;
+        this.imagePresent = null;
+        this.staffName = null;
+        this.timeline = null;
+        this.savingsProductId = null;
+        this.savingsProductName = null;
+        this.savingsAccountId =null;
+        this.legalForm = null;
+        this.groups = null;
+        this.officeOptions = null;
+        this.staffOptions = null;
+        this.narrations = null;
+        this.savingProductOptions = null;
+        this.savingAccountOptions = null;
+        this.genderOptions = null;
+        this.clientTypeOptions = null;
+        this.clientClassificationOptions = null;
+        this.clientNonPersonConstitutionOptions = null;
+        this.clientNonPersonMainBusinessLineOptions = null;
+        this.clientLegalFormOptions = null;
+        this.clientNonPersonDetails = null;
+        this.isAddressEnabled =null;
+        this.datatables = null;
+        this.familyMemberOptions=null;
+    }
+
+    private ClientData(Long legalFormId,Integer rowIndex,String fullname,Long officeId, Long clientTypeId,
+            Long clientClassificationId,Long staffId,Boolean active,LocalDate activationDate,LocalDate submittedOnDate,
+            String externalId,LocalDate dateOfBirth,String mobileNo,ClientNonPersonData clientNonPersonDetails,
+            AddressData address,String locale,String dateFormat) {
+        this.id = null;
+        this.accountNo = null;
+        this.externalId = externalId;
+        this.status = null;
+        this.subStatus = null;
+        this.active = active;
+        this.activationDate = activationDate;
+        this.firstname = null;
+        this.middlename = null;
+        this.lastname = null;
+        this.fullname = fullname;
+        this.displayName = null;
+        this.mobileNo = mobileNo;
+        this.dateOfBirth = dateOfBirth;
+        this.gender = null;
+        this.clientType = null;
+        this.clientClassification = null;
+        this.isStaff = null;
+        this.officeId = officeId;
+        this.officeName = null;
+        this.transferToOfficeId = null;
+        this.transferToOfficeName = null;
+        this.imageId = null;
+        this.imagePresent = null;
+        this.staffId = staffId;
+        this.staffName = null;
+        this.timeline = null;
+        this.savingsProductId = null;
+        this.savingsProductName = null;
+        this.savingsAccountId = null;
+        this.legalForm = null;
+        this.groups = null;
+        this.officeOptions = null;
+        this.staffOptions = null;
+        this.narrations = null;
+        this.savingProductOptions = null;
+        this.savingAccountOptions = null;
+        this.genderOptions = null;
+        this.clientTypeOptions = null;
+        this.clientClassificationOptions = null;
+        this.clientNonPersonConstitutionOptions = null;
+        this.clientNonPersonMainBusinessLineOptions = null;
+        this.clientLegalFormOptions = null;
+        this.clientNonPersonDetails = clientNonPersonDetails;
+        this.address = address;
+        this.isAddressEnabled = null;
+        this.datatables = null;
+        this.rowIndex = rowIndex;
+        this.dateFormat=dateFormat;
+        this.locale= locale;
+        this.clientTypeId = clientTypeId;
+        this.genderId = null;
+        this.clientClassificationId = clientClassificationId;
+        this.legalFormId = legalFormId;
+        this.submittedOnDate = submittedOnDate;
+        this.familyMemberOptions=null;
+    }
+
+    public ClientData(Long id) {
+        this.id = id;
+        this.accountNo = null;
+        this.externalId = null;
+        this.status = null;
+        this.subStatus = null;
+        this.active = null;
+        this.activationDate = null;
+        this.firstname = null;
+        this.middlename = null;
+        this.lastname = null;
+        this.fullname = null;
+        this.displayName = null;
+        this.mobileNo = null;
+        this.dateOfBirth = null;
+        this.gender = null;
+        this.clientType = null;
+        this.clientClassification = null;
+        this.isStaff = null;
+        this.officeId = null;
+        this.officeName = null;
+        this.transferToOfficeId = null;
+        this.transferToOfficeName = null;
+        this.imageId = null;
+        this.imagePresent = null;
+        this.staffId = null;
+        this.staffName = null;
+        this.timeline = null;
+        this.savingsProductId = null;
+        this.savingsProductName = null;
+        this.savingsAccountId = null;
+        this.legalForm = null;
+        this.groups = null;
+        this.officeOptions = null;
+        this.staffOptions = null;
+        this.narrations = null;
+        this.savingProductOptions = null;
+        this.savingAccountOptions = null;
+        this.genderOptions = null;
+        this.clientTypeOptions = null;
+        this.clientClassificationOptions = null;
+        this.clientNonPersonConstitutionOptions = null;
+        this.clientNonPersonMainBusinessLineOptions = null;
+        this.clientLegalFormOptions = null;
+        this.clientNonPersonDetails = null;
+        this.address = null;
+        this.isAddressEnabled = null;
+        this.datatables = null;
+        this.familyMemberOptions=null;
+    }
+
+    public Integer getRowIndex() {
+        return rowIndex;
+    }
+
+    public Long getSavingsAccountId() {
+        return savingsAccountId;
+    }
+
+    public Long getId(){return id;}
+
+    public String getOfficeName() {
+        return officeName;
+    }
+
     public static ClientData template(final Long officeId, final LocalDate joinedDate, final Collection<OfficeData> officeOptions,
             final Collection<StaffData> staffOptions, final Collection<CodeValueData> narrations,
             final Collection<CodeValueData> genderOptions, final Collection<SavingsProductData> savingProductOptions,

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientNonPersonData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientNonPersonData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientNonPersonData.java
index d6ffdb9..f81c921 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientNonPersonData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/data/ClientNonPersonData.java
@@ -18,6 +18,7 @@
  */
 package org.apache.fineract.portfolio.client.data;
 
+import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
 import org.apache.fineract.infrastructure.codes.data.CodeValueData;
 import org.joda.time.LocalDate;
 
@@ -32,6 +33,31 @@ public class ClientNonPersonData {
 	private final LocalDate incorpValidityTillDate;
     private final CodeValueData mainBusinessLine;
     private final String remarks;
+
+	//import fields
+	private Long mainBusinessLineId;
+	private Long constitutionId;
+	private String locale;
+	private String dateFormat;
+
+	public static ClientNonPersonData importInstance(String incorporationNo, LocalDate incorpValidityTillDate,
+			String remarks, Long mainBusinessLineId, Long constitutionId,String locale,String dateFormat){
+		return new ClientNonPersonData(incorporationNo,incorpValidityTillDate,remarks,
+				mainBusinessLineId,constitutionId,locale,dateFormat);
+	}
+	private ClientNonPersonData(String incorpNumber, LocalDate incorpValidityTillDate,
+			String remarks, Long mainBusinessLineId, Long constitutionId,String locale,String dateFormat) {
+
+		this.incorpNumber = incorpNumber;
+		this.incorpValidityTillDate = incorpValidityTillDate;
+		this.remarks = remarks;
+		this.mainBusinessLineId = mainBusinessLineId;
+		this.constitutionId = constitutionId;
+		this.dateFormat= dateFormat;
+		this.locale= locale;
+		this.constitution = null;
+		this.mainBusinessLine = null;
+	}
     
 	public ClientNonPersonData(CodeValueData constitution, String incorpNo, LocalDate incorpValidityTillDate,
 			CodeValueData mainBusinessLine, String remarks) {

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientReadPlatformServiceImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientReadPlatformServiceImpl.java
index b5e8825..9c0b932 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientReadPlatformServiceImpl.java
@@ -189,33 +189,34 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
         sqlBuilder.append("select SQL_CALC_FOUND_ROWS ");
         sqlBuilder.append(this.clientMapper.schema());
         sqlBuilder.append(" where (o.hierarchy like ? or transferToOffice.hierarchy like ?) ");
-        
-        if(searchParameters.isSelfUser()){
-        	sqlBuilder.append(" and c.id in (select umap.client_id from m_selfservice_user_client_mapping as umap where umap.appuser_id = ? ) ");
-        	paramList.add(appUserID);
-        }
 
-        final String extraCriteria = buildSqlStringFromClientCriteria(this.clientMapper.schema(), searchParameters, paramList);
-        
-        if (StringUtils.isNotBlank(extraCriteria)) {
-            sqlBuilder.append(" and (").append(extraCriteria).append(")");
-        }
+        if(searchParameters!=null) {
+            if (searchParameters.isSelfUser()) {
+                sqlBuilder.append(" and c.id in (select umap.client_id from m_selfservice_user_client_mapping as umap where umap.appuser_id = ? ) ");
+                paramList.add(appUserID);
+            }
 
-        if (searchParameters.isOrderByRequested()) {
-            sqlBuilder.append(" order by ").append(searchParameters.getOrderBy());
+            final String extraCriteria = buildSqlStringFromClientCriteria(this.clientMapper.schema(), searchParameters, paramList);
 
-            if (searchParameters.isSortOrderProvided()) {
-                sqlBuilder.append(' ').append(searchParameters.getSortOrder());
+            if (StringUtils.isNotBlank(extraCriteria)) {
+                sqlBuilder.append(" and (").append(extraCriteria).append(")");
             }
-        }
 
-        if (searchParameters.isLimited()) {
-            sqlBuilder.append(" limit ").append(searchParameters.getLimit());
-            if (searchParameters.isOffset()) {
-                sqlBuilder.append(" offset ").append(searchParameters.getOffset());
+            if (searchParameters.isOrderByRequested()) {
+                sqlBuilder.append(" order by ").append(searchParameters.getOrderBy());
+
+                if (searchParameters.isSortOrderProvided()) {
+                    sqlBuilder.append(' ').append(searchParameters.getSortOrder());
+                }
             }
-        }
 
+            if (searchParameters.isLimited()) {
+                sqlBuilder.append(" limit ").append(searchParameters.getLimit());
+                if (searchParameters.isOffset()) {
+                    sqlBuilder.append(" offset ").append(searchParameters.getOffset());
+                }
+            }
+        }
         final String sqlCountRows = "SELECT FOUND_ROWS()";
         return this.paginationHelper.fetchPage(this.jdbcTemplate, sqlCountRows, sqlBuilder.toString(), paramList.toArray(), this.clientMapper);
     }

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/data/FundData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/data/FundData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/data/FundData.java
index 58d8a9e..2857caf 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/data/FundData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/data/FundData.java
@@ -41,4 +41,12 @@ public class FundData implements Serializable {
         this.name = name;
         this.externalId = externalId;
     }
+
+    public String getName() {
+        return name;
+    }
+
+    public Long getId() {
+        return id;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResource.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResource.java
index 0195e99..c590fcd 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResource.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResource.java
@@ -18,6 +18,7 @@
  */
 package org.apache.fineract.portfolio.group.api;
 
+import java.io.InputStream;
 import java.util.*;
 
 import javax.ws.rs.Consumes;
@@ -32,13 +33,19 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
+import com.sun.jersey.core.header.FormDataContentDisposition;
+import com.sun.jersey.multipart.FormDataParam;
 import org.apache.commons.lang.StringUtils;
 import org.apache.fineract.accounting.journalentry.api.DateParam;
 import org.apache.fineract.commands.domain.CommandWrapper;
 import org.apache.fineract.commands.service.CommandWrapperBuilder;
 import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
+import org.apache.fineract.infrastructure.bulkimport.data.GlobalEntityType;
+import org.apache.fineract.infrastructure.bulkimport.service.BulkImportWorkbookPopulatorService;
+import org.apache.fineract.infrastructure.bulkimport.service.BulkImportWorkbookService;
 import org.apache.fineract.infrastructure.core.api.ApiParameterHelper;
 import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
 import org.apache.fineract.infrastructure.core.api.JsonQuery;
@@ -93,6 +100,8 @@ public class CentersApiResource {
     private final CalendarReadPlatformService calendarReadPlatformService;
     private final MeetingReadPlatformService meetingReadPlatformService;
     private final EntityDatatableChecksReadService entityDatatableChecksReadService;
+    private final BulkImportWorkbookService bulkImportWorkbookService;
+    private final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService;
 
     @Autowired
     public CentersApiResource(final PlatformSecurityContext context, final CenterReadPlatformService centerReadPlatformService,
@@ -103,7 +112,9 @@ public class CentersApiResource {
             final CollectionSheetReadPlatformService collectionSheetReadPlatformService, final FromJsonHelper fromJsonHelper,
             final AccountDetailsReadPlatformService accountDetailsReadPlatformService,
             final CalendarReadPlatformService calendarReadPlatformService, final MeetingReadPlatformService meetingReadPlatformService,
-            final EntityDatatableChecksReadService entityDatatableChecksReadService) {
+            final EntityDatatableChecksReadService entityDatatableChecksReadService,
+            final BulkImportWorkbookService bulkImportWorkbookService,
+            final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService) {
         this.context = context;
         this.centerReadPlatformService = centerReadPlatformService;
         this.centerApiJsonSerializer = centerApiJsonSerializer;
@@ -117,6 +128,8 @@ public class CentersApiResource {
         this.calendarReadPlatformService = calendarReadPlatformService;
         this.meetingReadPlatformService = meetingReadPlatformService;
         this.entityDatatableChecksReadService = entityDatatableChecksReadService;
+        this.bulkImportWorkbookPopulatorService=bulkImportWorkbookPopulatorService;
+        this.bulkImportWorkbookService=bulkImportWorkbookService;
     }
 
     @GET
@@ -334,4 +347,21 @@ public class CentersApiResource {
         final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
         return this.groupSummaryToApiJsonSerializer.serialize(settings, groupAccount, GROUP_ACCOUNTS_DATA_PARAMETERS);
     }
+
+    @GET
+    @Path("downloadtemplate")
+    @Produces("application/vnd.ms-excel")
+    public Response getCentersTemplate(@QueryParam("officeId")final Long officeId,@QueryParam("staffId")final Long staffId,
+            @QueryParam("dateFormat") final String dateFormat) {
+        return bulkImportWorkbookPopulatorService.getTemplate(GlobalEntityType.CENTERS.toString(), officeId,staffId,dateFormat);
+    }
+    @POST
+    @Path("uploadtemplate")
+    @Consumes(MediaType.MULTIPART_FORM_DATA)
+    public String postCentersTemplate(@FormDataParam("file") InputStream uploadedInputStream,
+            @FormDataParam("file") FormDataContentDisposition fileDetail,
+            @FormDataParam("locale") final String locale, @FormDataParam("dateFormat") final String dateFormat){
+        final Long importDocumentId=this. bulkImportWorkbookService.importWorkbook(GlobalEntityType.CENTERS.toString(), uploadedInputStream,fileDetail,locale,dateFormat);
+        return this.toApiJsonSerializer.serialize(importDocumentId);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java
index 96dc132..10d369d 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java
@@ -18,6 +18,7 @@
  */
 package org.apache.fineract.portfolio.group.api;
 
+import java.io.InputStream;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
@@ -36,12 +37,18 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
+import com.sun.jersey.core.header.FormDataContentDisposition;
+import com.sun.jersey.multipart.FormDataParam;
 import org.apache.commons.lang.StringUtils;
 import org.apache.fineract.commands.domain.CommandWrapper;
 import org.apache.fineract.commands.service.CommandWrapperBuilder;
 import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
+import org.apache.fineract.infrastructure.bulkimport.data.GlobalEntityType;
+import org.apache.fineract.infrastructure.bulkimport.service.BulkImportWorkbookPopulatorService;
+import org.apache.fineract.infrastructure.bulkimport.service.BulkImportWorkbookService;
 import org.apache.fineract.infrastructure.core.api.ApiParameterHelper;
 import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
 import org.apache.fineract.infrastructure.core.api.JsonQuery;
@@ -104,6 +111,9 @@ public class GroupsApiResource {
     private final CalendarReadPlatformService calendarReadPlatformService;
     private final MeetingReadPlatformService meetingReadPlatformService;
     private final EntityDatatableChecksReadService entityDatatableChecksReadService;
+    private final BulkImportWorkbookService bulkImportWorkbookService;
+    private final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService;
+
 
     @Autowired
     public GroupsApiResource(final PlatformSecurityContext context, final GroupReadPlatformService groupReadPlatformService,
@@ -117,7 +127,9 @@ public class GroupsApiResource {
             final GroupRolesReadPlatformService groupRolesReadPlatformService,
             final AccountDetailsReadPlatformService accountDetailsReadPlatformService,
             final CalendarReadPlatformService calendarReadPlatformService, final MeetingReadPlatformService meetingReadPlatformService,
-            final EntityDatatableChecksReadService entityDatatableChecksReadService) {
+            final EntityDatatableChecksReadService entityDatatableChecksReadService,
+            final BulkImportWorkbookService bulkImportWorkbookService,
+            final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService) {
 
         this.context = context;
         this.groupReadPlatformService = groupReadPlatformService;
@@ -135,6 +147,8 @@ public class GroupsApiResource {
         this.calendarReadPlatformService = calendarReadPlatformService;
         this.meetingReadPlatformService = meetingReadPlatformService;
         this.entityDatatableChecksReadService = entityDatatableChecksReadService;
+        this.bulkImportWorkbookPopulatorService=bulkImportWorkbookPopulatorService;
+        this.bulkImportWorkbookService=bulkImportWorkbookService;
     }
 
     @GET
@@ -441,4 +455,24 @@ public class GroupsApiResource {
         final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
         return this.groupSummaryToApiJsonSerializer.serialize(settings, groupAccount, GROUP_ACCOUNTS_DATA_PARAMETERS);
     }
+
+    @GET
+    @Path("downloadtemplate")
+    @Produces("application/vnd.ms-excel")
+    public Response getGroupsTemplate(@QueryParam("officeId")final Long officeId,
+            @QueryParam("staffId")final Long staffId,@QueryParam("dateFormat") final String dateFormat) {
+        return bulkImportWorkbookPopulatorService.getTemplate(GlobalEntityType.GROUPS.toString(),
+                officeId, staffId,dateFormat);
+    }
+
+    @POST
+    @Path("uploadtemplate")
+    @Consumes(MediaType.MULTIPART_FORM_DATA)
+    public String postGroupTemplate(@FormDataParam("file") InputStream uploadedInputStream,
+            @FormDataParam("file") FormDataContentDisposition fileDetail,
+            @FormDataParam("locale") final String locale, @FormDataParam("dateFormat") final String dateFormat){
+        final Long importDocumentId = this. bulkImportWorkbookService.importWorkbook(GlobalEntityType.GROUPS.toString(),
+                uploadedInputStream,fileDetail,locale,dateFormat);
+        return this.toApiJsonSerializer.serialize(importDocumentId);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/data/CenterData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/data/CenterData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/data/CenterData.java
index 2d2828d..7369a20 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/data/CenterData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/data/CenterData.java
@@ -22,6 +22,7 @@ import java.math.BigDecimal;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
 import org.apache.fineract.infrastructure.codes.data.CodeValueData;
 import org.apache.fineract.infrastructure.core.data.EnumOptionData;
 import org.apache.fineract.infrastructure.dataqueries.data.DatatableData;
@@ -67,6 +68,59 @@ public class CenterData {
 
     private List<DatatableData> datatables = null;
 
+    //import fields
+    private transient Integer rowIndex;
+    private String dateFormat;
+    private String locale;
+    private LocalDate submittedOnDate;
+
+    public static CenterData importInstance(String name,List<GroupGeneralData> groupMembers,LocalDate activationDate,
+            boolean active ,LocalDate submittedOnDate,String externalId, Long officeId,
+            Long staffId,Integer rowIndex,String dateFormat,String locale){
+
+        return new CenterData(name,groupMembers,activationDate, active,submittedOnDate, externalId, officeId, staffId, rowIndex,dateFormat,locale);
+    }
+
+    private CenterData(String name,List<GroupGeneralData> groupMembers,LocalDate activationDate,
+            boolean active ,LocalDate submittedOnDate,String externalId, Long officeId,
+            Long staffId,Integer rowIndex,String dateFormat,String locale) {
+        this.name = name;
+        this.groupMembers=groupMembers;
+        this.externalId = externalId;
+        this.officeId = officeId;
+        this.staffId = staffId;
+        this.active = active;
+        this.activationDate = activationDate;
+        this.submittedOnDate=submittedOnDate;
+        this.rowIndex = rowIndex;
+        this.dateFormat= dateFormat;
+        this.locale=locale;
+        this.status=null;
+        this.id=null;
+        this.accountNo = null;
+        this.staffName = null;
+        this.hierarchy = null;
+        this.timeline = null;
+        this.groupMembersOptions = null;
+        this.collectionMeetingCalendar = null;
+        this.closureReasons =null;
+        this.officeOptions = null;
+        this.staffOptions = null;
+        this.totalCollected =null;
+        this.totalOverdue = null;
+        this.totaldue = null;
+        this.installmentDue = null;
+        this.officeName=null;
+    }
+
+    public Integer getRowIndex() {
+        return rowIndex;
+    }
+
+    public String getOfficeName() {
+        return officeName;
+    }
+
     public static CenterData template(final Long officeId, final String accountNo, final LocalDate activationDate,
             final Collection<OfficeData> officeOptions, final Collection<StaffData> staffOptions,
             final Collection<GroupGeneralData> groupMembersOptions, final BigDecimal totalCollected, final BigDecimal totalOverdue,

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/data/GroupGeneralData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/data/GroupGeneralData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/data/GroupGeneralData.java
index d6c2259..5781bb8 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/data/GroupGeneralData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/data/GroupGeneralData.java
@@ -21,6 +21,7 @@ package org.apache.fineract.portfolio.group.data;
 import java.util.Collection;
 import java.util.List;
 
+import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
 import org.apache.fineract.infrastructure.codes.data.CodeValueData;
 import org.apache.fineract.infrastructure.core.data.EnumOptionData;
 import org.apache.fineract.infrastructure.dataqueries.data.DatatableData;
@@ -74,6 +75,104 @@ public class GroupGeneralData {
 
     private List<DatatableData> datatables = null;
 
+    //import fields
+    private transient Integer rowIndex;
+    private String dateFormat;
+    private String locale;
+    private LocalDate submittedOnDate;
+
+    public static GroupGeneralData importInstance(String groupName,List<ClientData> clientMembers,LocalDate activationDate,
+            LocalDate submittedOnDate ,Boolean active,String externalId,Long officeId,Long staffId,
+            Long centerId, Integer rowIndex,String locale,String dateFormat){
+
+        return new GroupGeneralData(groupName, clientMembers, activationDate, submittedOnDate,active, externalId,
+                officeId, staffId, centerId, rowIndex,locale,dateFormat);
+    }
+
+    private GroupGeneralData(String name,List<ClientData> clientMembers,LocalDate activationDate,
+            LocalDate submittedOnDate ,Boolean active,String externalId,Long officeId,Long staffId,
+            Long centerId, Integer rowIndex,String locale,String dateFormat ){
+        this.dateFormat= dateFormat;
+        this.locale= locale;
+        this.name = name;
+        this.clientMembers = clientMembers;
+        this.officeId = officeId;
+        this.staffId = staffId;
+        this.centerId = centerId;
+        this.externalId = externalId;
+        this.active = active;
+        this.activationDate = activationDate;
+        this.submittedOnDate=submittedOnDate;
+        this.rowIndex = rowIndex;
+        this.id=null;
+        this.accountNo = null;
+        this.status = null;
+        this.officeName = null;
+        this.centerName =null;
+        this.staffName = null;
+        this.hierarchy = null;
+        this.groupLevel = null;
+        this.activeClientMembers = null;
+        this.groupRoles = null;
+        this.calendarsData = null;
+        this.collectionMeetingCalendar = null;
+        this.centerOptions = null;
+        this.officeOptions = null;
+        this.staffOptions = null;
+        this.clientOptions = null;
+        this.availableRoles = null;
+        this.selectedRole = null;
+        this.closureReasons = null;
+        this.timeline = null;
+    }
+
+    public GroupGeneralData(Long id) {
+        this.id = id;
+        this.accountNo = null;
+        this.name = null;
+        this.externalId = null;
+        this.status = null;
+        this.active = null;
+        this.activationDate = null;
+        this.officeId = null;
+        this.officeName = null;
+        this.centerId = null;
+        this.centerName = null;
+        this.staffId = null;
+        this.staffName = null;
+        this.hierarchy = null;
+        this.groupLevel = null;
+        this.clientMembers = null;
+        this.activeClientMembers = null;
+        this.groupRoles = null;
+        this.calendarsData = null;
+        this.collectionMeetingCalendar = null;
+        this.centerOptions = null;
+        this.officeOptions = null;
+        this.staffOptions = null;
+        this.clientOptions = null;
+        this.availableRoles = null;
+        this.selectedRole = null;
+        this.closureReasons = null;
+        this.timeline = null;
+    }
+
+    public Integer getRowIndex() {
+        return rowIndex;
+    }
+
+    public Long getCenterId() {
+        return centerId;
+    }
+
+    public LocalDate getActivationDate() {
+        return activationDate;
+    }
+
+    public String getOfficeName() {
+        return officeName;
+    }
+
     public static GroupGeneralData lookup(final Long groupId, final String accountNo, final String groupName) {
         final Collection<ClientData> clientMembers = null;
         final Collection<GroupRoleData> groupRoles = null;

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java
index 34350c2..38823fb 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java
@@ -127,50 +127,50 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
 
         StringBuffer extraCriteria = new StringBuffer(200);
         extraCriteria.append(" and g.level_id = " + GroupTypes.CENTER.getId());
+        if (searchCriteria!=null) {
+            String sqlQueryCriteria = searchCriteria.getSqlSearch();
+            if (StringUtils.isNotBlank(sqlQueryCriteria)) {
+                SQLInjectionValidator.validateSQLInput(sqlQueryCriteria);
+                sqlQueryCriteria = sqlQueryCriteria.replaceAll(" display_name ", " g.display_name ");
+                sqlQueryCriteria = sqlQueryCriteria.replaceAll("display_name ", "g.display_name ");
+                extraCriteria.append(" and (").append(sqlQueryCriteria).append(") ");
+                this.columnValidator.validateSqlInjection(schemaSl, sqlQueryCriteria);
+            }
 
-        String sqlQueryCriteria = searchCriteria.getSqlSearch();
-        if (StringUtils.isNotBlank(sqlQueryCriteria)) {
-        	SQLInjectionValidator.validateSQLInput(sqlQueryCriteria);
-            sqlQueryCriteria = sqlQueryCriteria.replaceAll(" display_name ", " g.display_name ");
-            sqlQueryCriteria = sqlQueryCriteria.replaceAll("display_name ", "g.display_name ");
-            extraCriteria.append(" and (").append(sqlQueryCriteria).append(") ");
-            this.columnValidator.validateSqlInjection(schemaSl, sqlQueryCriteria);
-        }
-
-        final Long officeId = searchCriteria.getOfficeId();
-        if (officeId != null) {
-            extraCriteria.append(" and g.office_id = ? ");
-            paramList.add(officeId);
-        }
+            final Long officeId = searchCriteria.getOfficeId();
+            if (officeId != null) {
+                extraCriteria.append(" and g.office_id = ? ");
+                paramList.add(officeId);
+            }
 
-        final String externalId = searchCriteria.getExternalId();
-        if (externalId != null) {
-        	paramList.add(ApiParameterHelper.sqlEncodeString(externalId));
-            extraCriteria.append(" and g.external_id = ? ");
-        }
+            final String externalId = searchCriteria.getExternalId();
+            if (externalId != null) {
+                paramList.add(ApiParameterHelper.sqlEncodeString(externalId));
+                extraCriteria.append(" and g.external_id = ? ");
+            }
 
-        final String name = searchCriteria.getName();
-        if (name != null) {
-        	paramList.add(ApiParameterHelper.sqlEncodeString(name + "%"));
-            extraCriteria.append(" and g.display_name like ? ");
-        }
+            final String name = searchCriteria.getName();
+            if (name != null) {
+                paramList.add(ApiParameterHelper.sqlEncodeString(name + "%"));
+                extraCriteria.append(" and g.display_name like ? ");
+            }
 
-        final String hierarchy = searchCriteria.getHierarchy();
-        if (hierarchy != null) {
-        	paramList.add(ApiParameterHelper.sqlEncodeString(hierarchy + "%"));
-            extraCriteria.append(" and o.hierarchy like ? ");
-        }
+            final String hierarchy = searchCriteria.getHierarchy();
+            if (hierarchy != null) {
+                paramList.add(ApiParameterHelper.sqlEncodeString(hierarchy + "%"));
+                extraCriteria.append(" and o.hierarchy like ? ");
+            }
 
-        if (StringUtils.isNotBlank(extraCriteria.toString())) {
-            extraCriteria.delete(0, 4);
-        }
+            if (StringUtils.isNotBlank(extraCriteria.toString())) {
+                extraCriteria.delete(0, 4);
+            }
 
-        final Long staffId = searchCriteria.getStaffId();
-        if (staffId != null) {
-        	paramList.add(staffId);
-            extraCriteria.append(" and g.staff_id = ? ");
+            final Long staffId = searchCriteria.getStaffId();
+            if (staffId != null) {
+                paramList.add(staffId);
+                extraCriteria.append(" and g.staff_id = ? ");
+            }
         }
-
         return extraCriteria.toString();
     }
 
@@ -409,8 +409,9 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
 
     @Override
     public Collection<CenterData> retrieveAll(SearchParameters searchParameters, PaginationParameters parameters) {
-
-        this.paginationParametersDataValidator.validateParameterValues(parameters, supportedOrderByValues, "audits");
+        if (parameters!=null) {
+            this.paginationParametersDataValidator.validateParameterValues(parameters, supportedOrderByValues, "audits");
+        }
         final AppUser currentUser = this.context.authenticatedUser();
         final String hierarchy = currentUser.getOffice().getHierarchy();
         final String hierarchySearchString = hierarchy + "%";
@@ -421,24 +422,24 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
         sqlBuilder.append(" where o.hierarchy like ?");
         List<Object> paramList = new ArrayList<>(
                 Arrays.asList(hierarchySearchString));
-        
+        if (searchParameters!=null) {
         final String extraCriteria = getCenterExtraCriteria(this.centerMapper.schema(), paramList, searchParameters);
         this.columnValidator.validateSqlInjection(sqlBuilder.toString(), extraCriteria);
         if (StringUtils.isNotBlank(extraCriteria)) {
             sqlBuilder.append(" and (").append(extraCriteria).append(")");
         }
 
-        if (searchParameters.isOrderByRequested()) {
-            sqlBuilder.append(" order by ").append(searchParameters.getOrderBy()).append(' ').append(searchParameters.getSortOrder());
-        }
+            if (searchParameters.isOrderByRequested()) {
+                sqlBuilder.append(" order by ").append(searchParameters.getOrderBy()).append(' ').append(searchParameters.getSortOrder());
+            }
 
-        if (searchParameters.isLimited()) {
-            sqlBuilder.append(" limit ").append(searchParameters.getLimit());
-            if (searchParameters.isOffset()) {
-                sqlBuilder.append(" offset ").append(searchParameters.getOffset());
+            if (searchParameters.isLimited()) {
+                sqlBuilder.append(" limit ").append(searchParameters.getLimit());
+                if (searchParameters.isOffset()) {
+                    sqlBuilder.append(" offset ").append(searchParameters.getOffset());
+                }
             }
         }
-
         return this.jdbcTemplate.query(sqlBuilder.toString(), this.centerMapper, paramList.toArray());
     }
 

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupReadPlatformServiceImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupReadPlatformServiceImpl.java
index 8dd0ed6..e8a1fd6 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupReadPlatformServiceImpl.java
@@ -188,19 +188,22 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
         sqlBuilder.append(" where o.hierarchy like ?");
         List<Object> paramList = new ArrayList<>(
                 Arrays.asList(hierarchySearchString));
-        final String extraCriteria = getGroupExtraCriteria(this.allGroupTypesDataMapper.schema(), paramList, searchParameters);
-        if (StringUtils.isNotBlank(extraCriteria)) {
-            sqlBuilder.append(" and (").append(extraCriteria).append(")");
-        }
+        if (searchParameters!=null) {
+            final String extraCriteria = getGroupExtraCriteria(this.allGroupTypesDataMapper.schema(), paramList, searchParameters);
 
-        if (parameters.isOrderByRequested()) {
-            sqlBuilder.append(parameters.orderBySql());
+            if (StringUtils.isNotBlank(extraCriteria)) {
+                sqlBuilder.append(" and (").append(extraCriteria).append(")");
+            }
         }
+        if (parameters!=null) {
+            if (parameters.isOrderByRequested()) {
+                sqlBuilder.append(parameters.orderBySql());
+            }
 
-        if (parameters.isLimited()) {
-            sqlBuilder.append(parameters.limitSql());
+            if (parameters.isLimited()) {
+                sqlBuilder.append(parameters.limitSql());
+            }
         }
-
         return this.jdbcTemplate.query(sqlBuilder.toString(), this.allGroupTypesDataMapper, paramList.toArray());
     }
 
@@ -211,58 +214,57 @@ public class GroupReadPlatformServiceImpl implements GroupReadPlatformService {
 
         StringBuffer extraCriteria = new StringBuffer(200);
         extraCriteria.append(" and g.level_Id = ").append(GroupTypes.GROUP.getId());
-        String sqlSearch = searchCriteria.getSqlSearch();
-        if (sqlSearch != null) {
-        	SQLInjectionValidator.validateSQLInput(sqlSearch);
-            sqlSearch = sqlSearch.replaceAll(" display_name ", " g.display_name ");
-            sqlSearch = sqlSearch.replaceAll("display_name ", "g.display_name ");
-            extraCriteria.append(" and ( ").append(sqlSearch).append(") ");
-            this.columnValidator.validateSqlInjection(schemaSql, sqlSearch);
-        }
+            String sqlSearch = searchCriteria.getSqlSearch();
+            if (sqlSearch != null) {
+                SQLInjectionValidator.validateSQLInput(sqlSearch);
+                sqlSearch = sqlSearch.replaceAll(" display_name ", " g.display_name ");
+                sqlSearch = sqlSearch.replaceAll("display_name ", "g.display_name ");
+                extraCriteria.append(" and ( ").append(sqlSearch).append(") ");
+                this.columnValidator.validateSqlInjection(schemaSql, sqlSearch);
+            }
 
-        final Long officeId = searchCriteria.getOfficeId();
-        if (officeId != null) {
-        	paramList.add(officeId);
-            extraCriteria.append(" and g.office_id = ? ");
-        }
+            final Long officeId = searchCriteria.getOfficeId();
+            if (officeId != null) {
+                paramList.add(officeId);
+                extraCriteria.append(" and g.office_id = ? ");
+            }
 
-        final String externalId = searchCriteria.getExternalId();
-        if (externalId != null) {
-        	paramList.add(ApiParameterHelper.sqlEncodeString(externalId));
-            extraCriteria.append(" and g.external_id = ? ");
-        }
+            final String externalId = searchCriteria.getExternalId();
+            if (externalId != null) {
+                paramList.add(ApiParameterHelper.sqlEncodeString(externalId));
+                extraCriteria.append(" and g.external_id = ? ");
+            }
 
-        final String name = searchCriteria.getName();
-        if (name != null) {
-        	paramList.add(ApiParameterHelper.sqlEncodeString("%" + name + "%"));
-            extraCriteria.append(" and g.display_name like ? ");
-        }
+            final String name = searchCriteria.getName();
+            if (name != null) {
+                paramList.add(ApiParameterHelper.sqlEncodeString("%" + name + "%"));
+                extraCriteria.append(" and g.display_name like ? ");
+            }
 
-        final String hierarchy = searchCriteria.getHierarchy();
-        if (hierarchy != null) {
-        	paramList.add(ApiParameterHelper.sqlEncodeString(hierarchy + "%"));
-            extraCriteria.append(" and o.hierarchy like ? ");
-        }
+            final String hierarchy = searchCriteria.getHierarchy();
+            if (hierarchy != null) {
+                paramList.add(ApiParameterHelper.sqlEncodeString(hierarchy + "%"));
+                extraCriteria.append(" and o.hierarchy like ? ");
+            }
 
-        if (searchCriteria.isStaffIdPassed()) {
-        	paramList.add(searchCriteria.getStaffId());
-            extraCriteria.append(" and g.staff_id = ? ");
-        }
+            if (searchCriteria.isStaffIdPassed()) {
+                paramList.add(searchCriteria.getStaffId());
+                extraCriteria.append(" and g.staff_id = ? ");
+            }
 
-        if (StringUtils.isNotBlank(extraCriteria.toString())) {
-            extraCriteria.delete(0, 4);
-        }
+            if (StringUtils.isNotBlank(extraCriteria.toString())) {
+                extraCriteria.delete(0, 4);
+            }
 
-        final Long staffId = searchCriteria.getStaffId();
-        if (staffId != null) {
-        	paramList.add(staffId);
-            extraCriteria.append(" and g.staff_id = ? ");
-        }
-        
-        if(searchCriteria.isOrphansOnly()){
-        	extraCriteria.append(" and g.parent_id IS NULL");
-        }
+            final Long staffId = searchCriteria.getStaffId();
+            if (staffId != null) {
+                paramList.add(staffId);
+                extraCriteria.append(" and g.staff_id = ? ");
+            }
 
+            if (searchCriteria.isOrphansOnly()) {
+                extraCriteria.append(" and g.parent_id IS NULL");
+            }
         return extraCriteria.toString();
     }
 

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java
index e3c51c7..b1c6223 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.loanaccount.api;
 
 import static org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations.interestType;
 
+import java.io.InputStream;
 import java.util.*;
 
 import javax.ws.rs.Consumes;
@@ -34,12 +35,18 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 
+import com.sun.jersey.core.header.FormDataContentDisposition;
+import com.sun.jersey.multipart.FormDataParam;
 import org.apache.commons.lang.StringUtils;
 import org.apache.fineract.commands.domain.CommandWrapper;
 import org.apache.fineract.commands.service.CommandWrapperBuilder;
 import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
+import org.apache.fineract.infrastructure.bulkimport.data.GlobalEntityType;
+import org.apache.fineract.infrastructure.bulkimport.service.BulkImportWorkbookPopulatorService;
+import org.apache.fineract.infrastructure.bulkimport.service.BulkImportWorkbookService;
 import org.apache.fineract.infrastructure.codes.data.CodeValueData;
 import org.apache.fineract.infrastructure.codes.service.CodeValueReadPlatformService;
 import org.apache.fineract.infrastructure.core.api.ApiParameterHelper;
@@ -169,6 +176,9 @@ public class LoansApiResource {
     private final LoanScheduleHistoryReadPlatformService loanScheduleHistoryReadPlatformService;
     private final AccountDetailsReadPlatformService accountDetailsReadPlatformService;
     private final EntityDatatableChecksReadService entityDatatableChecksReadService;
+    private final BulkImportWorkbookService bulkImportWorkbookService;
+    private final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService;
+
 
     @Autowired
     public LoansApiResource(final PlatformSecurityContext context, final LoanReadPlatformService loanReadPlatformService,
@@ -189,7 +199,9 @@ public class LoansApiResource {
             final AccountAssociationsReadPlatformService accountAssociationsReadPlatformService,
             final LoanScheduleHistoryReadPlatformService loanScheduleHistoryReadPlatformService,
             final AccountDetailsReadPlatformService accountDetailsReadPlatformService,
-            final EntityDatatableChecksReadService entityDatatableChecksReadService) {
+            final EntityDatatableChecksReadService entityDatatableChecksReadService,
+            final BulkImportWorkbookService bulkImportWorkbookService,
+            final BulkImportWorkbookPopulatorService bulkImportWorkbookPopulatorService) {
         this.context = context;
         this.loanReadPlatformService = loanReadPlatformService;
         this.loanProductReadPlatformService = loanProductReadPlatformService;
@@ -215,6 +227,8 @@ public class LoansApiResource {
         this.loanScheduleHistoryReadPlatformService = loanScheduleHistoryReadPlatformService;
         this.accountDetailsReadPlatformService = accountDetailsReadPlatformService;
         this.entityDatatableChecksReadService = entityDatatableChecksReadService;
+        this.bulkImportWorkbookService=bulkImportWorkbookService;
+        this.bulkImportWorkbookPopulatorService=bulkImportWorkbookPopulatorService;
     }
 
     /*
@@ -755,4 +769,41 @@ public class LoansApiResource {
     private boolean is(final String commandParam, final String commandValue) {
         return StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase(commandValue);
     }
+
+    @GET
+    @Path("downloadtemplate")
+    @Produces("application/vnd.ms-excel")
+    public Response getLoansTemplate(@QueryParam("officeId") final Long officeId,
+            @QueryParam("staffId") final Long staffId,@QueryParam("dateFormat") final String dateFormat) {
+        return bulkImportWorkbookPopulatorService.getTemplate(GlobalEntityType.LOANS.toString(), officeId, staffId,dateFormat);
+    }
+
+    @GET
+    @Path("repayments/downloadtemplate")
+    @Produces("application/vnd.ms-excel")
+    public Response getLoanRepaymentTemplate(@QueryParam("officeId") final Long officeId,
+            @QueryParam("dateFormat") final String dateFormat) {
+        return bulkImportWorkbookPopulatorService.getTemplate(GlobalEntityType.LOAN_TRANSACTIONS.toString(), officeId, null,dateFormat);
+    }
+
+    @POST
+    @Path("uploadtemplate")
+    @Consumes(MediaType.MULTIPART_FORM_DATA)
+    public String postLoanTemplate(@FormDataParam("file") InputStream uploadedInputStream,
+            @FormDataParam("file") FormDataContentDisposition fileDetail,
+            @FormDataParam("locale") final String locale, @FormDataParam("dateFormat") final String dateFormat){
+        final Long importDocumentId = this. bulkImportWorkbookService.importWorkbook(GlobalEntityType.LOANS.toString(), uploadedInputStream,fileDetail,locale,dateFormat);
+        return this.toApiJsonSerializer.serialize(importDocumentId);
+    }
+
+    @POST
+    @Path("repayments/uploadtemplate")
+    @Consumes(MediaType.MULTIPART_FORM_DATA)
+    public String postLoanRepaymentTemplate(@FormDataParam("file") InputStream uploadedInputStream,
+            @FormDataParam("file") FormDataContentDisposition fileDetail,@FormDataParam("locale") final String locale,
+            @FormDataParam("dateFormat") final String dateFormat){
+        final Long importDocumentId = this.bulkImportWorkbookService.importWorkbook(GlobalEntityType.LOAN_TRANSACTIONS.toString(), uploadedInputStream,fileDetail,
+                locale,dateFormat);
+        return this.toApiJsonSerializer.serialize(importDocumentId);
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/fineract/blob/210647d4/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/DisbursementData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/DisbursementData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/DisbursementData.java
index 939a0ac..6e9c708 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/DisbursementData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/data/DisbursementData.java
@@ -20,6 +20,7 @@ package org.apache.fineract.portfolio.loanaccount.data;
 
 import java.math.BigDecimal;
 
+import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
 import org.joda.time.LocalDate;
 
 /**
@@ -37,6 +38,38 @@ public class DisbursementData implements Comparable<DisbursementData> {
     private final BigDecimal chargeAmount;
     private final BigDecimal waivedChargeAmount;
 
+    //import fields
+    private transient Integer rowIndex;
+    private String dateFormat;
+    private String locale;
+    private String note;
+    private transient String linkAccountId;
+
+    public  static DisbursementData importInstance(LocalDate actualDisbursementDate,String linkAccountId,
+            Integer rowIndex,String locale,String dateFormat){
+        return new DisbursementData(actualDisbursementDate,linkAccountId,rowIndex,locale,dateFormat);
+    }
+    private DisbursementData(LocalDate actualDisbursementDate,String linkAccountId,
+            Integer rowIndex,String locale,String dateFormat) {
+        this.dateFormat= dateFormat;
+        this.locale= locale;
+        this.actualDisbursementDate = actualDisbursementDate;
+        this.rowIndex = rowIndex;
+        this.note="";
+        this.linkAccountId=linkAccountId;
+        this.id=null;
+        this.expectedDisbursementDate=null;
+        this.principal=null;
+        this.loanChargeId=null;
+        this.chargeAmount=null;
+        this.waivedChargeAmount=null;
+
+    }
+
+    public String getLinkAccountId() {
+        return linkAccountId;
+    }
+
     public DisbursementData(Long id, final LocalDate expectedDisbursementDate, final LocalDate actualDisbursementDate,
             final BigDecimal principalDisbursed, final String loanChargeId, BigDecimal chargeAmount, BigDecimal waivedChargeAmount) {
         this.id = id;


Mime
View raw message