diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java index 9adaee5ae..44aee4146 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/importhandler/ImportHandlerUtils.java @@ -317,7 +317,7 @@ public final class ImportHandlerUtils { return 0L; } } else { - return 0L; + return null; } } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/populator/client/ClientEntityWorkbookPopulator.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/populator/client/ClientEntityWorkbookPopulator.java index 8d16218ae..3b64a5ffe 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/populator/client/ClientEntityWorkbookPopulator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/populator/client/ClientEntityWorkbookPopulator.java @@ -29,6 +29,9 @@ import org.apache.fineract.organisation.office.data.OfficeData; import org.apache.poi.hssf.usermodel.HSSFDataValidationHelper; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.ss.SpreadsheetVersion; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.CreationHelper; import org.apache.poi.ss.usermodel.DataValidation; import org.apache.poi.ss.usermodel.DataValidationConstraint; import org.apache.poi.ss.usermodel.DataValidationHelper; @@ -74,9 +77,34 @@ public class ClientEntityWorkbookPopulator extends AbstractWorkbookPopulator { setOfficeDateLookupTable(clientSheet, officeSheetPopulator.getOffices(), ClientEntityConstants.RELATIONAL_OFFICE_NAME_COL, ClientEntityConstants.RELATIONAL_OFFICE_OPENING_DATE_COL, dateFormat); setClientDataLookupTable(clientSheet); + setFormatStyle(workbook, clientSheet); setRules(clientSheet, dateFormat); } + private void setFormatStyle(Workbook workbook, Sheet worksheet) { + CellStyle dateCellStyle = workbook.createCellStyle(); + CreationHelper createHelper = workbook.getCreationHelper(); + dateCellStyle.setDataFormat(createHelper.createDataFormat().getFormat("yyyy-MM-dd")); + + for (int rowIndex = 1; rowIndex < SpreadsheetVersion.EXCEL97.getMaxRows(); rowIndex++) { + Row row = worksheet.getRow(rowIndex); + if (row == null) { + row = worksheet.createRow(rowIndex); + } + + setFormatActivationAndSubmittedDate(row, ClientEntityConstants.ACTIVATION_DATE_COL, dateCellStyle); + setFormatActivationAndSubmittedDate(row, ClientEntityConstants.SUBMITTED_ON_COL, dateCellStyle); + } + } + + private void setFormatActivationAndSubmittedDate(Row row, int columnIndex, CellStyle cellStyle) { + Cell cell = row.getCell(columnIndex); + if (cell == null) { + cell = row.createCell(columnIndex); + } + cell.setCellStyle(cellStyle); + } + private void setClientDataLookupTable(Sheet clientSheet) { int rowIndex = 0; for (CodeValueData clientTypeCodeValue : clientTypeCodeValues) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/populator/client/ClientPersonWorkbookPopulator.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/populator/client/ClientPersonWorkbookPopulator.java index 7fb495fc1..4d73d2e04 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/populator/client/ClientPersonWorkbookPopulator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/populator/client/ClientPersonWorkbookPopulator.java @@ -29,6 +29,9 @@ import org.apache.fineract.organisation.office.data.OfficeData; import org.apache.poi.hssf.usermodel.HSSFDataValidationHelper; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.ss.SpreadsheetVersion; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.CreationHelper; import org.apache.poi.ss.usermodel.DataValidation; import org.apache.poi.ss.usermodel.DataValidationConstraint; import org.apache.poi.ss.usermodel.DataValidationHelper; @@ -72,9 +75,34 @@ public class ClientPersonWorkbookPopulator extends AbstractWorkbookPopulator { setOfficeDateLookupTable(clientSheet, officeSheetPopulator.getOffices(), ClientPersonConstants.RELATIONAL_OFFICE_NAME_COL, ClientPersonConstants.RELATIONAL_OFFICE_OPENING_DATE_COL, dateFormat); setClientDataLookupTable(clientSheet); + setFormatStyle(workbook, clientSheet); setRules(clientSheet, dateFormat); } + private void setFormatStyle(Workbook workbook, Sheet worksheet) { + CellStyle dateCellStyle = workbook.createCellStyle(); + CreationHelper createHelper = workbook.getCreationHelper(); + dateCellStyle.setDataFormat(createHelper.createDataFormat().getFormat("yyyy-MM-dd")); + + for (int rowIndex = 1; rowIndex < SpreadsheetVersion.EXCEL97.getMaxRows(); rowIndex++) { + Row row = worksheet.getRow(rowIndex); + if (row == null) { + row = worksheet.createRow(rowIndex); + } + + setFormatActivationAndSubmittedDate(row, ClientPersonConstants.ACTIVATION_DATE_COL, dateCellStyle); + setFormatActivationAndSubmittedDate(row, ClientPersonConstants.SUBMITTED_ON_COL, dateCellStyle); + } + } + + private void setFormatActivationAndSubmittedDate(Row row, int columnIndex, CellStyle cellStyle) { + Cell cell = row.getCell(columnIndex); + if (cell == null) { + cell = row.createCell(columnIndex); + } + cell.setCellStyle(cellStyle); + } + private void setClientDataLookupTable(Sheet clientSheet) { int rowIndex = 0; for (CodeValueData clientTypeCodeValue : clientTypeCodeValues) {