use of org.mifos.dto.domain.CreateAccountPenaltyDto in project head by mifos.
the class GroupLoanAccountController method retrieveLoanSchedule.
public LoanScheduleDto retrieveLoanSchedule(int customerId, int productId, LoanAccountFormBean formBean, LoanScheduleFormBean loanScheduleFormBean, boolean resetRedoLoanAccountDetails) {
LoanApplicationStateDto applicationState = loanAccountServiceFacade.retrieveLoanApplicationState();
Integer accountState = applicationState.getConfiguredApplicationId();
LocalDate disbursementDate = LoanCreationHelper.translateDisbursementDateToLocalDate(formBean);
RecurringSchedule recurringSchedule = LoanCreationHelper.determineRecurringSchedule(formBean);
List<CreateAccountFeeDto> accountFees = LoanCreationHelper.translateToAccountFeeDtos(formBean);
List<CreateAccountFeeDto> additionalAccountFees = LoanCreationHelper.translateToAdditionalAccountFeeDtos(formBean);
List<CreateAccountPenaltyDto> accountPenalties = LoanCreationHelper.translateToAccountPenaltyDtos(formBean);
accountFees.addAll(additionalAccountFees);
Map<String, List<CreateAccountFeeDto>> memberAccountsFees = LoanCreationHelper.translateToMemberAccountsFeeDtos(formBean);
Map<String, List<CreateAccountFeeDto>> memberAccountsAdditionalFees = LoanCreationHelper.translateToMemberAccountsAdditionalFeeDtos(formBean);
for (Map.Entry<String, List<CreateAccountFeeDto>> memberAccountEntry : memberAccountsAdditionalFees.entrySet()) {
memberAccountsFees.get(memberAccountEntry.getKey()).addAll(memberAccountsAdditionalFees.get(memberAccountEntry.getKey()));
}
BigDecimal loanAmount = BigDecimal.valueOf(formBean.getAmount().doubleValue());
BigDecimal minAllowedLoanAmount = BigDecimal.valueOf(formBean.getMinAllowedAmount().doubleValue());
BigDecimal maxAllowedLoanAmount = BigDecimal.valueOf(formBean.getMaxAllowedAmount().doubleValue());
CreateLoanAccount loanAccountDetails = prepareLoanAccount(accountState, formBean, disbursementDate, recurringSchedule, accountFees, accountPenalties, loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount);
List<CreateLoanAccount> memberAccounts = createGroupLoanMembers(accountState, formBean, disbursementDate, recurringSchedule, memberAccountsFees, accountPenalties, loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount);
BigDecimal totalLoanAmount = BigDecimal.valueOf(formBean.getAmount().doubleValue());
CreateGroupLoanAccount createGroupLoanAccount = new CreateGroupLoanAccount(memberAccounts, totalLoanAmount, loanAccountDetails);
GroupLoanScheduleDto groupLoanScheduleDto = groupLoanAccountServiceFacade.getGroupLoanScheduleDto(createGroupLoanAccount, memberAccounts);
List<String> globalMemberIds = loanControllerHelper.getSelectedMemberGlobalIds(formBean);
List<Integer> memberIds = loanControllerHelper.getSelectedMemberIdsFromFormBean(formBean);
List<BigDecimal> memberAmounts = loanControllerHelper.getSelectedMemberAmounts(formBean);
loanScheduleFormBean.setVariableInstallments(groupLoanScheduleDto.getInstallments());
for (int i = 0; i < memberIds.size(); ++i) {
Integer memberId = memberIds.get(i);
String memberIdString = memberId.toString();
LoanScheduleFormBean memberScheduleBean = loanScheduleFormBean.getMemberSchedules().get(memberIdString);
if (memberScheduleBean == null) {
memberScheduleBean = new LoanScheduleFormBean();
}
memberScheduleBean.setGlobalCustomerId(globalMemberIds.get(i));
loanScheduleFormBean.getMemberSchedules().put(memberIdString, memberScheduleBean);
LoanScheduleDto memberLoanSchedule = groupLoanScheduleDto.getMemberSchedules().get(memberId);
loanControllerHelper.populateFormBeanFromDto(memberId, productId, formBean, memberScheduleBean, disbursementDate, memberLoanSchedule, resetRedoLoanAccountDetails);
memberScheduleBean.setLoanPrincipal(memberAmounts.get(i));
loanScheduleFormBean.setInstallments(memberScheduleBean.getInstallments());
}
loanScheduleFormBean.setActualPaymentAmounts(new ArrayList<Number>());
return groupLoanScheduleDto;
}
use of org.mifos.dto.domain.CreateAccountPenaltyDto in project head by mifos.
the class LoanAccountController method submitLoanApplication.
private LoanCreationResultDto submitLoanApplication(Integer accountState, LoanAccountFormBean formBean, LoanAccountQuestionGroupFormBean loanAccountQuestionGroupFormBean, LoanAccountCashFlow loanAccountCashFlow, CashFlowSummaryFormBean cashFlowSummaryFormBean, LoanScheduleFormBean loanScheduleFormBean) {
LocalDate disbursementDate = LoanCreationHelper.translateDisbursementDateToLocalDate(formBean);
RecurringSchedule recurringSchedule = LoanCreationHelper.determineRecurringSchedule(formBean);
List<CreateAccountFeeDto> accountFees = LoanCreationHelper.translateToAccountFeeDtos(formBean);
List<CreateAccountFeeDto> additionalAccountFees = LoanCreationHelper.translateToAdditionalAccountFeeDtos(formBean);
List<CreateAccountPenaltyDto> accountPenalties = LoanCreationHelper.translateToAccountPenaltyDtos(formBean);
accountFees.addAll(additionalAccountFees);
BigDecimal loanAmount = BigDecimal.valueOf(formBean.getAmount().doubleValue());
BigDecimal minAllowedLoanAmount = BigDecimal.valueOf(formBean.getMinAllowedAmount().doubleValue());
BigDecimal maxAllowedLoanAmount = BigDecimal.valueOf(formBean.getMaxAllowedAmount().doubleValue());
CreateLoanAccount loanAccountDetails = new CreateLoanAccount(formBean.getCustomerId(), formBean.getProductId(), accountState, loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount, formBean.getInterestRate().doubleValue(), disbursementDate, null, formBean.getNumberOfInstallments().intValue(), formBean.getMinNumberOfInstallments().intValue(), formBean.getMaxNumberOfInstallments().intValue(), formBean.getGraceDuration().intValue(), formBean.getFundId(), formBean.getLoanPurposeId(), formBean.getCollateralTypeId(), formBean.getCollateralNotes(), formBean.getExternalId(), formBean.isRepaymentScheduleIndependentOfCustomerMeeting(), recurringSchedule, accountFees, accountPenalties);
LoanCreationResultDto loanCreationResultDto = null;
if (formBean.isGlimApplicable()) {
List<GroupMemberAccountDto> memberAccounts = createGroupMemberAccounts(formBean);
BigDecimal totalLoanAmount = BigDecimal.valueOf(formBean.getAmount().doubleValue());
CreateGlimLoanAccount createGroupLoanAccount = new CreateGlimLoanAccount(memberAccounts, totalLoanAmount, loanAccountDetails);
loanCreationResultDto = loanAccountServiceFacade.createGroupLoanWithIndividualMonitoring(createGroupLoanAccount, loanAccountQuestionGroupFormBean.getQuestionGroups(), loanAccountCashFlow);
} else {
if (formBean.isVariableInstallmentsAllowed()) {
List<DateTime> installmentDates = cashFlowSummaryFormBean.getInstallments();
List<Number> totalInstallmentAmounts = cashFlowSummaryFormBean.getInstallmentAmounts();
if (installmentDates.isEmpty()) {
installmentDates = loanScheduleFormBean.getInstallments();
totalInstallmentAmounts = loanScheduleFormBean.getInstallmentAmounts();
}
// api for creating loan with premade loan schedule
loanCreationResultDto = loanAccountServiceFacade.createLoan(loanAccountDetails, loanAccountQuestionGroupFormBean.getQuestionGroups(), loanAccountCashFlow, installmentDates, totalInstallmentAmounts);
} else {
loanCreationResultDto = loanAccountServiceFacade.createLoan(loanAccountDetails, loanAccountQuestionGroupFormBean.getQuestionGroups(), loanAccountCashFlow);
}
}
List<CommonsMultipartFile> formFiles = formBean.getFiles();
List<UploadedFileDto> filesMetadata = formBean.getFilesMetadata();
for (int i = 0; i < formFiles.size(); i++) {
if (formFiles.get(i).getSize() != 0) {
InputStream inputStream;
try {
inputStream = formFiles.get(i).getInputStream();
} catch (IOException e) {
throw new MifosRuntimeException();
}
UploadedFileDto fileMetadata = filesMetadata.get(i);
loanAccountServiceFacade.uploadFile(loanCreationResultDto.getAccountId(), inputStream, fileMetadata);
}
}
return loanCreationResultDto;
}
use of org.mifos.dto.domain.CreateAccountPenaltyDto in project head by mifos.
the class LoanAccountController method submitLoanWithBackdatedPaymentsApplication.
private LoanCreationResultDto submitLoanWithBackdatedPaymentsApplication(Integer accountState, LoanAccountFormBean formBean, LoanAccountQuestionGroupFormBean loanAccountQuestionGroupFormBean, LoanAccountCashFlow loanAccountCashFlow, CashFlowSummaryFormBean cashFlowSummaryFormBean, LoanScheduleFormBean loanScheduleFormBean) {
LocalDate disbursementDate = LoanCreationHelper.translateDisbursementDateToLocalDate(formBean);
RecurringSchedule recurringSchedule = LoanCreationHelper.determineRecurringSchedule(formBean);
List<CreateAccountFeeDto> accountFees = LoanCreationHelper.translateToAccountFeeDtos(formBean);
List<CreateAccountPenaltyDto> accountPenalties = LoanCreationHelper.translateToAccountPenaltyDtos(formBean);
List<CreateAccountFeeDto> additionalAccountFees = LoanCreationHelper.translateToAdditionalAccountFeeDtos(formBean);
accountFees.addAll(additionalAccountFees);
BigDecimal loanAmount = BigDecimal.valueOf(formBean.getAmount().doubleValue());
BigDecimal minAllowedLoanAmount = BigDecimal.valueOf(formBean.getMinAllowedAmount().doubleValue());
BigDecimal maxAllowedLoanAmount = BigDecimal.valueOf(formBean.getMaxAllowedAmount().doubleValue());
CreateLoanAccount loanAccountDetails = new CreateLoanAccount(formBean.getCustomerId(), formBean.getProductId(), accountState, loanAmount, minAllowedLoanAmount, maxAllowedLoanAmount, formBean.getInterestRate().doubleValue(), disbursementDate, formBean.getDisbursalPaymentTypeId(), formBean.getNumberOfInstallments().intValue(), formBean.getMinNumberOfInstallments().intValue(), formBean.getMaxNumberOfInstallments().intValue(), formBean.getGraceDuration().intValue(), formBean.getFundId(), formBean.getLoanPurposeId(), formBean.getCollateralTypeId(), formBean.getCollateralNotes(), formBean.getExternalId(), formBean.isRepaymentScheduleIndependentOfCustomerMeeting(), recurringSchedule, accountFees, accountPenalties);
List<LoanPaymentDto> backdatedLoanPayments = new ArrayList<LoanPaymentDto>();
int index = 0;
List<Number> actualPaymentAmountDetails = cashFlowSummaryFormBean.getActualPaymentAmounts();
if (actualPaymentAmountDetails.isEmpty()) {
actualPaymentAmountDetails = loanScheduleFormBean.getActualPaymentAmounts();
}
for (Number actualPaymentAmount : actualPaymentAmountDetails) {
if (actualPaymentAmount.doubleValue() > 0) {
LocalDate transactionDate = new LocalDate(loanScheduleFormBean.getActualPaymentDates().get(index));
backdatedLoanPayments.add(new LoanPaymentDto(actualPaymentAmount.toString(), transactionDate, loanScheduleFormBean.getActualPaymentTypes().get(index), null));
}
index++;
}
LoanCreationResultDto loanCreationResultDto = null;
if (formBean.isGlimApplicable()) {
List<GroupMemberAccountDto> memberAccounts = createGroupMemberAccounts(formBean);
BigDecimal totalLoanAmount = BigDecimal.valueOf(formBean.getAmount().doubleValue());
CreateGlimLoanAccount createGroupLoanAccount = new CreateGlimLoanAccount(memberAccounts, totalLoanAmount, loanAccountDetails);
loanCreationResultDto = loanAccountServiceFacade.createBackdatedGroupLoanWithIndividualMonitoring(createGroupLoanAccount, backdatedLoanPayments, loanAccountQuestionGroupFormBean.getQuestionGroups(), loanAccountCashFlow);
} else if (formBean.isVariableInstallmentsAllowed()) {
List<DateTime> installmentDates = cashFlowSummaryFormBean.getInstallments();
List<Number> installmentPrincipalAmounts = cashFlowSummaryFormBean.getInstallmentAmounts();
if (installmentDates.isEmpty()) {
installmentDates = loanScheduleFormBean.getInstallments();
installmentPrincipalAmounts = loanScheduleFormBean.getInstallmentAmounts();
}
// api for creating loan with premade loan schedule
loanCreationResultDto = loanAccountServiceFacade.createBackdatedLoan(loanAccountDetails, backdatedLoanPayments, loanAccountQuestionGroupFormBean.getQuestionGroups(), loanAccountCashFlow, installmentDates, installmentPrincipalAmounts);
} else {
loanCreationResultDto = loanAccountServiceFacade.createBackdatedLoan(loanAccountDetails, backdatedLoanPayments, loanAccountQuestionGroupFormBean.getQuestionGroups(), loanAccountCashFlow);
}
return loanCreationResultDto;
}
use of org.mifos.dto.domain.CreateAccountPenaltyDto in project head by mifos.
the class LoanCreationHelper method translateToAccountPenaltyDtos.
public static List<CreateAccountPenaltyDto> translateToAccountPenaltyDtos(LoanAccountFormBean formBean) {
List<CreateAccountPenaltyDto> accountPenalties = new ArrayList<CreateAccountPenaltyDto>();
Number[] defaultPenaltyIds = formBean.getDefaultPenaltyId();
if (defaultPenaltyIds != null) {
int penaltyIndex = 0;
CreateAccountPenaltyDto accountPenalty = null;
for (Number penaltyId : defaultPenaltyIds) {
Boolean removeDefaultPenaltySelected = formBean.getDefaultPenaltySelected()[penaltyIndex];
if (removeDefaultPenaltySelected == null || !removeDefaultPenaltySelected) {
String amount = formBean.getDefaultPenaltyAmountOrRate()[penaltyIndex].toString();
accountPenalty = new CreateAccountPenaltyDto(penaltyId.intValue(), amount);
accountPenalties.add(accountPenalty);
}
penaltyIndex++;
}
}
return accountPenalties;
}
use of org.mifos.dto.domain.CreateAccountPenaltyDto in project head by mifos.
the class ImportLoansSavingsFacadeWebTier method saveLoans.
@Override
public ParsedLoansDto saveLoans(ParsedLoansDto parsedLoansDto) {
List<CreateAccountFeeDto> defaultAccountFees = new ArrayList<CreateAccountFeeDto>();
List<QuestionGroupDetail> questionGroupDetails = new ArrayList<QuestionGroupDetail>();
List<CreateAccountPenaltyDto> defaultPenalties = new ArrayList<CreateAccountPenaltyDto>();
for (ImportedLoanDetail detail : parsedLoansDto.getSuccessfullyParsedRows()) {
LoanCreationLoanDetailsDto lcldd = loanAccountServiceFacade.retrieveLoanDetailsForLoanAccountCreation(detail.getCustomerId(), detail.getPrdOfferingId(), false);
RecurringSchedule recurringSchedule = null;
MeetingDto meetingDto = lcldd.getCustomerMeetingDetail();
int meetingEvery = (lcldd.isRepaymentIndependentOfMeetingEnabled()) ? lcldd.getLoanOfferingMeetingDetail().getMeetingDetailsDto().getEvery() : meetingDto.getMeetingDetailsDto().getEvery();
int loanRecurrenceTypeId = (lcldd.isRepaymentIndependentOfMeetingEnabled()) ? lcldd.getLoanOfferingMeetingDetail().getMeetingDetailsDto().getRecurrenceTypeId() : meetingDto.getMeetingDetailsDto().getRecurrenceTypeId();
if (loanRecurrenceTypeId == 1) {
recurringSchedule = new WeeklySchedule(meetingEvery, meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getDayOfWeek());
} else if (loanRecurrenceTypeId == 2) {
if (meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getWeekOfMonth().equals(0)) {
recurringSchedule = new MonthlyOnDayOfMonthSchedule(meetingEvery, meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getDayNumber());
} else {
recurringSchedule = new MonthlyOnWeekOfMonthSchedule(meetingEvery, meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getWeekOfMonth(), meetingDto.getMeetingDetailsDto().getRecurrenceDetails().getDayOfWeek());
}
} else if (loanRecurrenceTypeId == 3) {
recurringSchedule = new DailySchedule(meetingEvery);
}
CreateLoanAccount cla = new CreateLoanAccount(detail.getCustomerId(), new Integer(detail.getPrdOfferingId()), new Integer(detail.getStatus()), detail.getLoanAmount(), lcldd.getMinLoanAmount(), lcldd.getMaxLoanAmount(), detail.getInterestRate().doubleValue(), new LocalDate(detail.getDisbursalDate().getTime()), null, detail.getNumberOfInstallments(), lcldd.getMinNumberOfInstallments(), lcldd.getMaxNumberOfInstallments(), detail.getGracePeriod(), detail.getSourceOfFundId(), detail.getLoanPurposeId(), detail.getCollateralTypeId(), detail.getCollateralNotes(), detail.getExternalId(), lcldd.isRepaymentIndependentOfMeetingEnabled(), recurringSchedule, defaultAccountFees, defaultPenalties);
cla.setPredefinedAccountNumber(detail.getAccountNumber());
cla.setFlagId(detail.getFlag());
this.loanAccountServiceFacade.createLoan(cla, questionGroupDetails, null);
}
return null;
}
Aggregations