This is an automated email from the ASF dual-hosted git repository.

adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new 9d53d1cb90 FINERACT-2202: Bulk import fix
9d53d1cb90 is described below

commit 9d53d1cb90996a15151d187724691ae8aa329567
Author: carlossortega <[email protected]>
AuthorDate: Fri Mar 7 16:33:26 2025 -0600

    FINERACT-2202: Bulk import fix
---
 .../importhandler/ImportHandlerUtils.java          |  2 +-
 .../client/ClientEntityWorkbookPopulator.java      | 28 ++++++++++++++++++++++
 .../client/ClientPersonWorkbookPopulator.java      | 28 ++++++++++++++++++++++
 3 files changed, 57 insertions(+), 1 deletion(-)

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 9adaee5aea..44aee41462 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 8d16218ae3..3b64a5ffef 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 7fb495fc1c..4d73d2e04e 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) {

Reply via email to