Fix Bulk Import failing for office names containing hyphens (FINERACT-1256)

This commit is contained in:
Michael Vorburger
2020-11-07 22:29:49 +01:00
committed by Aleksandar Vidakovic
parent 73e330a58e
commit ef3e2e3c92
20 changed files with 207 additions and 215 deletions
@@ -24,10 +24,12 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.regex.Pattern;
import org.apache.fineract.organisation.office.data.OfficeData;
import org.apache.fineract.portfolio.client.data.ClientData;
import org.apache.fineract.portfolio.group.data.GroupGeneralData;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Name;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
@@ -37,6 +39,7 @@ import org.slf4j.LoggerFactory;
public abstract class AbstractWorkbookPopulator implements WorkbookPopulator {
private static final Logger LOG = LoggerFactory.getLogger(AbstractWorkbookPopulator.class);
private static final Pattern NAME_REGEX = Pattern.compile("[ @#&()<>,;.:$£€§°\\\\/=!\\?\\-\\+\\*\"\\[\\]]");
protected void writeInt(int colIndex, Row row, int value) {
row.createCell(colIndex).setCellValue(value);
@@ -162,4 +165,11 @@ public abstract class AbstractWorkbookPopulator implements WorkbookPopulator {
}
}
/**
* See {@link Name#setNameName(String)} and https://issues.apache.org/jira/browse/FINERACT-1256.
*/
protected void setSanitized(Name poiName, String roughName) {
String sanitized = NAME_REGEX.matcher(roughName.trim()).replaceAll("_");
poiName.setNameName(sanitized);
}
}
@@ -40,9 +40,9 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class CentersWorkbookPopulator extends AbstractWorkbookPopulator {
private OfficeSheetPopulator officeSheetPopulator;
private PersonnelSheetPopulator personnelSheetPopulator;
private GroupSheetPopulator groupSheetPopulator;
private final OfficeSheetPopulator officeSheetPopulator;
private final PersonnelSheetPopulator personnelSheetPopulator;
private final GroupSheetPopulator groupSheetPopulator;
public CentersWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator, PersonnelSheetPopulator personnelSheetPopulator,
GroupSheetPopulator groupSheetPopulator) {
@@ -231,7 +231,5 @@ public class CentersWorkbookPopulator extends AbstractWorkbookPopulator {
+ officeNameToBeginEndIndexesOfStaff[0] + ":$B$" + officeNameToBeginEndIndexesOfStaff[1]);
}
}
}
}
@@ -46,7 +46,7 @@ import org.slf4j.LoggerFactory;
public class ChartOfAccountsWorkbook extends AbstractWorkbookPopulator {
private static final Logger LOG = LoggerFactory.getLogger(ChartOfAccountsWorkbook.class);
private List<GLAccountData> glAccounts;
private final List<GLAccountData> glAccounts;
private Map<String, List<String>> accountTypeToAccountNameAndTag;
private Map<Integer, Integer[]> accountTypeToBeginEndIndexesofAccountNames;
private List<String> accountTypesNoDuplicatesList;
@@ -76,7 +76,7 @@ public class ChartOfAccountsWorkbook extends AbstractWorkbookPopulator {
private void addToaccountTypeToAccountNameMap(String key, String value) {
List<String> values = accountTypeToAccountNameAndTag.get(key);
if (values == null) {
values = new ArrayList<String>();
values = new ArrayList<>();
}
if (!values.contains(value)) {
values.add(value);
@@ -128,14 +128,14 @@ public class ChartOfAccountsWorkbook extends AbstractWorkbookPopulator {
Name tags = chartOfAccountsWorkbook.createName();
Integer[] tagValueBeginEndIndexes = accountTypeToBeginEndIndexesofAccountNames.get(i);
if (accountTypeToBeginEndIndexesofAccountNames != null) {
tags.setNameName("Tags_" + accountTypesNoDuplicatesList.get(i));
setSanitized(tags, "Tags_" + accountTypesNoDuplicatesList.get(i));
tags.setRefersToFormula(TemplatePopulateImportConstants.CHART_OF_ACCOUNTS_SHEET_NAME + "!$S$" + tagValueBeginEndIndexes[0]
+ ":$S$" + tagValueBeginEndIndexes[1]);
}
Name accountNames = chartOfAccountsWorkbook.createName();
Integer[] accountNamesBeginEndIndexes = accountTypeToBeginEndIndexesofAccountNames.get(i);
if (accountNamesBeginEndIndexes != null) {
accountNames.setNameName("AccountName_" + accountTypesNoDuplicatesList.get(i));
setSanitized(accountNames, "AccountName_" + accountTypesNoDuplicatesList.get(i));
accountNames.setRefersToFormula(TemplatePopulateImportConstants.CHART_OF_ACCOUNTS_SHEET_NAME + "!$Q$"
+ accountNamesBeginEndIndexes[0] + ":$Q$" + accountNamesBeginEndIndexes[1]);
}
@@ -163,15 +163,15 @@ public class ChartOfAccountsWorkbook extends AbstractWorkbookPopulator {
private void setLookupTable(Sheet chartOfAccountsSheet) {
accountTypesNoDuplicatesList = new ArrayList<>();
for (int i = 0; i < glAccounts.size(); i++) {
if (!accountTypesNoDuplicatesList.contains(glAccounts.get(i).getType().getValue())) {
accountTypesNoDuplicatesList.add(glAccounts.get(i).getType().getValue());
for (GLAccountData glAccount : glAccounts) {
if (!accountTypesNoDuplicatesList.contains(glAccount.getType().getValue())) {
accountTypesNoDuplicatesList.add(glAccount.getType().getValue());
}
}
int rowIndex = 1;
int startIndex = 1;
int accountTypeIndex = 0;
accountTypeToBeginEndIndexesofAccountNames = new HashMap<Integer, Integer[]>();
accountTypeToBeginEndIndexesofAccountNames = new HashMap<>();
for (String accountType : accountTypesNoDuplicatesList) {
startIndex = rowIndex + 1;
Row row = chartOfAccountsSheet.createRow(rowIndex);
@@ -40,15 +40,15 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class ClientEntityWorkbookPopulator extends AbstractWorkbookPopulator {
private OfficeSheetPopulator officeSheetPopulator;
private PersonnelSheetPopulator personnelSheetPopulator;
private List<CodeValueData> clientTypeCodeValues;
private List<CodeValueData> constitutionCodeValues;
private List<CodeValueData> clientClassificationCodeValues;
private List<CodeValueData> addressTypesCodeValues;
private List<CodeValueData> stateProvinceCodeValues;
private List<CodeValueData> countryCodeValues;
private List<CodeValueData> mainBusinesslineCodeValues;
private final OfficeSheetPopulator officeSheetPopulator;
private final PersonnelSheetPopulator personnelSheetPopulator;
private final List<CodeValueData> clientTypeCodeValues;
private final List<CodeValueData> constitutionCodeValues;
private final List<CodeValueData> clientClassificationCodeValues;
private final List<CodeValueData> addressTypesCodeValues;
private final List<CodeValueData> stateProvinceCodeValues;
private final List<CodeValueData> countryCodeValues;
private final List<CodeValueData> mainBusinesslineCodeValues;
public ClientEntityWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator, PersonnelSheetPopulator personnelSheetPopulator,
List<CodeValueData> clientTypeCodeValues, List<CodeValueData> constitutionCodeValues, List<CodeValueData> mainBusinessline,
@@ -368,11 +368,10 @@ public class ClientEntityWorkbookPopulator extends AbstractWorkbookPopulator {
Integer[] officeNameToBeginEndIndexesOfStaff = personnelSheetPopulator.getOfficeNameToBeginEndIndexesOfStaff().get(i);
if (officeNameToBeginEndIndexesOfStaff != null) {
Name name = clientWorkbook.createName();
name.setNameName("Staff_" + offices.get(i).name().trim().replaceAll("[ )(]", "_"));
setSanitized(name, "Staff_" + offices.get(i).name());
name.setRefersToFormula(TemplatePopulateImportConstants.STAFF_SHEET_NAME + "!$B$" + officeNameToBeginEndIndexesOfStaff[0]
+ ":$B$" + officeNameToBeginEndIndexesOfStaff[1]);
}
}
}
}
@@ -40,14 +40,14 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class ClientPersonWorkbookPopulator extends AbstractWorkbookPopulator {
private OfficeSheetPopulator officeSheetPopulator;
private PersonnelSheetPopulator personnelSheetPopulator;
private List<CodeValueData> clientTypeCodeValues;
private List<CodeValueData> genderCodeValues;
private List<CodeValueData> clientClassificationCodeValues;
private List<CodeValueData> addressTypesCodeValues;
private List<CodeValueData> stateProvinceCodeValues;
private List<CodeValueData> countryCodeValues;
private final OfficeSheetPopulator officeSheetPopulator;
private final PersonnelSheetPopulator personnelSheetPopulator;
private final List<CodeValueData> clientTypeCodeValues;
private final List<CodeValueData> genderCodeValues;
private final List<CodeValueData> clientClassificationCodeValues;
private final List<CodeValueData> addressTypesCodeValues;
private final List<CodeValueData> stateProvinceCodeValues;
private final List<CodeValueData> countryCodeValues;
public ClientPersonWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator, PersonnelSheetPopulator personnelSheetPopulator,
List<CodeValueData> clientTypeCodeValues, List<CodeValueData> genderCodeValues, List<CodeValueData> clientClassification,
@@ -340,11 +340,10 @@ public class ClientPersonWorkbookPopulator extends AbstractWorkbookPopulator {
Integer[] officeNameToBeginEndIndexesOfStaff = personnelSheetPopulator.getOfficeNameToBeginEndIndexesOfStaff().get(i);
if (officeNameToBeginEndIndexesOfStaff != null) {
Name name = clientWorkbook.createName();
name.setNameName("Staff_" + offices.get(i).name().trim().replaceAll("[ )(]", "_"));
setSanitized(name, "Staff_" + offices.get(i).name());
name.setRefersToFormula(TemplatePopulateImportConstants.STAFF_SHEET_NAME + "!$B$" + officeNameToBeginEndIndexesOfStaff[0]
+ ":$B$" + officeNameToBeginEndIndexesOfStaff[1]);
}
}
}
}
@@ -44,11 +44,11 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class FixedDepositTransactionWorkbookPopulator extends AbstractWorkbookPopulator {
private OfficeSheetPopulator officeSheetPopulator;
private ClientSheetPopulator clientSheetPopulator;
private ExtrasSheetPopulator extrasSheetPopulator;
private final OfficeSheetPopulator officeSheetPopulator;
private final ClientSheetPopulator clientSheetPopulator;
private final ExtrasSheetPopulator extrasSheetPopulator;
private List<SavingsAccountData> savingsAccounts;
private final List<SavingsAccountData> savingsAccounts;
public FixedDepositTransactionWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator, ClientSheetPopulator clientSheetPopulator,
ExtrasSheetPopulator extrasSheetPopulator, List<SavingsAccountData> savingsAccounts) {
@@ -144,7 +144,7 @@ public class FixedDepositTransactionWorkbookPopulator extends AbstractWorkbookPo
Integer[] officeNameToBeginEndIndexesOfClients = clientSheetPopulator.getOfficeNameToBeginEndIndexesOfClients().get(i);
Name name = savingsTransactionWorkbook.createName();
if (officeNameToBeginEndIndexesOfClients != null) {
name.setNameName("Client_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(name, "Client_" + officeNames.get(i));
name.setRefersToFormula(TemplatePopulateImportConstants.CLIENT_SHEET_NAME + "!$B$" + officeNameToBeginEndIndexesOfClients[0]
+ ":$B$" + officeNameToBeginEndIndexesOfClients[1]);
}
@@ -178,8 +178,7 @@ public class FixedDepositTransactionWorkbookPopulator extends AbstractWorkbookPo
// Account Number Named after Clients
for (int j = 0; j < clientsWithActiveSavings.size(); j++) {
Name name = savingsTransactionWorkbook.createName();
name.setNameName(
"Account_" + clientsWithActiveSavings.get(j).replace(" ", "_") + "_" + clientIdsWithActiveSavings.get(j) + "_");
setSanitized(name, "Account_" + clientsWithActiveSavings.get(j) + "_" + clientIdsWithActiveSavings.get(j) + "_");
name.setRefersToFormula(TemplatePopulateImportConstants.FIXED_DEPOSIT_TRANSACTION_SHEET_NAME + "!$Q$"
+ clientNameToBeginEndIndexes.get(clientsWithActiveSavings.get(j))[0] + ":$Q$"
+ clientNameToBeginEndIndexes.get(clientsWithActiveSavings.get(j))[1]);
@@ -45,10 +45,10 @@ import org.slf4j.LoggerFactory;
public class FixedDepositWorkbookPopulator extends AbstractWorkbookPopulator {
private static final Logger LOG = LoggerFactory.getLogger(FixedDepositWorkbookPopulator.class);
private OfficeSheetPopulator officeSheetPopulator;
private ClientSheetPopulator clientSheetPopulator;
private PersonnelSheetPopulator personnelSheetPopulator;
private FixedDepositProductSheetPopulator productSheetPopulator;
private final OfficeSheetPopulator officeSheetPopulator;
private final ClientSheetPopulator clientSheetPopulator;
private final PersonnelSheetPopulator personnelSheetPopulator;
private final FixedDepositProductSheetPopulator productSheetPopulator;
public FixedDepositWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator, ClientSheetPopulator clientSheetPopulator,
PersonnelSheetPopulator personnelSheetPopulator, FixedDepositProductSheetPopulator fixedDepositProductSheetPopulator) {
@@ -195,12 +195,12 @@ public class FixedDepositWorkbookPopulator extends AbstractWorkbookPopulator {
Name clientName = savingsWorkbook.createName();
Name fieldOfficerName = savingsWorkbook.createName();
if (officeNameToBeginEndIndexesOfStaff != null) {
fieldOfficerName.setNameName("Staff_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(fieldOfficerName, "Staff_" + officeNames.get(i));
fieldOfficerName.setRefersToFormula(TemplatePopulateImportConstants.STAFF_SHEET_NAME + "!$B$"
+ officeNameToBeginEndIndexesOfStaff[0] + ":$B$" + officeNameToBeginEndIndexesOfStaff[1]);
}
if (officeNameToBeginEndIndexesOfClients != null) {
clientName.setNameName("Client_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(clientName, "Client_" + officeNames.get(i));
clientName.setRefersToFormula(TemplatePopulateImportConstants.CLIENT_SHEET_NAME + "!$B$"
+ officeNameToBeginEndIndexesOfClients[0] + ":$B$" + officeNameToBeginEndIndexesOfClients[1]);
}
@@ -231,13 +231,13 @@ public class FixedDepositWorkbookPopulator extends AbstractWorkbookPopulator {
FixedDepositProductData product = products.get(i);
String productName = product.getName().replaceAll("[ ]", "_");
interestCompoundingPeriodName.setNameName("Interest_Compouding_" + productName);
interestPostingPeriodName.setNameName("Interest_Posting_" + productName);
interestCalculationName.setNameName("Interest_Calculation_" + productName);
daysInYearName.setNameName("Days_In_Year_" + productName);
minDepositName.setNameName("Min_Deposit_" + productName);
maxDepositName.setNameName("Max_Deposit_" + productName);
depositName.setNameName("Deposit_" + productName);
setSanitized(interestCompoundingPeriodName, "Interest_Compouding_" + productName);
setSanitized(interestPostingPeriodName, "Interest_Posting_" + productName);
setSanitized(interestCalculationName, "Interest_Calculation_" + productName);
setSanitized(daysInYearName, "Days_In_Year_" + productName);
setSanitized(minDepositName, "Min_Deposit_" + productName);
setSanitized(maxDepositName, "Max_Deposit_" + productName);
setSanitized(depositName, "Deposit_" + productName);
interestCompoundingPeriodName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$E$" + (i + 2));
interestPostingPeriodName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$F$" + (i + 2));
interestCalculationName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$G$" + (i + 2));
@@ -247,15 +247,15 @@ public class FixedDepositWorkbookPopulator extends AbstractWorkbookPopulator {
maxDepositName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$M$" + (i + 2));
if (product.getMinDepositTermType() != null) {
minDepositTermTypeName.setNameName("Term_Type_" + productName);
setSanitized(minDepositTermTypeName, "Term_Type_" + productName);
minDepositTermTypeName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$P$" + (i + 2));
}
if (product.getLockinPeriodFrequency() != null) {
lockinPeriodName.setNameName("Lockin_Period_" + productName);
setSanitized(lockinPeriodName, "Lockin_Period_" + productName);
lockinPeriodName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$I$" + (i + 2));
}
if (product.getLockinPeriodFrequencyType() != null) {
lockinPeriodFrequencyName.setNameName("Lockin_Frequency_" + productName);
setSanitized(lockinPeriodFrequencyName, "Lockin_Frequency_" + productName);
lockinPeriodFrequencyName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$J$" + (i + 2));
}
}
@@ -41,10 +41,10 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class GroupsWorkbookPopulator extends AbstractWorkbookPopulator {
private OfficeSheetPopulator officeSheetPopulator;
private PersonnelSheetPopulator personnelSheetPopulator;
private CenterSheetPopulator centerSheetPopulator;
private ClientSheetPopulator clientSheetPopulator;
private final OfficeSheetPopulator officeSheetPopulator;
private final PersonnelSheetPopulator personnelSheetPopulator;
private final CenterSheetPopulator centerSheetPopulator;
private final ClientSheetPopulator clientSheetPopulator;
public GroupsWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator, PersonnelSheetPopulator personnelSheetPopulator,
CenterSheetPopulator centerSheetPopulator, ClientSheetPopulator clientSheetPopulator) {
@@ -241,17 +241,15 @@ public class GroupsWorkbookPopulator extends AbstractWorkbookPopulator {
Name centerName = centerWorkbook.createName();
if (officeNameToBeginEndIndexesOfStaff != null) {
loanOfficerName.setNameName("Staff_" + offices.get(i).name().trim().replaceAll("[ )(]", "_"));
setSanitized(loanOfficerName, "Staff_" + offices.get(i).name());
loanOfficerName.setRefersToFormula(TemplatePopulateImportConstants.STAFF_SHEET_NAME + "!$B$"
+ officeNameToBeginEndIndexesOfStaff[0] + ":$B$" + officeNameToBeginEndIndexesOfStaff[1]);
}
if (officeNameToBeginEndIndexesOfCenters != null) {
centerName.setNameName("Center_" + offices.get(i).name().trim().replaceAll("[ )(]", "_"));
setSanitized(centerName, "Center_" + offices.get(i).name());
centerName.setRefersToFormula(TemplatePopulateImportConstants.CENTER_SHEET_NAME + "!$B$"
+ officeNameToBeginEndIndexesOfCenters[0] + ":$B$" + officeNameToBeginEndIndexesOfCenters[1]);
}
}
}
}
@@ -45,11 +45,11 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class GuarantorWorkbookPopulator extends AbstractWorkbookPopulator {
private OfficeSheetPopulator officeSheetPopulator;
private ClientSheetPopulator clientSheetPopulator;
private List<LoanAccountData> loans;
private List<SavingsAccountData> savings;
private List<CodeValueData> guarantorRelationshipTypes;
private final OfficeSheetPopulator officeSheetPopulator;
private final ClientSheetPopulator clientSheetPopulator;
private final List<LoanAccountData> loans;
private final List<SavingsAccountData> savings;
private final List<CodeValueData> guarantorRelationshipTypes;
public GuarantorWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator, ClientSheetPopulator clientSheetPopulator,
List<LoanAccountData> loans, List<SavingsAccountData> savings, List<CodeValueData> guarantorRelationshipTypes) {
@@ -240,7 +240,7 @@ public class GuarantorWorkbookPopulator extends AbstractWorkbookPopulator {
private void setNames(Sheet worksheet) {
Workbook addGurarantorWorkbook = worksheet.getWorkbook();
ArrayList<String> officeNames = new ArrayList<String>(officeSheetPopulator.getOfficeNames());
ArrayList<String> officeNames = new ArrayList<>(officeSheetPopulator.getOfficeNames());
// Office Names
Name officeGroup = addGurarantorWorkbook.createName();
@@ -258,7 +258,7 @@ public class GuarantorWorkbookPopulator extends AbstractWorkbookPopulator {
Integer[] officeNameToBeginEndIndexesOfClients = clientSheetPopulator.getOfficeNameToBeginEndIndexesOfClients().get(i);
Name name = addGurarantorWorkbook.createName();
if (officeNameToBeginEndIndexesOfClients != null) {
name.setNameName("Client_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(name, "Client_" + officeNames.get(i));
name.setRefersToFormula(TemplatePopulateImportConstants.CLIENT_SHEET_NAME + "!$B$" + officeNameToBeginEndIndexesOfClients[0]
+ ":$B$" + officeNameToBeginEndIndexesOfClients[1]);
}
@@ -266,9 +266,9 @@ public class GuarantorWorkbookPopulator extends AbstractWorkbookPopulator {
// Counting clients with active loans and starting and end addresses of
// cells
HashMap<String, Integer[]> clientNameToBeginEndIndexes = new HashMap<String, Integer[]>();
ArrayList<String> clientsWithActiveLoans = new ArrayList<String>();
ArrayList<String> clientIdsWithActiveLoans = new ArrayList<String>();
HashMap<String, Integer[]> clientNameToBeginEndIndexes = new HashMap<>();
ArrayList<String> clientsWithActiveLoans = new ArrayList<>();
ArrayList<String> clientIdsWithActiveLoans = new ArrayList<>();
int startIndex = 1;
int endIndex = 1;
String clientName = "";
@@ -292,7 +292,7 @@ public class GuarantorWorkbookPopulator extends AbstractWorkbookPopulator {
// Account Number Named after Clients
for (int j = 0; j < clientsWithActiveLoans.size(); j++) {
Name name = addGurarantorWorkbook.createName();
name.setNameName("Account_" + clientsWithActiveLoans.get(j).replaceAll(" ", "_") + "_" + clientIdsWithActiveLoans.get(j) + "_");
setSanitized(name, "Account_" + clientsWithActiveLoans.get(j) + "_" + clientIdsWithActiveLoans.get(j) + "_");
name.setRefersToFormula(TemplatePopulateImportConstants.GUARANTOR_SHEET_NAME + "!$CE$"
+ clientNameToBeginEndIndexes.get(clientsWithActiveLoans.get(j))[0] + ":$CE$"
+ clientNameToBeginEndIndexes.get(clientsWithActiveLoans.get(j))[1]);
@@ -300,8 +300,8 @@ public class GuarantorWorkbookPopulator extends AbstractWorkbookPopulator {
/// savings
// Counting clients with active savings and starting and end addresses
/// of cells for naming
ArrayList<String> clientsWithActiveSavings = new ArrayList<String>();
ArrayList<String> clientIdsWithActiveSavings = new ArrayList<String>();
ArrayList<String> clientsWithActiveSavings = new ArrayList<>();
ArrayList<String> clientIdsWithActiveSavings = new ArrayList<>();
clientName = "";
clientId = "";
for (int i = 0; i < savings.size(); i++) {
@@ -322,8 +322,7 @@ public class GuarantorWorkbookPopulator extends AbstractWorkbookPopulator {
// Account Number Named after Clients
for (int j = 0; j < clientsWithActiveSavings.size(); j++) {
Name name = addGurarantorWorkbook.createName();
name.setNameName("SavingsAccount_" + clientsWithActiveSavings.get(j).replaceAll(" ", "_") + "_"
+ clientIdsWithActiveSavings.get(j) + "_");
setSanitized(name, "SavingsAccount_" + clientsWithActiveSavings.get(j) + "_" + clientIdsWithActiveSavings.get(j) + "_");
name.setRefersToFormula(TemplatePopulateImportConstants.GUARANTOR_SHEET_NAME + "!$CG$"
+ clientNameToBeginEndIndexes.get(clientsWithActiveSavings.get(j))[0] + ":$CG$"
+ clientNameToBeginEndIndexes.get(clientsWithActiveSavings.get(j))[1]);
@@ -39,9 +39,9 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class JournalEntriesWorkbookPopulator extends AbstractWorkbookPopulator {
private OfficeSheetPopulator officeSheetPopulator;
private GlAccountSheetPopulator glAccountSheetPopulator;
private ExtrasSheetPopulator extrasSheetPopulator;
private final OfficeSheetPopulator officeSheetPopulator;
private final GlAccountSheetPopulator glAccountSheetPopulator;
private final ExtrasSheetPopulator extrasSheetPopulator;
public JournalEntriesWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator, GlAccountSheetPopulator glAccountSheetPopulator,
ExtrasSheetPopulator extrasSheetPopulator) {
@@ -169,9 +169,7 @@ public class JournalEntriesWorkbookPopulator extends AbstractWorkbookPopulator {
private void setDefaults(Sheet worksheet) {
for (Integer rowNo = 1; rowNo < 1000; rowNo++) {
Row row = worksheet.createRow(rowNo);
worksheet.createRow(rowNo);
}
}
}
@@ -46,12 +46,12 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class LoanWorkbookPopulator extends AbstractWorkbookPopulator {
private OfficeSheetPopulator officeSheetPopulator;
private ClientSheetPopulator clientSheetPopulator;
private GroupSheetPopulator groupSheetPopulator;
private PersonnelSheetPopulator personnelSheetPopulator;
private LoanProductSheetPopulator productSheetPopulator;
private ExtrasSheetPopulator extrasSheetPopulator;
private final OfficeSheetPopulator officeSheetPopulator;
private final ClientSheetPopulator clientSheetPopulator;
private final GroupSheetPopulator groupSheetPopulator;
private final PersonnelSheetPopulator personnelSheetPopulator;
private final LoanProductSheetPopulator productSheetPopulator;
private final ExtrasSheetPopulator extrasSheetPopulator;
public LoanWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator, ClientSheetPopulator clientSheetPopulator,
GroupSheetPopulator groupSheetPopulator, PersonnelSheetPopulator personnelSheetPopulator,
@@ -432,21 +432,20 @@ public class LoanWorkbookPopulator extends AbstractWorkbookPopulator {
Name groupName = loanWorkbook.createName();
if (officeNameToBeginEndIndexesOfStaff != null) {
loanOfficerName.setNameName("Staff_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(loanOfficerName, "Staff_" + officeNames.get(i));
loanOfficerName.setRefersToFormula(TemplatePopulateImportConstants.STAFF_SHEET_NAME + "!$B$"
+ officeNameToBeginEndIndexesOfStaff[0] + ":$B$" + officeNameToBeginEndIndexesOfStaff[1]);
}
if (officeNameToBeginEndIndexesOfClients != null) {
clientName.setNameName("Client_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(clientName, "Client_" + officeNames.get(i));
clientName.setRefersToFormula(TemplatePopulateImportConstants.CLIENT_SHEET_NAME + "!$B$"
+ officeNameToBeginEndIndexesOfClients[0] + ":$B$" + officeNameToBeginEndIndexesOfClients[1]);
}
if (officeNameToBeginEndIndexesOfGroups != null) {
groupName.setNameName("Group_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(groupName, "Group_" + officeNames.get(i));
groupName.setRefersToFormula(TemplatePopulateImportConstants.GROUP_SHEET_NAME + "!$B$"
+ officeNameToBeginEndIndexesOfGroups[0] + ":$B$" + officeNameToBeginEndIndexesOfGroups[1]);
}
}
// Product Name
@@ -499,28 +498,28 @@ public class LoanWorkbookPopulator extends AbstractWorkbookPopulator {
Name graceOnInterestChargedName = loanWorkbook.createName();
Name startDateName = loanWorkbook.createName();
String productName = products.get(i).getName().replaceAll("[ ]", "_");
fundName.setNameName("FUND_" + productName);
principalName.setNameName("PRINCIPAL_" + productName);
minPrincipalName.setNameName("MIN_PRINCIPAL_" + productName);
maxPrincipalName.setNameName("MAX_PRINCIPAL_" + productName);
noOfRepaymentName.setNameName("NO_REPAYMENT_" + productName);
minNoOfRepayment.setNameName("MIN_REPAYMENT_" + productName);
maxNoOfRepaymentName.setNameName("MAX_REPAYMENT_" + productName);
repaymentEveryName.setNameName("REPAYMENT_EVERY_" + productName);
repaymentFrequencyName.setNameName("REPAYMENT_FREQUENCY_" + productName);
interestName.setNameName("INTEREST_" + productName);
minInterestName.setNameName("MIN_INTEREST_" + productName);
maxInterestName.setNameName("MAX_INTEREST_" + productName);
interestFrequencyName.setNameName("INTEREST_FREQUENCY_" + productName);
amortizationName.setNameName("AMORTIZATION_" + productName);
interestTypeName.setNameName("INTEREST_TYPE_" + productName);
interestCalculationPeriodName.setNameName("INTEREST_CALCULATION_" + productName);
transactionProcessingStrategyName.setNameName("STRATEGY_" + productName);
arrearsToleranceName.setNameName("ARREARS_TOLERANCE_" + productName);
graceOnPrincipalPaymentName.setNameName("GRACE_PRINCIPAL_" + productName);
graceOnInterestPaymentName.setNameName("GRACE_INTEREST_PAYMENT_" + productName);
graceOnInterestChargedName.setNameName("GRACE_INTEREST_CHARGED_" + productName);
startDateName.setNameName("START_DATE_" + productName);
setSanitized(fundName, "FUND_" + productName);
setSanitized(principalName, "PRINCIPAL_" + productName);
setSanitized(minPrincipalName, "MIN_PRINCIPAL_" + productName);
setSanitized(maxPrincipalName, "MAX_PRINCIPAL_" + productName);
setSanitized(noOfRepaymentName, "NO_REPAYMENT_" + productName);
setSanitized(minNoOfRepayment, "MIN_REPAYMENT_" + productName);
setSanitized(maxNoOfRepaymentName, "MAX_REPAYMENT_" + productName);
setSanitized(repaymentEveryName, "REPAYMENT_EVERY_" + productName);
setSanitized(repaymentFrequencyName, "REPAYMENT_FREQUENCY_" + productName);
setSanitized(interestName, "INTEREST_" + productName);
setSanitized(minInterestName, "MIN_INTEREST_" + productName);
setSanitized(maxInterestName, "MAX_INTEREST_" + productName);
setSanitized(interestFrequencyName, "INTEREST_FREQUENCY_" + productName);
setSanitized(amortizationName, "AMORTIZATION_" + productName);
setSanitized(interestTypeName, "INTEREST_TYPE_" + productName);
setSanitized(interestCalculationPeriodName, "INTEREST_CALCULATION_" + productName);
setSanitized(transactionProcessingStrategyName, "STRATEGY_" + productName);
setSanitized(arrearsToleranceName, "ARREARS_TOLERANCE_" + productName);
setSanitized(graceOnPrincipalPaymentName, "GRACE_PRINCIPAL_" + productName);
setSanitized(graceOnInterestPaymentName, "GRACE_INTEREST_PAYMENT_" + productName);
setSanitized(graceOnInterestChargedName, "GRACE_INTEREST_CHARGED_" + productName);
setSanitized(startDateName, "START_DATE_" + productName);
if (products.get(i).getFundName() != null) {
fundName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$C$" + (i + 2));
}
@@ -547,5 +546,4 @@ public class LoanWorkbookPopulator extends AbstractWorkbookPopulator {
startDateName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$X$" + (i + 2));
}
}
}
@@ -53,10 +53,10 @@ import org.slf4j.LoggerFactory;
public class LoanRepaymentWorkbookPopulator extends AbstractWorkbookPopulator {
private static final Logger LOG = LoggerFactory.getLogger(LoanRepaymentWorkbookPopulator.class);
private OfficeSheetPopulator officeSheetPopulator;
private ClientSheetPopulator clientSheetPopulator;
private ExtrasSheetPopulator extrasSheetPopulator;
private List<LoanAccountData> allloans;
private final OfficeSheetPopulator officeSheetPopulator;
private final ClientSheetPopulator clientSheetPopulator;
private final ExtrasSheetPopulator extrasSheetPopulator;
private final List<LoanAccountData> allloans;
private Map<Long, String> clientIdToClientExternalId;
public LoanRepaymentWorkbookPopulator(List<LoanAccountData> loans, OfficeSheetPopulator officeSheetPopulator,
@@ -173,7 +173,7 @@ public class LoanRepaymentWorkbookPopulator extends AbstractWorkbookPopulator {
Integer[] officeNameToBeginEndIndexesOfClients = clientSheetPopulator.getOfficeNameToBeginEndIndexesOfClients().get(i);
Name name = loanRepaymentWorkbook.createName();
if (officeNameToBeginEndIndexesOfClients != null) {
name.setNameName("Client_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(name, "Client_" + officeNames.get(i));
name.setRefersToFormula(TemplatePopulateImportConstants.CLIENT_SHEET_NAME + "!$B$" + officeNameToBeginEndIndexesOfClients[0]
+ ":$B$" + officeNameToBeginEndIndexesOfClients[1]);
}
@@ -181,9 +181,9 @@ public class LoanRepaymentWorkbookPopulator extends AbstractWorkbookPopulator {
// Counting clients with active loans and starting and end addresses of
// cells
HashMap<String, Integer[]> clientNameToBeginEndIndexes = new HashMap<String, Integer[]>();
ArrayList<String> clientsWithActiveLoans = new ArrayList<String>();
ArrayList<String> clientIdsWithActiveLoans = new ArrayList<String>();
HashMap<String, Integer[]> clientNameToBeginEndIndexes = new HashMap<>();
ArrayList<String> clientsWithActiveLoans = new ArrayList<>();
ArrayList<String> clientIdsWithActiveLoans = new ArrayList<>();
int startIndex = 1;
int endIndex = 1;
String clientName = "";
@@ -209,7 +209,7 @@ public class LoanRepaymentWorkbookPopulator extends AbstractWorkbookPopulator {
// Account Number Named after Clients
for (int j = 0; j < clientsWithActiveLoans.size(); j++) {
Name name = loanRepaymentWorkbook.createName();
name.setNameName("Account_" + clientsWithActiveLoans.get(j).replace(" ", "_") + "_" + clientIdsWithActiveLoans.get(j) + "_");
setSanitized(name, "Account_" + clientsWithActiveLoans.get(j) + "_" + clientIdsWithActiveLoans.get(j) + "_");
name.setRefersToFormula(TemplatePopulateImportConstants.LOAN_REPAYMENT_SHEET_NAME + "!$T$"
+ clientNameToBeginEndIndexes.get(clientsWithActiveLoans.get(j))[0] + ":$T$"
+ clientNameToBeginEndIndexes.get(clientsWithActiveLoans.get(j))[1]);
@@ -305,7 +305,5 @@ public class LoanRepaymentWorkbookPopulator extends AbstractWorkbookPopulator {
writeString(LoanRepaymentConstants.LOOKUP_PRINCIPAL_COL, rowHeader, "Lookup Principal");
writeString(LoanRepaymentConstants.LOOKUP_TOTAL_OUTSTANDING_AMOUNT_COL, rowHeader, "Lookup Total Outstanding amount");
writeString(LoanRepaymentConstants.LOOKUP_LOAN_DISBURSEMENT_DATE_COL, rowHeader, "Lookup Loan Disbursement Date");
}
}
@@ -37,7 +37,7 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class OfficeWorkbookPopulator extends AbstractWorkbookPopulator {
private List<OfficeData> offices;
private final List<OfficeData> offices;
public OfficeWorkbookPopulator(List<OfficeData> offices) {
this.offices = offices;
@@ -118,6 +118,5 @@ public class OfficeWorkbookPopulator extends AbstractWorkbookPopulator {
"IF(ISERROR(VLOOKUP($B" + (rowNo + 1) + ",$H$2:$I$" + (offices.size() + 1) + ",2,FALSE)),\"\",(VLOOKUP($B" + (rowNo + 1)
+ ",$H$2:$I$" + (offices.size() + 1) + ",2,FALSE)))");
}
}
}
@@ -44,11 +44,11 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class RecurringDepositTransactionWorkbookPopulator extends AbstractWorkbookPopulator {
private OfficeSheetPopulator officeSheetPopulator;
private ClientSheetPopulator clientSheetPopulator;
private ExtrasSheetPopulator extrasSheetPopulator;
private final OfficeSheetPopulator officeSheetPopulator;
private final ClientSheetPopulator clientSheetPopulator;
private final ExtrasSheetPopulator extrasSheetPopulator;
private List<SavingsAccountData> savingsAccounts;
private final List<SavingsAccountData> savingsAccounts;
public RecurringDepositTransactionWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator,
ClientSheetPopulator clientSheetPopulator, ExtrasSheetPopulator extrasSheetPopulator,
@@ -145,7 +145,7 @@ public class RecurringDepositTransactionWorkbookPopulator extends AbstractWorkbo
Integer[] officeNameToBeginEndIndexesOfClients = clientSheetPopulator.getOfficeNameToBeginEndIndexesOfClients().get(i);
Name name = savingsTransactionWorkbook.createName();
if (officeNameToBeginEndIndexesOfClients != null) {
name.setNameName("Client_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(name, "Client_" + officeNames.get(i));
name.setRefersToFormula(TemplatePopulateImportConstants.CLIENT_SHEET_NAME + "!$B$" + officeNameToBeginEndIndexesOfClients[0]
+ ":$B$" + officeNameToBeginEndIndexesOfClients[1]);
}
@@ -179,8 +179,7 @@ public class RecurringDepositTransactionWorkbookPopulator extends AbstractWorkbo
// Account Number Named after Clients
for (int j = 0; j < clientsWithActiveSavings.size(); j++) {
Name name = savingsTransactionWorkbook.createName();
name.setNameName(
"Account_" + clientsWithActiveSavings.get(j).replaceAll(" ", "_") + "_" + clientIdsWithActiveSavings.get(j) + "_");
setSanitized(name, "Account_" + clientsWithActiveSavings.get(j) + "_" + clientIdsWithActiveSavings.get(j) + "_");
name.setRefersToFormula(TemplatePopulateImportConstants.SAVINGS_TRANSACTION_SHEET_NAME + "!$Q$"
+ clientNameToBeginEndIndexes.get(clientsWithActiveSavings.get(j))[0] + ":$Q$"
+ clientNameToBeginEndIndexes.get(clientsWithActiveSavings.get(j))[1]);
@@ -42,10 +42,10 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class RecurringDepositWorkbookPopulator extends AbstractWorkbookPopulator {
private OfficeSheetPopulator officeSheetPopulator;
private ClientSheetPopulator clientSheetPopulator;
private PersonnelSheetPopulator personnelSheetPopulator;
private RecurringDepositProductSheetPopulator productSheetPopulator;
private final OfficeSheetPopulator officeSheetPopulator;
private final ClientSheetPopulator clientSheetPopulator;
private final PersonnelSheetPopulator personnelSheetPopulator;
private final RecurringDepositProductSheetPopulator productSheetPopulator;
public RecurringDepositWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator, ClientSheetPopulator clientSheetPopulator,
PersonnelSheetPopulator personnelSheetPopulator, RecurringDepositProductSheetPopulator recurringDepositProductSheetPopulator) {
@@ -334,12 +334,12 @@ public class RecurringDepositWorkbookPopulator extends AbstractWorkbookPopulator
Name clientName = savingsWorkbook.createName();
Name fieldOfficerName = savingsWorkbook.createName();
if (officeNameToBeginEndIndexesOfStaff != null) {
fieldOfficerName.setNameName("Staff_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(fieldOfficerName, "Staff_" + officeNames.get(i));
fieldOfficerName.setRefersToFormula(TemplatePopulateImportConstants.STAFF_SHEET_NAME + "!$B$"
+ officeNameToBeginEndIndexesOfStaff[0] + ":$B$" + officeNameToBeginEndIndexesOfStaff[1]);
}
if (officeNameToBeginEndIndexesOfClients != null) {
clientName.setNameName("Client_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(clientName, "Client_" + officeNames.get(i));
clientName.setRefersToFormula(TemplatePopulateImportConstants.CLIENT_SHEET_NAME + "!$B$"
+ officeNameToBeginEndIndexesOfClients[0] + ":$B$" + officeNameToBeginEndIndexesOfClients[1]);
}
@@ -373,16 +373,16 @@ public class RecurringDepositWorkbookPopulator extends AbstractWorkbookPopulator
RecurringDepositProductData product = products.get(i);
String productName = product.getName().replaceAll("[ ]", "_");
interestCompoundingPeriodName.setNameName("Interest_Compouding_" + productName);
interestPostingPeriodName.setNameName("Interest_Posting_" + productName);
interestCalculationName.setNameName("Interest_Calculation_" + productName);
daysInYearName.setNameName("Days_In_Year_" + productName);
minDepositName.setNameName("Min_Deposit_" + productName);
maxDepositName.setNameName("Max_Deposit_" + productName);
depositName.setNameName("Deposit_" + productName);
allowWithdrawalName.setNameName("Allow_Withdrawal_" + productName);
mandatoryDepositName.setNameName("Mandatory_Deposit_" + productName);
adjustAdvancePaymentsName.setNameName("Adjust_Advance_" + productName);
setSanitized(interestCompoundingPeriodName, "Interest_Compouding_" + productName);
setSanitized(interestPostingPeriodName, "Interest_Posting_" + productName);
setSanitized(interestCalculationName, "Interest_Calculation_" + productName);
setSanitized(daysInYearName, "Days_In_Year_" + productName);
setSanitized(minDepositName, "Min_Deposit_" + productName);
setSanitized(maxDepositName, "Max_Deposit_" + productName);
setSanitized(depositName, "Deposit_" + productName);
setSanitized(allowWithdrawalName, "Allow_Withdrawal_" + productName);
setSanitized(mandatoryDepositName, "Mandatory_Deposit_" + productName);
setSanitized(adjustAdvancePaymentsName, "Adjust_Advance_" + productName);
interestCompoundingPeriodName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$E$" + (i + 2));
interestPostingPeriodName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$F$" + (i + 2));
interestCalculationName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$G$" + (i + 2));
@@ -395,15 +395,15 @@ public class RecurringDepositWorkbookPopulator extends AbstractWorkbookPopulator
adjustAdvancePaymentsName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$Z$" + (i + 2));
if (product.getMinDepositTermType() != null) {
minDepositTermTypeName.setNameName("Term_Type_" + productName);
setSanitized(minDepositTermTypeName, "Term_Type_" + productName);
minDepositTermTypeName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$P$" + (i + 2));
}
if (product.getLockinPeriodFrequency() != null) {
lockinPeriodName.setNameName("Lockin_Period_" + productName);
setSanitized(lockinPeriodName, "Lockin_Period_" + productName);
lockinPeriodName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$I$" + (i + 2));
}
if (product.getLockinPeriodFrequencyType() != null) {
lockinPeriodFrequencyName.setNameName("Lockin_Frequency_" + productName);
setSanitized(lockinPeriodFrequencyName, "Lockin_Frequency_" + productName);
lockinPeriodFrequencyName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$J$" + (i + 2));
}
}
@@ -44,11 +44,11 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class SavingsTransactionsWorkbookPopulator extends AbstractWorkbookPopulator {
private OfficeSheetPopulator officeSheetPopulator;
private ClientSheetPopulator clientSheetPopulator;
private ExtrasSheetPopulator extrasSheetPopulator;
private final OfficeSheetPopulator officeSheetPopulator;
private final ClientSheetPopulator clientSheetPopulator;
private final ExtrasSheetPopulator extrasSheetPopulator;
private List<SavingsAccountData> savingsAccounts;
private final List<SavingsAccountData> savingsAccounts;
public SavingsTransactionsWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator, ClientSheetPopulator clientSheetPopulator,
ExtrasSheetPopulator extrasSheetPopulator, List<SavingsAccountData> savingsAccounts) {
@@ -144,7 +144,7 @@ public class SavingsTransactionsWorkbookPopulator extends AbstractWorkbookPopula
Integer[] officeNameToBeginEndIndexesOfClients = clientSheetPopulator.getOfficeNameToBeginEndIndexesOfClients().get(i);
Name name = savingsTransactionWorkbook.createName();
if (officeNameToBeginEndIndexesOfClients != null) {
name.setNameName("Client_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(name, "Client_" + officeNames.get(i));
name.setRefersToFormula(TemplatePopulateImportConstants.CLIENT_SHEET_NAME + "!$B$" + officeNameToBeginEndIndexesOfClients[0]
+ ":$B$" + officeNameToBeginEndIndexesOfClients[1]);
}
@@ -178,8 +178,7 @@ public class SavingsTransactionsWorkbookPopulator extends AbstractWorkbookPopula
// Account Number Named after Clients
for (int j = 0; j < clientsWithActiveSavings.size(); j++) {
Name name = savingsTransactionWorkbook.createName();
name.setNameName(
"Account_" + clientsWithActiveSavings.get(j).replace(" ", "_") + "_" + clientIdsWithActiveSavings.get(j) + "_");
setSanitized(name, "Account_" + clientsWithActiveSavings.get(j) + "_" + clientIdsWithActiveSavings.get(j) + "_");
name.setRefersToFormula(TemplatePopulateImportConstants.SAVINGS_TRANSACTION_SHEET_NAME + "!$Q$"
+ clientNameToBeginEndIndexes.get(clientsWithActiveSavings.get(j))[0] + ":$Q$"
+ clientNameToBeginEndIndexes.get(clientsWithActiveSavings.get(j))[1]);
@@ -43,11 +43,11 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class SavingsWorkbookPopulator extends AbstractWorkbookPopulator {
private OfficeSheetPopulator officeSheetPopulator;
private ClientSheetPopulator clientSheetPopulator;
private GroupSheetPopulator groupSheetPopulator;
private PersonnelSheetPopulator personnelSheetPopulator;
private SavingsProductSheetPopulator productSheetPopulator;
private final OfficeSheetPopulator officeSheetPopulator;
private final ClientSheetPopulator clientSheetPopulator;
private final GroupSheetPopulator groupSheetPopulator;
private final PersonnelSheetPopulator personnelSheetPopulator;
private final SavingsProductSheetPopulator productSheetPopulator;
public SavingsWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator, ClientSheetPopulator clientSheetPopulator,
GroupSheetPopulator groupSheetPopulator, PersonnelSheetPopulator personnelSheetPopulator,
@@ -322,17 +322,17 @@ public class SavingsWorkbookPopulator extends AbstractWorkbookPopulator {
Name fieldOfficerName = savingsWorkbook.createName();
Name groupName = savingsWorkbook.createName();
if (officeNameToBeginEndIndexesOfStaff != null) {
fieldOfficerName.setNameName("Staff_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(fieldOfficerName, "Staff_" + officeNames.get(i));
fieldOfficerName.setRefersToFormula(TemplatePopulateImportConstants.STAFF_SHEET_NAME + "!$B$"
+ officeNameToBeginEndIndexesOfStaff[0] + ":$B$" + officeNameToBeginEndIndexesOfStaff[1]);
}
if (officeNameToBeginEndIndexesOfClients != null) {
clientName.setNameName("Client_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(clientName, "Client_" + officeNames.get(i));
clientName.setRefersToFormula(TemplatePopulateImportConstants.CLIENT_SHEET_NAME + "!$B$"
+ officeNameToBeginEndIndexesOfClients[0] + ":$B$" + officeNameToBeginEndIndexesOfClients[1]);
}
if (officeNameToBeginEndIndexesOfGroups != null) {
groupName.setNameName("Group_" + officeNames.get(i).trim().replaceAll("[ )(]", "_"));
setSanitized(groupName, "Group_" + officeNames.get(i));
groupName.setRefersToFormula(TemplatePopulateImportConstants.GROUP_SHEET_NAME + "!$B$"
+ officeNameToBeginEndIndexesOfGroups[0] + ":$B$" + officeNameToBeginEndIndexesOfGroups[1]);
}
@@ -366,19 +366,19 @@ public class SavingsWorkbookPopulator extends AbstractWorkbookPopulator {
Name allowOverdraftName = savingsWorkbook.createName();
Name overdraftLimitName = savingsWorkbook.createName();
SavingsProductData product = products.get(i);
String productName = product.getName().replaceAll("[ ]", "_");
String productName = product.getName();
if (product.getNominalAnnualInterestRate() != null) {
interestRateName.setNameName("Interest_Rate_" + productName);
setSanitized(interestRateName, "Interest_Rate_" + productName);
interestRateName.setRefersToFormula("Products!$C$" + (i + 2));
}
interestCompoundingPeriodName.setNameName("Interest_Compouding_" + productName);
interestPostingPeriodName.setNameName("Interest_Posting_" + productName);
interestCalculationName.setNameName("Interest_Calculation_" + productName);
daysInYearName.setNameName("Days_In_Year_" + productName);
currencyName.setNameName("Currency_" + productName);
decimalPlacesName.setNameName("Decimal_Places_" + productName);
withdrawalFeeName.setNameName("Withdrawal_Fee_" + productName);
allowOverdraftName.setNameName("Overdraft_" + productName);
setSanitized(interestCompoundingPeriodName, "Interest_Compouding_" + productName);
setSanitized(interestPostingPeriodName, "Interest_Posting_" + productName);
setSanitized(interestCalculationName, "Interest_Calculation_" + productName);
setSanitized(daysInYearName, "Days_In_Year_" + productName);
setSanitized(currencyName, "Currency_" + productName);
setSanitized(decimalPlacesName, "Decimal_Places_" + productName);
setSanitized(withdrawalFeeName, "Withdrawal_Fee_" + productName);
setSanitized(allowOverdraftName, "Overdraft_" + productName);
interestCompoundingPeriodName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$D$" + (i + 2));
interestPostingPeriodName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$E$" + (i + 2));
@@ -389,26 +389,25 @@ public class SavingsWorkbookPopulator extends AbstractWorkbookPopulator {
withdrawalFeeName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$N$" + (i + 2));
allowOverdraftName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$O$" + (i + 2));
if (product.getOverdraftLimit() != null) {
overdraftLimitName.setNameName("Overdraft_Limit_" + productName);
setSanitized(overdraftLimitName, "Overdraft_Limit_" + productName);
overdraftLimitName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$P$" + (i + 2));
}
if (product.getMinRequiredOpeningBalance() != null) {
minOpeningBalanceName.setNameName("Min_Balance_" + productName);
setSanitized(minOpeningBalanceName, "Min_Balance_" + productName);
minOpeningBalanceName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$H$" + (i + 2));
}
if (product.getLockinPeriodFrequency() != null) {
lockinPeriodName.setNameName("Lockin_Period_" + productName);
setSanitized(lockinPeriodName, "Lockin_Period_" + productName);
lockinPeriodName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$I$" + (i + 2));
}
if (product.getLockinPeriodFrequencyType() != null) {
lockinPeriodFrequencyName.setNameName("Lockin_Frequency_" + productName);
setSanitized(lockinPeriodFrequencyName, "Lockin_Frequency_" + productName);
lockinPeriodFrequencyName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$J$" + (i + 2));
}
if (product.getCurrency().currencyInMultiplesOf() != null) {
inMultiplesOfName.setNameName("In_Multiples_" + productName);
setSanitized(inMultiplesOfName, "In_Multiples_" + productName);
inMultiplesOfName.setRefersToFormula(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME + "!$M$" + (i + 2));
}
}
}
}
@@ -41,9 +41,9 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class SharedAccountWorkBookPopulator extends AbstractWorkbookPopulator {
private SharedProductsSheetPopulator sharedProductsSheetPopulator;
private ClientSheetPopulator clientSheetPopulator;
private SavingsAccountSheetPopulator savingsAccountSheetPopulator;
private final SharedProductsSheetPopulator sharedProductsSheetPopulator;
private final ClientSheetPopulator clientSheetPopulator;
private final SavingsAccountSheetPopulator savingsAccountSheetPopulator;
public SharedAccountWorkBookPopulator(SharedProductsSheetPopulator sharedProductsSheetPopulator,
ClientSheetPopulator clientSheetPopulator, SavingsAccountSheetPopulator savingsAccountSheetPopulator) {
@@ -150,25 +150,25 @@ public class SharedAccountWorkBookPopulator extends AbstractWorkbookPopulator {
String productName = products.get(i).getName().replaceAll("[ ]", "_");
currecyName.setNameName("CURRENCY_" + productName);
setSanitized(currecyName, "CURRENCY_" + productName);
currecyName.setRefersToFormula(TemplatePopulateImportConstants.SHARED_PRODUCTS_SHEET_NAME + "!$C$" + (i + 2));
decimalPlacesName.setNameName("DECIMAL_PLACES_" + productName);
setSanitized(decimalPlacesName, "DECIMAL_PLACES_" + productName);
decimalPlacesName.setRefersToFormula(TemplatePopulateImportConstants.SHARED_PRODUCTS_SHEET_NAME + "!$D$" + (i + 2));
todaysPriceName.setNameName("TODAYS_PRICE_" + productName);
setSanitized(todaysPriceName, "TODAYS_PRICE_" + productName);
todaysPriceName.setRefersToFormula(TemplatePopulateImportConstants.SHARED_PRODUCTS_SHEET_NAME + "!$E$" + (i + 2));
currencyInMultiplesName.setNameName("CURRENCY_IN_MULTIPLES_" + productName);
setSanitized(currencyInMultiplesName, "CURRENCY_IN_MULTIPLES_" + productName);
currencyInMultiplesName.setRefersToFormula(TemplatePopulateImportConstants.SHARED_PRODUCTS_SHEET_NAME + "!$F$" + (i + 2));
chargesName1.setNameName("CHARGES_NAME_1_" + productName);
setSanitized(chargesName1, "CHARGES_NAME_1_" + productName);
chargesName1.setRefersToFormula(TemplatePopulateImportConstants.SHARED_PRODUCTS_SHEET_NAME + "!$I$" + (i + 2));
chargesName2.setNameName("CHARGES_NAME_2_" + productName);
setSanitized(chargesName2, "CHARGES_NAME_2_" + productName);
chargesName2.setRefersToFormula(TemplatePopulateImportConstants.SHARED_PRODUCTS_SHEET_NAME + "!$K$" + (i + 2));
chargesName3.setNameName("CHARGES_NAME_3_" + productName);
setSanitized(chargesName3, "CHARGES_NAME_3_" + productName);
chargesName3.setRefersToFormula(TemplatePopulateImportConstants.SHARED_PRODUCTS_SHEET_NAME + "!$M$" + (i + 2));
}
@@ -40,9 +40,9 @@ import org.apache.poi.ss.util.CellRangeAddressList;
public class UserWorkbookPopulator extends AbstractWorkbookPopulator {
private OfficeSheetPopulator officeSheetPopulator;
private PersonnelSheetPopulator personnelSheetPopulator;
private RoleSheetPopulator roleSheetPopulator;
private final OfficeSheetPopulator officeSheetPopulator;
private final PersonnelSheetPopulator personnelSheetPopulator;
private final RoleSheetPopulator roleSheetPopulator;
public UserWorkbookPopulator(OfficeSheetPopulator officeSheetPopulator, PersonnelSheetPopulator personnelSheetPopulator,
RoleSheetPopulator roleSheetPopulator) {
@@ -105,7 +105,7 @@ public class UserWorkbookPopulator extends AbstractWorkbookPopulator {
Name userOfficeName = userWorkbook.createName();
if (officeNameToBeginEndIndexesOfStaff != null) {
userOfficeName.setNameName("Staff_" + offices.get(i).name().trim().replaceAll("[ )(]", "_"));
setSanitized(userOfficeName, "Staff_" + offices.get(i).name());
userOfficeName.setRefersToFormula(TemplatePopulateImportConstants.STAFF_SHEET_NAME + "!$B$"
+ officeNameToBeginEndIndexesOfStaff[0] + ":$B$" + officeNameToBeginEndIndexesOfStaff[1]);
}
@@ -18,6 +18,8 @@
*/
package org.apache.fineract.integrationtests.bulkimport.populator.savings;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.ContentType;
@@ -37,7 +39,6 @@ import org.apache.fineract.integrationtests.common.savings.SavingsProductHelper;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -60,47 +61,46 @@ public class SavingsWorkbookPopulateTest {
// in order to populate helper sheets
OfficeHelper officeHelper = new OfficeHelper(requestSpec, responseSpec);
Integer outcome_office_creation = officeHelper.createOffice("02 May 2000");
Assertions.assertNotNull(outcome_office_creation, "Could not create office");
assertNotNull(outcome_office_creation, "Could not create office");
// in order to populate helper sheets
Integer outcome_client_creation = ClientHelper.createClient(requestSpec, responseSpec);
Assertions.assertNotNull(outcome_client_creation, "Could not create client");
assertNotNull(outcome_client_creation, "Could not create client");
// in order to populate helper sheets
Integer outcome_group_creation = GroupHelper.createGroup(requestSpec, responseSpec, true);
Assertions.assertNotNull(outcome_group_creation, "Could not create group");
assertNotNull(outcome_group_creation, "Could not create group");
// in order to populate helper sheets
Integer outcome_staff_creation = StaffHelper.createStaff(requestSpec, responseSpec);
Assertions.assertNotNull(outcome_staff_creation, "Could not create staff");
assertNotNull(outcome_staff_creation, "Could not create staff");
SavingsProductHelper savingsProductHelper = new SavingsProductHelper();
String jsonSavingsProduct = savingsProductHelper.build();
Integer outcome_sp_creaction = SavingsProductHelper.createSavingsProduct(jsonSavingsProduct, requestSpec, responseSpec);
Assertions.assertNotNull(outcome_sp_creaction, "Could not create Savings product");
assertNotNull(outcome_sp_creaction, "Could not create Savings product");
SavingsAccountHelper savingsAccountHelper = new SavingsAccountHelper(requestSpec, responseSpec);
Workbook workbook = savingsAccountHelper.getSavingsWorkbook("dd MMMM yyyy");
Sheet officeSheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow = officeSheet.getRow(1);
Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found ");
assertNotNull(firstOfficeRow.getCell(1), "No offices found ");
Sheet clientSheet = workbook.getSheet(TemplatePopulateImportConstants.CLIENT_SHEET_NAME);
Row firstClientRow = clientSheet.getRow(1);
Assertions.assertNotNull(firstClientRow.getCell(1), "No clients found ");
assertNotNull(firstClientRow.getCell(1), "No clients found ");
Sheet groupSheet = workbook.getSheet(TemplatePopulateImportConstants.GROUP_SHEET_NAME);
Row firstGroupRow = groupSheet.getRow(1);
Assertions.assertNotNull(firstGroupRow.getCell(1), "No groups found ");
assertNotNull(firstGroupRow.getCell(1), "No groups found ");
Sheet staffSheet = workbook.getSheet(TemplatePopulateImportConstants.STAFF_SHEET_NAME);
Row firstStaffRow = staffSheet.getRow(1);
Assertions.assertNotNull(firstStaffRow.getCell(1), "No staff found ");
assertNotNull(firstStaffRow.getCell(1), "No staff found ");
Sheet productSheet = workbook.getSheet(TemplatePopulateImportConstants.PRODUCT_SHEET_NAME);
Row firstProductRow = productSheet.getRow(1);
Assertions.assertNotNull(firstProductRow.getCell(1), "No products found ");
assertNotNull(firstProductRow.getCell(1), "No products found ");
}
}