use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.
the class TestCollectionSheetRetrieveSavingsAccountsUtils method createSavingsAccount.
public SavingsBO createSavingsAccount(CustomerBO customer, String shortName, String amount, boolean isVoluntary, boolean isPerIndividual) {
// johnw - unfortunately, in the current builder code, the settings for mandatory/voluntary and
// complete_group/per_individual are set at savings account level rather than at savings offering level as in
// the production system. However, this method creates a good savings account
SavingsProductBuilder savingsProductBuilder = new SavingsProductBuilder().withName(customer.getDisplayName()).withShortName(shortName);
if (customer.getCustomerLevel().getId().compareTo(CustomerLevel.CENTER.getValue()) == 0) {
savingsProductBuilder.appliesToCentersOnly();
}
if (customer.getCustomerLevel().getId().compareTo(CustomerLevel.GROUP.getValue()) == 0) {
savingsProductBuilder.appliesToGroupsOnly();
}
if (customer.getCustomerLevel().getId().compareTo(CustomerLevel.CLIENT.getValue()) == 0) {
savingsProductBuilder.appliesToClientsOnly();
}
SavingsOfferingBO savingsProduct = savingsProductBuilder.mandatory().withInterestRate(Double.valueOf("4.0")).buildForIntegrationTests();
if (isVoluntary) {
savingsProductBuilder.voluntary();
}
SavingsAccountBuilder savingsAccountBuilder = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(customer).withCreatedBy(IntegrationTestObjectMother.testUser()).completeGroup().withRecommendedAmount(TestUtils.createMoney(amount));
if (isPerIndividual) {
savingsAccountBuilder.perIndividual();
}
SavingsBO savingsAccount = null;
if (customer.getCustomerLevel().getId().compareTo(CustomerLevel.CENTER.getValue()) == 0) {
savingsAccount = savingsAccountBuilder.buildJointSavingsAccount();
} else {
savingsAccount = savingsAccountBuilder.build();
}
IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
return savingsAccount;
}
use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.
the class SavingsProductBuilder method build.
private SavingsOfferingBO build() {
final SavingsOfferingBO savingsProduct = new SavingsOfferingBO(savingsType, name, shortName, globalProductNumber, startDate, applicableToCustomer, category, productStatusEntity, interestCalcType, interestRate, maxAmountOfWithdrawal, depositGLCode, interesetGLCode, createdDate, createdByUserId);
savingsProduct.setMinAmntForInt(minAmountForInterestCalculation);
final PrdOfferingMeetingEntity scheduleForInstcalc = new PrdOfferingMeetingEntity(scheduleForInterestCalculationMeeting, savingsProduct, MeetingType.SAVINGS_INTEREST_CALCULATION_TIME_PERIOD);
final PrdOfferingMeetingEntity scheduleForInterestPosting = new PrdOfferingMeetingEntity(scheduleForInterestPostingMeeting, savingsProduct, MeetingType.SAVINGS_INTEREST_POSTING);
savingsProduct.setTimePerForInstcalc(scheduleForInstcalc);
savingsProduct.setTimePerForInstcalc(scheduleForInterestPosting);
savingsProduct.setMinAmntForInt(minAmntForInt);
if (this.mandatoryGroupTrackingType != null) {
savingsProduct.setRecommendedAmntUnit(this.mandatoryGroupTrackingType);
}
savingsProduct.setRecommendedAmount(mandatoryOrRecommendedAmount);
return savingsProduct;
}
use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.
the class BulkEntryDisplayHelperIntegrationTest method testBuildTableHeadings.
@Test
public void testBuildTableHeadings() {
LoanOfferingBO loanOffering = createLoanOfferingBO("Loan Offering", "LOAN");
java.util.Date currentDate = new java.util.Date(System.currentTimeMillis());
SavingsOfferingBO savingsOffering = TestObjectFactory.createSavingsProduct("Savings Offering", "SAVP", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
ProductDto loanOfferingDto = new ProductDto(loanOffering.getPrdOfferingId(), loanOffering.getPrdOfferingShortName());
ProductDto savingOfferingDto = new ProductDto(savingsOffering.getPrdOfferingId(), savingsOffering.getPrdOfferingShortName());
List<ProductDto> loanProducts = Arrays.asList(loanOfferingDto);
List<ProductDto> savingsProducts = Arrays.asList(savingOfferingDto);
UserContext userContext = TestObjectFactory.getContext();
String result = new BulkEntryDisplayHelper().buildTableHeadings(loanProducts, savingsProducts, userContext.getPreferredLocale()).toString();
StringAssert.assertContains("LOAN", result);
StringAssert.assertContains("SAVP", result);
StringAssert.assertContains("Due/Collections", result);
StringAssert.assertContains("Issues/Withdrawals", result);
StringAssert.assertContains("Client Name", result);
StringAssert.assertContains("A/C Collections", result);
StringAssert.assertContains("Attn", result);
TestObjectFactory.removeObject(loanOffering);
savingsOffering = null;
}
use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.
the class BulkEntryActionStrutsTest method getSuccessfulBulkEntry.
private CollectionSheetEntryGridDto getSuccessfulBulkEntry() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
Date startDate = new Date(System.currentTimeMillis());
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
LoanOfferingBO loanOffering1 = TestObjectFactory.createLoanOffering(startDate, meeting);
LoanOfferingBO loanOffering2 = TestObjectFactory.createLoanOffering("Loan2345", "313f", ApplicableTo.CLIENTS, startDate, PrdStatus.LOAN_ACTIVE, 300.0, 1.2, 3, InterestType.FLAT, meeting);
groupAccount = TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering1);
clientAccount = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 1, loanOffering2);
Date currentDate = new Date(System.currentTimeMillis());
// 2010-01-18: JohnW - This use of TestObjectFactory.createSavingsProduct used to break a number of
// business rules.
// E.g all the savings products were set up as applicable for Groups and "per individual" which is wrong for
// centers and clients. In the case of the client being wrongly set up as "Per Individual" it now triggers save
// collection sheet validation (which checks that the account associated with the client marked "per individual"
// matches its parent group or center)
// Also, when creating the center savings accounts (which is effectively "per individual") and the group savings
// account which is "per individual" the saving_schedule entries for the client are not written (they are in the
// production code).
//
// Considered using/updating the savingsProductBuilder functionality but that doesn't deal with the
// "per individual" aspect either (update: it does, but still problem with builder creating installments).
// Decided not to try and fix it up (good deal of effort involved) but rather change the
// TestObjectFactory.createSavingsProduct to accept a RecommendedAmountUnit parameter.
// Unfortunately it wouldn't allow a null parameter (which is valid for centers and clients) through so, where
// necessary, I picked a value that worked for the test but was wrong in a business rule sense (just as its
// always been).
// So the savings product test data doesn't adhere to business rules but all tests pass here and in others
// tests.
SavingsOfferingBO savingsOffering1 = TestObjectFactory.createSavingsProduct("SavingPrd1", "ased", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
SavingsOfferingBO savingsOffering2 = TestObjectFactory.createSavingsProduct("SavingPrd2", "cvdf", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
SavingsOfferingBO savingsOffering3 = TestObjectFactory.createSavingsProduct("SavingPrd3", "zxsd", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
centerSavingsAccount = TestObjectFactory.createSavingsAccount("43244334", center, Short.valueOf("16"), startDate, savingsOffering1);
groupSavingsAccount = TestObjectFactory.createSavingsAccount("43234434", group, Short.valueOf("16"), startDate, savingsOffering2);
clientSavingsAccount = TestObjectFactory.createSavingsAccount("43245434", client, Short.valueOf("16"), startDate, savingsOffering3);
CollectionSheetEntryDto bulkEntryParent = new CollectionSheetEntryDto(getCusomerView(center), null);
SavingsAccountDto centerSavingsAccountView = getSavingsAccountView(centerSavingsAccount);
centerSavingsAccountView.setDepositAmountEntered("100");
centerSavingsAccountView.setWithDrawalAmountEntered("10");
bulkEntryParent.addSavingsAccountDetail(centerSavingsAccountView);
bulkEntryParent.setCustomerAccountDetails(getCustomerAccountView(center));
CollectionSheetEntryDto bulkEntryChild = new CollectionSheetEntryDto(getCusomerView(group), null);
LoanAccountDto groupLoanAccountView = getLoanAccountView(groupAccount);
SavingsAccountDto groupSavingsAccountView = getSavingsAccountView(groupSavingsAccount);
groupSavingsAccountView.setDepositAmountEntered("100");
groupSavingsAccountView.setWithDrawalAmountEntered("10");
bulkEntryChild.addLoanAccountDetails(groupLoanAccountView);
bulkEntryChild.addSavingsAccountDetail(groupSavingsAccountView);
bulkEntryChild.setCustomerAccountDetails(getCustomerAccountView(group));
CollectionSheetEntryDto bulkEntrySubChild = new CollectionSheetEntryDto(getCusomerView(client), null);
LoanAccountDto clientLoanAccountView = getLoanAccountView(clientAccount);
clientLoanAccountView.setAmountPaidAtDisbursement(0.0);
SavingsAccountDto clientSavingsAccountView = getSavingsAccountView(clientSavingsAccount);
clientSavingsAccountView.setDepositAmountEntered("100");
clientSavingsAccountView.setWithDrawalAmountEntered("10");
bulkEntrySubChild.addLoanAccountDetails(clientLoanAccountView);
bulkEntrySubChild.setAttendence(new Short("2"));
bulkEntrySubChild.addSavingsAccountDetail(clientSavingsAccountView);
bulkEntrySubChild.setCustomerAccountDetails(getCustomerAccountView(client));
bulkEntryChild.addChildNode(bulkEntrySubChild);
bulkEntryParent.addChildNode(bulkEntryChild);
LoanAccountsProductDto childView = bulkEntryChild.getLoanAccountDetails().get(0);
childView.setPrdOfferingId(groupLoanAccountView.getPrdOfferingId());
childView.setEnteredAmount("100.0");
LoanAccountsProductDto subchildView = bulkEntrySubChild.getLoanAccountDetails().get(0);
subchildView.setDisBursementAmountEntered(clientAccount.getLoanAmount().toString());
subchildView.setPrdOfferingId(clientLoanAccountView.getPrdOfferingId());
ProductDto loanOfferingDto = new ProductDto(loanOffering1.getPrdOfferingId(), loanOffering1.getPrdOfferingShortName());
ProductDto loanOfferingDto2 = new ProductDto(loanOffering2.getPrdOfferingId(), loanOffering2.getPrdOfferingShortName());
List<ProductDto> loanProducts = Arrays.asList(loanOfferingDto, loanOfferingDto2);
ProductDto savingsOfferingDto = new ProductDto(savingsOffering1.getPrdOfferingId(), savingsOffering1.getPrdOfferingShortName());
ProductDto savingsOfferingDto2 = new ProductDto(savingsOffering2.getPrdOfferingId(), savingsOffering2.getPrdOfferingShortName());
ProductDto savingsOfferingDto3 = new ProductDto(savingsOffering3.getPrdOfferingId(), savingsOffering3.getPrdOfferingShortName());
List<ProductDto> savingsProducts = Arrays.asList(savingsOfferingDto, savingsOfferingDto2, savingsOfferingDto3);
final PersonnelDto loanOfficer = getPersonnelView(center.getPersonnel());
final OfficeDetailsDto officeDetailsDto = null;
final List<CustomValueListElementDto> attendanceTypesList = new ArrayList<CustomValueListElementDto>();
bulkEntryParent.setCountOfCustomers(3);
final CollectionSheetEntryGridDto bulkEntry = new CollectionSheetEntryGridDto(bulkEntryParent, loanOfficer, officeDetailsDto, getPaymentTypeView(), startDate, "324343242", startDate, loanProducts, savingsProducts, attendanceTypesList);
return bulkEntry;
}
use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.
the class CustomerPersistenceIntegrationTest method getCustomer.
private void getCustomer() throws Exception {
Date startDate = new Date(System.currentTimeMillis());
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
LoanOfferingBO loanOffering1 = TestObjectFactory.createLoanOffering("Loanwer", "43fs", startDate, meeting);
LoanOfferingBO loanOffering2 = TestObjectFactory.createLoanOffering("Loancd123", "vfr", startDate, meeting);
groupAccount = TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering1);
clientAccount = TestObjectFactory.createLoanAccount("3243", client, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering2);
MeetingBO meetingIntCalc = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
MeetingBO meetingIntPost = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
SavingsOfferingBO savingsOffering = TestObjectFactory.createSavingsProduct("SavingPrd12", "abc1", startDate, RecommendedAmountUnit.COMPLETE_GROUP, meetingIntCalc, meetingIntPost);
SavingsOfferingBO savingsOffering1 = TestObjectFactory.createSavingsProduct("SavingPrd11", "abc2", startDate, RecommendedAmountUnit.COMPLETE_GROUP, meetingIntCalc, meetingIntPost);
centerSavingsAccount = TestObjectFactory.createSavingsAccount("432434", center, Short.valueOf("16"), startDate, savingsOffering);
clientSavingsAccount = TestObjectFactory.createSavingsAccount("432434", client, Short.valueOf("16"), startDate, savingsOffering1);
}
Aggregations