Search in sources :

Example 1 with MandatoryHiddenFieldsDto

use of org.mifos.dto.domain.MandatoryHiddenFieldsDto in project head by mifos.

the class SystemUserController method createUserFormBean.

public UserFormBean createUserFormBean(final Long officeId, final UserFormBean formBean) {
    OfficeDto selectedOffice = this.officeServiceFacade.retrieveOfficeById(officeId.shortValue());
    formBean.setOfficeId(officeId);
    formBean.setOfficeName(selectedOffice.getName());
    MandatoryHiddenFieldsDto dtoFields = this.adminServiceFacade.retrieveHiddenMandatoryFields();
    formBean.getAddress().setAddress1Mandatory(dtoFields.isMandatorySystemAddress1());
    formBean.getAddress().setAddress2Hidden(dtoFields.isHideSystemAddress2());
    formBean.getAddress().setAddress3Hidden(dtoFields.isHideSystemAddress3());
    formBean.getAddress().setCityDistrictHidden(dtoFields.isHideSystemCity());
    formBean.getAddress().setStateHidden(dtoFields.isHideSystemState());
    formBean.getAddress().setCountryHidden(dtoFields.isHideSystemCountry());
    formBean.getAddress().setPostalCodeHidden(dtoFields.isHideSystemPostalCode());
    DefinePersonnelDto userRefData = this.personnelServiceFacade.retrieveInfoForNewUserDefinition(officeId.shortValue());
    Map<String, String> genderOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getGenderList()) {
        genderOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setGenderOptions(genderOptions);
    Map<String, String> maritalStatusOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getMaritalStatusList()) {
        maritalStatusOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setMaritalStatusOptions(maritalStatusOptions);
    Map<String, String> preferredLanguageOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getLanguageList()) {
        preferredLanguageOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setPreferredLanguageOptions(preferredLanguageOptions);
    Map<String, String> userTitleOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getTitleList()) {
        userTitleOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setUserTitleOptions(userTitleOptions);
    Map<String, String> userHierarchyOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getPersonnelLevelList()) {
        userHierarchyOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setUserHierarchyOptions(userHierarchyOptions);
    Map<String, String> availableRolesOptions = new LinkedHashMap<String, String>();
    for (ListElement option : userRefData.getRolesList()) {
        availableRolesOptions.put(option.getId().toString(), option.getName());
    }
    formBean.setAvailableRolesOptions(availableRolesOptions);
    formBean.setSelectedRolesOptions(new LinkedHashMap<String, String>());
    DateTime today = new DateTime();
    formBean.setMfiJoiningDateDay(today.getDayOfMonth());
    formBean.setMfiJoiningDateMonth(today.getMonthOfYear());
    formBean.setMfiJoiningDateYear(today.getYearOfEra());
    return formBean;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) ListElement(org.mifos.dto.screen.ListElement) MandatoryHiddenFieldsDto(org.mifos.dto.domain.MandatoryHiddenFieldsDto) DefinePersonnelDto(org.mifos.dto.screen.DefinePersonnelDto) DateTime(org.joda.time.DateTime) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with MandatoryHiddenFieldsDto

use of org.mifos.dto.domain.MandatoryHiddenFieldsDto in project head by mifos.

the class LoanAccountController method retrieveLoanCreationDetails.

@SuppressWarnings("PMD")
public LoanCreationLoanDetailsDto retrieveLoanCreationDetails(int customerId, int productId, String eventId, String fileToDelete, LoanAccountFormBean formBean) {
    if ("newFileSelected".equals(eventId)) {
        if (formBean.getSelectedFile() != null) {
            CommonsMultipartFile file = formBean.getSelectedFile();
            formBean.getFiles().add(file);
            formBean.getFilesMetadata().add(new UploadedFileDto(file.getOriginalFilename(), file.getContentType(), (int) file.getSize(), formBean.getSelectedFileDescription()));
        }
        return dto;
    } else if ("fileDeleted".equals(eventId)) {
        if (fileToDelete != null) {
            int index = 0;
            for (CommonsMultipartFile formFile : formBean.getFiles()) {
                if (formFile.getOriginalFilename().equals(fileToDelete)) {
                    index = formBean.getFiles().indexOf(formFile);
                    break;
                }
            }
            if (index >= 0) {
                formBean.getFiles().remove(index);
                formBean.getFilesMetadata().remove(index);
            }
        }
        return dto;
    }
    MandatoryHiddenFieldsDto mandatoryHidden = this.adminServiceFacade.retrieveHiddenMandatoryFieldsToRead();
    dto = this.loanAccountServiceFacade.retrieveLoanDetailsForLoanAccountCreation(customerId, Integer.valueOf(productId).shortValue(), formBean.isRedoLoanAccount());
    formBean.setLocale(Locale.getDefault());
    formBean.setDigitsBeforeDecimalForInterest(dto.getAppConfig().getDigitsBeforeDecimalForInterest());
    formBean.setDigitsAfterDecimalForInterest(dto.getAppConfig().getDigitsAfterDecimalForInterest());
    formBean.setDigitsBeforeDecimalForMonetaryAmounts(dto.getAppConfig().getDigitsBeforeDecimalForMonetaryAmounts());
    formBean.setDigitsAfterDecimalForMonetaryAmounts(dto.getAppConfig().getDigitsAfterDecimalForMonetaryAmounts());
    formBean.setProductId(productId);
    formBean.setCustomerId(dto.getCustomerDetailDto().getCustomerId());
    formBean.setRepaymentScheduleIndependentOfCustomerMeeting(dto.isRepaymentIndependentOfMeetingEnabled());
    formBean.setGraceDuration(dto.getGracePeriodInInstallments());
    formBean.setMaxGraceDuration(dto.getGracePeriodInInstallments());
    if (dto.isRepaymentIndependentOfMeetingEnabled()) {
        // use loan product to default meeting details
        Integer recursEvery = dto.getLoanOfferingMeetingDetail().getMeetingDetailsDto().getEvery();
        Integer dayOfMonth = dto.getLoanOfferingMeetingDetail().getMeetingDetailsDto().getRecurrenceDetails().getDayNumber();
        Integer weekOfMonth = dto.getLoanOfferingMeetingDetail().getMeetingDetailsDto().getRecurrenceDetails().getWeekOfMonth();
        Integer dayOfWeek = dto.getLoanOfferingMeetingDetail().getMeetingDetailsDto().getRecurrenceDetails().getDayOfWeek();
        Integer recurrenceType = dto.getLoanOfferingMeetingDetail().getMeetingDetailsDto().getRecurrenceTypeId();
        Integer customerRecurrenceType = dto.getCustomerMeetingDetail().getMeetingDetailsDto().getRecurrenceTypeId();
        if (recurrenceType.equals(customerRecurrenceType)) {
            // if customer and product meeting frequencies are the same e.g. weekly or monthly, then default to customer details except for recurrence details
            dayOfMonth = dto.getCustomerMeetingDetail().getMeetingDetailsDto().getRecurrenceDetails().getDayNumber();
            weekOfMonth = dto.getCustomerMeetingDetail().getMeetingDetailsDto().getRecurrenceDetails().getWeekOfMonth();
            dayOfWeek = dto.getCustomerMeetingDetail().getMeetingDetailsDto().getRecurrenceDetails().getDayOfWeek();
        }
        // sometimes it seems customer meeting information can be setup wrong (i.e. has a day of month even though its weekly)
        if (recurrenceType == 1) {
            if (dateInformationIsAvailable(dayOfWeek)) {
                formBean.setWeeklyDetails(dayOfWeek, recursEvery);
            }
        } else if (recurrenceType == 2) {
            if (dateInformationIsAvailable(weekOfMonth) && dateInformationIsAvailable(dayOfWeek)) {
                formBean.setWeekOfMonthDetails(weekOfMonth, dayOfWeek, recursEvery);
            } else if (dateInformationIsAvailable(dayOfMonth)) {
                formBean.setDayOfMonthDetails(dayOfMonth, recursEvery);
            }
        } else if (recurrenceType == 3) {
            formBean.setRepaymentRecursEvery(recursEvery);
        }
    }
    formBean.setVariableInstallmentsAllowed(dto.isVariableInstallmentsAllowed());
    if (dto.isVariableInstallmentsAllowed()) {
        formBean.setMinGapInDays(dto.getMinGapInDays());
        formBean.setMaxGapInDays(dto.getMaxGapInDays());
        formBean.setMinInstallmentAmount(dto.getMinInstallmentAmount());
    }
    formBean.setGlimApplicable(dto.isGlimApplicable());
    if (dto.isGroup()) {
        formBean.setGroupLoanWithMembersEnabled(dto.isGroupLoanWithMembersEnabled());
    }
    if (dto.isGlimApplicable() || (dto.isGroup() && dto.isGroupLoanWithMembersEnabled())) {
        List<LoanAccountDetailsDto> clientData = dto.getClientDetails();
        String[] clientGlobalIdArray = new String[clientData.size()];
        int index = 0;
        for (LoanAccountDetailsDto loanAccountDetailsDto : clientData) {
            clientGlobalIdArray[index] = loanAccountDetailsDto.getClientId();
            index++;
        }
        formBean.setClientGlobalId(clientGlobalIdArray);
        formBean.setClientSelectForGroup(new Boolean[clientData.size()]);
        formBean.setClientAmount(new Number[clientData.size()]);
        Integer[] loanPurpose = new Integer[clientData.size()];
        formBean.setClientLoanPurposeId(loanPurpose);
        Number[][] selectedFeeIndividualAmounts = new Number[3][clientData.size()];
        formBean.setSelectedFeeIndividualAmounts(selectedFeeIndividualAmounts);
        Number[][] defaultFeeIndividualAmounts = new Number[dto.getDefaultFees().size()][clientData.size()];
        formBean.setDefaultFeeIndividualAmounts(defaultFeeIndividualAmounts);
    } else {
        formBean.setAmount(Double.valueOf(dto.getDefaultLoanAmount().toPlainString()));
    }
    formBean.setMinAllowedAmount(dto.getMinLoanAmount());
    formBean.setMaxAllowedAmount(dto.getMaxLoanAmount());
    formBean.setInterestRate(dto.getDefaultInterestRate());
    formBean.setMinAllowedInterestRate(dto.getMinInterestRate());
    formBean.setMaxAllowedInterestRate(dto.getMaxInterestRate());
    formBean.setNumberOfInstallments(dto.getDefaultNumberOfInstallments());
    formBean.setMinNumberOfInstallments(dto.getMinNumberOfInstallments());
    formBean.setMaxNumberOfInstallments(dto.getMaxNumberOfInstallments());
    formBean.setSourceOfFundsMandatory(mandatoryHidden.isMandatoryLoanSourceOfFund());
    formBean.setPurposeOfLoanMandatory(mandatoryHidden.isMandatoryLoanAccountPurpose());
    formBean.setCollateralTypeAndNotesHidden(mandatoryHidden.isHideSystemCollateralTypeNotes());
    formBean.setExternalIdHidden(mandatoryHidden.isHideSystemExternalId());
    if (!mandatoryHidden.isHideSystemExternalId()) {
        formBean.setExternalIdMandatory(mandatoryHidden.isMandatorySystemExternalId());
    }
    LocalDate possibleDisbursementDate = dto.getNextPossibleDisbursementDate();
    if (possibleDisbursementDate != null) {
        formBean.setDisbursementDateDD(possibleDisbursementDate.getDayOfMonth());
        formBean.setDisbursementDateMM(possibleDisbursementDate.getMonthOfYear());
        formBean.setDisbursementDateYY(possibleDisbursementDate.getYearOfEra());
    }
    formBean.setCollateralNotes("");
    Number[] defaultFeeId = new Number[dto.getDefaultFees().size()];
    Number[] defaultFeeAmountOrRate = new Number[dto.getDefaultFees().size()];
    int index = 0;
    for (FeeDto defaultFee : dto.getDefaultFees()) {
        if (defaultFee.isRateBasedFee()) {
            defaultFeeAmountOrRate[index] = defaultFee.getRate();
        } else {
            defaultFeeAmountOrRate[index] = defaultFee.getAmountAsNumber();
        }
        defaultFeeId[index] = Long.valueOf(defaultFee.getId());
        index++;
    }
    formBean.setDefaultFeeAmountOrRate(defaultFeeAmountOrRate);
    formBean.setDefaultFeeId(defaultFeeId);
    formBean.setDefaultFeeSelected(new Boolean[dto.getDefaultFees().size()]);
    formBean.setDefaultFees(dto.getDefaultFees());
    Number[] defaultPenaltyId = new Number[dto.getDefaultPenalties().size()];
    Number[] defaultPenaltyAmountOrRate = new Number[dto.getDefaultPenalties().size()];
    int idx = 0;
    for (PenaltyDto defaultPenalty : dto.getDefaultPenalties()) {
        if (defaultPenalty.isRateBasedPenalty()) {
            defaultPenaltyAmountOrRate[idx] = defaultPenalty.getRate();
        } else {
            defaultPenaltyAmountOrRate[idx] = defaultPenalty.getAmountAsNumber();
        }
        defaultPenaltyId[idx] = Long.valueOf(defaultPenalty.getPenaltyId());
        idx++;
    }
    formBean.setDefaultPenaltyAmountOrRate(defaultPenaltyAmountOrRate);
    formBean.setDefaultPenaltyId(defaultPenaltyId);
    formBean.setDefaultPenaltySelected(new Boolean[dto.getDefaultPenalties().size()]);
    formBean.setDefaultPenalties(dto.getDefaultPenalties());
    Number[] selectedFeeId = new Number[3];
    formBean.setSelectedFeeId(selectedFeeId);
    Number[] selectedFeeAmount = new Number[3];
    formBean.setSelectedFeeAmount(selectedFeeAmount);
    formBean.setAdditionalFees(dto.getAdditionalFees());
    if (formBean.getFiles() == null) {
        formBean.setFiles(new ArrayList<CommonsMultipartFile>());
        formBean.setFilesMetadata(new ArrayList<UploadedFileDto>());
    }
    formBean.setLoanInformationOrder(informationOrderServiceFacade.getInformationOrder("CreateLoan"));
    return dto;
}
Also used : PenaltyDto(org.mifos.dto.domain.PenaltyDto) CreateAccountPenaltyDto(org.mifos.dto.domain.CreateAccountPenaltyDto) CreateAccountFeeDto(org.mifos.dto.domain.CreateAccountFeeDto) FeeDto(org.mifos.dto.domain.FeeDto) MandatoryHiddenFieldsDto(org.mifos.dto.domain.MandatoryHiddenFieldsDto) LocalDate(org.joda.time.LocalDate) LoanAccountDetailsDto(org.mifos.dto.domain.LoanAccountDetailsDto) CommonsMultipartFile(org.springframework.web.multipart.commons.CommonsMultipartFile) UploadedFileDto(org.mifos.dto.screen.UploadedFileDto)

Example 3 with MandatoryHiddenFieldsDto

use of org.mifos.dto.domain.MandatoryHiddenFieldsDto in project head by mifos.

the class AdminServiceFacadeWebTier method retrieveHiddenMandatoryFields.

@Override
public MandatoryHiddenFieldsDto retrieveHiddenMandatoryFields() {
    try {
        List<FieldConfigurationEntity> confFieldList = legacyFieldConfigurationDao.getAllConfigurationFieldList();
        MandatoryHiddenFieldsDto dto = new MandatoryHiddenFieldsDto();
        populateDto(dto, confFieldList);
        dto.setFamilyDetailsRequired(ClientRules.isFamilyDetailsRequired());
        return dto;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : PersistenceException(org.mifos.framework.exceptions.PersistenceException) FieldConfigurationEntity(org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity) MandatoryHiddenFieldsDto(org.mifos.dto.domain.MandatoryHiddenFieldsDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 4 with MandatoryHiddenFieldsDto

use of org.mifos.dto.domain.MandatoryHiddenFieldsDto in project head by mifos.

the class DefineMandatoryHiddenFieldsController method assembleDto.

private MandatoryHiddenFieldsDto assembleDto(DefineMandatoryHiddenFieldsFormBean bean) {
    MandatoryHiddenFieldsDto dto = new MandatoryHiddenFieldsDto();
    dto.setFamilyDetailsRequired(bean.isFamilyDetailsRequired());
    dto.setHideClientBusinessWorkActivities(bean.isHideClientBusinessWorkActivities());
    dto.setHideClientGovtId(bean.isHideClientGovtId());
    dto.setHideClientMiddleName(bean.isHideClientMiddleName());
    dto.setHideClientPhone(bean.isHideClientPhone());
    dto.setHideClientPovertyStatus(bean.isHideClientPovertyStatus());
    dto.setHideClientSecondLastName(bean.isHideClientSecondLastName());
    dto.setHideClientSpouseFatherInformation(bean.isHideClientSpouseFatherInformation());
    dto.setHideClientSpouseFatherMiddleName(bean.isHideClientSpouseFatherMiddleName());
    dto.setHideClientSpouseFatherSecondLastName(bean.isHideClientSpouseFatherSecondLastName());
    dto.setHideClientTrained(bean.isHideClientTrained());
    dto.setHideGroupTrained(bean.isHideGroupTrained());
    dto.setHideSystemAddress2(bean.isHideSystemAddress2());
    dto.setHideSystemAddress3(bean.isHideSystemAddress3());
    dto.setHideSystemAssignClientPostions(bean.isHideSystemAssignClientPostions());
    dto.setHideSystemCitizenShip(bean.isHideSystemCitizenShip());
    dto.setHideSystemCity(bean.isHideSystemCity());
    dto.setHideSystemCollateralTypeNotes(bean.isHideSystemCollateralTypeNotes());
    dto.setHideSystemCountry(bean.isHideSystemCountry());
    dto.setHideSystemEducationLevel(bean.isHideSystemEducationLevel());
    dto.setHideSystemEthnicity(bean.isHideSystemEthnicity());
    dto.setHideSystemExternalId(bean.isHideSystemExternalId());
    dto.setHideSystemHandicapped(bean.isHideSystemHandicapped());
    dto.setHideSystemPhoto(bean.isHideSystemPhoto());
    dto.setHideSystemPostalCode(bean.isHideSystemPostalCode());
    dto.setHideSystemReceiptIdDate(bean.isHideSystemReceiptIdDate());
    dto.setHideSystemState(bean.isHideSystemState());
    dto.setMandatoryClientBusinessWorkActivities(bean.isMandatoryClientBusinessWorkActivities());
    dto.setMandatoryClientGovtId(bean.isMandatoryClientGovtId());
    dto.setMandatoryClientMiddleName(bean.isMandatoryClientMiddleName());
    dto.setMandatoryClientPhone(bean.isMandatoryClientPhone());
    dto.setMandatoryClientPovertyStatus(bean.isMandatoryClientPovertyStatus());
    dto.setMandatoryMaritalStatus(bean.isMandatoryMaritalStatus());
    dto.setMandatoryClientFamilyDetails(bean.isMandatoryClientFamilyDetails());
    dto.setMandatoryClientSecondLastName(bean.isMandatoryClientSecondLastName());
    dto.setMandatoryClientSpouseFatherInformation(bean.isMandatoryClientSpouseFatherInformation());
    dto.setMandatoryClientSpouseFatherSecondLastName(bean.isMandatoryClientSpouseFatherSecondLastName());
    dto.setMandatoryClientTrained(bean.isMandatoryClientTrained());
    dto.setMandatoryClientTrainedOn(bean.isMandatoryClientTrainedOn());
    dto.setMandatoryNumberOfChildren(bean.isMandatoryNumberOfChildren());
    dto.setMandatorySystemAddress1(bean.isMandatorySystemAddress1());
    dto.setMandatorySystemCitizenShip(bean.isMandatorySystemCitizenShip());
    dto.setMandatorySystemEducationLevel(bean.isMandatorySystemEducationLevel());
    dto.setMandatorySystemEthnicity(bean.isMandatorySystemEthnicity());
    dto.setMandatorySystemExternalId(bean.isMandatorySystemExternalId());
    dto.setMandatorySystemHandicapped(bean.isMandatorySystemHandicapped());
    dto.setMandatorySystemPhoto(bean.isMandatorySystemPhoto());
    dto.setMandatoryLoanAccountPurpose(bean.isMandatoryLoanAccountPurpose());
    dto.setMandatoryLoanSourceOfFund(bean.isMandatoryLoanSourceOfFund());
    return dto;
}
Also used : MandatoryHiddenFieldsDto(org.mifos.dto.domain.MandatoryHiddenFieldsDto)

Aggregations

MandatoryHiddenFieldsDto (org.mifos.dto.domain.MandatoryHiddenFieldsDto)4 LinkedHashMap (java.util.LinkedHashMap)1 DateTime (org.joda.time.DateTime)1 LocalDate (org.joda.time.LocalDate)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 CreateAccountFeeDto (org.mifos.dto.domain.CreateAccountFeeDto)1 CreateAccountPenaltyDto (org.mifos.dto.domain.CreateAccountPenaltyDto)1 FeeDto (org.mifos.dto.domain.FeeDto)1 LoanAccountDetailsDto (org.mifos.dto.domain.LoanAccountDetailsDto)1 OfficeDto (org.mifos.dto.domain.OfficeDto)1 PenaltyDto (org.mifos.dto.domain.PenaltyDto)1 DefinePersonnelDto (org.mifos.dto.screen.DefinePersonnelDto)1 ListElement (org.mifos.dto.screen.ListElement)1 UploadedFileDto (org.mifos.dto.screen.UploadedFileDto)1 FieldConfigurationEntity (org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity)1 PersistenceException (org.mifos.framework.exceptions.PersistenceException)1 CommonsMultipartFile (org.springframework.web.multipart.commons.CommonsMultipartFile)1