├── .gitignore ├── .travis.yml ├── README.md ├── build.gradle ├── dataimport.properties ├── docs ├── ImportClassDiagram.png ├── PopulateClassDiagram.png ├── PopulatorDTODiagram.png ├── SampleImportSequenceDiagram.png ├── SamplePopulateSequenceDiagram.png ├── Thumbs.db ├── error1.png ├── error2.png ├── step1.png ├── step2.png ├── step3.png └── step4.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── src ├── main │ ├── java │ │ └── org │ │ │ └── openmf │ │ │ └── mifos │ │ │ └── dataimport │ │ │ ├── dto │ │ │ ├── AddGuarantor.java │ │ │ ├── Approval.java │ │ │ ├── AuthToken.java │ │ │ ├── Charge.java │ │ │ ├── ClosingOfSavingsAccounts.java │ │ │ ├── CreditDebit.java │ │ │ ├── Currency.java │ │ │ ├── Office.java │ │ │ ├── PaymentType.java │ │ │ ├── Personnel.java │ │ │ ├── Status.java │ │ │ ├── Transaction.java │ │ │ ├── Type.java │ │ │ ├── accounting │ │ │ │ ├── AddJournalEntries.java │ │ │ │ └── GlAccount.java │ │ │ ├── client │ │ │ │ ├── Center.java │ │ │ │ ├── Client.java │ │ │ │ ├── CompactCenter.java │ │ │ │ ├── CompactClient.java │ │ │ │ ├── CompactGroup.java │ │ │ │ ├── CorporateClient.java │ │ │ │ ├── Group.java │ │ │ │ ├── Meeting.java │ │ │ │ └── WeeklyMeeting.java │ │ │ ├── loan │ │ │ │ ├── CompactLoan.java │ │ │ │ ├── DisbursalData.java │ │ │ │ ├── Fund.java │ │ │ │ ├── GroupLoan.java │ │ │ │ ├── Loan.java │ │ │ │ ├── LoanDisbursal.java │ │ │ │ ├── LoanDisbursalToSavings.java │ │ │ │ ├── LoanProduct.java │ │ │ │ └── LoanTimeline.java │ │ │ └── savings │ │ │ │ ├── CompactSavingsAccount.java │ │ │ │ ├── FixedDepositAccount.java │ │ │ │ ├── FixedDepositProduct.java │ │ │ │ ├── GroupSavingsAccount.java │ │ │ │ ├── RecurringDepositAccount.java │ │ │ │ ├── RecurringDepositProduct.java │ │ │ │ ├── SavingsAccount.java │ │ │ │ ├── SavingsActivation.java │ │ │ │ ├── SavingsProduct.java │ │ │ │ └── SavingsTimeline.java │ │ │ ├── handler │ │ │ ├── AbstractDataImportHandler.java │ │ │ ├── DataImportHandler.java │ │ │ ├── ImportFormatType.java │ │ │ ├── ImportHandlerFactory.java │ │ │ ├── Result.java │ │ │ ├── accounting │ │ │ │ └── AddJournalEntriesHandler.java │ │ │ ├── client │ │ │ │ ├── CenterDataImportHandler.java │ │ │ │ ├── ClientDataImportHandler.java │ │ │ │ └── GroupDataImportHandler.java │ │ │ ├── loan │ │ │ │ ├── AddGuarantorDataImportHandler.java │ │ │ │ ├── LoanDataImportHandler.java │ │ │ │ └── LoanRepaymentDataImportHandler.java │ │ │ └── savings │ │ │ │ ├── ClosingOfSavingsAccountHandler.java │ │ │ │ ├── FixedDepositImportHandler.java │ │ │ │ ├── RecurringDepositAccountTransactionDataImportHandler.java │ │ │ │ ├── RecurringDepositImportHandler.java │ │ │ │ ├── SavingsDataImportHandler.java │ │ │ │ └── SavingsTransactionDataImportHandler.java │ │ │ ├── http │ │ │ ├── HttpRequestBuilder.java │ │ │ ├── MifosRestClient.java │ │ │ ├── RestClient.java │ │ │ ├── SimpleHttpRequest.java │ │ │ ├── SimpleHttpResponse.java │ │ │ └── TrustModifier.java │ │ │ ├── populator │ │ │ ├── AbstractWorkbookPopulator.java │ │ │ ├── CenterSheetPopulator.java │ │ │ ├── ClientSheetPopulator.java │ │ │ ├── ExtrasSheetPopulator.java │ │ │ ├── GlAccountSheetPopulator.java │ │ │ ├── GroupSheetPopulator.java │ │ │ ├── OfficeSheetPopulator.java │ │ │ ├── PersonnelSheetPopulator.java │ │ │ ├── WorkbookPopulator.java │ │ │ ├── WorkbookPopulatorFactory.java │ │ │ ├── accounting │ │ │ │ └── AddJournalEntriesWorkbookPopulator.java │ │ │ ├── client │ │ │ │ ├── CenterWorkbookPopulator.java │ │ │ │ ├── ClientWorkbookPopulator.java │ │ │ │ └── GroupWorkbookPopulator.java │ │ │ ├── loan │ │ │ │ ├── AddGuarantorWorkbookPopulator.java │ │ │ │ ├── LoanProductSheetPopulator.java │ │ │ │ ├── LoanRepaymentWorkbookPopulator.java │ │ │ │ └── LoanWorkbookPopulator.java │ │ │ └── savings │ │ │ │ ├── ClosingOfSavingsAccountsWorkbookPopulator.java │ │ │ │ ├── FixedDepositProductSheetPopulator.java │ │ │ │ ├── FixedDepositWorkbookPopulator.java │ │ │ │ ├── RecurringDepositProductSheetPopulator.java │ │ │ │ ├── RecurringDepositTransactionWorkbookPopulator.java │ │ │ │ ├── RecurringDepositWorkbookPopulator.java │ │ │ │ ├── SavingsProductSheetPopulator.java │ │ │ │ ├── SavingsTransactionWorkbookPopulator.java │ │ │ │ └── SavingsWorkbookPopulator.java │ │ │ ├── utils │ │ │ └── StringUtils.java │ │ │ └── web │ │ │ ├── ApplicationContextListner.java │ │ │ ├── DataImportServlet.java │ │ │ └── DownloadServiceServlet.java │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── index.html └── test │ ├── java │ └── org │ │ └── openmf │ │ └── mifos │ │ └── dataimport │ │ ├── handler │ │ ├── CenterDataImportHandlerTest.java │ │ ├── ClientImportHandlerTest.java │ │ ├── GroupDataImportHandlerTest.java │ │ ├── LoanImportHandlerTest.java │ │ ├── LoanRepaymentImportHandlerTest.java │ │ ├── SavingsImportHandlerTest.java │ │ └── SavingsTransactionDataImportHandlerTest.java │ │ └── populator │ │ ├── CenterSheetPopulatorTest.java │ │ ├── CenterWorkbookPopulatorTest.java │ │ ├── ClientSheetPopulatorTest.java │ │ ├── ClientWorkbookPopulatorTest.java │ │ ├── ExtrasSheetPopulatorTest.java │ │ ├── GroupSheetPopulatorTest.java │ │ ├── GroupWorkbookPopulatorTest.java │ │ ├── LoanProductSheetPopulatorTest.java │ │ ├── LoanRepaymentWorkbookPopulatorTest.java │ │ ├── LoanWorkbookPopulatorTest.java │ │ ├── OfficeSheetPopulatorTest.java │ │ ├── PersonnelSheetPopulatorTest.java │ │ ├── SavingsProductSheetPopulatorTest.java │ │ ├── SavingsTransactionWorkbookPopulatorTest.java │ │ └── SavingsWorkbookPopulatorTest.java │ └── resources │ ├── client │ ├── center.xls │ ├── client-corporate.xls │ ├── client.xls │ └── groups.xls │ ├── loan │ ├── loan.xls │ └── loanRepaymentHistory.xls │ ├── log4j.xml │ └── savings │ ├── savings.xls │ └── savingsTransactionHistory.xls └── travis_build.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle/ 2 | .project 3 | .classpath 4 | .settings/ 5 | target/ 6 | bin/ 7 | build/ 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - openjdk6 4 | notifications: 5 | email: true 6 | before_script: chmod -R 777 ./travis_build.sh 7 | script: ./travis_build.sh 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Data Import Tool 2 | ================ 3 | 4 | [![Join the chat at https://gitter.im/openMF/DataImportTool](https://badges.gitter.im/openMF/DataImportTool.svg)](https://gitter.im/openMF/DataImportTool?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 5 | 6 | Generating Excel Templates and Importing Bulk Data - Using simple servlet and Apache POI. 7 | 8 | Build Status 9 | ============ 10 | 11 | Travis 12 | 13 | [![Build 14 | Status](https://travis-ci.org/avikganguly01/DataImportTool.png?branch=master)](https://travis-ci.org/avikganguly01/DataImportTool) 15 | 16 | Setup Instructions 17 | ================== 18 | 19 | 1. Before you run the application, you need to have gradle installed and create a file dataimport.properties directly under your home directory. It should have the following 4 parameters:- 20 | 21 | mifos.endpoint=https://demo.openmf.org/fineract-provider/api/v1/ 22 | mifos.user.id=mifos 23 | mifos.password=password 24 | mifos.tenant.id=default 25 | 26 | sample file is at https://github.com/openMF/DataImportTool/blob/develop/dataimport.properties 27 | 28 | 2. Use the command "gradle clean tomcatRunWar" to run the application and access it at localhost:8070/DataImportTool. 29 | 30 | 3. If you are hosting the data import tool in the cloud, you need to ssh into the system to create the dataimport.properties file. 31 | 32 | Note :- Default gradlew config will allow you to remote debug on port 8006. 33 | 34 | Troubleshooting 35 | =============== 36 | 37 | 1. If you are hosting both this tool and the backend in the same system, you can change the debug port in gradlew.bat under mifosng-provider to listen in on a different port instead of 8005:- set DEFAULT_JVM_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8006,server=y,suspend=n 38 | 39 | 2. If you accidentally run out of heap size when running both in the same system, make sure your \_JAVA_OPTIONS in Environment variables is set to -Xms512m -Xmx512m -XX:MaxPermSize=512m and it is getting picked up by gradle. 40 | 41 | 42 | 43 | To Dos 44 | ====== 45 | 46 | 1. Transaction support for group loans and group savings -> (Blocker) Can't find an endpoint which returns all loan accounts or all loan accounts associated with groups. /loans returns only individual loans. 47 | 2. Better workbook populator unit tests which will use FormulaEvaluator to evaluate if the data validation formulas and in-cell formulas embedded as Strings are not broken due to shifting of columns. 48 | 3. Minor improvements to group related features once the release is stable (like sync repayments with meetings). 49 | 50 | Dev Setup 51 | ========= 52 | 1. Eclipsify using command gradle clean cleanEclipse eclipse 53 | 2. Import into project into workspace 54 | When opened, in the package explorer of the java perspective, right-click import->General->Existing projects into workspace. In the dialog that opens, specify the root directory option by browsing to and selecting the DataImportTool directory. 55 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | } 5 | 6 | dependencies { 7 | classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.5.0', 8 | 'com.bmuschko:gradle-tomcat-plugin:2.2.2' 9 | } 10 | } 11 | 12 | apply plugin: 'war' 13 | apply plugin: 'eclipse' 14 | apply plugin: 'idea' 15 | apply plugin: 'pmd' 16 | apply plugin: 'findbugs' 17 | apply plugin: 'com.bmuschko.tomcat' 18 | 19 | sourceCompatibility = JavaVersion.VERSION_1_6 20 | targetCompatibility = JavaVersion.VERSION_1_6 21 | 22 | group = 'org.mifostools' 23 | 24 | repositories { 25 | mavenCentral() 26 | } 27 | 28 | configurations { 29 | providedCompile 30 | compile 31 | runtime 32 | } 33 | 34 | compileJava.dependsOn(pmdMain) 35 | 36 | dependencies { 37 | def tomcatVersion = '7.0.42' 38 | tomcat "org.apache.tomcat.embed:tomcat-embed-core:7.0.42", 39 | "org.apache.tomcat.embed:tomcat-embed-logging-juli:7.0.42", 40 | "org.apache.tomcat.embed:tomcat-embed-jasper:7.0.42" 41 | 42 | providedCompile 'javax.servlet:javax.servlet-api:3.0.1' 43 | 44 | compile 'com.google.code.gson:gson:2.2.4', 45 | 'org.apache.poi:poi:3.9' 46 | 47 | testCompile 'junit:junit:4.11', 48 | 'org.mockito:mockito-all:1.9.5' 49 | 50 | } 51 | 52 | tomcatRunWar { 53 | httpPort = 8070 54 | httpsPort = 8433 55 | stopPort = 8071 56 | } 57 | -------------------------------------------------------------------------------- /dataimport.properties: -------------------------------------------------------------------------------- 1 | mifos.endpoint=https://demo.openmf.org/fineract-provider/api/v1/ 2 | mifos.user.id=mifos 3 | mifos.password=password 4 | mifos.tenant.id=default 5 | -------------------------------------------------------------------------------- /docs/ImportClassDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/docs/ImportClassDiagram.png -------------------------------------------------------------------------------- /docs/PopulateClassDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/docs/PopulateClassDiagram.png -------------------------------------------------------------------------------- /docs/PopulatorDTODiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/docs/PopulatorDTODiagram.png -------------------------------------------------------------------------------- /docs/SampleImportSequenceDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/docs/SampleImportSequenceDiagram.png -------------------------------------------------------------------------------- /docs/SamplePopulateSequenceDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/docs/SamplePopulateSequenceDiagram.png -------------------------------------------------------------------------------- /docs/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/docs/Thumbs.db -------------------------------------------------------------------------------- /docs/error1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/docs/error1.png -------------------------------------------------------------------------------- /docs/error2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/docs/error2.png -------------------------------------------------------------------------------- /docs/step1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/docs/step1.png -------------------------------------------------------------------------------- /docs/step2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/docs/step2.png -------------------------------------------------------------------------------- /docs/step3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/docs/step3.png -------------------------------------------------------------------------------- /docs/step4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/docs/step4.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jan 29 13:04:36 IST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8006,server=y,suspend=n" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS="DEFAULT_JVM_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8006,server=y,suspend=n"" 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/AddGuarantor.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto; 2 | 3 | import java.util.Locale; 4 | 5 | public class AddGuarantor { 6 | 7 | private final transient Integer rowIndex; 8 | private final transient Integer accountId; 9 | private final String dateFormat; 10 | private final Locale locale; 11 | private final String guarantorTypeId; 12 | private final String clientRelationshipTypeId; 13 | private final String entityId; 14 | private final String firstname; 15 | private final String lastname; 16 | private final String addressLine1; 17 | private final String addressLine2; 18 | private final String city; 19 | private final String dob; 20 | private final String zip; 21 | private final String savingsId; 22 | private final String amount; 23 | 24 | // private final String clientId; 25 | // private final String clientName; 26 | 27 | 28 | public AddGuarantor (String guarantorTypeId,String clientRelationshipTypeId,String entityId,String firstname, 29 | String lastname,String addressLine1,String addressLine2,String city,String dob,String zip,String savingsId,String amount,Integer rowIndex,Integer accountId){ 30 | 31 | this.guarantorTypeId=guarantorTypeId; 32 | this.clientRelationshipTypeId=clientRelationshipTypeId; 33 | this.entityId=entityId; 34 | this.firstname=firstname; 35 | this.lastname=lastname; 36 | this.addressLine1=addressLine1; 37 | this.addressLine2=addressLine2; 38 | this.city=city; 39 | this.dob=dob; 40 | this.zip=zip; 41 | this.locale = Locale.ENGLISH; 42 | this.dateFormat = "dd MMMM yyyy"; 43 | this.rowIndex=rowIndex; 44 | this.accountId=accountId; 45 | this.savingsId=savingsId; 46 | this.amount=amount; 47 | //this.clientId=clientId; 48 | //this.clientName=clientName; 49 | 50 | 51 | } 52 | 53 | public Integer getRowIndex() { 54 | return rowIndex; 55 | } 56 | 57 | public String getDateFormat() { 58 | return dateFormat; 59 | } 60 | 61 | public Locale getLocale() { 62 | return locale; 63 | } 64 | 65 | public String getGuarantorTypeId() { 66 | return guarantorTypeId; 67 | } 68 | 69 | public String getClientRelationshipTypeId() { 70 | return clientRelationshipTypeId; 71 | } 72 | 73 | public String getEntityId() { 74 | return entityId; 75 | } 76 | 77 | public String getFirstname() { 78 | return firstname; 79 | } 80 | 81 | public String getLastname() { 82 | return lastname; 83 | } 84 | 85 | public String getAddressLine1() { 86 | return addressLine1; 87 | } 88 | 89 | public String getAddressLine2() { 90 | return addressLine2; 91 | } 92 | 93 | public String getCity() { 94 | return city; 95 | } 96 | 97 | public String getDob() { 98 | return dob; 99 | } 100 | 101 | public String getZip() { 102 | return zip; 103 | } 104 | 105 | public Integer getAccountId() { 106 | return accountId; 107 | } 108 | 109 | public String getSavingsId() { 110 | return savingsId; 111 | } 112 | 113 | public String getAmount() { 114 | return amount; 115 | } 116 | 117 | /*public String getClientId() { 118 | return clientId; 119 | } 120 | 121 | public String getClientName() { 122 | return clientName; 123 | }*/ 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | } 132 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/Approval.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto; 2 | 3 | import java.util.Locale; 4 | 5 | public class Approval { 6 | 7 | private final transient Integer rowIndex; 8 | 9 | private final String approvedOnDate; 10 | 11 | private final String dateFormat; 12 | 13 | private final Locale locale; 14 | 15 | private final String note; 16 | 17 | public Approval(String approvedOnDate, Integer rowIndex ) { 18 | this.approvedOnDate = approvedOnDate; 19 | this.rowIndex = rowIndex; 20 | this.dateFormat = "dd MMMM yyyy"; 21 | this.locale = Locale.ENGLISH; 22 | this.note = ""; 23 | } 24 | 25 | public String getApprovedOnDate() { 26 | return approvedOnDate; 27 | } 28 | 29 | public Locale getLocale() { 30 | return locale; 31 | } 32 | 33 | public String getDateFormat() { 34 | return dateFormat; 35 | } 36 | 37 | public Integer getRowIndex() { 38 | return rowIndex; 39 | } 40 | 41 | public String getNote() { 42 | return note; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/AuthToken.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto; 2 | 3 | 4 | public class AuthToken { 5 | 6 | private String base64EncodedAuthenticationKey; 7 | 8 | public String getBase64EncodedAuthenticationKey() { 9 | return base64EncodedAuthenticationKey; 10 | } 11 | 12 | public void setBase64EncodedAuthenticationKey(String base64EncodedAuthenticationKey) { 13 | this.base64EncodedAuthenticationKey = base64EncodedAuthenticationKey; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/Charge.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto; 2 | 3 | public class Charge { 4 | 5 | private final String chargeId; 6 | private final Double amount; 7 | private final String dueDate; 8 | 9 | public Charge(String chargeId, Double amount, String dueDate) { 10 | this.chargeId = chargeId; 11 | this.amount = amount; 12 | this.dueDate = dueDate; 13 | } 14 | 15 | public String getChargeId() { 16 | return chargeId; 17 | } 18 | 19 | public Double getAmount() { 20 | return amount; 21 | } 22 | 23 | public String getDueDate() { 24 | return dueDate; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/ClosingOfSavingsAccounts.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto; 2 | 3 | import java.util.Locale; 4 | 5 | public class ClosingOfSavingsAccounts { 6 | 7 | private final transient Integer rowIndex; 8 | 9 | private final transient Integer accountId; 10 | 11 | private final String closedOnDate; 12 | 13 | private final String onAccountClosureId; 14 | 15 | private final String toSavingsAccountId; 16 | 17 | private final String dateFormat; 18 | 19 | private final String accountType; 20 | 21 | private final Locale locale; 22 | 23 | private final String note; 24 | 25 | public ClosingOfSavingsAccounts(Integer accountId, String closedOnDate, String onAccountClosureId,String toSavingsAccountId, String accountType,Integer rowIndex ) { 26 | this.accountId = accountId; 27 | this.closedOnDate = closedOnDate; 28 | this.onAccountClosureId = onAccountClosureId; 29 | this.toSavingsAccountId = toSavingsAccountId; 30 | this.accountType=accountType; 31 | this.rowIndex = rowIndex; 32 | this.dateFormat = "dd MMMM yyyy"; 33 | this.locale = Locale.ENGLISH; 34 | this.note = ""; 35 | } 36 | 37 | public String getClosedOnDate() { 38 | return closedOnDate; 39 | } 40 | 41 | public Locale getLocale() { 42 | return locale; 43 | } 44 | 45 | public String getDateFormat() { 46 | return dateFormat; 47 | } 48 | 49 | public String getOnAccountClosureId() { 50 | return onAccountClosureId; 51 | } 52 | 53 | public String getToSavingsAccountId() { 54 | return toSavingsAccountId; 55 | } 56 | 57 | public Integer getRowIndex() { 58 | return rowIndex; 59 | } 60 | 61 | public String getNote() { 62 | return note; 63 | } 64 | 65 | public Integer getAccountId() { 66 | return accountId; 67 | } 68 | 69 | public String getAccountType() { 70 | return accountType; 71 | } 72 | 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/CreditDebit.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto; 2 | 3 | public class CreditDebit { 4 | 5 | private final String glAccountId; 6 | private final String amount; 7 | 8 | 9 | public CreditDebit(String glAccountId, String amount) { 10 | this.glAccountId = glAccountId; 11 | this.amount = amount; 12 | 13 | } 14 | 15 | 16 | public String getGlAccountId() { 17 | return glAccountId; 18 | } 19 | 20 | 21 | public String getAmount() { 22 | return amount; 23 | } 24 | } 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/Currency.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto; 2 | 3 | 4 | public class Currency { 5 | 6 | private final String code; 7 | 8 | private final String name; 9 | 10 | private final Integer decimalPlaces; 11 | 12 | private final Integer inMultiplesOf; 13 | 14 | private final String displaySymbol; 15 | 16 | public Currency(String code, String name, Integer decimalPlaces, Integer inMultiplesOf, String displaySymbol) { 17 | this.code = code; 18 | this.name = name; 19 | this.decimalPlaces = decimalPlaces; 20 | this.inMultiplesOf = inMultiplesOf; 21 | this.displaySymbol = displaySymbol; 22 | } 23 | 24 | public String getCode() { 25 | return this.code; 26 | } 27 | 28 | public String getName() { 29 | return this.name; 30 | } 31 | 32 | public Integer getDecimalPlaces() { 33 | return this.decimalPlaces; 34 | } 35 | 36 | public Integer getInMultiplesOf() { 37 | return this.inMultiplesOf; 38 | } 39 | 40 | public String getDisplaySymbol() { 41 | return this.displaySymbol; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/Office.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class Office { 6 | 7 | private final Integer id; 8 | 9 | private final String name; 10 | 11 | private final String externalId; 12 | 13 | private final ArrayList openingDate; 14 | 15 | private final String parentName; 16 | 17 | private final String hierarchy; 18 | 19 | public Office(Integer id, String name, String externalId, ArrayList openingDate, String parentName, String hierarchy ) { 20 | this.id = id; 21 | this.name = name; 22 | this.parentName = parentName; 23 | this.externalId = externalId; 24 | this.openingDate = openingDate; 25 | this.hierarchy = hierarchy; 26 | } 27 | 28 | @Override 29 | public String toString() { 30 | return "OfficeObject [id=" + id + ", name=" + name + ", externalId=" + externalId + ", openingDate=" + openingDate + ", parentName=" + parentName + "]"; 31 | } 32 | 33 | public Integer getId() { 34 | return this.id; 35 | } 36 | 37 | public String getName() { 38 | return this.name; 39 | } 40 | 41 | public String getParentName() { 42 | return this.parentName; 43 | } 44 | 45 | public String getExternalId() { 46 | return this.externalId; 47 | } 48 | 49 | public ArrayList getOpeningDate() { 50 | return this.openingDate; 51 | } 52 | 53 | public String getHierarchy() { 54 | return this.hierarchy; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/PaymentType.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto; 2 | 3 | 4 | public class PaymentType { 5 | 6 | private final Integer id; 7 | 8 | private final String name; 9 | 10 | public PaymentType(Integer id, String name) { 11 | this.id = id; 12 | this.name = name; 13 | } 14 | 15 | public Integer getId() { 16 | return this.id; 17 | } 18 | 19 | public String getName() { 20 | return this.name; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/Personnel.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto; 2 | 3 | 4 | public class Personnel { 5 | 6 | private final Integer id; 7 | 8 | private final String firstname; 9 | 10 | private final String lastname; 11 | 12 | private final Integer officeId; 13 | 14 | private final String officeName; 15 | 16 | private final Boolean isLoanOfficer; 17 | 18 | public Personnel(Integer id, String firstname, String lastname, Integer officeId, String officeName, Boolean isLoanOfficer) { 19 | this.id = id; 20 | this.firstname = firstname; 21 | this.lastname = lastname; 22 | this.officeId = officeId; 23 | this.officeName = officeName; 24 | this.isLoanOfficer = isLoanOfficer; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "PersonnelObject [id=" + id + ", firstName=" + firstname + ", lastName=" + lastname + ", officeId=" + officeId +", officeName=" + officeName + ", isLoanOfficer=" + isLoanOfficer + "]"; 30 | } 31 | 32 | public Integer getId() { 33 | return this.id; 34 | } 35 | 36 | public String getName() { 37 | return this.firstname + " " + this.lastname; 38 | } 39 | 40 | public Integer getOfficeId() { 41 | return this.officeId; 42 | } 43 | 44 | public String getOfficeName() { 45 | return this.officeName; 46 | } 47 | 48 | public Boolean isLoanOfficer() { 49 | return this.isLoanOfficer; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/Status.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto; 2 | 3 | public class Status { 4 | 5 | private Boolean active; 6 | 7 | public Status(Boolean active){ 8 | this.active = active; 9 | } 10 | 11 | public Boolean isActive() { 12 | return this.active; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/Transaction.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto; 2 | 3 | import java.util.Locale; 4 | 5 | 6 | public class Transaction { 7 | 8 | private final transient Integer rowIndex; 9 | 10 | private final transient Integer accountId; 11 | 12 | private final transient String transactionType; 13 | 14 | private final String transactionAmount; 15 | 16 | private final String transactionDate; 17 | 18 | private final String paymentTypeId; 19 | 20 | private final String dateFormat; 21 | 22 | private final Locale locale; 23 | 24 | private final String accountNumber; 25 | 26 | private final String routingCode; 27 | 28 | private final String receiptNumber; 29 | 30 | private final String bankNumber; 31 | 32 | private final String checkNumber; 33 | 34 | public Transaction(String transactionAmount, String transactionDate, String paymentTypeId, String accountNumber, 35 | String checkNumber, String routingCode, String receiptNumber, String bankNumber, Integer accountId, String transactionType, Integer rowIndex) { 36 | this.transactionAmount = transactionAmount; 37 | this.transactionDate = transactionDate; 38 | this.paymentTypeId = paymentTypeId; 39 | this.accountNumber = accountNumber; 40 | this.checkNumber = checkNumber; 41 | this.routingCode = routingCode; 42 | this.receiptNumber = receiptNumber; 43 | this.bankNumber = bankNumber; 44 | this.accountId = accountId; 45 | this.transactionType = transactionType; 46 | this.rowIndex = rowIndex; 47 | this.dateFormat = "dd MMMM yyyy"; 48 | this.locale = Locale.ENGLISH; 49 | } 50 | 51 | public Transaction(String transactionAmount, String transactionDate, String paymentTypeId, Integer rowIndex) { 52 | this(transactionAmount, transactionDate, paymentTypeId, "", "", "", "", "", 0, "", rowIndex); 53 | } 54 | 55 | public String getTransactionAmount() { 56 | return transactionAmount; 57 | } 58 | 59 | public String getTransactionDate() { 60 | return transactionDate; 61 | } 62 | 63 | public String getPaymentTypeId() { 64 | return paymentTypeId; 65 | } 66 | 67 | public Locale getLocale() { 68 | return locale; 69 | } 70 | 71 | public String getDateFormat() { 72 | return dateFormat; 73 | } 74 | 75 | public String getAccountNumber() { 76 | return this.accountNumber; 77 | } 78 | 79 | public String getRoutingCode() { 80 | return this.routingCode; 81 | } 82 | 83 | public String getReceiptNumber() { 84 | return this.receiptNumber; 85 | } 86 | 87 | public String getBankNumber() { 88 | return this.bankNumber; 89 | } 90 | 91 | public String getCheckNumber() { 92 | return this.checkNumber; 93 | } 94 | 95 | public Integer getRowIndex() { 96 | return rowIndex; 97 | } 98 | 99 | public Integer getAccountId() { 100 | return accountId; 101 | } 102 | 103 | public String getTransactionType() { 104 | return transactionType; 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/Type.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto; 2 | 3 | 4 | public class Type { 5 | 6 | private final Integer id; 7 | 8 | private final String code; 9 | 10 | private final String value; 11 | 12 | public Type(Integer id, String code, String value) { 13 | this.id = id; 14 | this.code = code; 15 | this.value = value; 16 | } 17 | 18 | public Integer getId() { 19 | return this.id; 20 | } 21 | 22 | public String getCode() { 23 | return this.code; 24 | } 25 | 26 | public String getValue() { 27 | return this.value; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/accounting/AddJournalEntries.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.accounting; 2 | 3 | import java.util.List; 4 | import java.util.Locale; 5 | 6 | import org.openmf.mifos.dataimport.dto.CreditDebit; 7 | 8 | public class AddJournalEntries { 9 | 10 | private final transient Integer rowIndex; 11 | 12 | private final String dateFormat; 13 | 14 | private final Locale locale; 15 | 16 | private final String officeId; 17 | 18 | private final String transactionDate; 19 | 20 | private final String currencyCode; 21 | 22 | //private final String transactionTypeId; 23 | 24 | //private final String glAccountId; 25 | 26 | //private final String amount; 27 | 28 | private final String paymentTypeId; 29 | 30 | private List debits; 31 | 32 | private List credits; 33 | 34 | 35 | public AddJournalEntries(String officeId, String transactionDate, 36 | String currencyCode, String paymentTypeId,Integer rowIndex, List credits, 37 | List debits) { 38 | 39 | this.officeId = officeId; 40 | this.transactionDate = transactionDate; 41 | this.rowIndex = rowIndex; 42 | this.currencyCode = currencyCode; 43 | //this.transactionTypeId = transactionTypeId; 44 | //this.glAccountId= glAccountId; 45 | //this.amount = amount; 46 | this.paymentTypeId= paymentTypeId; 47 | this.credits = credits; 48 | this.debits = debits; 49 | this.dateFormat = "dd MMMM yyyy"; 50 | this.locale = Locale.ENGLISH; 51 | 52 | } 53 | 54 | public Locale getLocale() { 55 | return locale; 56 | } 57 | 58 | public Integer getRowIndex() { 59 | return rowIndex; 60 | } 61 | 62 | public String getDateFormat() { 63 | return dateFormat; 64 | } 65 | 66 | public String getOfficeId() { 67 | return officeId; 68 | } 69 | 70 | public String getTransactionDate() { 71 | return transactionDate; 72 | } 73 | 74 | public String getCurrencyCode() { 75 | return currencyCode; 76 | } 77 | 78 | public List getCredits() { 79 | return credits; 80 | } 81 | 82 | public List getDebits() { 83 | return debits; 84 | } 85 | 86 | //public String getGlAccountId() { 87 | // return glAccountId; 88 | //} 89 | 90 | // String getAmount() { 91 | // return amount; 92 | //} 93 | 94 | //public String getTransactionTypeId() { 95 | // return transactionTypeId; 96 | //} 97 | 98 | public String getPaymentTypeId() { 99 | return paymentTypeId; 100 | } 101 | 102 | 103 | public void addDebits(CreditDebit debit) { 104 | this.debits.add(debit); 105 | } 106 | 107 | public void addCredits(CreditDebit credit) { 108 | this.credits.add(credit); 109 | } 110 | 111 | 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/accounting/GlAccount.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.accounting; 2 | 3 | import org.openmf.mifos.dataimport.dto.Type; 4 | 5 | 6 | public class GlAccount { 7 | private final Integer id; 8 | 9 | private final String name; 10 | 11 | private final Type usage; 12 | 13 | public GlAccount(Integer id, String name, Type usage) { 14 | 15 | this.id = id; 16 | this.name = name; 17 | this.usage = usage; 18 | 19 | } 20 | 21 | public Integer getId() { 22 | return id; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public Type getUsage() { 30 | return usage; 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/client/Center.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.client; 2 | 3 | import java.util.Locale; 4 | 5 | public class Center { 6 | 7 | private final transient Integer rowIndex; 8 | private final transient String status; 9 | private final String dateFormat; 10 | private final Locale locale; 11 | private final String name; 12 | private final String officeId; 13 | private final String staffId; 14 | private final String externalId; 15 | private final String active; 16 | private final String activationDate; 17 | 18 | public Center(String name, String activationDate, String active, String externalId, String officeId, String staffId, Integer rowIndex, String status) { 19 | this.name = name; 20 | this.activationDate = activationDate; 21 | this.active = active; 22 | this.externalId = externalId; 23 | this.officeId = officeId; 24 | this.staffId = staffId; 25 | this.rowIndex = rowIndex; 26 | this.status = status; 27 | this.dateFormat = "dd MMMM yyyy"; 28 | this.locale = Locale.ENGLISH; 29 | } 30 | 31 | public Integer getRowIndex() { 32 | return rowIndex; 33 | } 34 | 35 | public String getDateFormat() { 36 | return dateFormat; 37 | } 38 | 39 | public Locale getLocale() { 40 | return locale; 41 | } 42 | 43 | public String getName() { 44 | return name; 45 | } 46 | 47 | public String getOfficeId() { 48 | return officeId; 49 | } 50 | 51 | public String getStaffId() { 52 | return staffId; 53 | } 54 | 55 | public String getExternalId() { 56 | return externalId; 57 | } 58 | 59 | public String isActive() { 60 | return active; 61 | } 62 | 63 | public String getActivationDate() { 64 | return activationDate; 65 | } 66 | 67 | public String getStatus() { 68 | return status; 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/client/Client.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.client; 2 | 3 | import java.util.Locale; 4 | 5 | public class Client { 6 | 7 | private final transient Integer rowIndex; 8 | 9 | private final String dateFormat; 10 | 11 | private final Locale locale; 12 | 13 | private final String officeId; 14 | 15 | private final String staffId; 16 | 17 | private final String firstname; 18 | 19 | private final String middlename; 20 | 21 | private final String lastname; 22 | 23 | private final String externalId; 24 | 25 | private final String active; 26 | 27 | private final String activationDate; 28 | 29 | 30 | public Client(String firstname, String lastname, String middlename, String activationDate, String active, String externalId, String officeId, String staffId, Integer rowIndex ) { 31 | this.firstname = firstname; 32 | this.lastname = lastname; 33 | this.middlename = middlename; 34 | this.activationDate = activationDate; 35 | this.active = active; 36 | this.externalId = externalId; 37 | this.officeId = officeId; 38 | this.staffId = staffId; 39 | this.rowIndex = rowIndex; 40 | this.dateFormat = "dd MMMM yyyy"; 41 | this.locale = Locale.ENGLISH; 42 | } 43 | 44 | public String getFirstName() { 45 | return this.firstname; 46 | } 47 | 48 | public String getLastName() { 49 | return this.lastname; 50 | } 51 | 52 | public String getMiddleName() { 53 | return this.middlename; 54 | } 55 | 56 | public String getActivationDate() { 57 | return this.activationDate; 58 | } 59 | 60 | public String isActive() { 61 | return this.active; 62 | } 63 | 64 | public String getExternalId() { 65 | return this.externalId; 66 | } 67 | 68 | public String getOfficeId() { 69 | return this.officeId; 70 | } 71 | 72 | public String getStaffId() { 73 | return this.staffId; 74 | } 75 | 76 | public Locale getLocale() { 77 | return locale; 78 | } 79 | 80 | public String getDateFormat() { 81 | return dateFormat; 82 | } 83 | 84 | public Integer getRowIndex() { 85 | return rowIndex; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/client/CompactCenter.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.client; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class CompactCenter { 6 | 7 | private final Integer id; 8 | private final String name; 9 | private final String officeName; 10 | private final ArrayList activationDate; 11 | private final Boolean active; 12 | 13 | public CompactCenter(Integer id, String name, String officeName, ArrayList activationDate, Boolean active) { 14 | this.id = id; 15 | this.name = name; 16 | this.activationDate = activationDate; 17 | this.officeName = officeName; 18 | this.active = active; 19 | } 20 | 21 | public Integer getId() { 22 | return id; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public String getOfficeName() { 30 | return officeName; 31 | } 32 | 33 | public ArrayList getActivationDate() { 34 | return activationDate; 35 | } 36 | 37 | public Boolean isActive() { 38 | return active; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/client/CompactClient.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.client; 2 | 3 | import java.util.ArrayList; 4 | 5 | 6 | public class CompactClient { 7 | 8 | private final Integer id; 9 | 10 | private final String displayName; 11 | 12 | private final String officeName; 13 | 14 | private final ArrayList activationDate; 15 | 16 | private final Boolean active; 17 | 18 | public CompactClient(Integer id, String displayName, String officeName, ArrayList activationDate, Boolean active) { 19 | this.id = id; 20 | this.displayName = displayName; 21 | this.activationDate = activationDate; 22 | this.officeName = officeName; 23 | this.active = active; 24 | } 25 | 26 | public Integer getId() { 27 | return this.id; 28 | } 29 | 30 | public String getDisplayName() { 31 | return this.displayName; 32 | } 33 | 34 | public ArrayList getActivationDate() { 35 | return this.activationDate; 36 | } 37 | 38 | public String getOfficeName() { 39 | return this.officeName; 40 | } 41 | 42 | public Boolean isActive() { 43 | return this.active; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/client/CompactGroup.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.client; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class CompactGroup { 6 | 7 | private final Integer id; 8 | private final String name; 9 | private final String officeName; 10 | private final ArrayList activationDate; 11 | private final Boolean active; 12 | 13 | public CompactGroup(Integer id, String name, String officeName, ArrayList activationDate, Boolean active) { 14 | this.id = id; 15 | this.name = name; 16 | this.activationDate = activationDate; 17 | this.officeName = officeName; 18 | this.active = active; 19 | } 20 | 21 | public Integer getId() { 22 | return id; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public String getOfficeName() { 30 | return officeName; 31 | } 32 | 33 | public ArrayList getActivationDate() { 34 | return activationDate; 35 | } 36 | 37 | public Boolean isActive() { 38 | return active; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/client/CorporateClient.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.client; 2 | 3 | 4 | public class CorporateClient extends Client { 5 | 6 | private final String fullname; 7 | 8 | 9 | public CorporateClient(String fullname, String activationDate, String active, String externalId, String officeId, String staffId, Integer rowIndex ) { 10 | super(null, null, null, activationDate, active, externalId, officeId, staffId, rowIndex); 11 | this.fullname = fullname; 12 | } 13 | 14 | public String getFullName() { 15 | return this.fullname; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/client/Group.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.client; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Locale; 5 | 6 | import org.openmf.mifos.dataimport.utils.StringUtils; 7 | 8 | public class Group { 9 | 10 | private final transient Integer rowIndex; 11 | private final transient String status; 12 | private final String dateFormat; 13 | private final Locale locale; 14 | private final String name; 15 | private final ArrayList clientMembers; 16 | private final String officeId; 17 | private final String staffId; 18 | private final String centerId; 19 | private final String externalId; 20 | private final String active; 21 | private final String activationDate; 22 | 23 | public Group(String name, ArrayList clientMembers, String activationDate, String active, String externalId, String officeId, String staffId, String centerId,Integer rowIndex, String status) { 24 | this.name = name; 25 | this.clientMembers = clientMembers; 26 | this.activationDate = activationDate; 27 | this.active = active; 28 | this.externalId = externalId; 29 | this.officeId = officeId; 30 | this.staffId = staffId; 31 | if(StringUtils.isBlank(centerId) || centerId.equalsIgnoreCase("0")) 32 | this.centerId=null; 33 | else 34 | this.centerId= centerId; 35 | this.rowIndex = rowIndex; 36 | this.status = status; 37 | this.dateFormat = "dd MMMM yyyy"; 38 | this.locale = Locale.ENGLISH; 39 | } 40 | 41 | public Integer getRowIndex() { 42 | return rowIndex; 43 | } 44 | 45 | public String getDateFormat() { 46 | return dateFormat; 47 | } 48 | 49 | public Locale getLocale() { 50 | return locale; 51 | } 52 | 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | public ArrayList getClientMembers() { 58 | return clientMembers; 59 | } 60 | 61 | public String getOfficeId() { 62 | return officeId; 63 | } 64 | 65 | public String getStaffId() { 66 | return staffId; 67 | } 68 | public String getCenterId() { 69 | return centerId; 70 | } 71 | 72 | public String getExternalId() { 73 | return externalId; 74 | } 75 | 76 | public String isActive() { 77 | return active; 78 | } 79 | 80 | public String getActivationDate() { 81 | return activationDate; 82 | } 83 | 84 | public String getStatus() { 85 | return status; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/client/Meeting.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.client; 2 | 3 | import java.util.Locale; 4 | 5 | //Meeting 6 | public class Meeting { 7 | 8 | private final transient Integer rowIndex; 9 | private transient String groupId; 10 | private transient String centerId; 11 | private final String dateFormat; 12 | private final Locale locale; 13 | private final String description; 14 | private final String typeId; 15 | private String title; 16 | private final String startDate; 17 | private final String repeating; 18 | private final String frequency; 19 | private final String interval; 20 | 21 | public Meeting(String startDate, String repeating, String frequency, String interval, Integer rowIndex ) { 22 | this.startDate = startDate; 23 | this.repeating = repeating; 24 | this.frequency = frequency; 25 | this.interval = interval; 26 | this.rowIndex = rowIndex; 27 | this.dateFormat = "dd MMMM yyyy"; 28 | this.locale = Locale.ENGLISH; 29 | this.description = ""; 30 | this.typeId = "1"; 31 | } 32 | 33 | public void setGroupId(String groupId) { 34 | this.groupId = groupId; 35 | } 36 | 37 | public void setTitle(String title) { 38 | this.title = title; 39 | } 40 | 41 | public Integer getRowIndex() { 42 | return rowIndex; 43 | } 44 | 45 | public Locale getLocale() { 46 | return locale; 47 | } 48 | 49 | public String getDescription() { 50 | return description; 51 | } 52 | 53 | public String getDateFormat() { 54 | return dateFormat; 55 | } 56 | 57 | public String getTypeId() { 58 | return typeId; 59 | } 60 | 61 | public String getTitle() { 62 | return title; 63 | } 64 | 65 | public String getStartDate() { 66 | return startDate; 67 | } 68 | 69 | public String isRepeating() { 70 | return repeating; 71 | } 72 | 73 | public String getFrequency() { 74 | return frequency; 75 | } 76 | 77 | public String getInterval() { 78 | return interval; 79 | } 80 | 81 | public String getGroupId() { 82 | return groupId; 83 | } 84 | 85 | public String getCenterId() { 86 | return centerId; 87 | } 88 | 89 | public void setCenterId(String centerId) { 90 | this.centerId = centerId; 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/client/WeeklyMeeting.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.client; 2 | 3 | 4 | public class WeeklyMeeting extends Meeting{ 5 | 6 | private final String repeatsOnDay; 7 | 8 | public WeeklyMeeting(String startDate, String repeating, String frequency, String interval, String repeatsOnDay, Integer rowIndex ) { 9 | super(startDate, repeating, frequency, interval, rowIndex ); 10 | this.repeatsOnDay = repeatsOnDay; 11 | } 12 | 13 | public String getRepeatsOnDay() { 14 | return repeatsOnDay; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/loan/CompactLoan.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.loan; 2 | 3 | import java.util.Comparator; 4 | import java.util.Locale; 5 | 6 | import org.openmf.mifos.dataimport.dto.Status; 7 | 8 | public class CompactLoan { 9 | 10 | private final String accountNo; 11 | 12 | private final String clientId; 13 | 14 | private final String clientName; 15 | 16 | private final String loanProductName; 17 | 18 | private final Double principal; 19 | 20 | private final LoanTimeline timeline; 21 | 22 | private final Status status; 23 | 24 | public CompactLoan(String accountNo, String clientId, String clientName, String loanProductName, Double principal, LoanTimeline timeline, Status status) { 25 | this.accountNo = accountNo; 26 | this.clientId = clientId; 27 | this.clientName = clientName; 28 | this.loanProductName = loanProductName; 29 | this.principal = principal; 30 | this.timeline = timeline; 31 | this.status = status; 32 | } 33 | 34 | public String getAccountNo() { 35 | return this.accountNo; 36 | } 37 | 38 | public String getClientId() { 39 | return clientId; 40 | } 41 | 42 | public String getClientName() { 43 | return this.clientName; 44 | } 45 | 46 | public String getLoanProductName() { 47 | return this.loanProductName; 48 | } 49 | 50 | public Double getPrincipal() { 51 | return this.principal; 52 | } 53 | 54 | public Boolean isActive() { 55 | return this.status.isActive(); 56 | } 57 | 58 | public LoanTimeline getTimeline() { 59 | return timeline; 60 | } 61 | 62 | public static final Comparator ClientNameComparator = new Comparator() { 63 | 64 | @Override 65 | public int compare(CompactLoan loan1, CompactLoan loan2) { 66 | String clientOfLoan1 = loan1.getClientName().toUpperCase(Locale.ENGLISH); 67 | String clientOfLoan2 = loan2.getClientName().toUpperCase(Locale.ENGLISH); 68 | return clientOfLoan1.compareTo(clientOfLoan2); 69 | } 70 | }; 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/loan/DisbursalData.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.loan; 2 | 3 | public class DisbursalData { 4 | 5 | private final String linkAccountId; 6 | 7 | private final LoanDisbursal loanDisbursal; 8 | 9 | public DisbursalData(String linkAccountId, LoanDisbursal loanDisbursal) { 10 | this.linkAccountId = linkAccountId; 11 | this.loanDisbursal = loanDisbursal; 12 | } 13 | 14 | public String getLinkAccountId() { 15 | return this.linkAccountId; 16 | } 17 | 18 | public LoanDisbursal getLoanDisbursal() { 19 | return loanDisbursal; 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/loan/Fund.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.loan; 2 | 3 | 4 | public class Fund { 5 | 6 | private final Integer id; 7 | 8 | private final String name; 9 | 10 | public Fund(Integer id, String name) { 11 | this.id = id; 12 | this.name = name; 13 | } 14 | 15 | public Integer getId() { 16 | return this.id; 17 | } 18 | 19 | public String getName() { 20 | return this.name; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/loan/GroupLoan.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.loan; 2 | 3 | public class GroupLoan extends Loan{ 4 | 5 | 6 | public GroupLoan(String loanType, String groupId, String productId, String loanOfficerId, String submittedOnDate, String fundId, 7 | String principal, String numberOfRepayments, String repaymentEvery, String repaymentFrequencyType, String loanTermFrequency, 8 | String loanTermFrequencyType, Double interestRatePerPeriod, String expectedDisbursementDate, String amortizationType, 9 | String interestType, String interestCalculationPeriodType, String inArrearsTolerance, String transactionProcessingStrategyId, 10 | String graceOnPrincipalPayment, String graceOnInterestPayment, String graceOnInterestCharged, String interestChargedFromDate, 11 | String repaymentsStartingFromDate, Integer rowIndex, String status,String externalId,String linkAccountId) { 12 | 13 | super(loanType, null, productId, loanOfficerId, submittedOnDate, fundId, principal, numberOfRepayments, repaymentEvery, repaymentFrequencyType, 14 | loanTermFrequency, loanTermFrequencyType, interestRatePerPeriod, expectedDisbursementDate, amortizationType, interestType, 15 | interestCalculationPeriodType, inArrearsTolerance, transactionProcessingStrategyId, graceOnPrincipalPayment, 16 | graceOnInterestPayment, graceOnInterestCharged, interestChargedFromDate, repaymentsStartingFromDate, rowIndex, status, externalId, groupId, null,linkAccountId ); 17 | 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/loan/LoanDisbursal.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.loan; 2 | 3 | import java.util.Locale; 4 | 5 | public class LoanDisbursal { 6 | 7 | private final transient Integer rowIndex; 8 | 9 | private final String actualDisbursementDate; 10 | 11 | private final String paymentTypeId; 12 | 13 | private final String dateFormat; 14 | 15 | private final Locale locale; 16 | 17 | private final String note; 18 | 19 | private final String accountNumber; 20 | 21 | private final String routingCode; 22 | 23 | private final String receiptNumber; 24 | 25 | private final String bankNumber; 26 | 27 | private final String checkNumber; 28 | 29 | public LoanDisbursal(String actualDisbursementDate, String paymentTypeId, Integer rowIndex) { 30 | this.actualDisbursementDate = actualDisbursementDate; 31 | this.paymentTypeId = paymentTypeId; 32 | this.rowIndex = rowIndex; 33 | this.dateFormat = "dd MMMM yyyy"; 34 | this.locale = Locale.ENGLISH; 35 | this.note = ""; 36 | this.accountNumber = null; 37 | this.routingCode = null; 38 | this.receiptNumber = null; 39 | this.bankNumber = null; 40 | this.checkNumber = null; 41 | } 42 | 43 | public String getActualDisbursementDate() { 44 | return actualDisbursementDate; 45 | } 46 | 47 | public String getPaymentTypeId() { 48 | return paymentTypeId; 49 | } 50 | 51 | public Locale getLocale() { 52 | return locale; 53 | } 54 | 55 | public String getDateFormat() { 56 | return dateFormat; 57 | } 58 | 59 | public Integer getRowIndex() { 60 | return rowIndex; 61 | } 62 | 63 | public String getNote() { 64 | return note; 65 | } 66 | 67 | public String getAccountNumber() { 68 | return accountNumber; 69 | } 70 | 71 | public String getRoutingCode() { 72 | return routingCode; 73 | } 74 | 75 | public String getReceiptNumber() { 76 | return receiptNumber; 77 | } 78 | 79 | public String getBankNumber() { 80 | return bankNumber; 81 | } 82 | 83 | public String getCheckNumber() { 84 | return checkNumber; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/loan/LoanDisbursalToSavings.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.loan; 2 | 3 | import java.util.Locale; 4 | 5 | public class LoanDisbursalToSavings { 6 | 7 | private final transient Integer rowIndex; 8 | 9 | private final String actualDisbursementDate; 10 | 11 | private final String dateFormat; 12 | 13 | private final Locale locale; 14 | 15 | private final String note; 16 | 17 | public LoanDisbursalToSavings(String actualDisbursementDate, Integer rowIndex) { 18 | this.actualDisbursementDate = actualDisbursementDate; 19 | this.rowIndex = rowIndex; 20 | this.dateFormat = "dd MMMM yyyy"; 21 | this.locale = Locale.ENGLISH; 22 | this.note = ""; 23 | } 24 | 25 | public String getActualDisbursementDate() { 26 | return actualDisbursementDate; 27 | } 28 | 29 | public Locale getLocale() { 30 | return locale; 31 | } 32 | 33 | public String getDateFormat() { 34 | return dateFormat; 35 | } 36 | 37 | public Integer getRowIndex() { 38 | return rowIndex; 39 | } 40 | 41 | public String getNote() { 42 | return note; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/loan/LoanTimeline.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.loan; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class LoanTimeline { 6 | 7 | private final ArrayList actualDisbursementDate; 8 | 9 | public LoanTimeline(ArrayList actualDisbursementDate) { 10 | this.actualDisbursementDate = actualDisbursementDate; 11 | } 12 | 13 | public ArrayList getActualDisbursementDate() { 14 | return this.actualDisbursementDate; 15 | } 16 | 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/savings/CompactSavingsAccount.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.savings; 2 | 3 | import java.util.Comparator; 4 | import java.util.Locale; 5 | 6 | import org.openmf.mifos.dataimport.dto.Status; 7 | 8 | public class CompactSavingsAccount { 9 | 10 | private final String accountNo; 11 | 12 | private final String clientId; 13 | 14 | private final String clientName; 15 | 16 | private final String savingsProductName; 17 | 18 | private final Double minRequiredOpeningBalance; 19 | 20 | private final SavingsTimeline timeline; 21 | 22 | private final Status status; 23 | 24 | public CompactSavingsAccount(String accountNo, String clientId, String clientName, String savingsProductName, 25 | Double minRequiredOpeningBalance, SavingsTimeline timeline, Status status) { 26 | this.accountNo = accountNo; 27 | this.clientId = clientId; 28 | this.clientName = clientName; 29 | this.savingsProductName = savingsProductName; 30 | this.minRequiredOpeningBalance = minRequiredOpeningBalance; 31 | this.timeline = timeline; 32 | this.status = status; 33 | } 34 | 35 | public String getClientName() { 36 | return clientName; 37 | } 38 | 39 | public String getClientId() { 40 | return clientId; 41 | } 42 | 43 | public String getAccountNo() { 44 | return accountNo; 45 | } 46 | 47 | public String getSavingsProductName() { 48 | return savingsProductName; 49 | } 50 | 51 | public Double getMinRequiredOpeningBalance() { 52 | return minRequiredOpeningBalance; 53 | } 54 | 55 | public Boolean isActive() { 56 | return this.status.isActive(); 57 | } 58 | 59 | public SavingsTimeline getTimeline() { 60 | return timeline; 61 | } 62 | 63 | public static final Comparator ClientNameComparator = new Comparator() { 64 | 65 | @Override 66 | public int compare(CompactSavingsAccount savings1, CompactSavingsAccount savings2) { 67 | String clientOfSavings1 = savings1.getClientName().toUpperCase(Locale.ENGLISH); 68 | String clientOfSavings2 = savings2.getClientName().toUpperCase(Locale.ENGLISH); 69 | return clientOfSavings1.compareTo(clientOfSavings2); 70 | } 71 | }; 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/savings/FixedDepositAccount.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.savings; 2 | 3 | import java.util.List; 4 | import java.util.Locale; 5 | 6 | import org.openmf.mifos.dataimport.dto.Charge; 7 | 8 | public class FixedDepositAccount { 9 | 10 | private final transient Integer rowIndex; 11 | 12 | private final transient String status; 13 | 14 | private final String clientId; 15 | 16 | private final String fieldOfficerId; 17 | 18 | private final String productId; 19 | 20 | private final String submittedOnDate; 21 | 22 | private final String interestCompoundingPeriodType; 23 | 24 | private final String interestPostingPeriodType; 25 | 26 | private final String interestCalculationType; 27 | 28 | private final String interestCalculationDaysInYearType; 29 | 30 | private final String lockinPeriodFrequency; 31 | 32 | private final String lockinPeriodFrequencyType; 33 | 34 | private final String depositAmount; 35 | 36 | private final String depositPeriod; 37 | 38 | private final String depositPeriodFrequencyId; 39 | 40 | private final String externalId; 41 | 42 | private final String dateFormat; 43 | 44 | private final Locale locale; 45 | 46 | private final List charges; 47 | 48 | public FixedDepositAccount(String clientId, String productId, String fieldOfficerId, String submittedOnDate, 49 | String interestCompoundingPeriodType, String interestPostingPeriodType, 50 | String interestCalculationType, String interestCalculationDaysInYearType, 51 | String lockinPeriodFrequency, String lockinPeriodFrequencyType, String depositAmount, String depositPeriod, 52 | String depositPeriodFrequencyId, String externalId,List charges, Integer rowIndex, String status) { 53 | this.clientId = clientId; 54 | this.productId = productId; 55 | this.fieldOfficerId = fieldOfficerId; 56 | this.submittedOnDate = submittedOnDate; 57 | this.interestCompoundingPeriodType = interestCompoundingPeriodType; 58 | this.interestPostingPeriodType = interestPostingPeriodType; 59 | this.interestCalculationType = interestCalculationType; 60 | this.interestCalculationDaysInYearType = interestCalculationDaysInYearType; 61 | this.lockinPeriodFrequency = lockinPeriodFrequency; 62 | this.lockinPeriodFrequencyType = lockinPeriodFrequencyType; 63 | this.depositAmount = depositAmount; 64 | this.depositPeriod = depositPeriod; 65 | this.depositPeriodFrequencyId = depositPeriodFrequencyId; 66 | this.externalId = externalId; 67 | this.rowIndex = rowIndex; 68 | this.status = status; 69 | this.dateFormat = "dd MMMM yyyy"; 70 | this.locale = Locale.ENGLISH; 71 | this.charges = charges; 72 | } 73 | 74 | public String getClientId() { 75 | return clientId; 76 | } 77 | 78 | public String getFieldOfficerId() { 79 | return fieldOfficerId; 80 | } 81 | 82 | public String getProductId() { 83 | return productId; 84 | } 85 | 86 | public String getInterestCompoundingPeriodType() { 87 | return interestCompoundingPeriodType; 88 | } 89 | 90 | public String getInterestPostingPeriodType() { 91 | return interestPostingPeriodType; 92 | } 93 | 94 | public String getInterestCalculationType() { 95 | return interestCalculationType; 96 | } 97 | 98 | public String getInterestCalculationDaysInYearType() { 99 | return interestCalculationDaysInYearType; 100 | } 101 | 102 | public String getLockinPeriodFrequency() { 103 | return lockinPeriodFrequency; 104 | } 105 | 106 | public String getLockinPeriodFrequencyType() { 107 | return lockinPeriodFrequencyType; 108 | } 109 | 110 | public String getDateFormat() { 111 | return dateFormat; 112 | } 113 | 114 | public Locale getLocale() { 115 | return locale; 116 | } 117 | 118 | public Integer getRowIndex() { 119 | return rowIndex; 120 | } 121 | 122 | public String getStatus() { 123 | return status; 124 | } 125 | 126 | public String getSubmittedOnDate() { 127 | return submittedOnDate; 128 | } 129 | 130 | public String getDepositAmount() { 131 | return depositAmount; 132 | } 133 | 134 | public String getDepositPeriod() { 135 | return depositPeriod; 136 | } 137 | 138 | public String getDepositPeriodFrequencyId() { 139 | return depositPeriodFrequencyId; 140 | } 141 | 142 | public String getExternalId() { 143 | return externalId; 144 | } 145 | 146 | public List getCharges() { 147 | return charges; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/savings/FixedDepositProduct.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.savings; 2 | 3 | import org.openmf.mifos.dataimport.dto.Currency; 4 | import org.openmf.mifos.dataimport.dto.Type; 5 | 6 | public class FixedDepositProduct { 7 | 8 | private final Integer id; 9 | 10 | private final String name; 11 | 12 | private final String shortName; 13 | 14 | private final Currency currency; 15 | 16 | private final Double nominalAnnualInterestRate; 17 | 18 | private final Double minDepositAmount; 19 | 20 | private final Double maxDepositAmount; 21 | 22 | private final Double depositAmount; 23 | 24 | private final Type interestCompoundingPeriodType; 25 | 26 | private final Type interestPostingPeriodType; 27 | 28 | private final Type interestCalculationType; 29 | 30 | private final Type interestCalculationDaysInYearType; 31 | 32 | private final Integer lockinPeriodFrequency; 33 | 34 | private final Type lockinPeriodFrequencyType; 35 | 36 | private final String preClosurePenalApplicable; 37 | 38 | private final Double preClosurePenalInterest; 39 | 40 | private final Type preClosureInterestOnType; 41 | 42 | private final Integer minDepositTerm; 43 | 44 | private final Integer maxDepositTerm; 45 | 46 | private final Type minDepositTermType; 47 | 48 | private final Type maxDepositTermType; 49 | 50 | private final Integer inMultiplesOfDepositTerm; 51 | 52 | private final Type inMultiplesOfDepositTermType; 53 | 54 | public FixedDepositProduct(Integer id, String name, String shortName, Currency currency, Double nominalAnnualInterestRate, 55 | Type interestCompoundingPeriodType, Type interestPostingPeriodType, Type interestCalculationType, Type interestCalculationDaysInYearType, 56 | Integer lockinPeriodFrequency, Type lockinPeriodFrequencyType, Double minDepositAmount, Double maxDepositAmount, 57 | Double depositAmount, String preClosurePenalApplicable, Double preClosurePenalInterest, Type preClosureInterestOnType, 58 | Integer minDepositTerm, Integer maxDepositTerm, Type minDepositTermType, Type maxDepositTermType, Integer inMultiplesOfDepositTerm, 59 | Type inMultiplesOfDepositTermType) { 60 | this.id = id; 61 | this.name = name; 62 | this.shortName = shortName; 63 | this.minDepositAmount = minDepositAmount; 64 | this.maxDepositAmount = maxDepositAmount; 65 | this.depositAmount = depositAmount; 66 | this.preClosurePenalApplicable = preClosurePenalApplicable; 67 | this.preClosurePenalInterest = preClosurePenalInterest; 68 | this.preClosureInterestOnType = preClosureInterestOnType; 69 | this.minDepositTerm = minDepositTerm; 70 | this.maxDepositTerm = maxDepositTerm; 71 | this.minDepositTermType = minDepositTermType; 72 | this.maxDepositTermType = maxDepositTermType; 73 | this.inMultiplesOfDepositTerm = inMultiplesOfDepositTerm; 74 | this.inMultiplesOfDepositTermType = inMultiplesOfDepositTermType; 75 | this.currency = currency; 76 | this.nominalAnnualInterestRate = nominalAnnualInterestRate; 77 | this.interestCompoundingPeriodType = interestCompoundingPeriodType; 78 | this.interestPostingPeriodType = interestPostingPeriodType; 79 | this.interestCalculationType = interestCalculationType; 80 | this.interestCalculationDaysInYearType = interestCalculationDaysInYearType; 81 | this.lockinPeriodFrequency = lockinPeriodFrequency; 82 | this.lockinPeriodFrequencyType = lockinPeriodFrequencyType; 83 | } 84 | 85 | public Integer getId() { 86 | return id; 87 | } 88 | 89 | public String getName() { 90 | return name; 91 | } 92 | 93 | public Currency getCurrency() { 94 | return currency; 95 | } 96 | 97 | public Double getNominalAnnualInterestRate() { 98 | return nominalAnnualInterestRate; 99 | } 100 | 101 | public Type getInterestCompoundingPeriodType() { 102 | return interestCompoundingPeriodType; 103 | } 104 | 105 | public Type getInterestPostingPeriodType() { 106 | return interestPostingPeriodType; 107 | } 108 | 109 | public Type getInterestCalculationType() { 110 | return interestCalculationType; 111 | } 112 | 113 | public Integer getLockinPeriodFrequency() { 114 | return lockinPeriodFrequency; 115 | } 116 | 117 | public Type getInterestCalculationDaysInYearType() { 118 | return interestCalculationDaysInYearType; 119 | } 120 | 121 | public Type getLockinPeriodFrequencyType() { 122 | return lockinPeriodFrequencyType; 123 | } 124 | 125 | public String getPreClosurePenalApplicable() { 126 | return preClosurePenalApplicable; 127 | } 128 | 129 | public Double getPreClosurePenalInterest() { 130 | return preClosurePenalInterest; 131 | } 132 | 133 | public Type getPreClosureInterestOnType() { 134 | return preClosureInterestOnType; 135 | } 136 | 137 | public Integer getMinDepositTerm() { 138 | return minDepositTerm; 139 | } 140 | 141 | public Integer getMaxDepositTerm() { 142 | return maxDepositTerm; 143 | } 144 | 145 | public Type getMaxDepositTermType() { 146 | return maxDepositTermType; 147 | } 148 | 149 | public Type getMinDepositTermType() { 150 | return minDepositTermType; 151 | } 152 | 153 | public Integer getInMultiplesOfDepositTerm() { 154 | return inMultiplesOfDepositTerm; 155 | } 156 | 157 | public Type getInMultiplesOfDepositTermType() { 158 | return inMultiplesOfDepositTermType; 159 | } 160 | 161 | public Double getMinDepositAmount() { 162 | return minDepositAmount; 163 | } 164 | 165 | public Double getMaxDepositAmount() { 166 | return maxDepositAmount; 167 | } 168 | 169 | public Double getDepositAmount() { 170 | return depositAmount; 171 | } 172 | 173 | public String getShortName() { 174 | return shortName; 175 | } 176 | } 177 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/savings/GroupSavingsAccount.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.savings; 2 | 3 | import java.util.List; 4 | 5 | import org.openmf.mifos.dataimport.dto.Charge; 6 | 7 | public class GroupSavingsAccount extends SavingsAccount{ 8 | 9 | private final String groupId; 10 | 11 | public GroupSavingsAccount(String groupId, String productId, String fieldOfficerId, String submittedOnDate, String nominalAnnualInterestRate, 12 | String interestCompoundingPeriodType, String interestPostingPeriodType, String interestCalculationType, String interestCalculationDaysInYearType, 13 | String minRequiredOpeningBalance, String lockinPeriodFrequency, String lockinPeriodFrequencyType, String withdrawalFeeForTransfers, Integer rowIndex, String status, String externalId,List charges,String allowOverdraft, String overdraftLimit) { 14 | super(null, productId, fieldOfficerId, submittedOnDate, nominalAnnualInterestRate, interestCompoundingPeriodType, interestPostingPeriodType, 15 | interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, rowIndex, status,externalId,charges,allowOverdraft,overdraftLimit); 16 | this.groupId = groupId; 17 | 18 | } 19 | 20 | public String getGroupId() { 21 | return groupId; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/savings/SavingsAccount.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.savings; 2 | 3 | import java.util.List; 4 | import java.util.Locale; 5 | 6 | import org.openmf.mifos.dataimport.dto.Charge; 7 | 8 | public class SavingsAccount { 9 | 10 | private final transient Integer rowIndex; 11 | 12 | private final transient String status; 13 | 14 | private final String clientId; 15 | 16 | private final String fieldOfficerId; 17 | 18 | private final String productId; 19 | 20 | private final String submittedOnDate; 21 | 22 | private final String nominalAnnualInterestRate; 23 | 24 | private final String interestCompoundingPeriodType; 25 | 26 | private final String interestPostingPeriodType; 27 | 28 | private final String interestCalculationType; 29 | 30 | private final String interestCalculationDaysInYearType; 31 | 32 | private final String minRequiredOpeningBalance; 33 | 34 | private final String lockinPeriodFrequency; 35 | 36 | private final String lockinPeriodFrequencyType; 37 | 38 | private final String withdrawalFeeForTransfers; 39 | 40 | private final String dateFormat; 41 | 42 | private final String externalId; 43 | 44 | private final Locale locale; 45 | 46 | private final List charges; 47 | 48 | private final String allowOverdraft; 49 | 50 | private final String overdraftLimit; 51 | 52 | public SavingsAccount(String clientId, String productId, String fieldOfficerId, String submittedOnDate, 53 | String nominalAnnualInterestRate, String interestCompoundingPeriodType, String interestPostingPeriodType, 54 | String interestCalculationType, String interestCalculationDaysInYearType, String minRequiredOpeningBalance, 55 | String lockinPeriodFrequency, String lockinPeriodFrequencyType, String withdrawalFeeForTransfers, Integer rowIndex, 56 | String status, String externalId, List charges, String allowOverdraft ,String overdraftLimit ) { 57 | this.clientId = clientId; 58 | this.productId = productId; 59 | this.fieldOfficerId = fieldOfficerId; 60 | this.submittedOnDate = submittedOnDate; 61 | this.nominalAnnualInterestRate = nominalAnnualInterestRate; 62 | this.interestCompoundingPeriodType = interestCompoundingPeriodType; 63 | this.interestPostingPeriodType = interestPostingPeriodType; 64 | this.interestCalculationType = interestCalculationType; 65 | this.interestCalculationDaysInYearType = interestCalculationDaysInYearType; 66 | this.minRequiredOpeningBalance = minRequiredOpeningBalance; 67 | this.lockinPeriodFrequency = lockinPeriodFrequency; 68 | this.lockinPeriodFrequencyType = lockinPeriodFrequencyType; 69 | this.withdrawalFeeForTransfers = withdrawalFeeForTransfers; 70 | this.rowIndex = rowIndex; 71 | this.status = status; 72 | this.dateFormat = "dd MMMM yyyy"; 73 | this.locale = Locale.ENGLISH; 74 | this.externalId = externalId; 75 | this.charges = charges; 76 | this.allowOverdraft= allowOverdraft; 77 | this.overdraftLimit= overdraftLimit; 78 | } 79 | 80 | public String getClientId() { 81 | return clientId; 82 | } 83 | 84 | public String getFieldOfficerId() { 85 | return fieldOfficerId; 86 | } 87 | 88 | public String getProductId() { 89 | return productId; 90 | } 91 | 92 | public String getNominalAnnualInterestRate() { 93 | return nominalAnnualInterestRate; 94 | } 95 | 96 | public String getInterestCompoundingPeriodType() { 97 | return interestCompoundingPeriodType; 98 | } 99 | 100 | public String getInterestPostingPeriodType() { 101 | return interestPostingPeriodType; 102 | } 103 | 104 | public String getInterestCalculationType() { 105 | return interestCalculationType; 106 | } 107 | 108 | public String getInterestCalculationDaysInYearType() { 109 | return interestCalculationDaysInYearType; 110 | } 111 | 112 | public String getMinRequiredOpeningBalance() { 113 | return minRequiredOpeningBalance; 114 | } 115 | 116 | public String getLockinPeriodFrequency() { 117 | return lockinPeriodFrequency; 118 | } 119 | 120 | public String getLockinPeriodFrequencyType() { 121 | return lockinPeriodFrequencyType; 122 | } 123 | 124 | public String getDateFormat() { 125 | return dateFormat; 126 | } 127 | 128 | public Locale getLocale() { 129 | return locale; 130 | } 131 | 132 | public Integer getRowIndex() { 133 | return rowIndex; 134 | } 135 | 136 | public String getStatus() { 137 | return status; 138 | } 139 | 140 | public String getSubmittedOnDate() { 141 | return submittedOnDate; 142 | } 143 | 144 | public String getWithdrawalFeeForTransfers() { 145 | return withdrawalFeeForTransfers; 146 | } 147 | 148 | public String getExternalId() { 149 | return externalId; 150 | 151 | } 152 | 153 | public List getCharges() { 154 | return charges; 155 | } 156 | 157 | public String getAllowOverdraft() { 158 | return allowOverdraft; 159 | } 160 | 161 | public String getOverdraftLimit() { 162 | return overdraftLimit; 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/savings/SavingsActivation.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.savings; 2 | 3 | import java.util.Locale; 4 | 5 | public class SavingsActivation { 6 | 7 | private final transient Integer rowIndex; 8 | 9 | private final String activatedOnDate; 10 | 11 | private final String dateFormat; 12 | 13 | private final Locale locale; 14 | 15 | public SavingsActivation(String activatedOnDate, Integer rowIndex ) { 16 | this.activatedOnDate = activatedOnDate; 17 | this.rowIndex = rowIndex; 18 | this.dateFormat = "dd MMMM yyyy"; 19 | this.locale = Locale.ENGLISH; 20 | } 21 | 22 | public String getActivatedOnDate() { 23 | return activatedOnDate; 24 | } 25 | 26 | public Locale getLocale() { 27 | return locale; 28 | } 29 | 30 | public String getDateFormat() { 31 | return dateFormat; 32 | } 33 | 34 | public Integer getRowIndex() { 35 | return rowIndex; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/savings/SavingsProduct.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.savings; 2 | 3 | import org.openmf.mifos.dataimport.dto.Currency; 4 | import org.openmf.mifos.dataimport.dto.Type; 5 | 6 | public class SavingsProduct { 7 | 8 | private final Integer id; 9 | 10 | private final String name; 11 | 12 | private final Currency currency; 13 | 14 | private final Double nominalAnnualInterestRate; 15 | 16 | private final Type interestCompoundingPeriodType; 17 | 18 | private final Type interestPostingPeriodType; 19 | 20 | private final Type interestCalculationType; 21 | 22 | private final Type interestCalculationDaysInYearType; 23 | 24 | private final Double minRequiredOpeningBalance; 25 | 26 | private final Integer lockinPeriodFrequency; 27 | 28 | private final Type lockinPeriodFrequencyType; 29 | 30 | private final String withdrawalFeeForTransfers; 31 | 32 | private final String allowOverdraft; 33 | 34 | private final Integer overdraftLimit; 35 | 36 | public SavingsProduct(Integer id, String name, Currency currency, Double nominalAnnualInterestRate, Type interestCompoundingPeriodType, 37 | Type interestPostingPeriodType, Type interestCalculationType, Type interestCalculationDaysInYearType, 38 | Double minRequiredOpeningBalance, Integer lockinPeriodFrequency, Type lockinPeriodFrequencyType, String withdrawalFeeForTransfers, 39 | String allowOverdraft, Integer overdraftLimit) { 40 | this.id = id; 41 | this.name = name; 42 | this.currency = currency; 43 | this.nominalAnnualInterestRate = nominalAnnualInterestRate; 44 | this.interestCompoundingPeriodType = interestCompoundingPeriodType; 45 | this.interestPostingPeriodType = interestPostingPeriodType; 46 | this.interestCalculationType = interestCalculationType; 47 | this.interestCalculationDaysInYearType = interestCalculationDaysInYearType; 48 | this.minRequiredOpeningBalance = minRequiredOpeningBalance; 49 | this.lockinPeriodFrequency = lockinPeriodFrequency; 50 | this.lockinPeriodFrequencyType = lockinPeriodFrequencyType; 51 | this.withdrawalFeeForTransfers = withdrawalFeeForTransfers; 52 | this.overdraftLimit = overdraftLimit; 53 | this.allowOverdraft = allowOverdraft; 54 | } 55 | 56 | public Integer getId() { 57 | return this.id; 58 | } 59 | 60 | public String getName() { 61 | return this.name; 62 | } 63 | 64 | public Currency getCurrency() { 65 | return this.currency; 66 | } 67 | 68 | public Double getNominalAnnualInterestRate() { 69 | return this.nominalAnnualInterestRate; 70 | } 71 | 72 | public Type getInterestCompoundingPeriodType() { 73 | return this.interestCompoundingPeriodType; 74 | } 75 | 76 | public Type getInterestPostingPeriodType() { 77 | return this.interestPostingPeriodType; 78 | } 79 | 80 | public Type getInterestCalculationType() { 81 | return this.interestCalculationType; 82 | } 83 | 84 | public Type getInterestCalculationDaysInYearType() { 85 | return this.interestCalculationDaysInYearType; 86 | } 87 | 88 | public Double getMinRequiredOpeningBalance() { 89 | return this.minRequiredOpeningBalance; 90 | } 91 | 92 | public Integer getLockinPeriodFrequency() { 93 | return this.lockinPeriodFrequency; 94 | } 95 | 96 | public Type getLockinPeriodFrequencyType() { 97 | return this.lockinPeriodFrequencyType; 98 | } 99 | 100 | public String getWithdrawalFeeForTransfers() { 101 | return withdrawalFeeForTransfers; 102 | } 103 | 104 | public String getAllowOverdraft() { 105 | return allowOverdraft; 106 | } 107 | 108 | public Integer getOverdraftLimit() { 109 | return overdraftLimit; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/dto/savings/SavingsTimeline.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.dto.savings; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class SavingsTimeline { 6 | 7 | private final ArrayList activatedOnDate; 8 | 9 | public SavingsTimeline(ArrayList activatedOnDate) { 10 | this.activatedOnDate = activatedOnDate; 11 | } 12 | 13 | public ArrayList getActivatedOnDate() { 14 | return this.activatedOnDate; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/handler/DataImportHandler.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler; 2 | 3 | 4 | public interface DataImportHandler { 5 | 6 | Result parse(); 7 | 8 | Result upload(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/handler/ImportFormatType.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler; 2 | 3 | 4 | 5 | public enum ImportFormatType { 6 | 7 | XLSX_OPEN ("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"), 8 | XLS ("application/vnd.ms-excel"), 9 | ODS ("application/vnd.oasis.opendocument.spreadsheet"); 10 | 11 | 12 | private final String format; 13 | 14 | private ImportFormatType(String format) { 15 | this.format= format; 16 | } 17 | 18 | public String getFormat() { 19 | return format; 20 | } 21 | 22 | public static ImportFormatType of(String name) { 23 | for(ImportFormatType type : ImportFormatType.values()) { 24 | if(type.getFormat().equals(name)) { 25 | return type; 26 | } 27 | } 28 | throw new IllegalArgumentException("Only excel files accepted! provided : " +name ); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/handler/ImportHandlerFactory.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler; 2 | 3 | import java.io.IOException; 4 | 5 | import org.apache.poi.ss.usermodel.Workbook; 6 | import org.openmf.mifos.dataimport.handler.accounting.AddJournalEntriesHandler; 7 | import org.openmf.mifos.dataimport.handler.client.CenterDataImportHandler; 8 | import org.openmf.mifos.dataimport.handler.client.ClientDataImportHandler; 9 | import org.openmf.mifos.dataimport.handler.client.GroupDataImportHandler; 10 | import org.openmf.mifos.dataimport.handler.loan.AddGuarantorDataImportHandler; 11 | import org.openmf.mifos.dataimport.handler.loan.LoanDataImportHandler; 12 | import org.openmf.mifos.dataimport.handler.loan.LoanRepaymentDataImportHandler; 13 | import org.openmf.mifos.dataimport.handler.savings.ClosingOfSavingsAccountHandler; 14 | import org.openmf.mifos.dataimport.handler.savings.FixedDepositImportHandler; 15 | import org.openmf.mifos.dataimport.handler.savings.RecurringDepositAccountTransactionDataImportHandler; 16 | import org.openmf.mifos.dataimport.handler.savings.RecurringDepositImportHandler; 17 | import org.openmf.mifos.dataimport.handler.savings.SavingsDataImportHandler; 18 | import org.openmf.mifos.dataimport.handler.savings.SavingsTransactionDataImportHandler; 19 | import org.openmf.mifos.dataimport.http.MifosRestClient; 20 | 21 | 22 | public class ImportHandlerFactory { 23 | 24 | public static final DataImportHandler createImportHandler(Workbook workbook) throws IOException { 25 | 26 | if(workbook.getSheetIndex("Clients") == 0) { 27 | return new ClientDataImportHandler(workbook, new MifosRestClient()); 28 | }else if(workbook.getSheetIndex("Groups") == 0) { 29 | return new GroupDataImportHandler(workbook, new MifosRestClient()); 30 | }else if(workbook.getSheetIndex("Centers") == 0) { 31 | return new CenterDataImportHandler(workbook, new MifosRestClient()); 32 | }else if(workbook.getSheetIndex("Loans") == 0) { 33 | return new LoanDataImportHandler(workbook, new MifosRestClient()); 34 | } else if(workbook.getSheetIndex("LoanRepayment") == 0) { 35 | return new LoanRepaymentDataImportHandler(workbook, new MifosRestClient()); 36 | } else if(workbook.getSheetIndex("Savings") == 0) { 37 | return new SavingsDataImportHandler(workbook, new MifosRestClient()); 38 | } else if(workbook.getSheetIndex("SavingsTransaction") == 0) { 39 | return new SavingsTransactionDataImportHandler(workbook, new MifosRestClient()); 40 | } else if(workbook.getSheetIndex("FixedDeposit") == 0) { 41 | return new FixedDepositImportHandler(workbook, new MifosRestClient()); 42 | } else if(workbook.getSheetIndex("RecurringDeposit") == 0) { 43 | return new RecurringDepositImportHandler(workbook, new MifosRestClient()); 44 | } else if(workbook.getSheetIndex("RecurringDepositTransaction") == 0) { 45 | return new RecurringDepositAccountTransactionDataImportHandler(workbook, new MifosRestClient()); 46 | }else if(workbook.getSheetIndex("ClosingOfSavingsAccounts") == 0) { 47 | return new ClosingOfSavingsAccountHandler(workbook, new MifosRestClient()); 48 | }else if(workbook.getSheetIndex("AddJournalEntries") == 0) { 49 | return new AddJournalEntriesHandler(workbook, new MifosRestClient()); 50 | }else if(workbook.getSheetIndex("guarantor") == 0) { 51 | return new AddGuarantorDataImportHandler(workbook, new MifosRestClient()); 52 | } 53 | 54 | 55 | 56 | throw new IllegalArgumentException("No work sheet found for processing : active sheet " + workbook.getSheetName(0)); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/handler/Result.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Result { 7 | 8 | private List errors = new ArrayList(); 9 | 10 | public void addError(String message) { 11 | errors.add(message); 12 | } 13 | 14 | public List getErrors() { 15 | return errors; 16 | } 17 | 18 | public boolean isSuccess() { 19 | return errors.isEmpty(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/handler/client/ClientDataImportHandler.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler.client; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.apache.poi.ss.usermodel.Cell; 7 | import org.apache.poi.ss.usermodel.IndexedColors; 8 | import org.apache.poi.ss.usermodel.Row; 9 | import org.apache.poi.ss.usermodel.Sheet; 10 | import org.apache.poi.ss.usermodel.Workbook; 11 | import org.openmf.mifos.dataimport.dto.client.Client; 12 | import org.openmf.mifos.dataimport.dto.client.CorporateClient; 13 | import org.openmf.mifos.dataimport.handler.AbstractDataImportHandler; 14 | import org.openmf.mifos.dataimport.handler.Result; 15 | import org.openmf.mifos.dataimport.http.RestClient; 16 | import org.openmf.mifos.dataimport.utils.StringUtils; 17 | 18 | import com.google.gson.Gson; 19 | 20 | public class ClientDataImportHandler extends AbstractDataImportHandler { 21 | 22 | 23 | private static final int FIRST_NAME_COL = 0; 24 | private static final int FULL_NAME_COL = 0; 25 | private static final int LAST_NAME_COL = 1; 26 | private static final int MIDDLE_NAME_COL = 2; 27 | private static final int OFFICE_NAME_COL = 3; 28 | private static final int STAFF_NAME_COL = 4; 29 | private static final int EXTERNAL_ID_COL = 5; 30 | private static final int ACTIVATION_DATE_COL = 6; 31 | private static final int ACTIVE_COL = 7; 32 | private static final int STATUS_COL = 8; 33 | 34 | private List clients; 35 | private String clientType; 36 | 37 | private final RestClient restClient; 38 | private final Workbook workbook; 39 | 40 | public ClientDataImportHandler(Workbook workbook, RestClient client) { 41 | this.workbook = workbook; 42 | this.restClient = client; 43 | clients = new ArrayList(); 44 | } 45 | 46 | @Override 47 | public Result parse() { 48 | Result result = new Result(); 49 | Sheet clientSheet = workbook.getSheet("Clients"); 50 | Integer noOfEntries = getNumberOfRows(clientSheet, 0); 51 | clientType = getClientType(clientSheet); 52 | for (int rowIndex = 1; rowIndex < noOfEntries; rowIndex++) { 53 | Row row; 54 | try { 55 | row = clientSheet.getRow(rowIndex); 56 | if(isNotImported(row, STATUS_COL)) { 57 | clients.add(parseAsClient(row)); 58 | } 59 | } catch (Exception e) { 60 | result.addError("Row = " + rowIndex + " , " + e.getMessage()); 61 | } 62 | } 63 | return result; 64 | } 65 | 66 | private String getClientType(Sheet clientSheet) { 67 | if(readAsString(FIRST_NAME_COL, clientSheet.getRow(0)).equals("First Name*")) 68 | return "Individual"; 69 | else 70 | return "Corporate"; 71 | } 72 | 73 | 74 | private Client parseAsClient(Row row) { 75 | String officeName = readAsString(OFFICE_NAME_COL, row); 76 | String officeId = getIdByName(workbook.getSheet("Offices"), officeName).toString(); 77 | String staffName = readAsString(STAFF_NAME_COL, row); 78 | String staffId = getIdByName(workbook.getSheet("Staff"), staffName).toString(); 79 | String externalId = readAsString(EXTERNAL_ID_COL, row); 80 | String activationDate = readAsDate(ACTIVATION_DATE_COL, row); 81 | String active = readAsBoolean(ACTIVE_COL, row).toString(); 82 | if(clientType.equals("Individual")) { 83 | String firstName = readAsString(FIRST_NAME_COL, row); 84 | String lastName = readAsString(LAST_NAME_COL, row); 85 | String middleName = readAsString(MIDDLE_NAME_COL, row); 86 | if(StringUtils.isBlank(firstName)) { 87 | throw new IllegalArgumentException("Name is blank"); 88 | } 89 | return new Client(firstName, lastName, middleName, activationDate, active, externalId, officeId, staffId, row.getRowNum()); 90 | } else { 91 | String fullName = readAsString(FULL_NAME_COL, row); 92 | if(StringUtils.isBlank(fullName)) { 93 | throw new IllegalArgumentException("Name is blank"); 94 | } 95 | return new CorporateClient(fullName, activationDate, active, externalId, officeId, staffId, row.getRowNum()); 96 | } 97 | } 98 | 99 | @Override 100 | public Result upload() { 101 | Result result = new Result(); 102 | Sheet clientSheet = workbook.getSheet("Clients"); 103 | restClient.createAuthToken(); 104 | for (Client client : clients) { 105 | try { 106 | Gson gson = new Gson(); 107 | String payload = gson.toJson(client); 108 | restClient.post("clients", payload); 109 | 110 | Cell statusCell = clientSheet.getRow(client.getRowIndex()).createCell(STATUS_COL); 111 | statusCell.setCellValue("Imported"); 112 | statusCell.setCellStyle(getCellStyle(workbook, IndexedColors.LIGHT_GREEN)); 113 | } catch (RuntimeException e) { 114 | String message = parseStatus(e.getMessage()); 115 | Cell statusCell = clientSheet.getRow(client.getRowIndex()).createCell(STATUS_COL); 116 | statusCell.setCellValue(message); 117 | statusCell.setCellStyle(getCellStyle(workbook, IndexedColors.RED)); 118 | result.addError("Row = " + client.getRowIndex() + " ," + message); 119 | } 120 | } 121 | clientSheet.setColumnWidth(STATUS_COL, 15000); 122 | writeString(STATUS_COL, clientSheet.getRow(0), "Status"); 123 | return result; 124 | } 125 | 126 | public List getClients() { 127 | return clients; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/handler/loan/LoanRepaymentDataImportHandler.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler.loan; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.apache.poi.ss.usermodel.Cell; 7 | import org.apache.poi.ss.usermodel.IndexedColors; 8 | import org.apache.poi.ss.usermodel.Row; 9 | import org.apache.poi.ss.usermodel.Sheet; 10 | import org.apache.poi.ss.usermodel.Workbook; 11 | import org.openmf.mifos.dataimport.dto.Transaction; 12 | import org.openmf.mifos.dataimport.handler.AbstractDataImportHandler; 13 | import org.openmf.mifos.dataimport.handler.Result; 14 | import org.openmf.mifos.dataimport.http.RestClient; 15 | 16 | import com.google.gson.Gson; 17 | 18 | public class LoanRepaymentDataImportHandler extends AbstractDataImportHandler { 19 | 20 | 21 | 22 | private final RestClient restClient; 23 | private final Workbook workbook; 24 | 25 | private List loanRepayments; 26 | private String loanAccountId = ""; 27 | 28 | private static final int LOAN_ACCOUNT_NO_COL = 2; 29 | private static final int AMOUNT_COL = 5; 30 | private static final int REPAID_ON_DATE_COL = 6; 31 | private static final int REPAYMENT_TYPE_COL = 7; 32 | private static final int ACCOUNT_NO_COL = 8; 33 | private static final int CHECK_NO_COL = 9; 34 | private static final int ROUTING_CODE_COL = 10; 35 | private static final int RECEIPT_NO_COL = 11; 36 | private static final int BANK_NO_COL = 12; 37 | private static final int STATUS_COL = 13; 38 | 39 | public LoanRepaymentDataImportHandler(Workbook workbook, RestClient client) { 40 | this.workbook = workbook; 41 | this.restClient = client; 42 | loanRepayments = new ArrayList(); 43 | } 44 | 45 | @Override 46 | public Result parse() { 47 | Result result = new Result(); 48 | Sheet loanRepaymentSheet = workbook.getSheet("LoanRepayment"); 49 | Integer noOfEntries = getNumberOfRows(loanRepaymentSheet, AMOUNT_COL); 50 | for (int rowIndex = 1; rowIndex < noOfEntries; rowIndex++) { 51 | Row row; 52 | try { 53 | row = loanRepaymentSheet.getRow(rowIndex); 54 | if(isNotImported(row, STATUS_COL)) 55 | loanRepayments.add(parseAsLoanRepayment(row)); 56 | } catch (Exception e) { 57 | result.addError("Row = " + rowIndex + " , " + e.getMessage()); 58 | } 59 | } 60 | return result; 61 | } 62 | 63 | private Transaction parseAsLoanRepayment(Row row) { 64 | String loanAccountIdCheck = readAsInt(LOAN_ACCOUNT_NO_COL, row); 65 | if(!loanAccountIdCheck.equals("")) 66 | loanAccountId = loanAccountIdCheck; 67 | String repaymentAmount = readAsDouble(AMOUNT_COL, row).toString(); 68 | String repaymentDate = readAsDate(REPAID_ON_DATE_COL, row); 69 | String repaymentType = readAsString(REPAYMENT_TYPE_COL, row); 70 | String repaymentTypeId = getIdByName(workbook.getSheet("Extras"), repaymentType).toString(); 71 | String accountNumber = readAsLong(ACCOUNT_NO_COL, row); 72 | String checkNumber = readAsLong(CHECK_NO_COL, row); 73 | String routingCode = readAsLong(ROUTING_CODE_COL, row); 74 | String receiptNumber = readAsLong(RECEIPT_NO_COL, row); 75 | String bankNumber = readAsLong(BANK_NO_COL, row); 76 | return new Transaction(repaymentAmount, repaymentDate, repaymentTypeId, accountNumber, 77 | checkNumber, routingCode, receiptNumber, bankNumber, Integer.parseInt(loanAccountId), "", row.getRowNum()); 78 | } 79 | 80 | @Override 81 | public Result upload() { 82 | Result result = new Result(); 83 | Sheet loanRepaymentSheet = workbook.getSheet("LoanRepayment"); 84 | restClient.createAuthToken(); 85 | for (Transaction loanRepayment : loanRepayments) { 86 | try { 87 | Gson gson = new Gson(); 88 | String payload = gson.toJson(loanRepayment); 89 | restClient.post("loans/" + loanRepayment.getAccountId() + "/transactions?command=repayment", payload); 90 | Cell statusCell = loanRepaymentSheet.getRow(loanRepayment.getRowIndex()).createCell(STATUS_COL); 91 | statusCell.setCellValue("Imported"); 92 | statusCell.setCellStyle(getCellStyle(workbook, IndexedColors.LIGHT_GREEN)); 93 | } catch (Exception e) { 94 | Cell loanAccountIdCell = loanRepaymentSheet.getRow(loanRepayment.getRowIndex()).createCell(LOAN_ACCOUNT_NO_COL); 95 | loanAccountIdCell.setCellValue(loanRepayment.getAccountId()); 96 | String message = parseStatus(e.getMessage()); 97 | Cell statusCell = loanRepaymentSheet.getRow(loanRepayment.getRowIndex()).createCell(STATUS_COL); 98 | statusCell.setCellValue(message); 99 | statusCell.setCellStyle(getCellStyle(workbook, IndexedColors.RED)); 100 | result.addError("Row = " + loanRepayment.getRowIndex() + " ," + message); 101 | } 102 | } 103 | loanRepaymentSheet.setColumnWidth(STATUS_COL, 15000); 104 | writeString(STATUS_COL, loanRepaymentSheet.getRow(0), "Status"); 105 | return result; 106 | } 107 | 108 | public List getLoanRepayments() { 109 | return loanRepayments; 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/handler/savings/ClosingOfSavingsAccountHandler.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler.savings; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.apache.poi.ss.usermodel.Cell; 7 | import org.apache.poi.ss.usermodel.IndexedColors; 8 | import org.apache.poi.ss.usermodel.Row; 9 | import org.apache.poi.ss.usermodel.Sheet; 10 | import org.apache.poi.ss.usermodel.Workbook; 11 | import org.openmf.mifos.dataimport.dto.ClosingOfSavingsAccounts; 12 | import org.openmf.mifos.dataimport.handler.AbstractDataImportHandler; 13 | import org.openmf.mifos.dataimport.handler.Result; 14 | import org.openmf.mifos.dataimport.http.RestClient; 15 | 16 | import com.google.gson.Gson; 17 | 18 | public class ClosingOfSavingsAccountHandler extends AbstractDataImportHandler{ 19 | 20 | 21 | private final RestClient restClient; 22 | private final Workbook workbook; 23 | 24 | private List closedOnDate = new ArrayList(); 25 | private String savingsAccountId = ""; 26 | 27 | private static final int ACCOUNT_TYPE_COL=2; 28 | private static final int SAVINGS_ACCOUNT_NO_COL = 3; 29 | private static final int CLOSED_ON_DATE = 6; 30 | private static final int ON_ACCOUNT_CLOSURE_ID = 7; 31 | private static final int TO_SAVINGS_ACCOUNT_ID = 8; 32 | private static final int STATUS_COL = 10; 33 | 34 | 35 | public ClosingOfSavingsAccountHandler(Workbook workbook, RestClient client) { 36 | this.workbook = workbook; 37 | this.restClient = client; 38 | } 39 | 40 | @Override 41 | public Result parse() { 42 | Result result = new Result(); 43 | Sheet savingsSheet = workbook.getSheet("ClosingOfSavingsAccounts"); 44 | Integer noOfEntries = getNumberOfRows(savingsSheet, 0); 45 | for (int rowIndex = 1; rowIndex < noOfEntries; rowIndex++) { 46 | Row row; 47 | try { 48 | row = savingsSheet.getRow(rowIndex); 49 | if (isNotImported(row, STATUS_COL)) { 50 | closedOnDate.add(paseAsSavingsClosed(row)); 51 | } 52 | } catch (RuntimeException re) { 53 | result.addError("Row = " + rowIndex + " , " + re.getMessage()); 54 | } 55 | } 56 | return result; 57 | } 58 | 59 | 60 | 61 | 62 | private ClosingOfSavingsAccounts paseAsSavingsClosed(Row row) { 63 | String savingsAccountIdCheck = readAsInt(SAVINGS_ACCOUNT_NO_COL, row); 64 | if(!savingsAccountIdCheck.equals("")) 65 | savingsAccountId = savingsAccountIdCheck; 66 | String closedOnDate = readAsDate(CLOSED_ON_DATE,row); 67 | String onAccountClosure = readAsLong(ON_ACCOUNT_CLOSURE_ID,row); 68 | String toSavingsAccountId = readAsLong(TO_SAVINGS_ACCOUNT_ID, row); 69 | String accountType = readAsString(ACCOUNT_TYPE_COL, row); 70 | return new ClosingOfSavingsAccounts(Integer.parseInt(savingsAccountId),accountType,closedOnDate,onAccountClosure,toSavingsAccountId, row.getRowNum()); 71 | } 72 | 73 | @Override 74 | public Result upload() { 75 | Result result = new Result(); 76 | Sheet savingsTransactionSheet = workbook.getSheet("ClosingOfSavingsAccounts"); 77 | restClient.createAuthToken(); 78 | for (ClosingOfSavingsAccounts transaction : closedOnDate) { 79 | try { 80 | Gson gson = new Gson(); 81 | String payload = gson.toJson(transaction); 82 | restClient.post(transaction.getAccountType() +"/"+transaction.getAccountId()+ "?command=close", payload); 83 | 84 | Cell statusCell = savingsTransactionSheet.getRow(transaction.getRowIndex()).createCell(STATUS_COL); 85 | statusCell.setCellValue("Imported"); 86 | statusCell.setCellStyle(getCellStyle(workbook, IndexedColors.LIGHT_GREEN)); 87 | } catch (Exception e) { 88 | Cell savingsAccountIdCell = savingsTransactionSheet.getRow(transaction.getRowIndex()).createCell(SAVINGS_ACCOUNT_NO_COL); 89 | savingsAccountIdCell.setCellValue(transaction.getAccountId()); 90 | String message = parseStatus(e.getMessage()); 91 | 92 | Cell statusCell = savingsTransactionSheet.getRow(transaction.getRowIndex()).createCell(STATUS_COL); 93 | statusCell.setCellValue(message); 94 | statusCell.setCellStyle(getCellStyle(workbook, IndexedColors.RED)); 95 | result.addError("Row = " + transaction.getRowIndex() + " ," + message); 96 | } 97 | } 98 | savingsTransactionSheet.setColumnWidth(STATUS_COL, 15000); 99 | writeString(STATUS_COL, savingsTransactionSheet.getRow(0), "Status"); 100 | return result; 101 | } 102 | 103 | 104 | 105 | 106 | public static int getClosedOnDate() { 107 | return CLOSED_ON_DATE; 108 | } 109 | 110 | public static int getOnAccountClosureId() { 111 | return ON_ACCOUNT_CLOSURE_ID; 112 | } 113 | 114 | public static int getToSavingsAccountId() { 115 | return TO_SAVINGS_ACCOUNT_ID; 116 | } 117 | 118 | } 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/handler/savings/RecurringDepositAccountTransactionDataImportHandler.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler.savings; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.apache.poi.ss.usermodel.Cell; 7 | import org.apache.poi.ss.usermodel.IndexedColors; 8 | import org.apache.poi.ss.usermodel.Row; 9 | import org.apache.poi.ss.usermodel.Sheet; 10 | import org.apache.poi.ss.usermodel.Workbook; 11 | import org.openmf.mifos.dataimport.dto.Transaction; 12 | import org.openmf.mifos.dataimport.handler.AbstractDataImportHandler; 13 | import org.openmf.mifos.dataimport.handler.Result; 14 | import org.openmf.mifos.dataimport.http.RestClient; 15 | 16 | import com.google.gson.Gson; 17 | 18 | public class RecurringDepositAccountTransactionDataImportHandler extends AbstractDataImportHandler { 19 | 20 | 21 | 22 | private final RestClient restClient; 23 | private final Workbook workbook; 24 | 25 | private List savingsTransactions; 26 | private String savingsAccountId = ""; 27 | 28 | private static final int SAVINGS_ACCOUNT_NO_COL = 2; 29 | private static final int TRANSACTION_TYPE_COL = 5; 30 | private static final int AMOUNT_COL = 6; 31 | private static final int TRANSACTION_DATE_COL = 7; 32 | private static final int PAYMENT_TYPE_COL = 8; 33 | private static final int ACCOUNT_NO_COL = 9; 34 | private static final int CHECK_NO_COL = 10; 35 | private static final int ROUTING_CODE_COL = 11; 36 | private static final int RECEIPT_NO_COL = 12; 37 | private static final int BANK_NO_COL = 13; 38 | private static final int STATUS_COL = 14; 39 | 40 | public RecurringDepositAccountTransactionDataImportHandler(Workbook workbook, RestClient client) { 41 | this.workbook = workbook; 42 | this.restClient = client; 43 | savingsTransactions = new ArrayList(); 44 | } 45 | 46 | @Override 47 | public Result parse() { 48 | Result result = new Result(); 49 | Sheet savingsTransactionSheet = workbook.getSheet("RecurringDepositTransaction"); 50 | Integer noOfEntries = getNumberOfRows(savingsTransactionSheet, AMOUNT_COL); 51 | for (int rowIndex = 1; rowIndex < noOfEntries; rowIndex++) { 52 | Row row; 53 | try { 54 | row = savingsTransactionSheet.getRow(rowIndex); 55 | if(isNotImported(row, STATUS_COL)) 56 | savingsTransactions.add(parseAsTransaction(row)); 57 | } catch (Exception e) { 58 | result.addError("Row = " + rowIndex + " , " + e.getMessage()); 59 | } 60 | } 61 | return result; 62 | } 63 | 64 | private Transaction parseAsTransaction(Row row) { 65 | String savingsAccountIdCheck = readAsInt(SAVINGS_ACCOUNT_NO_COL, row); 66 | if(!savingsAccountIdCheck.equals("")) 67 | savingsAccountId = savingsAccountIdCheck; 68 | String transactionType = readAsString(TRANSACTION_TYPE_COL, row); 69 | String amount = readAsDouble(AMOUNT_COL, row).toString(); 70 | String transactionDate = readAsDate(TRANSACTION_DATE_COL, row); 71 | String paymentType = readAsString(PAYMENT_TYPE_COL, row); 72 | String paymentTypeId = getIdByName(workbook.getSheet("Extras"), paymentType).toString(); 73 | String accountNumber = readAsLong(ACCOUNT_NO_COL, row); 74 | String checkNumber = readAsLong(CHECK_NO_COL, row); 75 | String routingCode = readAsLong(ROUTING_CODE_COL, row); 76 | String receiptNumber = readAsLong(RECEIPT_NO_COL, row); 77 | String bankNumber = readAsLong(BANK_NO_COL, row); 78 | return new Transaction(amount, transactionDate, paymentTypeId, accountNumber, 79 | checkNumber, routingCode, receiptNumber, bankNumber, Integer.parseInt(savingsAccountId), transactionType, row.getRowNum()); 80 | } 81 | 82 | @Override 83 | public Result upload() { 84 | Result result = new Result(); 85 | Sheet savingsTransactionSheet = workbook.getSheet("RecurringDepositTransaction"); 86 | restClient.createAuthToken(); 87 | for (Transaction transaction : savingsTransactions) { 88 | try { 89 | Gson gson = new Gson(); 90 | String payload = gson.toJson(transaction); 91 | restClient.post("recurringdepositaccounts/" + transaction.getAccountId() + "/transactions?command=" + transaction.getTransactionType(), payload); 92 | 93 | Cell statusCell = savingsTransactionSheet.getRow(transaction.getRowIndex()).createCell(STATUS_COL); 94 | statusCell.setCellValue("Imported"); 95 | statusCell.setCellStyle(getCellStyle(workbook, IndexedColors.LIGHT_GREEN)); 96 | } catch (Exception e) { 97 | Cell savingsAccountIdCell = savingsTransactionSheet.getRow(transaction.getRowIndex()).createCell(SAVINGS_ACCOUNT_NO_COL); 98 | savingsAccountIdCell.setCellValue(transaction.getAccountId()); 99 | String message = parseStatus(e.getMessage()); 100 | 101 | Cell statusCell = savingsTransactionSheet.getRow(transaction.getRowIndex()).createCell(STATUS_COL); 102 | statusCell.setCellValue(message); 103 | statusCell.setCellStyle(getCellStyle(workbook, IndexedColors.RED)); 104 | result.addError("Row = " + transaction.getRowIndex() + " ," + message); 105 | } 106 | } 107 | savingsTransactionSheet.setColumnWidth(STATUS_COL, 15000); 108 | writeString(STATUS_COL, savingsTransactionSheet.getRow(0), "Status"); 109 | return result; 110 | } 111 | 112 | public List getSavingsTransactions() { 113 | return savingsTransactions; 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/handler/savings/SavingsTransactionDataImportHandler.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler.savings; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.apache.poi.ss.usermodel.Cell; 7 | import org.apache.poi.ss.usermodel.IndexedColors; 8 | import org.apache.poi.ss.usermodel.Row; 9 | import org.apache.poi.ss.usermodel.Sheet; 10 | import org.apache.poi.ss.usermodel.Workbook; 11 | import org.openmf.mifos.dataimport.dto.Transaction; 12 | import org.openmf.mifos.dataimport.handler.AbstractDataImportHandler; 13 | import org.openmf.mifos.dataimport.handler.Result; 14 | import org.openmf.mifos.dataimport.http.RestClient; 15 | 16 | import com.google.gson.Gson; 17 | 18 | public class SavingsTransactionDataImportHandler extends AbstractDataImportHandler { 19 | 20 | 21 | 22 | private final RestClient restClient; 23 | private final Workbook workbook; 24 | 25 | private List savingsTransactions; 26 | private String savingsAccountId = ""; 27 | 28 | private static final int SAVINGS_ACCOUNT_NO_COL = 2; 29 | private static final int TRANSACTION_TYPE_COL = 5; 30 | private static final int AMOUNT_COL = 6; 31 | private static final int TRANSACTION_DATE_COL = 7; 32 | private static final int PAYMENT_TYPE_COL = 8; 33 | private static final int ACCOUNT_NO_COL = 9; 34 | private static final int CHECK_NO_COL = 10; 35 | private static final int ROUTING_CODE_COL = 11; 36 | private static final int RECEIPT_NO_COL = 12; 37 | private static final int BANK_NO_COL = 13; 38 | private static final int STATUS_COL = 14; 39 | 40 | public SavingsTransactionDataImportHandler(Workbook workbook, RestClient client) { 41 | this.workbook = workbook; 42 | this.restClient = client; 43 | savingsTransactions = new ArrayList(); 44 | } 45 | 46 | @Override 47 | public Result parse() { 48 | Result result = new Result(); 49 | Sheet savingsTransactionSheet = workbook.getSheet("SavingsTransaction"); 50 | Integer noOfEntries = getNumberOfRows(savingsTransactionSheet, AMOUNT_COL); 51 | for (int rowIndex = 1; rowIndex < noOfEntries; rowIndex++) { 52 | Row row; 53 | try { 54 | row = savingsTransactionSheet.getRow(rowIndex); 55 | if(isNotImported(row, STATUS_COL)) 56 | savingsTransactions.add(parseAsTransaction(row)); 57 | } catch (Exception e) { 58 | result.addError("Row = " + rowIndex + " , " + e.getMessage()); 59 | } 60 | } 61 | return result; 62 | } 63 | 64 | private Transaction parseAsTransaction(Row row) { 65 | String savingsAccountIdCheck = readAsInt(SAVINGS_ACCOUNT_NO_COL, row); 66 | if(!savingsAccountIdCheck.equals("")) 67 | savingsAccountId = savingsAccountIdCheck; 68 | String transactionType = readAsString(TRANSACTION_TYPE_COL, row); 69 | String amount = readAsDouble(AMOUNT_COL, row).toString(); 70 | String transactionDate = readAsDate(TRANSACTION_DATE_COL, row); 71 | String paymentType = readAsString(PAYMENT_TYPE_COL, row); 72 | String paymentTypeId = getIdByName(workbook.getSheet("Extras"), paymentType).toString(); 73 | String accountNumber = readAsLong(ACCOUNT_NO_COL, row); 74 | String checkNumber = readAsLong(CHECK_NO_COL, row); 75 | String routingCode = readAsLong(ROUTING_CODE_COL, row); 76 | String receiptNumber = readAsLong(RECEIPT_NO_COL, row); 77 | String bankNumber = readAsLong(BANK_NO_COL, row); 78 | return new Transaction(amount, transactionDate, paymentTypeId, accountNumber, 79 | checkNumber, routingCode, receiptNumber, bankNumber, Integer.parseInt(savingsAccountId), transactionType, row.getRowNum()); 80 | } 81 | 82 | @Override 83 | public Result upload() { 84 | Result result = new Result(); 85 | Sheet savingsTransactionSheet = workbook.getSheet("SavingsTransaction"); 86 | restClient.createAuthToken(); 87 | for (Transaction transaction : savingsTransactions) { 88 | try { 89 | Gson gson = new Gson(); 90 | String payload = gson.toJson(transaction); 91 | restClient.post("savingsaccounts/" + transaction.getAccountId() + "/transactions?command=" + transaction.getTransactionType(), payload); 92 | 93 | Cell statusCell = savingsTransactionSheet.getRow(transaction.getRowIndex()).createCell(STATUS_COL); 94 | statusCell.setCellValue("Imported"); 95 | statusCell.setCellStyle(getCellStyle(workbook, IndexedColors.LIGHT_GREEN)); 96 | } catch (Exception e) { 97 | Cell savingsAccountIdCell = savingsTransactionSheet.getRow(transaction.getRowIndex()).createCell(SAVINGS_ACCOUNT_NO_COL); 98 | savingsAccountIdCell.setCellValue(transaction.getAccountId()); 99 | String message = parseStatus(e.getMessage()); 100 | 101 | Cell statusCell = savingsTransactionSheet.getRow(transaction.getRowIndex()).createCell(STATUS_COL); 102 | statusCell.setCellValue(message); 103 | statusCell.setCellStyle(getCellStyle(workbook, IndexedColors.RED)); 104 | result.addError("Row = " + transaction.getRowIndex() + " ," + message); 105 | } 106 | } 107 | savingsTransactionSheet.setColumnWidth(STATUS_COL, 15000); 108 | writeString(STATUS_COL, savingsTransactionSheet.getRow(0), "Status"); 109 | return result; 110 | } 111 | 112 | public List getSavingsTransactions() { 113 | return savingsTransactions; 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/http/HttpRequestBuilder.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.http; 2 | 3 | import java.io.IOException; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | import org.openmf.mifos.dataimport.http.SimpleHttpRequest.Method; 8 | 9 | public class HttpRequestBuilder 10 | { 11 | private String url; 12 | 13 | private Method method; 14 | 15 | private String content; 16 | 17 | private Map headers = new HashMap(); 18 | 19 | public HttpRequestBuilder withURL(String url) { 20 | this.url = url; 21 | return this; 22 | } 23 | 24 | public HttpRequestBuilder withMethod(Method method) { 25 | this.method = method; 26 | return this; 27 | } 28 | 29 | public HttpRequestBuilder withContent(String content) { 30 | this.content = content; 31 | return this; 32 | } 33 | 34 | public HttpRequestBuilder addHeader(String name, String value) { 35 | headers.put(name, value); 36 | return this; 37 | } 38 | 39 | public SimpleHttpResponse execute() throws IOException { 40 | SimpleHttpRequest request = new SimpleHttpRequest(url, method, headers, content); 41 | return new SimpleHttpResponse(request.getConnection()); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/http/MifosRestClient.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.http; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.InputStreamReader; 7 | import java.net.HttpURLConnection; 8 | 9 | import javax.net.ssl.HostnameVerifier; 10 | import javax.net.ssl.HttpsURLConnection; 11 | import javax.net.ssl.SSLSession; 12 | 13 | import org.openmf.mifos.dataimport.dto.AuthToken; 14 | import org.openmf.mifos.dataimport.http.SimpleHttpRequest.Method; 15 | 16 | import com.google.gson.Gson; 17 | 18 | 19 | public class MifosRestClient implements RestClient { 20 | 21 | 22 | private final String baseURL; 23 | 24 | private final String userName; 25 | 26 | private final String password; 27 | 28 | private final String tenantId; 29 | 30 | private String authToken; 31 | 32 | static { 33 | if(System.getProperty("mifos.endpoint").contains("localhost")) { 34 | //for localhost testing only 35 | HttpsURLConnection.setDefaultHostnameVerifier( 36 | new HostnameVerifier(){ 37 | 38 | @Override 39 | public boolean verify(String hostname, @SuppressWarnings("unused") SSLSession sslSession) { 40 | if (hostname.equals("localhost")) { 41 | return true; 42 | } 43 | return false; 44 | } 45 | }); 46 | } 47 | } 48 | 49 | public MifosRestClient() { 50 | 51 | baseURL = System.getProperty("mifos.endpoint"); 52 | userName = System.getProperty("mifos.user.id"); 53 | password = System.getProperty("mifos.password"); 54 | tenantId = System.getProperty("mifos.tenant.id"); 55 | }; 56 | 57 | public static final class Header { 58 | public static final String AUTHORIZATION = "Authorization"; 59 | public static final String CONTENT_TYPE = "Content-Type"; 60 | public static final String FINERACT_TENANT_ID = "Fineract-Platform-TenantId"; 61 | } 62 | 63 | 64 | @Override 65 | public String post(String path, String payload) { 66 | String url = baseURL + path; 67 | try { 68 | 69 | SimpleHttpResponse response = new HttpRequestBuilder().withURL(url).withMethod(Method.POST) 70 | .addHeader(Header.AUTHORIZATION, "Basic " + authToken) 71 | .addHeader(Header.CONTENT_TYPE, "application/json; charset=utf-8") 72 | .addHeader(Header.FINERACT_TENANT_ID, tenantId) 73 | .withContent(payload).execute(); 74 | String content = readContentAndClose(response.getContent()); 75 | if (response.getStatus() != HttpURLConnection.HTTP_OK) 76 | { 77 | throw new IllegalStateException(content); 78 | } 79 | return content; 80 | } catch (IOException e) { 81 | throw new IllegalStateException(e); 82 | } 83 | } 84 | 85 | @Override 86 | public String get(String path) { 87 | String url = baseURL + path; 88 | try { 89 | SimpleHttpResponse response = new HttpRequestBuilder().withURL(url).withMethod(Method.GET) 90 | .addHeader(Header.AUTHORIZATION, "Basic " + authToken) 91 | .addHeader(Header.FINERACT_TENANT_ID,tenantId) 92 | .execute(); 93 | String content = readContentAndClose(response.getContent()); 94 | if(response.getStatus() != HttpURLConnection.HTTP_OK) 95 | { 96 | throw new IllegalStateException(content); 97 | } 98 | return content; 99 | } catch (IOException e) { 100 | throw new IllegalStateException(e); 101 | } 102 | } 103 | 104 | @Override 105 | public void createAuthToken() { 106 | String url = baseURL + "authentication?username=" + userName + "&password=" + password; 107 | try { 108 | SimpleHttpResponse response = new HttpRequestBuilder().withURL(url).withMethod(Method.POST) 109 | .addHeader(Header.FINERACT_TENANT_ID, tenantId) 110 | .addHeader(Header.CONTENT_TYPE, "application/json; charset=utf-8").execute(); 111 | String content = readContentAndClose(response.getContent()); 112 | AuthToken auth = new Gson().fromJson(content, AuthToken.class); 113 | authToken = auth.getBase64EncodedAuthenticationKey(); 114 | } catch (IOException e) { 115 | throw new IllegalStateException(e); 116 | } 117 | } 118 | 119 | private String readContentAndClose(InputStream content) throws IOException { 120 | InputStreamReader stream = new InputStreamReader(content,"UTF-8"); 121 | BufferedReader reader = new BufferedReader(stream); 122 | String data = reader.readLine(); 123 | stream.close(); 124 | reader.close(); 125 | return data; 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/http/RestClient.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.http; 2 | 3 | 4 | public interface RestClient { 5 | 6 | String post(String path, String payload); 7 | 8 | String get(String path); 9 | 10 | void createAuthToken(); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/http/SimpleHttpRequest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.http; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStreamWriter; 5 | import java.net.HttpURLConnection; 6 | import java.net.URL; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | import java.util.Map.Entry; 10 | 11 | public class SimpleHttpRequest { 12 | 13 | private static final int HTTP_TIMEOUT = 100 * 1000; // 100 secs 14 | 15 | private final HttpURLConnection connection; 16 | 17 | public static enum Method { 18 | GET, POST; 19 | } 20 | 21 | public SimpleHttpRequest(String url, Method method, Map headers, String content) throws IOException { 22 | URL obj = new URL(url); 23 | connection = (HttpURLConnection) obj.openConnection(); 24 | TrustModifier.relaxHostChecking(connection); 25 | connection.setRequestMethod(method.name()); 26 | connection.setReadTimeout(HTTP_TIMEOUT); 27 | connection.setUseCaches(false); 28 | for (Entry header : headers.entrySet()) { 29 | connection.addRequestProperty(header.getKey(), header.getValue()); 30 | } 31 | if (content != null) { 32 | connection.setDoOutput(true); 33 | OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream(),"UTF-8"); 34 | out.write(content); 35 | close(out); 36 | } 37 | } 38 | 39 | private void close(OutputStreamWriter out) throws IOException { 40 | 41 | try { 42 | out.flush(); 43 | out.close(); 44 | } catch (IOException e) { 45 | out.close(); 46 | } 47 | } 48 | 49 | public SimpleHttpRequest(String url, Map headers, String content) throws IOException { 50 | this(url, Method.GET, headers, content); 51 | } 52 | 53 | public SimpleHttpRequest(String url, String content) throws IOException { 54 | this(url, Method.GET, new HashMap(), content); 55 | } 56 | 57 | public SimpleHttpRequest(String url) throws IOException { 58 | this(url, Method.GET, new HashMap(), null); 59 | } 60 | 61 | public int status() throws IOException { 62 | return connection.getResponseCode(); 63 | } 64 | 65 | public HttpURLConnection getConnection() throws IOException { 66 | return connection; 67 | 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/http/SimpleHttpResponse.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.http; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.net.HttpURLConnection; 6 | 7 | public class SimpleHttpResponse 8 | { 9 | private HttpURLConnection connection; 10 | 11 | private InputStream content; 12 | 13 | public SimpleHttpResponse(HttpURLConnection connection) 14 | { 15 | this.connection = connection; 16 | } 17 | 18 | public int getStatus() throws IOException 19 | { 20 | return connection.getResponseCode(); 21 | } 22 | 23 | 24 | public InputStream getContent() throws IOException 25 | { 26 | if(connection.getResponseCode() == HttpURLConnection.HTTP_OK) 27 | content = connection.getInputStream(); 28 | else 29 | content = connection.getErrorStream(); 30 | return content; 31 | } 32 | 33 | @SuppressWarnings("PMD") 34 | public void destroy() { 35 | if (content != null) try { 36 | content.close(); 37 | } catch (IOException e) { 38 | try { 39 | content.close(); 40 | } catch (IOException e1) { 41 | // do nothing 42 | } 43 | } 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/http/TrustModifier.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.http; 2 | 3 | import java.net.HttpURLConnection; 4 | import java.security.KeyManagementException; 5 | import java.security.KeyStoreException; 6 | import java.security.NoSuchAlgorithmException; 7 | import java.security.cert.CertificateException; 8 | import java.security.cert.X509Certificate; 9 | 10 | import javax.net.ssl.HostnameVerifier; 11 | import javax.net.ssl.HttpsURLConnection; 12 | import javax.net.ssl.SSLContext; 13 | import javax.net.ssl.SSLSession; 14 | import javax.net.ssl.SSLSocketFactory; 15 | import javax.net.ssl.TrustManager; 16 | import javax.net.ssl.X509TrustManager; 17 | 18 | public class TrustModifier { 19 | private static final TrustingHostnameVerifier 20 | TRUSTING_HOSTNAME_VERIFIER = new TrustingHostnameVerifier(); 21 | private static SSLSocketFactory factory; 22 | 23 | /** Call this with any HttpURLConnection, and it will 24 | modify the trust settings if it is an HTTPS connection. */ 25 | public static String relaxHostChecking(HttpURLConnection conn) { 26 | try{ 27 | if (conn instanceof HttpsURLConnection) { 28 | HttpsURLConnection httpsConnection = (HttpsURLConnection) conn; 29 | SSLSocketFactory factory = prepFactory(httpsConnection); 30 | httpsConnection.setSSLSocketFactory(factory); 31 | httpsConnection.setHostnameVerifier(TRUSTING_HOSTNAME_VERIFIER); 32 | } 33 | return ""; 34 | } catch (KeyStoreException kse) { 35 | return kse.getMessage(); 36 | } catch (KeyManagementException kme) { 37 | return kme.getMessage(); 38 | } catch (NoSuchAlgorithmException nsae) { 39 | return nsae.getMessage(); 40 | } 41 | } 42 | 43 | static synchronized SSLSocketFactory prepFactory(@SuppressWarnings("unused") HttpsURLConnection httpsConnection) 44 | throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException { 45 | 46 | if (factory == null) { 47 | SSLContext ctx = SSLContext.getInstance("TLS"); 48 | ctx.init(null, new TrustManager[]{ new AlwaysTrustManager() }, null); 49 | factory = ctx.getSocketFactory(); 50 | } 51 | return factory; 52 | } 53 | 54 | private static final class TrustingHostnameVerifier implements HostnameVerifier { 55 | @Override 56 | public boolean verify(@SuppressWarnings("unused") String hostname, @SuppressWarnings("unused") SSLSession session) { 57 | return true; 58 | } 59 | } 60 | 61 | private static class AlwaysTrustManager implements X509TrustManager { 62 | @Override 63 | public void checkClientTrusted(@SuppressWarnings("unused") X509Certificate[] arg0, @SuppressWarnings("unused") String arg1) throws CertificateException { } 64 | @Override 65 | public void checkServerTrusted(@SuppressWarnings("unused") X509Certificate[] arg0, @SuppressWarnings("unused") String arg1) throws CertificateException { } 66 | @Override 67 | public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/populator/AbstractWorkbookPopulator.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.populator; 2 | 3 | import java.text.ParseException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Calendar; 6 | import java.util.Date; 7 | import java.util.List; 8 | import java.util.Locale; 9 | 10 | import org.apache.poi.ss.usermodel.Cell; 11 | import org.apache.poi.ss.usermodel.CellStyle; 12 | import org.apache.poi.ss.usermodel.Row; 13 | import org.apache.poi.ss.usermodel.Sheet; 14 | import org.apache.poi.ss.usermodel.Workbook; 15 | import org.openmf.mifos.dataimport.dto.Office; 16 | import org.openmf.mifos.dataimport.dto.client.CompactClient; 17 | import org.openmf.mifos.dataimport.dto.client.CompactGroup; 18 | 19 | public abstract class AbstractWorkbookPopulator implements WorkbookPopulator { 20 | 21 | protected void writeInt(int colIndex, Row row, int value) { 22 | row.createCell(colIndex).setCellValue(value); 23 | } 24 | 25 | protected void writeLong(int colIndex, Row row, long value) { 26 | row.createCell(colIndex).setCellValue(value); 27 | } 28 | 29 | protected void writeString(int colIndex, Row row, String value) { 30 | row.createCell(colIndex).setCellValue(value); 31 | } 32 | 33 | protected void writeDouble(int colIndex, Row row, double value) { 34 | row.createCell(colIndex).setCellValue(value); 35 | } 36 | 37 | protected void writeFormula(int colIndex, Row row, String formula) { 38 | row.createCell(colIndex).setCellType(Cell.CELL_TYPE_FORMULA); 39 | row.createCell(colIndex).setCellFormula(formula); 40 | } 41 | 42 | protected CellStyle getDateCellStyle(Workbook workbook) { 43 | CellStyle dateCellStyle = workbook.createCellStyle(); 44 | short df = workbook.createDataFormat().getFormat("dd/mm/yy"); 45 | dateCellStyle.setDataFormat(df); 46 | return dateCellStyle; 47 | } 48 | 49 | protected void writeDate(int colIndex, Row row, String value, CellStyle dateCellStyle) { 50 | try { 51 | //To make validation between functions inclusive. 52 | Date date = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH).parse(value); 53 | Calendar cal = Calendar.getInstance(); 54 | cal.setTime(date); 55 | cal.set(Calendar.HOUR_OF_DAY, 0); 56 | cal.set(Calendar.MINUTE, 0); 57 | cal.set(Calendar.SECOND, 0); 58 | cal.set(Calendar.MILLISECOND, 0); 59 | Date dateWithoutTime = cal.getTime(); 60 | row.createCell(colIndex).setCellValue(dateWithoutTime); 61 | row.getCell(colIndex).setCellStyle(dateCellStyle); 62 | } catch (ParseException pe) { 63 | throw new IllegalArgumentException("ParseException"); 64 | } 65 | } 66 | 67 | protected void setClientAndGroupDateLookupTable(Sheet sheet, List clients, List groups, 68 | int nameCol, int activationDateCol) { 69 | Workbook workbook = sheet.getWorkbook(); 70 | CellStyle dateCellStyle = workbook.createCellStyle(); 71 | short df = workbook.createDataFormat().getFormat("dd/mm/yy"); 72 | dateCellStyle.setDataFormat(df); 73 | int rowIndex = 0; 74 | for(CompactClient client: clients) { 75 | Row row = sheet.getRow(++rowIndex); 76 | if(row == null) 77 | row = sheet.createRow(rowIndex); 78 | writeString(nameCol, row, client.getDisplayName().replaceAll("[ )(] ", "_") + "("+client.getId() + ")"); 79 | writeDate(activationDateCol, row, client.getActivationDate().get(2) + "/" + client.getActivationDate().get(1) + "/" + client.getActivationDate().get(0), dateCellStyle); 80 | } 81 | if(groups == null) 82 | return; 83 | for(CompactGroup group: groups) { 84 | Row row = sheet.getRow(++rowIndex); 85 | if(row == null) 86 | row = sheet.createRow(rowIndex); 87 | writeString(nameCol, row, group.getName().replaceAll("[ )(] ", "_")); 88 | writeDate(activationDateCol, row, group.getActivationDate().get(2) + "/" + group.getActivationDate().get(1) + "/" + group.getActivationDate().get(0), dateCellStyle); 89 | } 90 | } 91 | 92 | protected void setOfficeDateLookupTable(Sheet sheet, List offices, int officeNameCol, int activationDateCol) { 93 | Workbook workbook = sheet.getWorkbook(); 94 | CellStyle dateCellStyle = workbook.createCellStyle(); 95 | short df = workbook.createDataFormat().getFormat("dd/mm/yy"); 96 | dateCellStyle.setDataFormat(df); 97 | int rowIndex = 0; 98 | for(Office office:offices) { 99 | Row row = sheet.createRow(++rowIndex); 100 | writeString(officeNameCol, row, office.getName().trim().replaceAll("[ )(]", "_")); 101 | writeDate(activationDateCol, row, ""+office.getOpeningDate().get(2)+"/"+office.getOpeningDate().get(1)+"/"+office.getOpeningDate().get(0), dateCellStyle); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/populator/ExtrasSheetPopulator.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.populator; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Iterator; 5 | import java.util.List; 6 | 7 | import org.apache.poi.ss.usermodel.Row; 8 | import org.apache.poi.ss.usermodel.Sheet; 9 | import org.apache.poi.ss.usermodel.Workbook; 10 | import org.openmf.mifos.dataimport.dto.Currency; 11 | import org.openmf.mifos.dataimport.dto.PaymentType; 12 | import org.openmf.mifos.dataimport.dto.loan.Fund; 13 | import org.openmf.mifos.dataimport.handler.Result; 14 | import org.openmf.mifos.dataimport.http.RestClient; 15 | 16 | import com.google.gson.Gson; 17 | import com.google.gson.JsonArray; 18 | import com.google.gson.JsonElement; 19 | import com.google.gson.JsonParser; 20 | 21 | public class ExtrasSheetPopulator extends AbstractWorkbookPopulator { 22 | 23 | private final RestClient client; 24 | 25 | private String content; 26 | 27 | private List funds; 28 | private List paymentTypes; 29 | private List currencies; 30 | 31 | private static final int FUND_ID_COL = 0; 32 | private static final int FUND_NAME_COL = 1; 33 | private static final int PAYMENT_TYPE_ID_COL = 2; 34 | private static final int PAYMENT_TYPE_NAME_COL = 3; 35 | private static final int CURRENCY_CODE_COL = 4; 36 | private static final int CURRENCY_NAME_COL = 5; 37 | 38 | public ExtrasSheetPopulator(RestClient client) { 39 | this.client = client; 40 | } 41 | 42 | @Override 43 | public Result downloadAndParse() { 44 | Result result = new Result(); 45 | try { 46 | client.createAuthToken(); 47 | funds = new ArrayList(); 48 | content = client.get("funds"); 49 | Gson gson = new Gson(); 50 | JsonElement json = new JsonParser().parse(content); 51 | JsonArray array = json.getAsJsonArray(); 52 | Iterator iterator = array.iterator(); 53 | while (iterator.hasNext()) { 54 | json = iterator.next(); 55 | Fund fund = gson.fromJson(json, Fund.class); 56 | funds.add(fund); 57 | } 58 | paymentTypes = new ArrayList(); 59 | content = client.get("paymenttypes"); 60 | json = new JsonParser().parse(content); 61 | array = json.getAsJsonArray(); 62 | iterator = array.iterator(); 63 | while (iterator.hasNext()) { 64 | json = iterator.next(); 65 | PaymentType paymentType = gson 66 | .fromJson(json, PaymentType.class); 67 | paymentTypes.add(paymentType); 68 | } 69 | 70 | currencies = new ArrayList(); 71 | content = client.get("currencies"); 72 | array = new JsonParser().parse(content).getAsJsonObject() 73 | .get("selectedCurrencyOptions").getAsJsonArray(); 74 | iterator = array.iterator(); 75 | while (iterator.hasNext()) { 76 | json = iterator.next(); 77 | Currency currency = gson.fromJson(json, Currency.class); 78 | currencies.add(currency); 79 | } 80 | } catch (Exception e) { 81 | result.addError(e.getMessage()); 82 | e.printStackTrace(); 83 | } 84 | return result; 85 | } 86 | 87 | @Override 88 | public Result populate(Workbook workbook) { 89 | Result result = new Result(); 90 | try { 91 | int fundRowIndex = 1; 92 | Sheet extrasSheet = workbook.createSheet("Extras"); 93 | setLayout(extrasSheet); 94 | for (Fund fund : funds) { 95 | Row row = extrasSheet.createRow(fundRowIndex++); 96 | writeInt(FUND_ID_COL, row, fund.getId()); 97 | writeString(FUND_NAME_COL, row, fund.getName()); 98 | } 99 | int paymentTypeRowIndex = 1; 100 | for (PaymentType paymentType : paymentTypes) { 101 | Row row; 102 | if (paymentTypeRowIndex < fundRowIndex) 103 | row = extrasSheet.getRow(paymentTypeRowIndex++); 104 | else 105 | row = extrasSheet.createRow(paymentTypeRowIndex++); 106 | writeInt(PAYMENT_TYPE_ID_COL, row, paymentType.getId()); 107 | writeString(PAYMENT_TYPE_NAME_COL, row, paymentType.getName() 108 | .trim().replaceAll("[ )(]", "_")); 109 | } 110 | int currencyCodeRowIndex = 1; 111 | for (Currency currencie : currencies) { 112 | Row row; 113 | if (currencyCodeRowIndex < paymentTypeRowIndex) 114 | row = extrasSheet.getRow(currencyCodeRowIndex++); 115 | else 116 | row = extrasSheet.createRow(currencyCodeRowIndex++); 117 | 118 | writeString(CURRENCY_NAME_COL, row, currencie.getName().trim() 119 | .replaceAll("[ )(]", "_")); 120 | writeString(CURRENCY_CODE_COL, row, currencie.getCode()); 121 | } 122 | extrasSheet.protectSheet(""); 123 | } catch (Exception e) { 124 | result.addError(e.getMessage()); 125 | e.printStackTrace(); 126 | } 127 | return result; 128 | } 129 | 130 | private void setLayout(Sheet worksheet) { 131 | worksheet.setColumnWidth(FUND_ID_COL, 4000); 132 | worksheet.setColumnWidth(FUND_NAME_COL, 7000); 133 | worksheet.setColumnWidth(PAYMENT_TYPE_ID_COL, 4000); 134 | worksheet.setColumnWidth(PAYMENT_TYPE_NAME_COL, 7000); 135 | worksheet.setColumnWidth(CURRENCY_NAME_COL, 7000); 136 | worksheet.setColumnWidth(CURRENCY_CODE_COL, 7000); 137 | Row rowHeader = worksheet.createRow(0); 138 | rowHeader.setHeight((short) 500); 139 | writeString(FUND_ID_COL, rowHeader, "Fund ID"); 140 | writeString(FUND_NAME_COL, rowHeader, "Name"); 141 | writeString(PAYMENT_TYPE_ID_COL, rowHeader, "Payment Type ID"); 142 | writeString(PAYMENT_TYPE_NAME_COL, rowHeader, "Payment Type Name"); 143 | writeString(CURRENCY_NAME_COL, rowHeader, "Currency Type "); 144 | writeString(CURRENCY_CODE_COL, rowHeader, "Currency Code "); 145 | } 146 | 147 | public Integer getFundsSize() { 148 | return funds.size(); 149 | } 150 | 151 | public Integer getPaymentTypesSize() { 152 | return paymentTypes.size(); 153 | } 154 | 155 | public List getFunds() { 156 | return funds; 157 | } 158 | 159 | public List getPaymentTypes() { 160 | return paymentTypes; 161 | } 162 | 163 | public Integer getCurrencysSize() { 164 | return currencies.size(); 165 | } 166 | 167 | } 168 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/populator/GlAccountSheetPopulator.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.populator; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Iterator; 5 | import java.util.List; 6 | 7 | import org.apache.poi.ss.usermodel.Row; 8 | import org.apache.poi.ss.usermodel.Sheet; 9 | import org.apache.poi.ss.usermodel.Workbook; 10 | import org.openmf.mifos.dataimport.dto.accounting.GlAccount; 11 | import org.openmf.mifos.dataimport.handler.Result; 12 | import org.openmf.mifos.dataimport.http.RestClient; 13 | 14 | import com.google.gson.Gson; 15 | import com.google.gson.JsonArray; 16 | import com.google.gson.JsonElement; 17 | import com.google.gson.JsonParser; 18 | 19 | public class GlAccountSheetPopulator extends AbstractWorkbookPopulator { 20 | 21 | 22 | private final RestClient client; 23 | private static final int ID_COL = 0; 24 | private static final int ACCOUNT_NAME_COL = 1; 25 | 26 | private List glAccounts; 27 | private ArrayList glAccountNames; 28 | 29 | public GlAccountSheetPopulator(RestClient client) { 30 | this.client = client; 31 | } 32 | 33 | private String content; 34 | 35 | @Override 36 | public Result downloadAndParse() { 37 | Result result = new Result(); 38 | try { 39 | client.createAuthToken(); 40 | glAccounts = new ArrayList(); 41 | glAccountNames = new ArrayList(); 42 | content = client.get("glaccounts"); 43 | parseglAccounts(); 44 | } catch (Exception e) { 45 | result.addError(e.getMessage()); 46 | 47 | } 48 | return result; 49 | } 50 | 51 | private void parseglAccounts() { 52 | Gson gson = new Gson(); 53 | JsonElement json = new JsonParser().parse(content); 54 | JsonArray array = json.getAsJsonArray(); 55 | Iterator iterator = array.iterator(); 56 | while(iterator.hasNext()) { 57 | json = iterator.next(); 58 | GlAccount glAccount = gson.fromJson(json, GlAccount.class); 59 | if(glAccount.getUsage().getValue().equals("DETAIL")) 60 | glAccounts.add(glAccount); 61 | glAccountNames.add(glAccount.getName().trim().replaceAll("[ )(]", "_")); 62 | } 63 | } 64 | 65 | @Override 66 | public Result populate(Workbook workbook) { 67 | Result result = new Result(); 68 | try{ 69 | int rowIndex = 1; 70 | Sheet glAccountSheet = workbook.createSheet("GlAccounts"); 71 | setLayout(glAccountSheet); 72 | 73 | populateglAccounts(glAccountSheet, rowIndex); 74 | glAccountSheet.protectSheet(""); 75 | } catch (Exception e) { 76 | result.addError(e.getMessage()); 77 | 78 | } 79 | return result; 80 | } 81 | 82 | private void populateglAccounts(Sheet GlAccountSheet, int rowIndex) { 83 | for(GlAccount glAccount:glAccounts) { 84 | Row row = GlAccountSheet.createRow(rowIndex); 85 | writeInt(ID_COL, row, glAccount.getId()); 86 | writeString(ACCOUNT_NAME_COL, row, glAccount.getName().trim().replaceAll("[ )(]", "_")); 87 | rowIndex++; 88 | } 89 | } 90 | 91 | private void setLayout(Sheet worksheet) { 92 | worksheet.setColumnWidth(ID_COL, 2000); 93 | worksheet.setColumnWidth(ACCOUNT_NAME_COL, 7000); 94 | Row rowHeader = worksheet.createRow(0); 95 | rowHeader.setHeight((short)500); 96 | writeString(ID_COL, rowHeader, "Gl Account ID"); 97 | writeString(ACCOUNT_NAME_COL, rowHeader, "Gl Account Name"); 98 | } 99 | 100 | public Integer getGlAccountNamesSize(){ 101 | return glAccountNames.size(); 102 | } 103 | } 104 | 105 | 106 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/populator/OfficeSheetPopulator.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.populator; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Iterator; 5 | import java.util.List; 6 | 7 | import org.apache.poi.ss.usermodel.Row; 8 | import org.apache.poi.ss.usermodel.Sheet; 9 | import org.apache.poi.ss.usermodel.Workbook; 10 | import org.openmf.mifos.dataimport.dto.Office; 11 | import org.openmf.mifos.dataimport.handler.Result; 12 | import org.openmf.mifos.dataimport.http.RestClient; 13 | 14 | import com.google.gson.Gson; 15 | import com.google.gson.JsonArray; 16 | import com.google.gson.JsonElement; 17 | import com.google.gson.JsonParser; 18 | 19 | public class OfficeSheetPopulator extends AbstractWorkbookPopulator { 20 | 21 | 22 | 23 | private final RestClient client; 24 | 25 | private String content; 26 | 27 | private List offices; 28 | private ArrayList officeNames; 29 | 30 | private static final int ID_COL = 0; 31 | private static final int OFFICE_NAME_COL = 1; 32 | 33 | public OfficeSheetPopulator(RestClient client) { 34 | this.client = client; 35 | } 36 | 37 | @Override 38 | public Result downloadAndParse() { 39 | Result result = new Result(); 40 | try { 41 | client.createAuthToken(); 42 | offices = new ArrayList(); 43 | officeNames = new ArrayList(); 44 | content = client.get("offices?limit=-1"); 45 | parseOffices(); 46 | } catch (Exception e) { 47 | result.addError(e.getMessage()); 48 | 49 | e.printStackTrace(); 50 | } 51 | return result; 52 | } 53 | 54 | @Override 55 | public Result populate(Workbook workbook) { 56 | Result result = new Result(); 57 | try{ 58 | int rowIndex = 1; 59 | Sheet officeSheet = workbook.createSheet("Offices"); 60 | setLayout(officeSheet); 61 | 62 | populateOffices(officeSheet, rowIndex); 63 | officeSheet.protectSheet(""); 64 | } catch (Exception e) { 65 | result.addError(e.getMessage()); 66 | 67 | e.printStackTrace(); 68 | } 69 | return result; 70 | } 71 | 72 | private void populateOffices(Sheet officeSheet, int rowIndex) { 73 | for(Office office:offices) { 74 | Row row = officeSheet.createRow(rowIndex); 75 | writeInt(ID_COL, row, office.getId()); 76 | writeString(OFFICE_NAME_COL, row, office.getName().trim().replaceAll("[ )(]", "_")); 77 | rowIndex++; 78 | } 79 | } 80 | 81 | private void parseOffices() { 82 | Gson gson = new Gson(); 83 | JsonElement json = new JsonParser().parse(content); 84 | JsonArray array = json.getAsJsonArray(); 85 | Iterator iterator = array.iterator(); 86 | while(iterator.hasNext()) { 87 | json = iterator.next(); 88 | Office office = gson.fromJson(json, Office.class); 89 | offices.add(office); 90 | officeNames.add(office.getName().trim().replaceAll("[ )(]", "_")); 91 | } 92 | } 93 | 94 | private void setLayout(Sheet worksheet) { 95 | worksheet.setColumnWidth(ID_COL, 2000); 96 | worksheet.setColumnWidth(OFFICE_NAME_COL, 7000); 97 | Row rowHeader = worksheet.createRow(0); 98 | rowHeader.setHeight((short)500); 99 | writeString(ID_COL, rowHeader, "ID"); 100 | writeString(OFFICE_NAME_COL, rowHeader, "Name"); 101 | } 102 | 103 | public List getOffices() { 104 | return offices; 105 | } 106 | 107 | public String[] getOfficeNames() { 108 | return officeNames.toArray(new String[officeNames.size()]); 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/populator/WorkbookPopulator.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.populator; 2 | 3 | import org.apache.poi.ss.usermodel.Workbook; 4 | import org.openmf.mifos.dataimport.handler.Result; 5 | 6 | public interface WorkbookPopulator { 7 | 8 | Result downloadAndParse(); 9 | 10 | Result populate(Workbook workbook); 11 | 12 | } -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/populator/WorkbookPopulatorFactory.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.populator; 2 | 3 | import java.io.IOException; 4 | 5 | import org.openmf.mifos.dataimport.http.MifosRestClient; 6 | import org.openmf.mifos.dataimport.populator.accounting.AddJournalEntriesWorkbookPopulator; 7 | import org.openmf.mifos.dataimport.populator.client.CenterWorkbookPopulator; 8 | import org.openmf.mifos.dataimport.populator.client.ClientWorkbookPopulator; 9 | import org.openmf.mifos.dataimport.populator.client.GroupWorkbookPopulator; 10 | import org.openmf.mifos.dataimport.populator.loan.AddGuarantorWorkbookPopulator; 11 | import org.openmf.mifos.dataimport.populator.loan.LoanProductSheetPopulator; 12 | import org.openmf.mifos.dataimport.populator.loan.LoanRepaymentWorkbookPopulator; 13 | import org.openmf.mifos.dataimport.populator.loan.LoanWorkbookPopulator; 14 | import org.openmf.mifos.dataimport.populator.savings.ClosingOfSavingsAccountsWorkbookPopulator; 15 | import org.openmf.mifos.dataimport.populator.savings.FixedDepositProductSheetPopulator; 16 | import org.openmf.mifos.dataimport.populator.savings.FixedDepositWorkbookPopulator; 17 | import org.openmf.mifos.dataimport.populator.savings.RecurringDepositProductSheetPopulator; 18 | import org.openmf.mifos.dataimport.populator.savings.RecurringDepositTransactionWorkbookPopulator; 19 | import org.openmf.mifos.dataimport.populator.savings.RecurringDepositWorkbookPopulator; 20 | import org.openmf.mifos.dataimport.populator.savings.SavingsProductSheetPopulator; 21 | import org.openmf.mifos.dataimport.populator.savings.SavingsTransactionWorkbookPopulator; 22 | import org.openmf.mifos.dataimport.populator.savings.SavingsWorkbookPopulator; 23 | 24 | public class WorkbookPopulatorFactory { 25 | 26 | 27 | public static final WorkbookPopulator createWorkbookPopulator(String parameter, String template) throws IOException { 28 | MifosRestClient restClient = new MifosRestClient(); 29 | 30 | if(template.trim().equals("client")) 31 | return new ClientWorkbookPopulator (parameter, new OfficeSheetPopulator(restClient), new PersonnelSheetPopulator(Boolean.FALSE, restClient)); 32 | else if(template.trim().equals("groups")) 33 | return new GroupWorkbookPopulator(new OfficeSheetPopulator(restClient), new PersonnelSheetPopulator(Boolean.FALSE, restClient), new CenterSheetPopulator(restClient), 34 | new ClientSheetPopulator(restClient)); 35 | else if(template.trim().equals("centers")) 36 | return new CenterWorkbookPopulator(new OfficeSheetPopulator(restClient), new PersonnelSheetPopulator(Boolean.FALSE, restClient)); 37 | else if(template.trim().equals("loan")) 38 | return new LoanWorkbookPopulator(new OfficeSheetPopulator(restClient), new ClientSheetPopulator(restClient), new GroupSheetPopulator(restClient), 39 | new PersonnelSheetPopulator(Boolean.TRUE, restClient), new LoanProductSheetPopulator(restClient), new ExtrasSheetPopulator(restClient)); 40 | else if(template.trim().equals("loanRepaymentHistory")) 41 | return new LoanRepaymentWorkbookPopulator(restClient, new OfficeSheetPopulator(restClient), new ClientSheetPopulator(restClient), new ExtrasSheetPopulator(restClient)); 42 | else if(template.trim().equals("savings")) 43 | return new SavingsWorkbookPopulator(new OfficeSheetPopulator(restClient), new ClientSheetPopulator(restClient), new GroupSheetPopulator(restClient), 44 | new PersonnelSheetPopulator(Boolean.TRUE, restClient), new SavingsProductSheetPopulator(restClient)); 45 | else if(template.trim().equals("savingsTransactionHistory")) 46 | return new SavingsTransactionWorkbookPopulator(restClient, new OfficeSheetPopulator(restClient), new ClientSheetPopulator(restClient), new ExtrasSheetPopulator(restClient)); 47 | else if(template.trim().equals("fixedDeposit")) 48 | return new FixedDepositWorkbookPopulator(new OfficeSheetPopulator(restClient), new ClientSheetPopulator(restClient), 49 | new PersonnelSheetPopulator(Boolean.TRUE, restClient), new FixedDepositProductSheetPopulator(restClient)); 50 | else if(template.trim().equals("recurringDeposit")) 51 | return new RecurringDepositWorkbookPopulator(new OfficeSheetPopulator(restClient), new ClientSheetPopulator(restClient), 52 | new PersonnelSheetPopulator(Boolean.TRUE, restClient), new RecurringDepositProductSheetPopulator(restClient)); 53 | else if(template.trim().equals("recurringDepositHistory")) 54 | return new RecurringDepositTransactionWorkbookPopulator(restClient, new OfficeSheetPopulator(restClient), new ClientSheetPopulator(restClient), new ExtrasSheetPopulator(restClient)); 55 | else if(template.trim().equals("closingOfSavingsAccounts")) 56 | return new ClosingOfSavingsAccountsWorkbookPopulator(restClient, new OfficeSheetPopulator(restClient), new ClientSheetPopulator(restClient)); 57 | else if(template.trim().equals("journalentries")) 58 | return new AddJournalEntriesWorkbookPopulator(new OfficeSheetPopulator(restClient), new GlAccountSheetPopulator(restClient),new ExtrasSheetPopulator(restClient)); 59 | else if(template.trim().equals("guarantor")) 60 | 61 | return new AddGuarantorWorkbookPopulator(restClient, new OfficeSheetPopulator(restClient), new ClientSheetPopulator(restClient)); 62 | throw new IllegalArgumentException("Can't find populator."); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/utils/StringUtils.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.utils; 2 | 3 | public class StringUtils { 4 | 5 | public static final boolean isBlank(String input) { 6 | return input == null || input.trim().equals(""); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/web/ApplicationContextListner.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.web; 2 | 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.IOException; 6 | import java.util.Properties; 7 | 8 | import javax.servlet.ServletContextEvent; 9 | import javax.servlet.ServletContextListener; 10 | import javax.servlet.annotation.WebListener; 11 | 12 | import org.openmf.mifos.dataimport.utils.StringUtils; 13 | 14 | @WebListener 15 | public class ApplicationContextListner implements ServletContextListener { 16 | 17 | @Override 18 | public void contextInitialized(@SuppressWarnings("unused") ServletContextEvent sce) { 19 | Properties prop = new Properties(); 20 | String homeDirectory = System.getProperty("user.home"); 21 | FileInputStream fis = null; 22 | try { 23 | File file = new File(homeDirectory + "/dataimport.properties"); 24 | fis = new FileInputStream(file); 25 | prop.load(fis); 26 | readAndSetAsSysProp("mifos.endpoint", "http://localhost:8080", prop); 27 | readAndSetAsSysProp("mifos.user.id", "mifos", prop); 28 | readAndSetAsSysProp("mifos.password", "testmifos", prop); 29 | readAndSetAsSysProp("mifos.tenant.id", "default", prop); 30 | fis.close(); 31 | } catch (IOException e) { 32 | throw new IllegalStateException(e); 33 | } 34 | } 35 | 36 | 37 | private void readAndSetAsSysProp(String key, String defaultValue, Properties prop) { 38 | String value = prop.getProperty(key); 39 | if(!StringUtils.isBlank(value)) { 40 | System.setProperty(key, value); 41 | } else { 42 | System.setProperty(key, defaultValue); 43 | } 44 | } 45 | 46 | 47 | @Override 48 | public void contextDestroyed(@SuppressWarnings("unused") ServletContextEvent sce) { 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/web/DataImportServlet.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.web; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.io.OutputStream; 6 | import java.io.OutputStreamWriter; 7 | 8 | import javax.servlet.ServletException; 9 | import javax.servlet.annotation.MultipartConfig; 10 | import javax.servlet.annotation.WebServlet; 11 | import javax.servlet.http.HttpServlet; 12 | import javax.servlet.http.HttpServletRequest; 13 | import javax.servlet.http.HttpServletResponse; 14 | import javax.servlet.http.Part; 15 | 16 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 17 | import org.apache.poi.ss.usermodel.Workbook; 18 | import org.openmf.mifos.dataimport.handler.DataImportHandler; 19 | import org.openmf.mifos.dataimport.handler.ImportFormatType; 20 | import org.openmf.mifos.dataimport.handler.ImportHandlerFactory; 21 | import org.openmf.mifos.dataimport.handler.Result; 22 | 23 | @WebServlet(name = "DataImportServlet", urlPatterns = {"/import"}) 24 | @MultipartConfig(maxFileSize=10000000, fileSizeThreshold=10000000) 25 | public class DataImportServlet extends HttpServlet { 26 | 27 | private static final long serialVersionUID = 1L; 28 | 29 | @Override 30 | public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 31 | 32 | String filename = ""; 33 | try { 34 | Part part = request.getPart("file"); 35 | filename = readFileName(part); 36 | ImportFormatType.of(part.getContentType()); 37 | InputStream content = part.getInputStream(); 38 | Workbook workbook = new HSSFWorkbook(content); 39 | DataImportHandler handler = ImportHandlerFactory.createImportHandler(workbook); 40 | Result result = parseAndUpload(handler); 41 | writeResult(workbook, result, response); 42 | } catch (IOException e) { 43 | throw new ServletException("Cannot import request. " + filename, e); 44 | } 45 | 46 | } 47 | 48 | private String readFileName(Part part) { 49 | String filename = null; 50 | for (String s : part.getHeader("content-disposition").split(";")) { 51 | if (s.trim().startsWith("filename")) { 52 | filename = s.split("=")[1].replaceAll("\"", ""); 53 | } 54 | } 55 | return filename; 56 | } 57 | 58 | private Result parseAndUpload(DataImportHandler handler) throws IOException { 59 | Result result = handler.parse(); 60 | if (result.isSuccess()) { 61 | result = handler.upload(); 62 | } 63 | return result; 64 | } 65 | 66 | private void writeResult(Workbook workbook, Result result, HttpServletResponse response) throws IOException { 67 | OutputStream stream = response.getOutputStream(); 68 | OutputStreamWriter out = new OutputStreamWriter(stream,"UTF-8"); 69 | if(result.isSuccess()) { 70 | out.write("" 71 | + "" 72 | + "" 80 | + "" 81 | + "
Data Import Tool
<" 82 | + "div id='container'>" 83 | + "
" 84 | + "
Import complete
" 85 | + "" 86 | + "
" 87 | + "" 88 | + "" 89 | + ""); 90 | } else { 91 | // for(String e : result.getErrors()) 92 | // logger.debug("Failed: " + e); 93 | String fileName = "Re-Upload.xls"; 94 | response.setContentType("application/vnd.ms-excel"); 95 | response.setHeader("Content-Disposition", "attachment;filename="+fileName); 96 | workbook.write(stream); 97 | } 98 | out.flush(); 99 | out.close(); 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/org/openmf/mifos/dataimport/web/DownloadServiceServlet.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.web; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | import java.io.OutputStreamWriter; 6 | 7 | import javax.servlet.ServletException; 8 | import javax.servlet.annotation.WebServlet; 9 | import javax.servlet.http.HttpServlet; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | 13 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 14 | import org.apache.poi.ss.usermodel.Workbook; 15 | import org.openmf.mifos.dataimport.handler.Result; 16 | import org.openmf.mifos.dataimport.populator.WorkbookPopulator; 17 | import org.openmf.mifos.dataimport.populator.WorkbookPopulatorFactory; 18 | 19 | @WebServlet(name = "DownloadServiceServlet", urlPatterns = {"/download"}) 20 | public class DownloadServiceServlet extends HttpServlet { 21 | 22 | private static final long serialVersionUID = 2L; 23 | 24 | @Override 25 | public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 26 | 27 | String fileName = request.getParameter("template"); 28 | try{ 29 | String parameter = null; 30 | if(request.getParameter("template").equals("client")) 31 | parameter = request.getParameter("clientType"); 32 | WorkbookPopulator populator = WorkbookPopulatorFactory.createWorkbookPopulator(parameter, fileName); 33 | Workbook workbook = new HSSFWorkbook(); 34 | Result result = downloadAndPopulate(workbook, populator); 35 | fileName=fileName+".xls"; 36 | writeToStream(workbook, result, response, fileName); 37 | }catch(Exception e){ 38 | e.printStackTrace(); 39 | throw new ServletException("Cannot download template - " + fileName, e); 40 | } 41 | } 42 | 43 | Result downloadAndPopulate(Workbook workbook, WorkbookPopulator populator) throws IOException { 44 | Result result = populator.downloadAndParse(); 45 | if(result.isSuccess()) { 46 | result = populator.populate(workbook); 47 | } 48 | return result; 49 | } 50 | 51 | void writeToStream(Workbook workbook, Result result, HttpServletResponse response, String fileName) throws IOException { 52 | OutputStream stream = response.getOutputStream(); 53 | if(result.isSuccess()) { 54 | response.setContentType("application/vnd.ms-excel"); 55 | response.setHeader("Content-Disposition", "attachment;filename="+fileName); 56 | workbook.write(stream); 57 | stream.flush(); 58 | stream.close(); 59 | } 60 | else { 61 | OutputStreamWriter out = new OutputStreamWriter(stream,"UTF-8"); 62 | for(String e : result.getErrors()) { 63 | out.write(e); 64 | } 65 | out.flush(); 66 | out.close(); 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/test/java/org/openmf/mifos/dataimport/handler/CenterDataImportHandlerTest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 7 | import org.apache.poi.ss.usermodel.Workbook; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.mockito.Mock; 12 | import org.mockito.runners.MockitoJUnitRunner; 13 | import org.openmf.mifos.dataimport.dto.client.Center; 14 | import org.openmf.mifos.dataimport.dto.client.WeeklyMeeting; 15 | import org.openmf.mifos.dataimport.handler.client.CenterDataImportHandler; 16 | import org.openmf.mifos.dataimport.http.RestClient; 17 | 18 | @RunWith(MockitoJUnitRunner.class) 19 | public class CenterDataImportHandlerTest { 20 | 21 | @Mock 22 | RestClient restClient; 23 | 24 | @Test 25 | public void shouldParsecentersAndMeetings() throws IOException { 26 | InputStream is = this.getClass().getClassLoader().getResourceAsStream("client/centers.xls"); 27 | Workbook book = new HSSFWorkbook(is); 28 | CenterDataImportHandler handler = new CenterDataImportHandler(book, restClient); 29 | Result result = handler.parse(); 30 | Assert.assertTrue(result.isSuccess()); 31 | Assert.assertEquals(1, handler.getCenters().size()); 32 | Center center = handler.getCenters().get(0); 33 | WeeklyMeeting meeting = (WeeklyMeeting)handler.getMeetings().get(0); 34 | Assert.assertEquals("Test center X", center.getName()); 35 | Assert.assertEquals("1", center.getOfficeId()); 36 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Offices"), "Head_Office").toString()); 37 | Assert.assertEquals("1", center.getStaffId()); 38 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Staff"), "Sahil Chatta").toString()); 39 | Assert.assertEquals("4531",center.getExternalId()); 40 | Assert.assertEquals("true", center.isActive()); 41 | Assert.assertEquals("13 September 2013", center.getActivationDate()); 42 | Assert.assertEquals("14 September 2013", meeting.getStartDate()); 43 | Assert.assertEquals("true", meeting.isRepeating()); 44 | Assert.assertEquals("2", meeting.getFrequency()); 45 | Assert.assertEquals("2", meeting.getInterval()); 46 | Assert.assertEquals("3", meeting.getRepeatsOnDay()); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/org/openmf/mifos/dataimport/handler/ClientImportHandlerTest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 7 | import org.apache.poi.ss.usermodel.Workbook; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.mockito.Mock; 12 | import org.mockito.runners.MockitoJUnitRunner; 13 | import org.openmf.mifos.dataimport.dto.client.Client; 14 | import org.openmf.mifos.dataimport.dto.client.CorporateClient; 15 | import org.openmf.mifos.dataimport.handler.client.ClientDataImportHandler; 16 | import org.openmf.mifos.dataimport.http.RestClient; 17 | 18 | @RunWith(MockitoJUnitRunner.class) 19 | public class ClientImportHandlerTest { 20 | 21 | @Mock 22 | RestClient restClient; 23 | 24 | @Test 25 | public void shouldParseIndividualClient() throws IOException { 26 | 27 | InputStream is = this.getClass().getClassLoader().getResourceAsStream("client/client.xls"); 28 | Workbook book = new HSSFWorkbook(is); 29 | ClientDataImportHandler handler = new ClientDataImportHandler(book, restClient); 30 | Result result = handler.parse(); 31 | Assert.assertTrue(result.isSuccess()); 32 | Assert.assertEquals(1, handler.getClients().size()); 33 | Client client = handler.getClients().get(0); 34 | Assert.assertEquals("David", client.getFirstName()); 35 | Assert.assertEquals("Spade", client.getLastName()); 36 | Assert.assertEquals("7", client.getOfficeId()); 37 | Assert.assertEquals("7", handler.getIdByName(book.getSheet("Offices"), "Branch_5").toString()); 38 | Assert.assertEquals("3", client.getStaffId()); 39 | Assert.assertEquals("3", handler.getIdByName(book.getSheet("Staff"), "Raul Albiol").toString()); 40 | Assert.assertEquals("19 May 2013", client.getActivationDate()); 41 | Assert.assertEquals("true", client.isActive()); 42 | } 43 | 44 | @Test 45 | public void shouldParseCorporateClient() throws IOException { 46 | InputStream is = this.getClass().getClassLoader().getResourceAsStream("client/client-corporate.xls"); 47 | Workbook book = new HSSFWorkbook(is); 48 | ClientDataImportHandler handler = new ClientDataImportHandler(book, restClient); 49 | Result result = handler.parse(); 50 | Assert.assertTrue(result.isSuccess()); 51 | Assert.assertEquals(1, handler.getClients().size()); 52 | CorporateClient client = (CorporateClient) handler.getClients().get(0); 53 | Assert.assertEquals("Remo Fernandez", client.getFullName()); 54 | Assert.assertEquals("9", client.getOfficeId()); 55 | Assert.assertEquals("9", handler.getIdByName(book.getSheet("Offices"), "Branch_7").toString()); 56 | Assert.assertEquals("4", client.getStaffId()); 57 | Assert.assertEquals("4", handler.getIdByName(book.getSheet("Staff"), "Tomas Rosicky").toString()); 58 | Assert.assertEquals("19 May 2013", client.getActivationDate()); 59 | Assert.assertEquals("true", client.isActive()); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/test/java/org/openmf/mifos/dataimport/handler/GroupDataImportHandlerTest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 7 | import org.apache.poi.ss.usermodel.Workbook; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.mockito.Mock; 12 | import org.mockito.runners.MockitoJUnitRunner; 13 | import org.openmf.mifos.dataimport.dto.client.Group; 14 | import org.openmf.mifos.dataimport.dto.client.WeeklyMeeting; 15 | import org.openmf.mifos.dataimport.handler.client.GroupDataImportHandler; 16 | import org.openmf.mifos.dataimport.http.RestClient; 17 | 18 | @RunWith(MockitoJUnitRunner.class) 19 | public class GroupDataImportHandlerTest { 20 | 21 | @Mock 22 | RestClient restClient; 23 | 24 | @Test 25 | public void shouldParseGroupsAndMeetings() throws IOException { 26 | InputStream is = this.getClass().getClassLoader().getResourceAsStream("client/groups.xls"); 27 | Workbook book = new HSSFWorkbook(is); 28 | GroupDataImportHandler handler = new GroupDataImportHandler(book, restClient); 29 | Result result = handler.parse(); 30 | Assert.assertTrue(result.isSuccess()); 31 | Assert.assertEquals(1, handler.getGroups().size()); 32 | Group group = handler.getGroups().get(0); 33 | WeeklyMeeting meeting = (WeeklyMeeting)handler.getMeetings().get(0); 34 | Assert.assertEquals("Test Group X", group.getName()); 35 | Assert.assertEquals("1", group.getOfficeId()); 36 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Offices"), "Head_Office").toString()); 37 | Assert.assertEquals("1", group.getStaffId()); 38 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Staff"), "Sahil Chatta").toString()); 39 | Assert.assertEquals("1", group.getCenterId()); 40 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Center"), "Center1").toString()); 41 | Assert.assertEquals("4531",group.getExternalId()); 42 | Assert.assertEquals("true", group.isActive()); 43 | Assert.assertEquals("13 September 2013", group.getActivationDate()); 44 | Assert.assertEquals("1", group.getClientMembers().get(0)); 45 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Clients"), "Arsene K Wenger").toString()); 46 | 47 | Assert.assertEquals("14 September 2013", meeting.getStartDate()); 48 | Assert.assertEquals("true", meeting.isRepeating()); 49 | Assert.assertEquals("2", meeting.getFrequency()); 50 | Assert.assertEquals("2", meeting.getInterval()); 51 | Assert.assertEquals("3", meeting.getRepeatsOnDay()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/org/openmf/mifos/dataimport/handler/LoanImportHandlerTest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 7 | import org.apache.poi.ss.usermodel.Workbook; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.mockito.Mock; 12 | import org.mockito.runners.MockitoJUnitRunner; 13 | import org.openmf.mifos.dataimport.dto.Approval; 14 | import org.openmf.mifos.dataimport.dto.Transaction; 15 | import org.openmf.mifos.dataimport.dto.loan.GroupLoan; 16 | import org.openmf.mifos.dataimport.dto.loan.Loan; 17 | import org.openmf.mifos.dataimport.handler.loan.LoanDataImportHandler; 18 | import org.openmf.mifos.dataimport.http.RestClient; 19 | 20 | @RunWith(MockitoJUnitRunner.class) 21 | public class LoanImportHandlerTest { 22 | 23 | @Mock 24 | RestClient restClient; 25 | 26 | @Test 27 | public void shouldParseLoan() throws IOException { 28 | 29 | InputStream is = this.getClass().getClassLoader().getResourceAsStream("loan/loan.xls"); 30 | Workbook book = new HSSFWorkbook(is); 31 | LoanDataImportHandler handler = new LoanDataImportHandler(book, restClient); 32 | Result result = handler.parse(); 33 | Assert.assertTrue(result.isSuccess()); 34 | Assert.assertEquals(2, handler.getLoans().size()); 35 | Assert.assertEquals(2, handler.getApprovalDates().size()); 36 | Assert.assertEquals(2, handler.getDisbursalDates().size()); 37 | Assert.assertEquals(2, handler.getLoanRepayments().size()); 38 | Loan loan = handler.getLoans().get(0); 39 | Approval loanApproval = handler.getApprovalDates().get(0); 40 | // DisbursalData loanDisbursal = handler.getDisbursalDates().get(0); 41 | Transaction loanRepayment = handler.getLoanRepayments().get(0); 42 | Assert.assertEquals("1", loan.getClientId()); 43 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Clients"), "Arsene K Wenger").toString()); 44 | Assert.assertEquals("1", loan.getProductId()); 45 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Products"), "HM").toString()); 46 | Assert.assertEquals("1", loan.getLoanOfficerId()); 47 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Staff"), "Sahil Chatta").toString()); 48 | Assert.assertEquals("02 July 2013", loan.getSubmittedOnDate()); 49 | Assert.assertEquals("1", loan.getFundId()); 50 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Extras"), "Fund1").toString()); 51 | Assert.assertEquals("15000.0", loan.getPrincipal()); 52 | Assert.assertEquals("10", loan.getNumberOfRepayments()); 53 | Assert.assertEquals("2", loan.getRepaymentEvery()); 54 | Assert.assertEquals("2", loan.getRepaymentFrequencyType()); 55 | Assert.assertEquals("20", loan.getLoanTermFrequency()); 56 | Assert.assertEquals("2", loan.getLoanTermFrequencyType()); 57 | Assert.assertEquals("7", loan.getInterestRatePerPeriod()); 58 | Assert.assertEquals("1", loan.getAmortizationType()); 59 | Assert.assertEquals("0", loan.getInterestType()); 60 | Assert.assertEquals("1", loan.getInterestCalculationPeriodType()); 61 | Assert.assertEquals("3", loan.getInArrearsTolerance()); 62 | Assert.assertEquals("4", loan.getTransactionProcessingStrategyId()); 63 | Assert.assertEquals("1", loan.getGraceOnPrincipalPayment()); 64 | Assert.assertEquals("2", loan.getGraceOnInterestPayment()); 65 | Assert.assertEquals("1", loan.getGraceOnInterestCharged()); 66 | Assert.assertEquals("04 July 2013", loan.getInterestChargedFromDate()); 67 | Assert.assertEquals("01 August 2013", loan.getRepaymentsStartingFromDate()); 68 | Assert.assertEquals("03 July 2013", loanApproval.getApprovedOnDate()); 69 | //Assert.assertEquals("04 July 2013", loanDisbursal.getActualDisbursementDate()); 70 | //Assert.assertEquals("10", loanDisbursal.getPaymentTypeId()); 71 | Assert.assertEquals("10", handler.getIdByName(book.getSheet("Extras"), "Cash").toString()); 72 | Assert.assertEquals("3000.0", loanRepayment.getTransactionAmount()); 73 | Assert.assertEquals("01 September 2013", loanRepayment.getTransactionDate()); 74 | Assert.assertEquals("11", loanRepayment.getPaymentTypeId()); 75 | Assert.assertEquals("11", handler.getIdByName(book.getSheet("Extras"), "MPesa").toString()); 76 | Assert.assertEquals("4531",loan.getExternalId()); 77 | GroupLoan groupLoan = (GroupLoan)handler.getLoans().get(1); 78 | Assert.assertEquals("1", groupLoan.getGroupId()); 79 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Groups"), "Group 1").toString()); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/test/java/org/openmf/mifos/dataimport/handler/LoanRepaymentImportHandlerTest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 7 | import org.apache.poi.ss.usermodel.Workbook; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.mockito.Mock; 12 | import org.mockito.runners.MockitoJUnitRunner; 13 | import org.openmf.mifos.dataimport.dto.Transaction; 14 | import org.openmf.mifos.dataimport.handler.loan.LoanRepaymentDataImportHandler; 15 | import org.openmf.mifos.dataimport.http.RestClient; 16 | 17 | @RunWith(MockitoJUnitRunner.class) 18 | public class LoanRepaymentImportHandlerTest { 19 | 20 | @Mock 21 | RestClient restClient; 22 | 23 | @Test 24 | public void shouldParseLoanRepayment() throws IOException { 25 | 26 | InputStream is = this.getClass().getClassLoader().getResourceAsStream("loan/loanRepaymentHistory.xls"); 27 | Workbook book = new HSSFWorkbook(is); 28 | LoanRepaymentDataImportHandler handler = new LoanRepaymentDataImportHandler(book, restClient); 29 | Result result = handler.parse(); 30 | Assert.assertTrue(result.isSuccess()); 31 | Assert.assertEquals(2, handler.getLoanRepayments().size()); 32 | Transaction loanRepayment = handler.getLoanRepayments().get(0); 33 | Transaction loanRepaymentWithoutId = handler.getLoanRepayments().get(1); 34 | Assert.assertEquals("1", loanRepayment.getAccountId().toString()); 35 | Assert.assertEquals("1", loanRepaymentWithoutId.getAccountId().toString()); 36 | Assert.assertEquals("1300.0", loanRepayment.getTransactionAmount()); 37 | Assert.assertEquals("700.0", loanRepaymentWithoutId.getTransactionAmount()); 38 | Assert.assertEquals("01 September 2013", loanRepayment.getTransactionDate()); 39 | Assert.assertEquals("03 September 2013", loanRepaymentWithoutId.getTransactionDate()); 40 | Assert.assertEquals("11", loanRepayment.getPaymentTypeId()); 41 | Assert.assertEquals("11", handler.getIdByName(book.getSheet("Extras"), "MPesa").toString()); 42 | Assert.assertEquals("10", loanRepaymentWithoutId.getPaymentTypeId()); 43 | Assert.assertEquals("10", handler.getIdByName(book.getSheet("Extras"), "Cash").toString()); 44 | Assert.assertEquals("12", loanRepayment.getAccountNumber()); 45 | Assert.assertEquals("13", loanRepayment.getCheckNumber()); 46 | Assert.assertEquals("14", loanRepayment.getRoutingCode()); 47 | Assert.assertEquals("15", loanRepayment.getReceiptNumber()); 48 | Assert.assertEquals("16", loanRepayment.getBankNumber()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/org/openmf/mifos/dataimport/handler/SavingsImportHandlerTest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 7 | import org.apache.poi.ss.usermodel.Workbook; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.mockito.Mock; 12 | import org.mockito.runners.MockitoJUnitRunner; 13 | import org.openmf.mifos.dataimport.dto.Approval; 14 | import org.openmf.mifos.dataimport.dto.savings.GroupSavingsAccount; 15 | import org.openmf.mifos.dataimport.dto.savings.SavingsAccount; 16 | import org.openmf.mifos.dataimport.dto.savings.SavingsActivation; 17 | import org.openmf.mifos.dataimport.handler.savings.SavingsDataImportHandler; 18 | import org.openmf.mifos.dataimport.http.RestClient; 19 | 20 | @RunWith(MockitoJUnitRunner.class) 21 | public class SavingsImportHandlerTest { 22 | 23 | @Mock 24 | RestClient restClient; 25 | 26 | @Test 27 | public void shouldParseSavingsAccount() throws IOException { 28 | 29 | InputStream is = this.getClass().getClassLoader().getResourceAsStream("savings/savings.xls"); 30 | Workbook book = new HSSFWorkbook(is); 31 | SavingsDataImportHandler handler = new SavingsDataImportHandler(book, restClient); 32 | Result result = handler.parse(); 33 | Assert.assertTrue(result.isSuccess()); 34 | Assert.assertEquals(2, handler.getSavings().size()); 35 | Assert.assertEquals(2, handler.getApprovalDates().size()); 36 | Assert.assertEquals(2, handler.getActivationDates().size()); 37 | SavingsAccount savings = handler.getSavings().get(0); 38 | Approval savingsApproval = handler.getApprovalDates().get(0); 39 | SavingsActivation savingsActivation = handler.getActivationDates().get(0); 40 | 41 | Assert.assertEquals("1", savings.getClientId()); 42 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Clients"), "Arsene K Wenger").toString()); 43 | Assert.assertEquals("2", savings.getProductId()); 44 | Assert.assertEquals("2", handler.getIdByName(book.getSheet("Products"), "SP2").toString()); 45 | Assert.assertEquals("1", savings.getFieldOfficerId()); 46 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Staff"), "Sahil Chatta").toString()); 47 | Assert.assertEquals("01 August 2013", savings.getSubmittedOnDate()); 48 | Assert.assertEquals("10", savings.getNominalAnnualInterestRate()); 49 | Assert.assertEquals("4", savings.getInterestCompoundingPeriodType()); 50 | Assert.assertEquals("5", savings.getInterestPostingPeriodType()); 51 | Assert.assertEquals("2", savings.getInterestCalculationType()); 52 | Assert.assertEquals("365", savings.getInterestCalculationDaysInYearType()); 53 | Assert.assertEquals("1000", savings.getMinRequiredOpeningBalance()); 54 | Assert.assertEquals("1", savings.getLockinPeriodFrequency()); 55 | Assert.assertEquals("0", savings.getLockinPeriodFrequencyType()); 56 | 57 | Assert.assertEquals("02 August 2013", savingsApproval.getApprovedOnDate()); 58 | Assert.assertEquals("03 August 2013", savingsActivation.getActivatedOnDate()); 59 | 60 | GroupSavingsAccount groupSavings = (GroupSavingsAccount)handler.getSavings().get(1); 61 | Assert.assertEquals("1", groupSavings.getGroupId()); 62 | Assert.assertEquals("1", handler.getIdByName(book.getSheet("Groups"), "Group 1").toString()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/test/java/org/openmf/mifos/dataimport/handler/SavingsTransactionDataImportHandlerTest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.handler; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | 6 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 7 | import org.apache.poi.ss.usermodel.Workbook; 8 | import org.junit.Assert; 9 | import org.junit.Test; 10 | import org.junit.runner.RunWith; 11 | import org.mockito.Mock; 12 | import org.mockito.runners.MockitoJUnitRunner; 13 | import org.openmf.mifos.dataimport.dto.Transaction; 14 | import org.openmf.mifos.dataimport.handler.savings.SavingsTransactionDataImportHandler; 15 | import org.openmf.mifos.dataimport.http.RestClient; 16 | 17 | @RunWith(MockitoJUnitRunner.class) 18 | public class SavingsTransactionDataImportHandlerTest { 19 | 20 | 21 | @Mock 22 | RestClient restClient; 23 | 24 | @Test 25 | public void shouldParseSavingsTransaction() throws IOException { 26 | 27 | InputStream is = this.getClass().getClassLoader().getResourceAsStream("savings/savingsTransactionHistory.xls"); 28 | Workbook book = new HSSFWorkbook(is); 29 | SavingsTransactionDataImportHandler handler = new SavingsTransactionDataImportHandler(book, restClient); 30 | Result result = handler.parse(); 31 | Assert.assertTrue(result.isSuccess()); 32 | Assert.assertEquals(2, handler.getSavingsTransactions().size()); 33 | Transaction savingsTransaction = handler.getSavingsTransactions().get(0); 34 | Transaction savingsTransactionWithoutId = handler.getSavingsTransactions().get(1); 35 | Assert.assertEquals("7", savingsTransaction.getAccountId().toString()); 36 | Assert.assertEquals("7", savingsTransactionWithoutId.getAccountId().toString()); 37 | Assert.assertEquals("100.0", savingsTransaction.getTransactionAmount()); 38 | Assert.assertEquals("75.0", savingsTransactionWithoutId.getTransactionAmount()); 39 | Assert.assertEquals("06 September 2013", savingsTransaction.getTransactionDate()); 40 | Assert.assertEquals("07 September 2013", savingsTransactionWithoutId.getTransactionDate()); 41 | Assert.assertEquals("15", savingsTransaction.getPaymentTypeId()); 42 | Assert.assertEquals("15", handler.getIdByName(book.getSheet("Extras"), "Cash").toString()); 43 | Assert.assertEquals("17", savingsTransactionWithoutId.getPaymentTypeId()); 44 | Assert.assertEquals("17", handler.getIdByName(book.getSheet("Extras"), "Check").toString()); 45 | Assert.assertEquals("12", savingsTransaction.getAccountNumber()); 46 | Assert.assertEquals("13", savingsTransaction.getCheckNumber()); 47 | Assert.assertEquals("14", savingsTransaction.getRoutingCode()); 48 | Assert.assertEquals("15", savingsTransaction.getReceiptNumber()); 49 | Assert.assertEquals("16", savingsTransaction.getBankNumber()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/org/openmf/mifos/dataimport/populator/CenterSheetPopulatorTest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.populator; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 8 | import org.apache.poi.ss.usermodel.Row; 9 | import org.apache.poi.ss.usermodel.Sheet; 10 | import org.apache.poi.ss.usermodel.Workbook; 11 | import org.junit.Assert; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | import org.mockito.Mock; 15 | import org.mockito.Mockito; 16 | import org.mockito.runners.MockitoJUnitRunner; 17 | import org.openmf.mifos.dataimport.dto.client.CompactCenter; 18 | import org.openmf.mifos.dataimport.handler.Result; 19 | import org.openmf.mifos.dataimport.http.RestClient; 20 | 21 | @RunWith(MockitoJUnitRunner.class) 22 | public class CenterSheetPopulatorTest { 23 | 24 | CenterSheetPopulator populator; 25 | 26 | @Mock 27 | RestClient restClient; 28 | 29 | //private String[] officeNameToBeginEndIndexesOfCenters; 30 | 31 | @Test 32 | public void shouldDownloadAndParseCenters() { 33 | 34 | Mockito.when(restClient.get("centers?limit=-1")).thenReturn("{\"totalFilteredRecords\": 1,\"pageItems\": [{\"id\": 1, \"name\": \"Center 1\", \"externalId\":" + 35 | " \"B1561\", \"status\": {\"id\": 300, \"code\": \"centerStatusType.active\", \"value\": \"Active\"},\"active\": true,\"activationDate\":" + 36 | " [2013,9,1], \"officeId\": 1, \"officeName\": \"Head Office\", \"staffId\": 1, \"staffName\": \"Chatta, Sahil\", \"hierarchy\": \".1.\"}]}"); 37 | 38 | Mockito.when(restClient.get("offices?limit=-1")).thenReturn("[{\"id\":1,\"name\":\"Head Office\",\"nameDecorated\":\"Head Office\",\"externalId\": \"1\"," + 39 | "\"openingDate\":[2009,1,1],\"hierarchy\": \".\"},{\"id\": 2,\"name\": \"Office1\",\"nameDecorated\": \"....Office1\",\"openingDate\":[2013,4,1]," + 40 | "\"hierarchy\": \".2.\",\"parentId\": 1,\"parentName\": \"Head Office\"}]"); 41 | 42 | populator = new CenterSheetPopulator(restClient); 43 | Result result = populator.downloadAndParse(); 44 | 45 | Assert.assertTrue(result.isSuccess()); 46 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("centers?limit=-1"); 47 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("offices?limit=-1"); 48 | 49 | List centers = populator.getCenters(); 50 | CompactCenter center = centers.get(0); 51 | Assert.assertEquals(1, centers.size()); 52 | 53 | Assert.assertEquals("1", center.getId().toString()); 54 | Assert.assertEquals("Center 1", center.getName()); 55 | Assert.assertEquals("Head Office", center.getOfficeName()); 56 | Assert.assertEquals("2013", center.getActivationDate().get(0).toString()); 57 | Assert.assertEquals("9", center.getActivationDate().get(1).toString()); 58 | Assert.assertEquals("1", center.getActivationDate().get(2).toString()); 59 | } 60 | 61 | @Test 62 | public void shouldPopulateCenterSheet() { 63 | 64 | Mockito.when(restClient.get("centers?limit=-1")).thenReturn("{\"totalFilteredRecords\": 1,\"pageItems\": [{\"id\": 1, \"name\": \"Center 1\", \"externalId\":" + 65 | " \"B1561\", \"status\": {\"id\": 300, \"code\": \"centerStatusType.active\", \"value\": \"Active\"},\"active\": true,\"activationDate\":" + 66 | " [2013,9,1], \"officeId\": 1, \"officeName\": \"Head Office\", \"staffId\": 1, \"staffName\": \"Chatta, Sahil\", \"hierarchy\": \".1.\"}]}"); 67 | 68 | Mockito.when(restClient.get("offices?limit=-1")).thenReturn("[{\"id\":1,\"name\":\"Head Office\",\"nameDecorated\":\"Head Office\",\"externalId\": \"1\"," + 69 | "\"openingDate\":[2009,1,1],\"hierarchy\": \".\"},{\"id\": 2,\"name\": \"Office1\",\"nameDecorated\": \"....Office1\",\"openingDate\":[2013,4,1]," + 70 | "\"hierarchy\": \".2.\",\"parentId\": 1,\"parentName\": \"Head Office\"}]"); 71 | 72 | populator = new CenterSheetPopulator(restClient); 73 | populator.downloadAndParse(); 74 | Workbook book = new HSSFWorkbook(); 75 | Result result = populator.populate(book); 76 | Integer[] officeNameToBeginEndIndexesOfCenters = populator.getOfficeNameToBeginEndIndexesOfCenters().get(0); 77 | Map> officeToCenters = populator.getOfficeToCenters(); 78 | Map centerNameToCenterId = populator.getCenterNameToCenterId(); 79 | 80 | Assert.assertTrue(result.isSuccess()); 81 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("centers?limit=-1"); 82 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("offices?limit=-1"); 83 | 84 | Sheet centerSheet = book.getSheet("Centers"); 85 | Row row = centerSheet.getRow(1); 86 | Assert.assertEquals("Head_Office", row.getCell(0).getStringCellValue()); 87 | Assert.assertEquals("Center 1", row.getCell(1).getStringCellValue()); 88 | Assert.assertEquals("1.0", "" + row.getCell(2).getNumericCellValue()); 89 | 90 | Assert.assertEquals("2", "" + officeNameToBeginEndIndexesOfCenters[0]); 91 | Assert.assertEquals("2", "" + officeNameToBeginEndIndexesOfCenters[1]); 92 | Assert.assertEquals("1", "" + officeToCenters.size()); 93 | Assert.assertEquals("1", "" + officeToCenters.get("Head_Office").size()); 94 | Assert.assertEquals("Center", "" + officeToCenters.get("Head_Office").get(0)); 95 | Assert.assertEquals("1", "" + centerNameToCenterId.size()); 96 | Assert.assertEquals("1", "" + centerNameToCenterId.get("Center 1")); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/test/java/org/openmf/mifos/dataimport/populator/CenterWorkbookPopulatorTest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.populator; 2 | 3 | import java.text.DateFormat; 4 | import java.text.SimpleDateFormat; 5 | 6 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 7 | import org.apache.poi.ss.usermodel.Row; 8 | import org.apache.poi.ss.usermodel.Sheet; 9 | import org.apache.poi.ss.usermodel.Workbook; 10 | import org.junit.Assert; 11 | import org.junit.Test; 12 | import org.junit.runner.RunWith; 13 | import org.mockito.Mock; 14 | import org.mockito.Mockito; 15 | import org.mockito.runners.MockitoJUnitRunner; 16 | import org.openmf.mifos.dataimport.handler.Result; 17 | import org.openmf.mifos.dataimport.http.RestClient; 18 | import org.openmf.mifos.dataimport.populator.client.CenterWorkbookPopulator; 19 | 20 | @RunWith(MockitoJUnitRunner.class) 21 | public class CenterWorkbookPopulatorTest { 22 | 23 | @Mock 24 | RestClient restClient; 25 | private static final int LOOKUP_OFFICE_NAME_COL = 251; 26 | private static final int LOOKUP_OFFICE_OPENING_DATE_COL = 252; 27 | 28 | @Test 29 | public void shouldPopulateCenterWorkbook() { 30 | Mockito.when(restClient.get("offices?limit=-1")).thenReturn("[{\"id\":1,\"name\":\"Head Office\",\"nameDecorated\":\"Head Office\",\"externalId\": \"1\"," + 31 | "\"openingDate\":[2009,1,1],\"hierarchy\": \".\"},{\"id\": 2,\"name\": \"Office1\",\"nameDecorated\": \"....Office1\",\"openingDate\":[2013,4,1]," + 32 | "\"hierarchy\": \".2.\",\"parentId\": 1,\"parentName\": \"Head Office\"}]"); 33 | Mockito.when(restClient.get("staff?limit=-1")).thenReturn("[{\"id\": 1, \"firstname\": \"Sahil\", \"lastname\": \"Chatta\", \"displayName\": \"Chatta, Sahil\"," + 34 | " \"officeId\": 1,\"officeName\": \"Head Office\", \"isLoanOfficer\": true },{\"id\": 2, \"firstname\": \"Edin\", \"lastname\": \"Dzeko\",\"displayName\":" + 35 | " \"Dzeko, Edin\",\"officeId\": 2,\"officeName\": \"Office1\",\"isLoanOfficer\": true}]"); 36 | /*Mockito.when(restClient.get("centers?limit=-1")).thenReturn("{\"totalFilteredRecords\": 2,\"pageItems\": [{\"id\": 1,\"accountNo\": \"000000001\"," + 37 | "\"status\": {\"id\": 300,\"code\": \"centerStatusType.active\",\"value\": \"Active\"},\"active\": true,\"activationDate\": [2013,7,1]," + 38 | "\"firstname\": \"Arsene\",\"middlename\": \"K\",\"lastname\": \"Wenger\",\"displayName\": \"Arsene K Wenger\",\"officeId\": 1," + 39 | "\"officeName\": \"Head Office\",\"staffId\": 1,\"staffName\": \"Chatta, Sahil\"},{\"id\": 2,\"accountNo\": \"000000002\"," + 40 | "\"status\": {\"id\": 300,\"code\": \"clientStatusType.active\",\"value\": \"Active\"},\"active\": true,\"activationDate\": [2013,7,1]," + 41 | "\"firstname\": \"Billy\",\"middlename\": \"T\",\"lastname\": \"Bob\",\"displayName\": \"Billy T Bob\",\"officeId\": 2,\"officeName\": \"Office1\"," + 42 | "\"staffId\": 2,\"staffName\": \"Dzeko, Edin\"}]}");*/ 43 | 44 | Boolean onlyLoanOfficers = Boolean.FALSE; 45 | CenterWorkbookPopulator centerWorkbookPopulator = new CenterWorkbookPopulator(new OfficeSheetPopulator(restClient), 46 | new PersonnelSheetPopulator(onlyLoanOfficers, restClient) ); 47 | centerWorkbookPopulator.downloadAndParse(); 48 | Workbook centerWorkbook = new HSSFWorkbook(); 49 | Result result = centerWorkbookPopulator.populate(centerWorkbook); 50 | Assert.assertTrue(result.isSuccess()); 51 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("offices?limit=-1"); 52 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("staff?limit=-1"); 53 | //Mockito.verify(restClient, Mockito.atLeastOnce()).get("clients?limit=-1");*/ 54 | 55 | Sheet centerSheet = centerWorkbook.getSheet("Centers"); 56 | Row row = centerSheet.getRow(0); 57 | 58 | //If test fails, also check if column letters embedded in formulas in setDefault and setRules have changed or not. 59 | Assert.assertEquals("Center Name*", row.getCell(0).getStringCellValue()); 60 | Assert.assertEquals("Office Name*", row.getCell(1).getStringCellValue()); 61 | Assert.assertEquals("Staff Name*", row.getCell(2).getStringCellValue()); 62 | Assert.assertEquals("External ID", row.getCell(3).getStringCellValue()); 63 | Assert.assertEquals("Active*", row.getCell(4).getStringCellValue()); 64 | Assert.assertEquals("Activation Date*", row.getCell(5).getStringCellValue()); 65 | Assert.assertEquals("Meeting Start Date* (On or After)", row.getCell(6).getStringCellValue()); 66 | Assert.assertEquals("Repeat*", row.getCell(7).getStringCellValue()); 67 | Assert.assertEquals("Frequency*", row.getCell(8).getStringCellValue()); 68 | Assert.assertEquals("Interval*", row.getCell(9).getStringCellValue()); 69 | Assert.assertEquals("Repeats On*", row.getCell(10).getStringCellValue()); 70 | //Assert.assertEquals("Client Names* (Enter in consecutive cells horizontally)", row.getCell(14).getStringCellValue()); 71 | Assert.assertEquals("Office Name", row.getCell(LOOKUP_OFFICE_NAME_COL).getStringCellValue()); 72 | Assert.assertEquals("Opening Date", row.getCell(LOOKUP_OFFICE_OPENING_DATE_COL).getStringCellValue()); 73 | 74 | //Date Lookup Table test 75 | DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy"); 76 | row = centerSheet.getRow(1); 77 | Assert.assertEquals("Head_Office", row.getCell(LOOKUP_OFFICE_NAME_COL).getStringCellValue()); 78 | Assert.assertEquals("01 January 2009", dateFormat.format(row.getCell(LOOKUP_OFFICE_OPENING_DATE_COL).getDateCellValue())); 79 | row = centerSheet.getRow(2); 80 | Assert.assertEquals("Office1", row.getCell(LOOKUP_OFFICE_NAME_COL).getStringCellValue()); 81 | Assert.assertEquals("01 April 2013", dateFormat.format(row.getCell(LOOKUP_OFFICE_OPENING_DATE_COL).getDateCellValue())); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/test/java/org/openmf/mifos/dataimport/populator/ClientWorkbookPopulatorTest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.populator; 2 | 3 | import java.text.DateFormat; 4 | import java.text.SimpleDateFormat; 5 | 6 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 7 | import org.apache.poi.ss.usermodel.Row; 8 | import org.apache.poi.ss.usermodel.Sheet; 9 | import org.apache.poi.ss.usermodel.Workbook; 10 | import org.junit.Assert; 11 | import org.junit.Test; 12 | import org.junit.runner.RunWith; 13 | import org.mockito.Mock; 14 | import org.mockito.Mockito; 15 | import org.mockito.runners.MockitoJUnitRunner; 16 | import org.openmf.mifos.dataimport.handler.Result; 17 | import org.openmf.mifos.dataimport.http.RestClient; 18 | import org.openmf.mifos.dataimport.populator.client.ClientWorkbookPopulator; 19 | 20 | @RunWith(MockitoJUnitRunner.class) 21 | public class ClientWorkbookPopulatorTest { 22 | 23 | @Mock 24 | RestClient restClient; 25 | 26 | private static final int RELATIONAL_OFFICE_NAME_COL = 16; 27 | private static final int RELATIONAL_OFFICE_OPENING_DATE_COL = 17; 28 | 29 | @Test 30 | public void shouldPopulateClientWorkbook() { 31 | 32 | Mockito.when(restClient.get("offices?limit=-1")).thenReturn("[{\"id\":1,\"name\":\"Head Office\",\"nameDecorated\":\"Head Office\",\"externalId\": \"1\"," + 33 | "\"openingDate\":[2009,1,1],\"hierarchy\": \".\"},{\"id\": 2,\"name\": \"Office1\",\"nameDecorated\": \"....Office1\",\"openingDate\":[2013,4,1]," + 34 | "\"hierarchy\": \".2.\",\"parentId\": 1,\"parentName\": \"Head Office\"}]"); 35 | Mockito.when(restClient.get("staff?limit=-1")).thenReturn("[{\"id\": 1, \"firstname\": \"Sahil\", \"lastname\": \"Chatta\", \"displayName\": \"Chatta, Sahil\"," + 36 | " \"officeId\": 1,\"officeName\": \"Head Office\", \"isLoanOfficer\": true },{\"id\": 2, \"firstname\": \"Edin\", \"lastname\": \"Dzeko\",\"displayName\":" + 37 | " \"Dzeko, Edin\",\"officeId\": 2,\"officeName\": \"Office1\",\"isLoanOfficer\": true}]"); 38 | 39 | Boolean onlyLoanOfficers = Boolean.FALSE; 40 | ClientWorkbookPopulator individualClientWorkbookPopulator = new ClientWorkbookPopulator("individual", 41 | new OfficeSheetPopulator(restClient), new PersonnelSheetPopulator(onlyLoanOfficers, restClient)); 42 | ClientWorkbookPopulator corporateClientWorkbookPopulator = new ClientWorkbookPopulator("corporate", 43 | new OfficeSheetPopulator(restClient), new PersonnelSheetPopulator(onlyLoanOfficers, restClient)); 44 | individualClientWorkbookPopulator.downloadAndParse(); 45 | corporateClientWorkbookPopulator.downloadAndParse(); 46 | 47 | Workbook individualClientWorkbook = new HSSFWorkbook(); 48 | Workbook corporateClientWorkbook = new HSSFWorkbook(); 49 | Result result = individualClientWorkbookPopulator.populate(individualClientWorkbook); 50 | Assert.assertTrue(result.isSuccess()); 51 | result = corporateClientWorkbookPopulator.populate(corporateClientWorkbook); 52 | Assert.assertTrue(result.isSuccess()); 53 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("offices?limit=-1"); 54 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("staff?limit=-1"); 55 | 56 | Sheet individualClientSheet = individualClientWorkbook.getSheet("Clients"); 57 | Sheet corporateClientSheet = corporateClientWorkbook.getSheet("Clients"); 58 | Row row = individualClientSheet.getRow(0); 59 | 60 | //If test fails, also check if column letters embedded in formulas in setDefault and setRules have changed or not. 61 | Assert.assertEquals("First Name*", row.getCell(0).getStringCellValue()); 62 | Assert.assertEquals("Last Name*", row.getCell(1).getStringCellValue()); 63 | Assert.assertEquals("Middle Name", row.getCell(2).getStringCellValue()); 64 | Assert.assertEquals("Office Name*", row.getCell(3).getStringCellValue()); 65 | Assert.assertEquals("Staff Name*", row.getCell(4).getStringCellValue()); 66 | Assert.assertEquals("External ID", row.getCell(5).getStringCellValue()); 67 | Assert.assertEquals("Activation Date*", row.getCell(6).getStringCellValue()); 68 | Assert.assertEquals("Active*", row.getCell(7).getStringCellValue()); 69 | Assert.assertEquals("Office Name", row.getCell(RELATIONAL_OFFICE_NAME_COL).getStringCellValue()); 70 | Assert.assertEquals("Opening Date", row.getCell(RELATIONAL_OFFICE_OPENING_DATE_COL).getStringCellValue()); 71 | 72 | Assert.assertEquals("Full/Business Name*", corporateClientSheet.getRow(0).getCell(0).getStringCellValue()); 73 | 74 | //Date Lookup Table test 75 | DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy"); 76 | row = individualClientSheet.getRow(1); 77 | Assert.assertEquals("Head_Office", row.getCell(RELATIONAL_OFFICE_NAME_COL).getStringCellValue()); 78 | Assert.assertEquals("01 January 2009", dateFormat.format(row.getCell(RELATIONAL_OFFICE_OPENING_DATE_COL).getDateCellValue())); 79 | row = individualClientSheet.getRow(2); 80 | Assert.assertEquals("Office1", row.getCell(RELATIONAL_OFFICE_NAME_COL).getStringCellValue()); 81 | Assert.assertEquals("01 April 2013", dateFormat.format(row.getCell(RELATIONAL_OFFICE_OPENING_DATE_COL).getDateCellValue())); 82 | 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/test/java/org/openmf/mifos/dataimport/populator/ExtrasSheetPopulatorTest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.populator; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 6 | import org.apache.poi.ss.usermodel.Row; 7 | import org.apache.poi.ss.usermodel.Sheet; 8 | import org.apache.poi.ss.usermodel.Workbook; 9 | import org.junit.Assert; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.mockito.Mock; 13 | import org.mockito.Mockito; 14 | import org.mockito.runners.MockitoJUnitRunner; 15 | import org.openmf.mifos.dataimport.dto.PaymentType; 16 | import org.openmf.mifos.dataimport.dto.loan.Fund; 17 | import org.openmf.mifos.dataimport.handler.Result; 18 | import org.openmf.mifos.dataimport.http.RestClient; 19 | 20 | @RunWith(MockitoJUnitRunner.class) 21 | public class ExtrasSheetPopulatorTest { 22 | 23 | // SUT - System Under Test 24 | ExtrasSheetPopulator populator; 25 | 26 | @Mock 27 | RestClient restClient; 28 | 29 | @Test 30 | public void shouldDownloadAndParseFundsAndPaymentTypes() { 31 | 32 | Mockito.when(restClient.get("funds")).thenReturn("[{\"id\": 1,\"name\": \"Fund1\"}]"); 33 | Mockito.when(restClient.get("codes/12/codevalues")).thenReturn("[{\"id\": 10,\"name\": \"Cash\",\"position\": 1},{\"id\": 11,\"name\": \"MPesa\",\"position\": 2}]"); 34 | 35 | populator = new ExtrasSheetPopulator(restClient); 36 | Result result = populator.downloadAndParse(); 37 | List funds = populator.getFunds(); 38 | List paymentTypes = populator.getPaymentTypes(); 39 | Assert.assertEquals(1, funds.size()); 40 | Assert.assertEquals(2, paymentTypes.size()); 41 | Fund fund = funds.get(0); 42 | PaymentType paymentType = paymentTypes.get(1); 43 | 44 | Assert.assertTrue(result.isSuccess()); 45 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("funds"); 46 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("codes/12/codevalues"); 47 | Assert.assertEquals("1", fund.getId().toString()); 48 | Assert.assertEquals("Fund1", fund.getName()); 49 | Assert.assertEquals("11", paymentType.getId().toString()); 50 | Assert.assertEquals("MPesa", paymentType.getName()); 51 | } 52 | 53 | @Test 54 | public void shouldPopulateExtrasSheet() { 55 | 56 | Mockito.when(restClient.get("funds")).thenReturn("[{\"id\": 1,\"name\": \"Fund1\"}]"); 57 | Mockito.when(restClient.get("codes/12/codevalues")).thenReturn("[{\"id\": 10,\"name\": \"Cash\",\"position\": 1},{\"id\": 11,\"name\": \"MPesa\",\"position\": 2}]"); 58 | 59 | populator = new ExtrasSheetPopulator(restClient); 60 | populator.downloadAndParse(); 61 | Workbook book = new HSSFWorkbook(); 62 | Result result = populator.populate(book); 63 | 64 | Assert.assertTrue(result.isSuccess()); 65 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("funds"); 66 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("codes/12/codevalues"); 67 | 68 | Sheet extrasSheet = book.getSheet("Extras"); 69 | Row row = extrasSheet.getRow(1); 70 | Assert.assertEquals("1.0", "" + row.getCell(0).getNumericCellValue()); 71 | Assert.assertEquals("Fund1", row.getCell(1).getStringCellValue()); 72 | Assert.assertEquals("10.0", "" + row.getCell(2).getNumericCellValue()); 73 | Assert.assertEquals("Cash", row.getCell(3).getStringCellValue()); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/test/java/org/openmf/mifos/dataimport/populator/GroupSheetPopulatorTest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.populator; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 8 | import org.apache.poi.ss.usermodel.Row; 9 | import org.apache.poi.ss.usermodel.Sheet; 10 | import org.apache.poi.ss.usermodel.Workbook; 11 | import org.junit.Assert; 12 | import org.junit.Test; 13 | import org.junit.runner.RunWith; 14 | import org.mockito.Mock; 15 | import org.mockito.Mockito; 16 | import org.mockito.runners.MockitoJUnitRunner; 17 | import org.openmf.mifos.dataimport.dto.client.CompactGroup; 18 | import org.openmf.mifos.dataimport.handler.Result; 19 | import org.openmf.mifos.dataimport.http.RestClient; 20 | 21 | @RunWith(MockitoJUnitRunner.class) 22 | public class GroupSheetPopulatorTest { 23 | 24 | GroupSheetPopulator populator; 25 | 26 | @Mock 27 | RestClient restClient; 28 | 29 | @Test 30 | public void shouldDownloadAndParseGroups() { 31 | 32 | Mockito.when(restClient.get("groups?limit=-1")).thenReturn("{\"totalFilteredRecords\": 1,\"pageItems\": [{\"id\": 1, \"name\": \"Group 1\", \"externalId\":" + 33 | " \"B1561\", \"status\": {\"id\": 300, \"code\": \"clientStatusType.active\", \"value\": \"Active\"},\"active\": true,\"activationDate\":" + 34 | " [2013,9,1], \"officeId\": 1, \"officeName\": \"Head Office\", \"staffId\": 1, \"staffName\": \"Chatta, Sahil\", \"hierarchy\": \".1.\"}]}"); 35 | 36 | Mockito.when(restClient.get("offices?limit=-1")).thenReturn("[{\"id\":1,\"name\":\"Head Office\",\"nameDecorated\":\"Head Office\",\"externalId\": \"1\"," + 37 | "\"openingDate\":[2009,1,1],\"hierarchy\": \".\"},{\"id\": 2,\"name\": \"Office1\",\"nameDecorated\": \"....Office1\",\"openingDate\":[2013,4,1]," + 38 | "\"hierarchy\": \".2.\",\"parentId\": 1,\"parentName\": \"Head Office\"}]"); 39 | 40 | populator = new GroupSheetPopulator(restClient); 41 | Result result = populator.downloadAndParse(); 42 | 43 | Assert.assertTrue(result.isSuccess()); 44 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("groups?limit=-1"); 45 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("offices?limit=-1"); 46 | 47 | List groups = populator.getGroups(); 48 | CompactGroup group = groups.get(0); 49 | Assert.assertEquals(1, groups.size()); 50 | 51 | Assert.assertEquals("1", group.getId().toString()); 52 | Assert.assertEquals("Group 1", group.getName()); 53 | Assert.assertEquals("Head Office", group.getOfficeName()); 54 | Assert.assertEquals("2013", group.getActivationDate().get(0).toString()); 55 | Assert.assertEquals("9", group.getActivationDate().get(1).toString()); 56 | Assert.assertEquals("1", group.getActivationDate().get(2).toString()); 57 | } 58 | 59 | @Test 60 | public void shouldPopulateGroupSheet() { 61 | 62 | Mockito.when(restClient.get("groups?limit=-1")).thenReturn("{\"totalFilteredRecords\": 1,\"pageItems\": [{\"id\": 1, \"name\": \"Group 1\", \"externalId\":" + 63 | " \"B1561\", \"status\": {\"id\": 300, \"code\": \"clientStatusType.active\", \"value\": \"Active\"},\"active\": true,\"activationDate\":" + 64 | " [2013,9,1], \"officeId\": 1, \"officeName\": \"Head Office\", \"staffId\": 1, \"staffName\": \"Chatta, Sahil\", \"hierarchy\": \".1.\"}]}"); 65 | 66 | Mockito.when(restClient.get("offices?limit=-1")).thenReturn("[{\"id\":1,\"name\":\"Head Office\",\"nameDecorated\":\"Head Office\",\"externalId\": \"1\"," + 67 | "\"openingDate\":[2009,1,1],\"hierarchy\": \".\"},{\"id\": 2,\"name\": \"Office1\",\"nameDecorated\": \"....Office1\",\"openingDate\":[2013,4,1]," + 68 | "\"hierarchy\": \".2.\",\"parentId\": 1,\"parentName\": \"Head Office\"}]"); 69 | 70 | populator = new GroupSheetPopulator(restClient); 71 | populator.downloadAndParse(); 72 | Workbook book = new HSSFWorkbook(); 73 | Result result = populator.populate(book); 74 | Integer[] officeNameToBeginEndIndexesOfGroups = populator.getOfficeNameToBeginEndIndexesOfGroups().get(0); 75 | Map> officeToGroups = populator.getOfficeToGroups(); 76 | Map groupNameToGroupId = populator.getGroupNameToGroupId(); 77 | 78 | Assert.assertTrue(result.isSuccess()); 79 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("groups?limit=-1"); 80 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("offices?limit=-1"); 81 | 82 | Sheet groupSheet = book.getSheet("Groups"); 83 | Row row = groupSheet.getRow(1); 84 | Assert.assertEquals("Head_Office", row.getCell(0).getStringCellValue()); 85 | Assert.assertEquals("Group 1", row.getCell(1).getStringCellValue()); 86 | Assert.assertEquals("1.0", "" + row.getCell(2).getNumericCellValue()); 87 | 88 | Assert.assertEquals("2", "" + officeNameToBeginEndIndexesOfGroups[0]); 89 | Assert.assertEquals("2", "" + officeNameToBeginEndIndexesOfGroups[1]); 90 | Assert.assertEquals("1", "" + officeToGroups.size()); 91 | Assert.assertEquals("1", "" + officeToGroups.get("Head_Office").size()); 92 | Assert.assertEquals("Group 1", "" + officeToGroups.get("Head_Office").get(0)); 93 | Assert.assertEquals("1", "" + groupNameToGroupId.size()); 94 | Assert.assertEquals("1", "" + groupNameToGroupId.get("Group 1")); 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/test/java/org/openmf/mifos/dataimport/populator/OfficeSheetPopulatorTest.java: -------------------------------------------------------------------------------- 1 | package org.openmf.mifos.dataimport.populator; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; 6 | import org.apache.poi.ss.usermodel.Row; 7 | import org.apache.poi.ss.usermodel.Sheet; 8 | import org.apache.poi.ss.usermodel.Workbook; 9 | import org.junit.Assert; 10 | import org.junit.Test; 11 | import org.junit.runner.RunWith; 12 | import org.mockito.Mock; 13 | import org.mockito.Mockito; 14 | import org.mockito.runners.MockitoJUnitRunner; 15 | import org.openmf.mifos.dataimport.dto.Office; 16 | import org.openmf.mifos.dataimport.handler.Result; 17 | import org.openmf.mifos.dataimport.http.RestClient; 18 | 19 | @RunWith(MockitoJUnitRunner.class) 20 | public class OfficeSheetPopulatorTest { 21 | 22 | // SUT - System Under Test 23 | OfficeSheetPopulator populator; 24 | 25 | @Mock 26 | RestClient restClient; 27 | 28 | @Test 29 | public void shouldDownloadAndParseOffices() { 30 | 31 | Mockito.when(restClient.get("offices?limit=-1")).thenReturn("[{\"id\":1,\"name\":\"Head Office\",\"nameDecorated\":\"Head Office\",\"externalId\": \"1\"," + 32 | "\"openingDate\":[2009,1,1],\"hierarchy\": \".\"},{\"id\": 2,\"name\": \"Office1\",\"nameDecorated\": \"....Office1\",\"openingDate\":[2013,4,1]," + 33 | "\"hierarchy\": \".2.\",\"parentId\": 1,\"parentName\": \"Head Office\"}]"); 34 | 35 | populator = new OfficeSheetPopulator(restClient); 36 | Result result = populator.downloadAndParse(); 37 | 38 | Assert.assertTrue(result.isSuccess()); 39 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("offices?limit=-1"); 40 | List offices = populator.getOffices(); 41 | Assert.assertEquals(2, offices.size()); 42 | Office office = offices.get(1); 43 | Assert.assertEquals("2", office.getId().toString()); 44 | Assert.assertEquals("Office1", office.getName()); 45 | Assert.assertEquals("Head Office", office.getParentName()); 46 | Assert.assertEquals(".2.", office.getHierarchy()); 47 | Assert.assertEquals("2013", office.getOpeningDate().get(0).toString()); 48 | Assert.assertEquals("4", office.getOpeningDate().get(1).toString()); 49 | Assert.assertEquals("1", office.getOpeningDate().get(2).toString()); 50 | Assert.assertEquals(null, office.getExternalId()); 51 | } 52 | 53 | @Test 54 | public void shouldPopulateOfficeSheet() { 55 | 56 | Mockito.when(restClient.get("offices?limit=-1")).thenReturn("[{\"id\":1,\"name\":\"Head Office\",\"nameDecorated\":\"Head Office\",\"externalId\": \"1\"," + 57 | "\"openingDate\":[2009,1,1],\"hierarchy\": \".\"},{\"id\": 2,\"name\": \"Office1\",\"nameDecorated\": \"....Office1\",\"openingDate\":[2013,4,1]," + 58 | "\"hierarchy\": \".2.\",\"parentId\": 1,\"parentName\": \"Head Office\"}]"); 59 | 60 | populator = new OfficeSheetPopulator(restClient); 61 | populator.downloadAndParse(); 62 | Workbook book = new HSSFWorkbook(); 63 | Result result = populator.populate(book); 64 | 65 | Assert.assertTrue(result.isSuccess()); 66 | Mockito.verify(restClient, Mockito.atLeastOnce()).get("offices?limit=-1"); 67 | 68 | Sheet officeSheet = book.getSheet("Offices"); 69 | Row row = officeSheet.getRow(2); 70 | Assert.assertEquals("2.0", "" + row.getCell(0).getNumericCellValue()); 71 | Assert.assertEquals("Office1", row.getCell(1).getStringCellValue()); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/test/resources/client/center.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/src/test/resources/client/center.xls -------------------------------------------------------------------------------- /src/test/resources/client/client-corporate.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/src/test/resources/client/client-corporate.xls -------------------------------------------------------------------------------- /src/test/resources/client/client.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/src/test/resources/client/client.xls -------------------------------------------------------------------------------- /src/test/resources/client/groups.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/src/test/resources/client/groups.xls -------------------------------------------------------------------------------- /src/test/resources/loan/loan.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/src/test/resources/loan/loan.xls -------------------------------------------------------------------------------- /src/test/resources/loan/loanRepaymentHistory.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/src/test/resources/loan/loanRepaymentHistory.xls -------------------------------------------------------------------------------- /src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/test/resources/savings/savings.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/src/test/resources/savings/savings.xls -------------------------------------------------------------------------------- /src/test/resources/savings/savingsTransactionHistory.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/openMF/DataImportTool/bc4b8e8a68d6b02d6ff06b73aad4bdba0e71a3a1/src/test/resources/savings/savingsTransactionHistory.xls -------------------------------------------------------------------------------- /travis_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | gradle clean check --------------------------------------------------------------------------------