...
Past history of loans is not captured.
Steps to getting setup
Create
...
base schema with
...
base data
From a blank mifos schema:
- apply latestbase-schema.sql
- apply latestbase-data.sql
- update 'admin' users password to 'testmifos'
...
Reference data populated by applying latestbase-data.sql and which must exist for application to work.
...
Code Block |
---|
package demo.migration; import java.io.InputStream; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; import org.joda.time.DateTime; import org.joda.time.LocalDate; import org.mifos.application.admin.servicefacade.AdminServiceFacade; import org.mifos.application.admin.servicefacade.OfficeServiceFacade; import org.mifos.application.admin.servicefacade.PersonnelServiceFacade; import org.mifos.application.master.business.MifosCurrency; import org.mifos.application.meeting.util.helpers.MeetingType; import org.mifos.application.meeting.util.helpers.RecurrenceType; import org.mifos.application.servicefacade.ClientServiceFacade; import org.mifos.application.servicefacade.GroupServiceFacade; import org.mifos.application.servicefacade.SavingsServiceFacade; import org.mifos.application.util.helpers.YesNoFlag; import org.mifos.calendar.DayOfWeek; import org.mifos.customers.client.business.NameType; import org.mifos.customers.util.helpers.CustomerStatus; import org.mifos.dto.domain.AddressDto; import org.mifos.dto.domain.ApplicableAccountFeeDto; import org.mifos.dto.domain.ClientCreationDetail; import org.mifos.dto.domain.GroupCreationDetail; import org.mifos.dto.domain.MeetingDetailsDto; import org.mifos.dto.domain.MeetingDto; import org.mifos.dto.domain.MeetingRecurrenceDto; import org.mifos.dto.domain.MeetingTypeDto; import org.mifos.dto.domain.SavingsDetailDto; import org.mifos.dto.screen.ClientFamilyDetailDto; import org.mifos.dto.screen.ClientNameDetailDto; import org.mifos.dto.screen.ClientPersonalDetailDto; import org.mifos.dto.screen.ProductDisplayDto; import org.mifos.framework.hibernate.helper.StaticHibernateUtil; import org.mifos.framework.util.helpers.Money; import org.mifos.security.AuthenticationAuthorizationServiceFacade; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class KMBIMigrationDemo { public static void main(String[] args) { System.setProperty("mifos.mode", "main"); String[] configLocations = new String[2]; configLocations[0] = "classpath:/org/mifos/config/resources/applicationContext.xml"; configLocations[1] = "classpath:META-INF/spring/QuestionnaireContext.xml"; // NOTE: Questionaire is coupled with applicationContext due to // QuestionaireMigration effort. ApplicationContext applicationContext = new ClassPathXmlApplicationContext(configLocations); // NOTE: need to ensure hibernateUtil is initialised StaticHibernateUtil.initialize(); // NOTE: need to set default currency final MifosCurrency RUPEE = new MifosCurrency((short) 2, "RUPEE", BigDecimal.valueOf(1.0), "INR"); Money.setDefaultCurrency(RUPEE); System.out.println("fetching service"); ClientServiceFacade clientServiceFacade = applicationContext.getBean(ClientServiceFacade.class); AuthenticationAuthorizationServiceFacade authenticationAuthorizationServiceFacade = applicationContext.getBean(AuthenticationAuthorizationServiceFacade.class); System.out.println("found"); // authenticate first of all authenticationAuthorizationServiceFacade.reloadUserDetailsForSecurityContext("mifos"); List<Short> selectedSavingProducts = new ArrayList<Short>(); String clientName = "CARMELITA DAGALLA ALCARAZ"; Short clientStatus = CustomerStatus.CLIENT_ACTIVE.getValue(); boolean trained = true; Date trainedOn = new DateTime().withDate(2010, 11, 30).toDate(); Date mfiJoiningDate = new DateTime().withDate(2010, 12, 06).toDate(); LocalDate activationDate = new LocalDate(mfiJoiningDate); String externalId = null; AddressDto address = new AddressDto("48M. SANTOS ST. SANTULAN", null, null, "MALABON CITY", null, "PHILIPPINES", "1470", null); Short formedBy = null; Date dateOfBirth = new DateTime().withDate(1954, 5, 14).toDate(); String governmentId = null; Short groupFlag = YesNoFlag.YES.getValue(); Integer salutation = Integer.valueOf(2001); //Mrs. see custom reference-data for salutations String firstName = "CARMELITA"; String middleName = "DAGALLA"; String lastName = "ALCARAZ"; String secondLastName = null; ClientNameDetailDto clientNameDetailDto = new ClientNameDetailDto(NameType.CLIENT.getValue(), salutation, firstName, middleName, lastName, secondLastName); Integer ethinicity = Integer.valueOf(19); // no Integer citizenship = Integer.valueOf(2006); // roman catholic Integer handicapped = null; Integer businessActivities = Integer.valueOf(2029); // sari sari Integer maritalStatus = Integer.valueOf(2005); // widow Integer educationLevel = Integer.valueOf(2018); // high school Short numChildren = Short.valueOf("1"); Short gender = Short.valueOf("50"); // female Short povertyStatus = null; ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(ethinicity, citizenship, handicapped, businessActivities, maritalStatus, educationLevel, numChildren, gender, povertyStatus); ClientNameDetailDto spouseFatherName = null; InputStream picture = null; List<ApplicableAccountFeeDto> feesToApply = new ArrayList<ApplicableAccountFeeDto>(); String parentGroupId = "5"; List<ClientNameDetailDto> familyNames = new ArrayList<ClientNameDetailDto>(); List<ClientFamilyDetailDto> familyDetails = new ArrayList<ClientFamilyDetailDto>(); Short loanOfficerId = null; // 2 inherit from parent Short officeId = null; // 11 inherit from parent ClientCreationDetail client = new ClientCreationDetail(selectedSavingProducts, clientName, clientStatus, mfiJoiningDate, externalId, address, formedBy, dateOfBirth, governmentId, trained, trainedOn, groupFlag, clientNameDetailDto, clientPersonalDetailDto, spouseFatherName, picture, feesToApply, parentGroupId, familyNames, familyDetails, loanOfficerId, officeId, activationDate); MeetingDto meeting = null; // will inherit meeting of parent group. List<SavingsDetailDto> savings = new ArrayList<SavingsDetailDto>(); clientServiceFacade.createNewClient(client, meeting, savings); } } |
Results of migrating client using API (taking into account activiation/mfiJoining date in past)
...