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));
}
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;
}
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());
}
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);
}
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;
}
Aggregations