use of org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto in project head by mifos.
the class LoanAccountServiceFacadeWebTier method retrieveMultipleLoanAccountDetails.
@Override
public MultipleLoanAccountDetailsDto retrieveMultipleLoanAccountDetails(String searchId, Short branchId, Integer productId) {
List<ClientBO> clients = this.customerDao.findActiveClientsUnderParent(searchId, branchId);
if (clients.isEmpty()) {
throw new BusinessRuleException(LoanConstants.NOSEARCHRESULTS);
}
LoanOfferingBO loanOffering = this.loanProductDao.findById(productId);
// FIXME - Refactor MultipleLoanCreationDto into proper Dto
List<MultipleLoanCreationDto> multipleLoanDetails = buildClientViewHelper(loanOffering, clients);
List<ValueListElement> allLoanPruposes = this.loanProductDao.findAllLoanPurposes();
boolean loanPendingApprovalStateEnabled = ProcessFlowRules.isLoanPendingApprovalStateEnabled();
return new MultipleLoanAccountDetailsDto(allLoanPruposes, loanPendingApprovalStateEnabled);
}
use of org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto in project head by mifos.
the class MultipleLoanAccountsCreationAction method get.
@TransactionDemarcate(joinToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
MultipleLoanAccountsCreationActionForm loanActionForm = (MultipleLoanAccountsCreationActionForm) form;
String searchId = loanActionForm.getCenterSearchId();
Short branchId = getShortValue(loanActionForm.getBranchOfficeId());
Integer productId = Integer.parseInt(loanActionForm.getPrdOfferingId());
MultipleLoanAccountDetailsDto multipleLoanDetails = this.loanAccountServiceFacade.retrieveMultipleLoanAccountDetails(searchId, branchId, productId);
List<ClientBO> clients = this.customerDao.findActiveClientsUnderParent(searchId, branchId);
if (clients.isEmpty()) {
throw new BusinessRuleException(LoanConstants.NOSEARCHRESULTS);
}
LoanOfferingBO loanOffering = this.loanProductDao.findById(productId);
List<MultipleLoanCreationDto> multipleLoanDetailsXX = buildClientViewHelper(loanOffering, clients);
loanActionForm.setClientDetails(multipleLoanDetailsXX);
SessionUtils.setAttribute(LoanConstants.LOANOFFERING, loanOffering, request);
SessionUtils.setCollectionAttribute(MasterConstants.BUSINESS_ACTIVITIES, multipleLoanDetails.getAllLoanPruposes(), request);
SessionUtils.setAttribute(CustomerConstants.PENDING_APPROVAL_DEFINED, multipleLoanDetails.isLoanPendingApprovalStateEnabled(), request);
return mapping.findForward(ActionForwards.get_success.toString());
}
use of org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto in project head by mifos.
the class MultipleLoanAccountsCreationAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
MultipleLoanAccountsCreationActionForm loanActionForm = (MultipleLoanAccountsCreationActionForm) form;
Integer centerId = getIntegerValue(loanActionForm.getCenterId());
Short loanProductId = getShortValue(loanActionForm.getPrdOfferingId());
Short accountStateId = getShortValue(loanActionForm.getStateSelected());
List<MultipleLoanCreationDto> applicableClientDetails = loanActionForm.getApplicableClientDetails();
List<CreateLoanRequest> createMultipleLoans = new ArrayList<CreateLoanRequest>();
for (MultipleLoanCreationDto clientDetail : applicableClientDetails) {
CreateLoanRequest createLoanRequest = new CreateLoanRequest(centerId, loanProductId, accountStateId, clientDetail.getClientId(), clientDetail.getLoanAmount(), clientDetail.getDefaultNoOfInstall(), clientDetail.getMaxLoanAmount().toString(), clientDetail.getMinLoanAmount().toString(), clientDetail.getMaxNoOfInstall(), clientDetail.getMinNoOfInstall(), getIntegerValue(clientDetail.getBusinessActivity()));
createMultipleLoans.add(createLoanRequest);
}
List<String> accountNumbers = this.loanAccountServiceFacade.createMultipleLoans(createMultipleLoans);
request.setAttribute(LoanConstants.ACCOUNTS_LIST, accountNumbers);
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.accounts.loan.util.helpers.MultipleLoanCreationDto in project head by mifos.
the class MultipleLoanAccountsCreationActionForm method checkValidationForCreate.
private void checkValidationForCreate(ActionErrors errors, HttpServletRequest request) throws PageExpiredException, ServiceException {
logger.debug("inside checkValidationForCreate method");
List<MultipleLoanCreationDto> applicableClientDetails = getApplicableClientDetails();
if (CollectionUtils.isEmpty(applicableClientDetails)) {
addError(errors, LoanConstants.APPL_RECORDS, LoanExceptionConstants.SELECT_ATLEAST_ONE_RECORD, getLabel(ConfigurationConstants.CLIENT));
return;
}
for (MultipleLoanCreationDto clientDetail : applicableClientDetails) {
try {
if (!clientDetail.isLoanAmountInRange()) {
addError(errors, LoanConstants.LOANAMOUNT, LoanExceptionConstants.INVALIDMINMAX, this.getLocalizedMessage("loan.loanAmountFor") + clientDetail.getClientName(), clientDetail.getMinLoanAmount().toString(), clientDetail.getMaxLoanAmount().toString());
}
} catch (NumberFormatException nfe) {
addError(errors, LoanConstants.LOANAMOUNT, LoanExceptionConstants.INVALIDMINMAX, this.getLocalizedMessage("loan.loanAmountFor") + clientDetail.getClientName(), clientDetail.getMinLoanAmount().toString(), clientDetail.getMaxLoanAmount().toString());
}
if (StringUtils.isEmpty(clientDetail.getBusinessActivity()) && isPurposeOfLoanMandatory(request)) {
addError(errors, LoanConstants.PURPOSE_OF_LOAN, LoanExceptionConstants.CUSTOMER_PURPOSE_OF_LOAN_FIELD);
}
}
logger.debug("outside checkValidationForCreate method");
}
Aggregations