Search in sources :

Example 16 with AmountFeeBO

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

the class CenterCreationUsingCustomerServiceIntegrationTest method canCreateCenterWithFeeThatMatchesMeetingPeriod.

@Test
public void canCreateCenterWithFeeThatMatchesMeetingPeriod() throws Exception {
    // minimal details
    MeetingBuilder aWeeklyMeeting = new MeetingBuilder().customerMeeting().weekly().every(1).startingToday();
    String centerName = "Center-IntegrationTest";
    OfficeBO anExistingBranch = sampleBranchOffice();
    PersonnelBO existingLoanOfficer = testUser();
    DateTime aWeekFromNow = new DateTime().plusWeeks(1);
    CenterBO center = new CenterBuilder().withName(centerName).with(aWeeklyMeeting).with(anExistingBranch).withLoanOfficer(existingLoanOfficer).withMfiJoiningDate(aWeekFromNow).withUserContext().build();
    // setup
    AmountFeeBO existingWeeklyFee = new FeeBuilder().with(aWeeklyMeeting).appliesToCenterOnly().with(anExistingBranch).build();
    IntegrationTestObjectMother.saveFee(existingWeeklyFee);
    AccountFeesEntity accountFee = new AccountFeesEntity(null, existingWeeklyFee, existingWeeklyFee.getFeeAmount().getAmountDoubleValue());
    List<AccountFeesEntity> centerAccountFees = new ArrayList<AccountFeesEntity>();
    centerAccountFees.add(accountFee);
    // exercise test
    customerService.createCenter(center, center.getCustomerMeetingValue(), centerAccountFees);
    // verification
    assertThat(center.getCustomerId(), is(notNullValue()));
    assertThat(center.getGlobalCustNum(), is(notNullValue()));
    assertThat(center.getCustomerAccount().getAccountFees().isEmpty(), is(false));
}
Also used : FeeBuilder(org.mifos.domain.builders.FeeBuilder) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) DateTime(org.joda.time.DateTime) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Example 17 with AmountFeeBO

use of org.mifos.accounts.fees.business.AmountFeeBO 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 18 with AmountFeeBO

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

the class CustomerPersistenceIntegrationTest method testGetCustomerAccountsForFee.

@Test
public void testGetCustomerAccountsForFee() throws Exception {
    groupAccount = getLoanAccount();
    FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("ClientPeridoicFee", FeeCategory.CENTER, "5", RecurrenceType.WEEKLY, Short.valueOf("1"));
    AccountFeesEntity accountFee = new AccountFeesEntity(center.getCustomerAccount(), periodicFee, ((AmountFeeBO) periodicFee).getFeeAmount().getAmountDoubleValue());
    CustomerAccountBO customerAccount = center.getCustomerAccount();
    AccountTestUtils.addAccountFees(accountFee, customerAccount);
    TestObjectFactory.updateObject(customerAccount);
    StaticHibernateUtil.flushSession();
    // check for the account fee
    List<AccountBO> accountList = new CustomerPersistence().getCustomerAccountsForFee(periodicFee.getFeeId());
    Assert.assertNotNull(accountList);
    Assert.assertEquals(1, accountList.size());
    Assert.assertTrue(accountList.get(0) instanceof CustomerAccountBO);
    // get all objects again
    groupAccount = TestObjectFactory.getObject(LoanBO.class, groupAccount.getAccountId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    center = TestObjectFactory.getCustomer(center.getCustomerId());
}
Also used : CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) AccountBO(org.mifos.accounts.business.AccountBO) CustomerAccountBO(org.mifos.customers.business.CustomerAccountBO) LoanBO(org.mifos.accounts.loan.business.LoanBO) FeeBO(org.mifos.accounts.fees.business.FeeBO) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO) Test(org.junit.Test)

Example 19 with AmountFeeBO

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

the class IntegrationTestObjectMother method createCenter.

public static void createCenter(CenterBO center, MeetingBO meeting, AmountFeeBO... fees) {
    UserContext userContext = TestUtils.makeUser();
    center.setUserContext(userContext);
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    for (AmountFeeBO fee : fees) {
        AccountFeesEntity accountFee = new AccountFeesEntity(null, fee, fee.getFeeAmount().getAmountDoubleValue());
        accountFees.add(accountFee);
    }
    customerService.createCenter(center, meeting, accountFees);
}
Also used : UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) AmountFeeBO(org.mifos.accounts.fees.business.AmountFeeBO)

Example 20 with AmountFeeBO

use of org.mifos.accounts.fees.business.AmountFeeBO 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)

Aggregations

AmountFeeBO (org.mifos.accounts.fees.business.AmountFeeBO)41 ArrayList (java.util.ArrayList)24 MeetingBO (org.mifos.application.meeting.business.MeetingBO)18 Test (org.junit.Test)17 FeeBO (org.mifos.accounts.fees.business.FeeBO)17 Money (org.mifos.framework.util.helpers.Money)16 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)14 DateTime (org.joda.time.DateTime)13 FeeBuilder (org.mifos.domain.builders.FeeBuilder)13 CenterBuilder (org.mifos.domain.builders.CenterBuilder)12 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)11 FeeDto (org.mifos.accounts.fees.business.FeeDto)8 CenterBO (org.mifos.customers.center.business.CenterBO)8 CategoryTypeEntity (org.mifos.accounts.fees.business.CategoryTypeEntity)6 FeeFrequencyTypeEntity (org.mifos.accounts.fees.business.FeeFrequencyTypeEntity)6 RateFeeBO (org.mifos.accounts.fees.business.RateFeeBO)6 BigDecimal (java.math.BigDecimal)5 Date (java.sql.Date)5 LocalDate (org.joda.time.LocalDate)5 CreateAccountFeeDto (org.mifos.dto.domain.CreateAccountFeeDto)5