Search in sources :

Example 26 with FeeDto

use of org.mifos.accounts.fees.business.FeeDto in project head by mifos.

the class GroupActionStrutsTest method getFees.

private List<FeeDto> getFees(RecurrenceType frequency) {
    List<FeeDto> fees = new ArrayList<FeeDto>();
    AmountFeeBO fee1 = (AmountFeeBO) TestObjectFactory.createPeriodicAmountFee("PeriodicAmountFee", FeeCategory.GROUP, "200", frequency, Short.valueOf("2"));
    fees.add(new FeeDto(TestObjectFactory.getContext(), fee1));
    StaticHibernateUtil.flushAndClearSession();
    return fees;
}
Also used : ArrayList(java.util.ArrayList) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO)

Example 27 with FeeDto

use of org.mifos.accounts.fees.business.FeeDto in project head by mifos.

the class LoanAccountActionFormTest method createDefaultFees.

private ArrayList<FeeDto> createDefaultFees() {
    AmountFeeBO amountFee = createMock(AmountFeeBO.class);
    expect(amountFee.getFeeId()).andReturn(Short.valueOf("1"));
    expect(amountFee.getFeeType()).andReturn(RateAmountFlag.AMOUNT).times(2);
    expect(amountFee.getFeeName()).andReturn("TestAmountFee");
    expect(amountFee.getFeeAmount()).andReturn(new Money(TestUtils.RUPEE, "5000.0")).times(2);
    expect(amountFee.isPeriodic()).andReturn(false).times(2);
    replay(amountFee);
    RateFeeBO rateFee = createMock(RateFeeBO.class);
    expect(rateFee.getFeeId()).andReturn(Short.valueOf("1"));
    expect(rateFee.getFeeType()).andReturn(RateAmountFlag.RATE).times(2);
    expect(rateFee.getFeeName()).andReturn("TestRateFee");
    expect(rateFee.getRate()).andReturn(2.12345);
    expect(rateFee.getFeeFormula()).andReturn(createFeeFormulaEntityMock());
    expect(rateFee.isPeriodic()).andReturn(false).times(2);
    replay(rateFee);
    UserContext userContext = createMock(UserContext.class);
    expect(userContext.getLocaleId()).andReturn(Short.valueOf("1")).times(2);
    replay(userContext);
    ArrayList<FeeDto> defaultFees = new ArrayList<FeeDto>();
    defaultFees.add(new FeeDto(userContext, amountFee));
    defaultFees.add(new FeeDto(userContext, rateFee));
    return defaultFees;
}
Also used : RateFeeBO(org.mifos.accounts.fees.business.RateFeeBO) Money(org.mifos.framework.util.helpers.Money) UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) FeeDto(org.mifos.accounts.fees.business.FeeDto) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO)

Example 28 with FeeDto

use of org.mifos.accounts.fees.business.FeeDto in project head by mifos.

the class LoanAccountActionFormTest method testValidateAdditionalFeesWithMultipleInstancesOfTheSameOneTimeFee.

public void testValidateAdditionalFeesWithMultipleInstancesOfTheSameOneTimeFee() throws Exception {
    List<FeeDto> additionalFeeList = createDefaultFees();
    List<FeeDto> additionalFeeList2 = createDefaultFees();
    additionalFeeList2.add(additionalFeeList.get(0));
    FlowManager flowMgrMock = createMock(FlowManager.class);
    HttpSession sessionMock = createMock(HttpSession.class);
    HttpServletRequest requestMock = createMock(HttpServletRequest.class);
    expect(requestMock.getSession()).andReturn(sessionMock);
    expect(requestMock.getAttribute(Constants.CURRENTFLOWKEY)).andReturn("currentFlowKey");
    expect(sessionMock.getAttribute(Constants.FLOWMANAGER)).andReturn(flowMgrMock);
    expect(flowMgrMock.getFromFlow("currentFlowKey", LoanConstants.ADDITIONAL_FEES_LIST)).andReturn(additionalFeeList);
    ActionErrors errors = new ActionErrors();
    form.validateAdditionalFee(errors, Locale.ENGLISH, TestUtils.RUPEE, requestMock);
    Assert.assertEquals("There should be a 'Multiple instances of the same one-time fee are not allowed' error", 1, errors.size());
    ActionMessage actionMessage = (ActionMessage) errors.get().next();
    Assert.assertEquals("There should be a 'Multiple instances of the same one-time fee are not allowed' error", ProductDefinitionConstants.MULTIPLE_ONE_TIME_FEES_NOT_ALLOWED, actionMessage.getKey());
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) FlowManager(org.mifos.framework.util.helpers.FlowManager) HttpSession(javax.servlet.http.HttpSession) FeeDto(org.mifos.accounts.fees.business.FeeDto) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 29 with FeeDto

use of org.mifos.accounts.fees.business.FeeDto in project head by mifos.

the class CustomerApplicableFeesDto method toDto.

public static CustomerApplicableFeesDto toDto(List<FeeBO> fees, UserContext userContext) {
    List<FeeDto> additionalFees = new ArrayList<FeeDto>();
    List<FeeDto> defaultFees = new ArrayList<FeeDto>();
    for (FeeBO fee : fees) {
        if (fee.isCustomerDefaultFee()) {
            defaultFees.add(new FeeDto(userContext, fee));
        } else {
            additionalFees.add(new FeeDto(userContext, fee));
        }
    }
    return new CustomerApplicableFeesDto(defaultFees, additionalFees);
}
Also used : ArrayList(java.util.ArrayList) FeeDto(org.mifos.accounts.fees.business.FeeDto) FeeBO(org.mifos.accounts.fees.business.FeeBO)

Example 30 with FeeDto

use of org.mifos.accounts.fees.business.FeeDto in project head by mifos.

the class ClientServiceFacadeWebTier method retrieveClientFormCreationData.

@Override
public ClientFormCreationDto retrieveClientFormCreationData(Short groupFlag, Short officeId, String parentGroupId) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    List<PersonnelDto> personnelList = new ArrayList<PersonnelDto>();
    MeetingBO parentCustomerMeeting = null;
    Short formedByPersonnelId = null;
    String formedByPersonnelName = "";
    String centerDisplayName = "";
    String groupDisplayName = "";
    String officeName = "";
    List<FeeBO> fees = new ArrayList<FeeBO>();
    Short applicableOfficeId = officeId;
    if (YesNoFlag.YES.getValue().equals(groupFlag)) {
        Integer parentCustomerId = Integer.valueOf(parentGroupId);
        CustomerBO parentCustomer = this.customerDao.findCustomerById(parentCustomerId);
        groupDisplayName = parentCustomer.getDisplayName();
        if (parentCustomer.getPersonnel() != null) {
            formedByPersonnelId = parentCustomer.getPersonnel().getPersonnelId();
            formedByPersonnelName = parentCustomer.getPersonnel().getDisplayName();
        }
        if (parentCustomer.getParentCustomer() != null) {
            centerDisplayName = parentCustomer.getParentCustomer().getDisplayName();
        }
        applicableOfficeId = parentCustomer.getOffice().getOfficeId();
        officeName = parentCustomer.getOffice().getOfficeName();
        if (parentCustomer.getCustomerMeeting() != null) {
            parentCustomerMeeting = parentCustomer.getCustomerMeetingValue();
            fees = this.customerDao.retrieveFeesApplicableToClientsRefinedBy(parentCustomer.getCustomerMeetingValue());
        } else {
            fees = this.customerDao.retrieveFeesApplicableToClients();
        }
    } else if (YesNoFlag.NO.getValue().equals(groupFlag)) {
        CenterCreation centerCreation = new CenterCreation(applicableOfficeId, userContext.getId(), userContext.getLevelId(), userContext.getPreferredLocale());
        personnelList = this.personnelDao.findActiveLoanOfficersForOffice(centerCreation);
        fees = this.customerDao.retrieveFeesApplicableToClients();
    }
    CustomerApplicableFeesDto applicableFees = CustomerApplicableFeesDto.toDto(fees, userContext);
    List<ApplicableAccountFeeDto> defaultFees = new ArrayList<ApplicableAccountFeeDto>();
    for (FeeDto fee : applicableFees.getDefaultFees()) {
        defaultFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
    }
    List<ApplicableAccountFeeDto> additionalFees = new ArrayList<ApplicableAccountFeeDto>();
    for (FeeDto fee : applicableFees.getAdditionalFees()) {
        additionalFees.add(new ApplicableAccountFeeDto(fee.getFeeIdValue().intValue(), fee.getFeeName(), fee.getAmount(), fee.isRemoved(), fee.isWeekly(), fee.isMonthly(), fee.isPeriodic(), fee.getFeeSchedule()));
    }
    List<SavingsDetailDto> savingsOfferings = this.customerDao.retrieveSavingOfferingsApplicableToClient();
    ClientRulesDto clientRules = retrieveClientRules();
    ClientDropdownsDto clientDropdowns = retrieveClientDropdownData();
    List<PersonnelDto> formedByPersonnel = this.customerDao.findLoanOfficerThatFormedOffice(applicableOfficeId);
    MeetingDto parentMeeting = null;
    if (parentCustomerMeeting != null) {
        parentMeeting = parentCustomerMeeting.toDto();
    }
    return new ClientFormCreationDto(clientDropdowns, clientRules, applicableOfficeId, officeName, formedByPersonnelId, formedByPersonnelName, personnelList, formedByPersonnel, savingsOfferings, parentMeeting, centerDisplayName, groupDisplayName, additionalFees, defaultFees);
}
Also used : SavingsDetailDto(org.mifos.dto.domain.SavingsDetailDto) UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) ArrayList(java.util.ArrayList) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) FeeDto(org.mifos.accounts.fees.business.FeeDto) PersonnelDto(org.mifos.dto.domain.PersonnelDto) MifosUser(org.mifos.security.MifosUser) ApplicableAccountFeeDto(org.mifos.dto.domain.ApplicableAccountFeeDto) CustomerMeetingDto(org.mifos.dto.domain.CustomerMeetingDto) MeetingDto(org.mifos.dto.domain.MeetingDto) CenterCreation(org.mifos.dto.domain.CenterCreation) ClientRulesDto(org.mifos.dto.domain.ClientRulesDto) CustomerBO(org.mifos.customers.business.CustomerBO) FeeBO(org.mifos.accounts.fees.business.FeeBO) ClientFormCreationDto(org.mifos.dto.screen.ClientFormCreationDto) ClientDropdownsDto(org.mifos.dto.screen.ClientDropdownsDto)

Aggregations

FeeDto (org.mifos.accounts.fees.business.FeeDto)44 ArrayList (java.util.ArrayList)29 Test (org.junit.Test)22 ApplicableAccountFeeDto (org.mifos.dto.domain.ApplicableAccountFeeDto)21 FeeBO (org.mifos.accounts.fees.business.FeeBO)13 List (java.util.List)12 AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)11 MeetingBO (org.mifos.application.meeting.business.MeetingBO)10 Date (java.util.Date)7 CustomFieldDto (org.mifos.dto.domain.CustomFieldDto)5 UserContext (org.mifos.security.util.UserContext)5 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)4 MifosUser (org.mifos.security.MifosUser)4 FundBO (org.mifos.accounts.fund.business.FundBO)3 BusinessActivityEntity (org.mifos.application.master.business.BusinessActivityEntity)3 ClientCustActionForm (org.mifos.customers.client.struts.actionforms.ClientCustActionForm)3 PersonnelDto (org.mifos.dto.domain.PersonnelDto)3 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 DateTime (org.joda.time.DateTime)2