use of org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity in project head by mifos.
the class TestObjectFactory method deleteSpecificAccount.
private static void deleteSpecificAccount(final AccountBO account, final Session session) {
if (account instanceof LoanBO) {
LoanBO loan = (LoanBO) account;
if (null != loan.getLoanSummary()) {
session.delete(loan.getLoanSummary());
}
session.delete(account);
loan.getLoanOffering().getLoanOfferingMeeting().setMeeting(null);
session.delete(loan.getLoanOffering().getLoanOfferingMeeting());
session.delete(loan.getLoanOffering());
}
if (account instanceof SavingsBO) {
SavingsBO savings = (SavingsBO) account;
session.delete(account);
// FIXME - no longer create a meeting to track intereswt calculation for each savings account, instead we always use value from savigns product.
// session.delete(savings.getTimePerForInstcalc());
PrdOfferingMeetingEntity prdOfferingMeeting1 = savings.getSavingsOffering().getTimePerForInstcalc();
prdOfferingMeeting1.setMeeting(null);
session.delete(prdOfferingMeeting1);
PrdOfferingMeetingEntity prdOfferingMeeting2 = savings.getSavingsOffering().getFreqOfPostIntcalc();
prdOfferingMeeting2.setMeeting(null);
session.delete(prdOfferingMeeting2);
session.delete(savings.getSavingsOffering());
} else {
session.delete(account);
}
}
use of org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity in project head by mifos.
the class AdminServiceFacadeWebTier method updateLoanProduct.
@Override
public PrdOfferingDto updateLoanProduct(LoanProductRequest loanProductRequest) {
LoanOfferingBO loanProductForUpdate = this.loanProductDao.findById(loanProductRequest.getProductDetails().getId());
// enforced by integrity constraints on table also.
if (loanProductForUpdate.isDifferentName(loanProductRequest.getProductDetails().getName())) {
this.savingsProductDao.validateProductWithSameNameDoesNotExist(loanProductRequest.getProductDetails().getName());
}
if (loanProductForUpdate.isDifferentShortName(loanProductRequest.getProductDetails().getShortName())) {
this.savingsProductDao.validateProductWithSameShortNameDoesNotExist(loanProductRequest.getProductDetails().getShortName());
}
// domain rule validation - put on domain entity
if (loanProductForUpdate.isDifferentStartDate(loanProductRequest.getProductDetails().getStartDate())) {
validateStartDateIsNotBeforeToday(loanProductRequest.getProductDetails().getStartDate());
validateStartDateIsNotOverOneYearFromToday(loanProductRequest.getProductDetails().getStartDate());
validateEndDateIsPastStartDate(loanProductRequest.getProductDetails().getStartDate(), loanProductRequest.getProductDetails().getEndDate());
}
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
LoanOfferingBO newLoanProductDetails = this.loanProductAssembler.fromDto(user, loanProductRequest);
loanProductForUpdate.updateDetails(userContext);
HibernateTransactionHelper transactionHelper = new HibernateTransactionHelperForStaticHibernateUtil();
try {
transactionHelper.startTransaction();
transactionHelper.beginAuditLoggingFor(loanProductForUpdate);
loanProductForUpdate.updateDetailsOfProductNotInUse(newLoanProductDetails.getPrdOfferingName(), newLoanProductDetails.getPrdOfferingShortName(), newLoanProductDetails.getDescription(), newLoanProductDetails.getPrdCategory(), newLoanProductDetails.getStartDate(), newLoanProductDetails.getEndDate(), newLoanProductDetails.getPrdApplicableMaster(), newLoanProductDetails.getPrdStatus());
loanProductForUpdate.update(newLoanProductDetails.isIncludeInLoanCounter(), newLoanProductDetails.isInterestWaived());
if (newLoanProductDetails.isLoanAmountTypeSameForAllLoan()) {
loanProductForUpdate.updateLoanAmountDetails(newLoanProductDetails.getEligibleLoanAmountSameForAllLoan());
} else if (newLoanProductDetails.isLoanAmountTypeAsOfLastLoanAmount()) {
loanProductForUpdate.updateLoanAmountByLastLoanDetails(newLoanProductDetails.getLoanAmountFromLastLoan());
} else if (newLoanProductDetails.isLoanAmountTypeFromLoanCycle()) {
loanProductForUpdate.updateLoanAmountLoanCycleDetails(newLoanProductDetails.getLoanAmountFromLoanCycle());
}
loanProductForUpdate.updateInterestRateDetails(newLoanProductDetails.getMinInterestRate(), newLoanProductDetails.getMaxInterestRate(), newLoanProductDetails.getDefInterestRate());
PrdOfferingMeetingEntity entity = newLoanProductDetails.getLoanOfferingMeeting();
MeetingBO meeting = new MeetingBO(entity.getMeeting().getRecurrenceType(), entity.getMeeting().getRecurAfter(), entity.getMeeting().getStartDate(), MeetingType.LOAN_INSTALLMENT);
loanProductForUpdate.updateRepaymentDetails(meeting, newLoanProductDetails.getGracePeriodType(), newLoanProductDetails.getGracePeriodDuration());
if (newLoanProductDetails.isNoOfInstallTypeSameForAllLoan()) {
loanProductForUpdate.updateInstallmentDetails(newLoanProductDetails.getNoOfInstallSameForAllLoan());
} else if (newLoanProductDetails.isNoOfInstallTypeFromLastLoan()) {
loanProductForUpdate.updateInstallmentByLastLoanDetails(newLoanProductDetails.getNoOfInstallFromLastLoan());
} else if (newLoanProductDetails.isNoOfInstallTypeFromLoanCycle()) {
loanProductForUpdate.updateInstallmentLoanCycleDetails(newLoanProductDetails.getNoOfInstallFromLoanCycle());
}
loanProductForUpdate.updateFees(newLoanProductDetails.getLoanOfferingFees());
loanProductForUpdate.updateFunds(newLoanProductDetails.getLoanOfferingFunds());
loanProductForUpdate.updatePenalties(newLoanProductDetails.getLoanOfferingPenalties());
this.loanProductDao.save(loanProductForUpdate);
transactionHelper.commitTransaction();
return loanProductForUpdate.toDto();
} catch (Exception e) {
transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
transactionHelper.closeSession();
}
}
use of org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity in project head by mifos.
the class LoanProductBuilder method build.
private LoanOfferingBO build() {
final LoanOfferingBO loanProduct = new LoanOfferingBO(depositGLCode, interesetGLCode, interestType, minInterestRate, maxInterestRate, defaultInterestRate, interestPaidAtDisbursement, principalDueLastInstallment, name, shortName, globalProductNumber, startDate, applicableToCustomer, category, productStatusEntity, createdDate, createdByUserId);
if (useLoanAmountSameForAllLoans) {
final Double minLoanAmount = Double.valueOf("100.0");
final Double maxLoanAmount = Double.valueOf("100000.0");
final Double defaultLoanAmount = Double.valueOf("1000.0");
loanProduct.setLoanAmountSameForAllLoan(new LoanAmountSameForAllLoanBO(minLoanAmount, maxLoanAmount, defaultLoanAmount, loanProduct));
}
if (useNoOfInstallSameForAllLoans) {
final Short minNoOfInstallmentsForLoan = Short.valueOf("1");
final Short maxNoOfInstallmentsForLoan = Short.valueOf("11");
final Short defaultNoOfInstallmentsForLoan = Short.valueOf("6");
loanProduct.setNoOfInstallSameForAllLoan(new NoOfInstallSameForAllLoanBO(minNoOfInstallmentsForLoan, maxNoOfInstallmentsForLoan, defaultNoOfInstallmentsForLoan, loanProduct));
}
loanProduct.setGracePeriodType(new GracePeriodTypeEntity(graceType));
loanProduct.setLoanOfferingMeeting(new PrdOfferingMeetingEntity(meeting, loanProduct, MeetingType.LOAN_INSTALLMENT));
return loanProduct;
}
use of org.mifos.accounts.productdefinition.business.PrdOfferingMeetingEntity 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;
}
Aggregations