use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.
the class SavingsBOIntegrationTest method testGenerateMeetingForNextYear.
@Test
public void testGenerateMeetingForNextYear() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("center1", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
SavingsTestHelper SavingsTestHelper = new SavingsTestHelper();
SavingsOfferingBO savingsOfferingBO = SavingsTestHelper.createSavingsOffering("dfasdasd1", "sad1");
savingsOfferingBO.setRecommendedAmntUnit(RecommendedAmountUnit.COMPLETE_GROUP);
SavingsBO savingsBO = SavingsTestHelper.createSavingsAccount(savingsOfferingBO, group, AccountState.SAVINGS_ACTIVE, TestUtils.makeUser());
Short LastInstallmentId = savingsBO.getLastInstallmentId();
AccountActionDateEntity lastYearLastInstallment = savingsBO.getAccountActionDate(LastInstallmentId);
Integer installmetId = lastYearLastInstallment.getInstallmentId().intValue() + (short) 1;
List<Days> workingDays = new FiscalCalendarRules().getWorkingDaysAsJodaTimeDays();
List<Holiday> holidays = new ArrayList<Holiday>();
savingsBO.generateNextSetOfMeetingDates(workingDays, holidays);
TestObjectFactory.updateObject(savingsBO);
TestObjectFactory.updateObject(center);
TestObjectFactory.updateObject(group);
TestObjectFactory.updateObject(savingsBO);
center = (CustomerBO) StaticHibernateUtil.getSessionTL().get(CustomerBO.class, center.getCustomerId());
group = (CustomerBO) StaticHibernateUtil.getSessionTL().get(CustomerBO.class, group.getCustomerId());
savingsBO = (SavingsBO) StaticHibernateUtil.getSessionTL().get(SavingsBO.class, savingsBO.getAccountId());
MeetingBO meetingBO = center.getCustomerMeeting().getMeeting();
meetingBO.setMeetingStartDate(lastYearLastInstallment.getActionDate());
List<Date> meetingDates = TestObjectFactory.getMeetingDates(group.getOfficeId(), meetingBO, 10);
meetingDates.remove(0);
Date FirstSavingInstallmetDate = savingsBO.getAccountActionDate(installmetId.shortValue()).getActionDate();
Calendar calendar2 = Calendar.getInstance();
calendar2.setTime(meetingDates.get(0));
Calendar calendar3 = Calendar.getInstance();
calendar3.setTime(FirstSavingInstallmetDate);
Assert.assertEquals(0, new GregorianCalendar(calendar3.get(Calendar.YEAR), calendar3.get(Calendar.MONTH), calendar3.get(Calendar.DATE), 0, 0, 0).compareTo(new GregorianCalendar(calendar2.get(Calendar.YEAR), calendar2.get(Calendar.MONTH), calendar2.get(Calendar.DATE), 0, 0, 0)));
}
use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.
the class ClientIntegrationTest method testFailure_InitialSavingsOfferingAtCreate.
@Test
public void testFailure_InitialSavingsOfferingAtCreate() throws Exception {
savingsOffering1 = TestObjectFactory.createSavingsProduct("Offering1", "s1", SavingsType.MANDATORY, ApplicableTo.CLIENTS, new Date(System.currentTimeMillis()));
ClientNameDetailDto clientView = new ClientNameDetailDto(NameType.CLIENT.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "Client", "", "1", "");
clientView.setNames(ClientRules.getNameSequence());
ClientNameDetailDto spouseView = new ClientNameDetailDto(NameType.SPOUSE.getValue(), TestObjectFactory.SAMPLE_SALUTATION, "first", "middle", "last", "secondLast");
spouseView.setNames(ClientRules.getNameSequence());
ClientPersonalDetailDto clientPersonalDetailDto = new ClientPersonalDetailDto(1, 1, 1, 1, 1, 1, Short.valueOf("1"), Short.valueOf("1"), Short.valueOf("41"));
List<SavingsOfferingBO> offerings = new ArrayList<SavingsOfferingBO>();
offerings.add(savingsOffering1);
offerings.add(savingsOffering1);
try {
client = new ClientBO(TestObjectFactory.getContext(), clientView.getDisplayName(), CustomerStatus.CLIENT_PARTIAL, null, null, null, null, null, offerings, personnel, officeBo, null, null, null, null, null, YesNoFlag.NO.getValue(), clientView, spouseView, clientPersonalDetailDto);
} catch (CustomerException ce) {
Assert.assertEquals(ClientConstants.ERRORS_DUPLICATE_OFFERING_SELECTED, ce.getKey());
Assert.assertTrue(true);
}
savingsOffering1 = (SavingsOfferingBO) TestObjectFactory.getObject(SavingsOfferingBO.class, savingsOffering1.getPrdOfferingId());
}
use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.
the class GroupPerformanceHistoryUsingCustomerServiceIntegrationTest method shouldGetTotalSavingsBalance.
@Test
public void shouldGetTotalSavingsBalance() throws Exception {
// setup
SavingsOfferingBO groupSavingsProduct = new SavingsProductBuilder().appliesToGroupsOnly().voluntary().withName("groupSavings").withShortName("GSP").buildForIntegrationTests();
IntegrationTestObjectMother.createProduct(groupSavingsProduct);
SavingsBO groupSavingsAccount = new SavingsAccountBuilder().withSavingsProduct(groupSavingsProduct).withCustomer(existingActiveClient).withCreatedBy(IntegrationTestObjectMother.testUser()).withSavingsOfficer(existingLoanOfficer).withBalanceOf(new Money(Money.getDefaultCurrency(), "200.0")).build();
IntegrationTestObjectMother.saveSavingsAccount(groupSavingsAccount);
SavingsOfferingBO clientSavingsProduct = new SavingsProductBuilder().appliesToClientsOnly().voluntary().withName("clientSavings").withShortName("CSP").buildForIntegrationTests();
IntegrationTestObjectMother.createProduct(clientSavingsProduct);
SavingsBO clientSavingsAccount = new SavingsAccountBuilder().withSavingsProduct(clientSavingsProduct).withCustomer(existingActiveClient).withCreatedBy(IntegrationTestObjectMother.testUser()).withSavingsOfficer(existingLoanOfficer).withBalanceOf(new Money(Money.getDefaultCurrency(), "550.0")).build();
IntegrationTestObjectMother.saveSavingsAccount(clientSavingsAccount);
existingGroup = customerDao.findGroupBySystemId(existingGroup.getGlobalCustNum());
// exercise test
Money savingsAmount = existingGroup.getGroupPerformanceHistory().getTotalSavingsAmount();
// verification
assertThat(savingsAmount.getAmountDoubleValue(), is(750.0));
}
use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.
the class TestObjectFactory method createSavingsProduct.
public static SavingsOfferingBO createSavingsProduct(final String name, final String shortName, final ApplicableTo applicableTo, final Date startDate, final PrdStatus status, final Double recommendedAmount, final RecommendedAmountUnit recommendedAmountUnit, final Double intRate, final Double maxAmtWithdrawl, final Double minAmtForInt, final SavingsType savingsType, final InterestCalcType interestCalculationType, final MeetingBO intCalcMeeting, final MeetingBO intPostMeeting, final Short depGLCode, final Short withGLCode) {
GLCodeEntity depglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, depGLCode);
GLCodeEntity intglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, withGLCode);
ProductCategoryBO productCategory = (ProductCategoryBO) TestObjectFactory.getObject(ProductCategoryBO.class, SAMPLE_CATEGORY);
PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(applicableTo);
SavingsTypeEntity savingsTypeEntity = new SavingsTypeEntity(savingsType);
InterestCalcTypeEntity intCalType = new InterestCalcTypeEntity(interestCalculationType);
RecommendedAmntUnitEntity amountUnit = new RecommendedAmntUnitEntity(recommendedAmountUnit);
SavingsOfferingBO product;
try {
product = new SavingsOfferingBO(TestUtils.makeUserWithLocales(), name, shortName, productCategory, prdApplicableMaster, startDate, null, null, amountUnit, savingsTypeEntity, intCalType, intCalcMeeting, intPostMeeting, TestUtils.createMoney(recommendedAmount), TestUtils.createMoney(maxAmtWithdrawl), TestUtils.createMoney(minAmtForInt), intRate, depglCodeEntity, intglCodeEntity);
} catch (ProductDefinitionException e) {
throw new RuntimeException(e);
} catch (SystemException e) {
throw new RuntimeException(e);
}
PrdStatusEntity prdStatus = testObjectPersistence.retrievePrdStatus(status);
product.setPrdStatus(prdStatus);
return (SavingsOfferingBO) testObjectPersistence.persist(product);
}
use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.
the class IntegrationTestObjectMother method createClient.
public static void createClient(ClientBO client, MeetingBO meeting) throws CustomerException {
UserContext userContext = TestUtils.makeUser();
client.setUserContext(userContext);
List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
List<SavingsOfferingBO> selectedOfferings = new ArrayList<SavingsOfferingBO>();
customerService.createClient(client, meeting, accountFees, selectedOfferings);
}
Aggregations