use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class SavingsAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
SavingsActionForm savingsActionForm = ((SavingsActionForm) form);
logger.debug("In SavingsAction::create(), accountStateId: " + savingsActionForm.getStateSelected());
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
CustomerBO customer = (CustomerBO) SessionUtils.getAttribute(SavingsConstants.CLIENT, request);
Integer customerId = customer.getCustomerId();
Integer productId = Integer.valueOf(savingsActionForm.getSelectedPrdOfferingId());
String recommendedOrMandatoryAmount = savingsActionForm.getRecommendedAmount();
Short accountState = Short.valueOf(savingsActionForm.getStateSelected());
customer = this.customerDao.findCustomerById(customerId);
checkPermissionForCreate(accountState, uc, customer.getOffice().getOfficeId(), customer.getPersonnel().getPersonnelId());
SavingsAccountCreationDto savingsAccountCreation = new SavingsAccountCreationDto(productId, customerId, accountState, recommendedOrMandatoryAmount);
Long savingsId = this.savingsServiceFacade.createSavingsAccount(savingsAccountCreation);
SavingsBO saving = this.savingsDao.findById(savingsId);
createGroupQuestionnaire.saveResponses(request, savingsActionForm, saving.getAccountId());
request.setAttribute(SavingsConstants.GLOBALACCOUNTNUM, saving.getGlobalAccountNum());
request.setAttribute(SavingsConstants.RECORD_OFFICE_ID, saving.getOffice().getOfficeId());
request.setAttribute(SavingsConstants.CLIENT_NAME, customer.getDisplayName());
request.setAttribute(SavingsConstants.CLIENT_ID, customer.getCustomerId());
request.setAttribute(SavingsConstants.CLIENT_LEVEL, customer.getCustomerLevel().getId());
logger.info("In SavingsAction::create(), Savings object saved successfully ");
return mapping.findForward("create_success");
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class SavingsAction method waiveAmountDue.
@TransactionDemarcate(joinToken = true)
public ActionForward waiveAmountDue(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In SavingsAction::waiveAmountDue()");
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
Integer versionNum = savings.getVersionNo();
savings = this.savingsDao.findBySystemId(((SavingsActionForm) form).getGlobalAccountNum());
checkVersionMismatch(versionNum, savings.getVersionNo());
savings.setUserContext(uc);
Long savingsId = savings.getAccountId().longValue();
this.savingsServiceFacade.waiveNextDepositAmountDue(savingsId);
return mapping.findForward("waiveAmount_success");
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class AccountRegenerateScheduleIntegrationTestCase method validateSchedules.
private void validateSchedules(List<LocalDate> expectedMeetingDates, List<LocalDate> expectedLoanMeetingDates) {
center = TestObjectFactory.getCenter(center.getCustomerId());
accountBO = TestObjectFactory.getObject(LoanBO.class, accountBO.getAccountId());
savingsBO = TestObjectFactory.getObject(SavingsBO.class, savingsBO.getAccountId());
int count = 0;
for (AccountActionDateEntity actionDateEntity : center.getCustomerAccount().getAccountActionDates()) {
if (count < expectedMeetingDates.size()) {
checkScheduleDates(expectedMeetingDates.get(count), actionDateEntity);
}
++count;
}
log("---");
org.junit.Assert.assertEquals(numberOfLoanInstallments, (accountBO.getAccountActionDates().size()));
count = 0;
for (AccountActionDateEntity actionDateEntity : accountBO.getAccountActionDates()) {
if (count < expectedLoanMeetingDates.size()) {
checkScheduleDates(expectedLoanMeetingDates.get(count), actionDateEntity);
}
++count;
}
log("+++");
count = 0;
for (AccountActionDateEntity actionDateEntity : savingsBO.getAccountActionDates()) {
if (count < expectedLoanMeetingDates.size()) {
checkScheduleDates(expectedLoanMeetingDates.get(count), actionDateEntity);
}
++count;
}
log("===");
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class AccountRegenerateScheduleIntegrationTestCase method validateSchedulesForClosedAndCancelled.
private void validateSchedulesForClosedAndCancelled(List<LocalDate> expectedMeetingDates, List<LocalDate> expectedLoanMeetingDates) {
center = TestObjectFactory.getCenter(center.getCustomerId());
accountBO = TestObjectFactory.getObject(LoanBO.class, accountBO.getAccountId());
savingsBO = TestObjectFactory.getObject(SavingsBO.class, savingsBO.getAccountId());
int count = 0;
for (AccountActionDateEntity actionDateEntity : group.getCustomerAccount().getAccountActionDates()) {
if (count < expectedMeetingDates.size()) {
checkScheduleDates(expectedMeetingDates.get(count), actionDateEntity);
}
++count;
}
log("---");
count = 0;
for (AccountActionDateEntity actionDateEntity : accountBO.getAccountActionDates()) {
if (count < expectedLoanMeetingDates.size()) {
checkScheduleDates(expectedLoanMeetingDates.get(count), actionDateEntity);
}
++count;
}
log("+++");
count = 0;
for (AccountActionDateEntity actionDateEntity : savingsBO.getAccountActionDates()) {
if (count < expectedLoanMeetingDates.size()) {
checkScheduleDates(expectedLoanMeetingDates.get(count), actionDateEntity);
}
++count;
}
log("===");
}
use of org.mifos.accounts.savings.business.SavingsBO 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;
}
Aggregations