use of org.mifos.application.master.business.InterestTypesEntity in project head by mifos.
the class LoanBusinessServiceTest method shouldNotComputeVariableInstallmentSchedule.
@SuppressWarnings("unchecked")
@Test
public void shouldNotComputeVariableInstallmentSchedule() throws Exception {
LoanAccountActionForm loanAccountActionForm = mock(LoanAccountActionForm.class);
when(loanAccountActionForm.isVariableInstallmentsAllowed()).thenReturn(false);
InterestTypesEntity interestTypesEntity = new InterestTypesEntity(InterestType.DECLINING);
when(loanBO.getInterestType()).thenReturn(interestTypesEntity);
when(legacyLoanDao.findBySystemId(anyString())).thenReturn(loanBO);
loanBusinessService.applyDailyInterestRatesWhereApplicable(new LoanScheduleGenerationDto(TestUtils.getDate(22, 8, 2010), loanBO, loanAccountActionForm.isVariableInstallmentsAllowed(), loanAccountActionForm.getLoanAmountValue(), loanAccountActionForm.getInterestDoubleValue()), locale);
verify(loanBO, never()).updateInstallmentSchedule(any(List.class));
}
use of org.mifos.application.master.business.InterestTypesEntity in project head by mifos.
the class LoanOfferingBOIntegrationTest method createIntitalObjects.
private void createIntitalObjects() {
prdApplicableMaster = new PrdApplicableMasterEntity(ApplicableTo.CLIENTS);
frequency = getMeeting();
principalglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, (short) 7);
intglCodeEntity = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, (short) 7);
productCategory = TestObjectFactory.getLoanPrdCategory();
interestTypes = new InterestTypesEntity(InterestType.FLAT);
}
use of org.mifos.application.master.business.InterestTypesEntity in project head by mifos.
the class LoanOfferingBOIntegrationTest method testLoanOfferingWithEqualPrincipalDecliningInterestNoDeductionAtDisbursement.
@Test
public void testLoanOfferingWithEqualPrincipalDecliningInterestNoDeductionAtDisbursement() throws Exception {
createIntitalObjects();
interestTypes = new InterestTypesEntity(InterestType.DECLINING_EPI);
Date startDate = offSetCurrentDate(0);
Date endDate = offSetCurrentDate(2);
LoanOfferingBO loanOffering = new LoanOfferingBO(TestObjectFactory.getContext(), "Loan Offering", "LOAP", productCategory, prdApplicableMaster, startDate, endDate, null, null, null, interestTypes, new Money(getCurrency(), "1000"), new Money(getCurrency(), "3000"), new Money(getCurrency(), "2000.0"), 12.0, 2.0, 3.0, (short) 20, (short) 11, (short) 17, false, false, false, null, null, null, frequency, principalglCodeEntity, intglCodeEntity, waiverInterest);
Assert.assertEquals(InterestType.DECLINING_EPI, loanOffering.getInterestType());
}
use of org.mifos.application.master.business.InterestTypesEntity in project head by mifos.
the class TestObjectFactory method createLoanOfferingFromLastLoan.
public static LoanOfferingBO createLoanOfferingFromLastLoan(final String name, final String shortName, final ApplicableTo applicableTo, final Date startDate, final PrdStatus offeringStatus, final Double defIntRate, final InterestType interestType, final boolean interestDeductedAtDisbursement, final boolean principalDueInLastInstallment, final MeetingBO meeting, final GraceType graceType, final LoanPrdActionForm loanPrdActionForm) {
PrdApplicableMasterEntity prdApplicableMaster = new PrdApplicableMasterEntity(applicableTo);
ProductCategoryBO productCategory = TestObjectFactory.getLoanPrdCategory();
GracePeriodTypeEntity gracePeriodType = new GracePeriodTypeEntity(graceType);
InterestTypesEntity interestTypes = new InterestTypesEntity(interestType);
GLCodeEntity glCodePrincipal = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, Short.valueOf("11"));
GLCodeEntity glCodeInterest = (GLCodeEntity) StaticHibernateUtil.getSessionTL().get(GLCodeEntity.class, Short.valueOf("21"));
short gracePeriodDuration = (short) 2;
LoanOfferingBO loanOffering;
boolean loanCounter = true;
boolean waiverInterest = true;
try {
loanOffering = new LoanOfferingBO(getContext(), name, shortName, productCategory, prdApplicableMaster, startDate, null, null, gracePeriodType, gracePeriodDuration, interestTypes, defIntRate, defIntRate, defIntRate, loanCounter, interestDeductedAtDisbursement, principalDueInLastInstallment, new ArrayList<FundBO>(), new ArrayList<FeeBO>(), new ArrayList<PenaltyBO>(), meeting, glCodePrincipal, glCodeInterest, loanPrdActionForm, waiverInterest);
} catch (ProductDefinitionException e) {
throw new RuntimeException(e);
}
PrdStatusEntity prdStatus = testObjectPersistence.retrievePrdStatus(offeringStatus);
LoanOfferingTestUtils.setStatus(loanOffering, prdStatus);
LoanOfferingTestUtils.setGracePeriodType(loanOffering, gracePeriodType, gracePeriodDuration);
return (LoanOfferingBO) testObjectPersistence.persist(loanOffering);
}
use of org.mifos.application.master.business.InterestTypesEntity in project head by mifos.
the class LoanProductAssembler method fromDto.
public LoanOfferingBO fromDto(MifosUser user, LoanProductRequest loanProductRequest) {
try {
Integer userId = user.getUserId();
ProductDetailsDto productDetails = loanProductRequest.getProductDetails();
String name = productDetails.getName();
String shortName = productDetails.getShortName();
String description = productDetails.getDescription();
Integer category = productDetails.getCategory();
boolean loanCycleCounter = loanProductRequest.isIncludeInLoanCycleCounter();
boolean waiverInterest = loanProductRequest.isWaiverInterest();
PrdStatusEntity activeStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.LOAN_ACTIVE);
PrdStatusEntity inActiveStatus = new PrdOfferingPersistence().getPrdStatus(PrdStatus.LOAN_INACTIVE);
PrdStatusEntity selectedStatus = activeStatus;
if (productDetails.getStatus() != null && inActiveStatus.getOfferingStatusId().equals(productDetails.getStatus().shortValue())) {
selectedStatus = inActiveStatus;
}
MifosCurrency currency = Money.getDefaultCurrency();
if (AccountingRules.isMultiCurrencyEnabled()) {
currency = AccountingRules.getCurrencyByCurrencyId(loanProductRequest.getCurrencyId().shortValue());
}
ProductCategoryBO productCategory = this.loanProductDao.findActiveProductCategoryById(category);
DateTime startDate = productDetails.getStartDate();
DateTime endDate = productDetails.getEndDate();
ApplicableTo applicableTo = ApplicableTo.fromInt(productDetails.getApplicableFor());
PrdApplicableMasterEntity applicableToEntity = this.loanProductDao.findApplicableProductType(applicableTo);
LoanAmountCalculation loanAmountCalculation = this.loanProductCaluclationTypeAssembler.assembleLoanAmountCalculationFromDto(loanProductRequest.getLoanAmountDetails());
InterestType interestType = InterestType.fromInt(loanProductRequest.getInterestRateType());
Double minRate = loanProductRequest.getInterestRateRange().getMin().doubleValue();
Double maxRate = loanProductRequest.getInterestRateRange().getMax().doubleValue();
Double defaultRate = loanProductRequest.getInterestRateRange().getTheDefault().doubleValue();
InterestTypesEntity interestTypeEntity = this.loanProductDao.findInterestType(interestType);
RecurrenceType recurrence = RecurrenceType.fromInt(loanProductRequest.getRepaymentDetails().getFrequencyType().shortValue());
Integer recurEvery = loanProductRequest.getRepaymentDetails().getRecurs();
LoanInstallmentCalculation loanInstallmentCalculation = this.loanProductCaluclationTypeAssembler.assembleLoanInstallmentCalculationFromDto(loanProductRequest.getRepaymentDetails().getInstallmentCalculationDetails());
GraceType gracePeriodType = GraceType.fromInt(loanProductRequest.getRepaymentDetails().getGracePeriodType());
GracePeriodTypeEntity gracePeriodTypeEntity = this.loanProductDao.findGracePeriodType(gracePeriodType);
Integer gracePeriodDuration = loanProductRequest.getRepaymentDetails().getGracePeriodDuration();
List<FeeBO> applicableFees = new ArrayList<FeeBO>();
List<Integer> applicableFeeIds = loanProductRequest.getApplicableFees();
for (Integer feeId : applicableFeeIds) {
FeeBO fee = ApplicationContextProvider.getBean(FeeDao.class).findById(feeId.shortValue());
applicableFees.add(fee);
}
List<FundBO> applicableFunds = new ArrayList<FundBO>();
List<Integer> applicableFundIds = loanProductRequest.getAccountDetails().getApplicableFunds();
for (Integer fundId : applicableFundIds) {
FundBO fund = this.fundDao.findById(fundId.shortValue());
applicableFunds.add(fund);
}
List<PenaltyBO> applicablePenalties = new ArrayList<PenaltyBO>();
List<Integer> applicablePenaltyIds = loanProductRequest.getApplicablePenalties();
for (Integer penaltyId : applicablePenaltyIds) {
PenaltyBO penalty = this.penaltyDao.findPenaltyById(penaltyId);
applicablePenalties.add(penalty);
}
GLCodeEntity interestGlCode = this.generalLedgerDao.findGlCodeById(loanProductRequest.getAccountDetails().getInterestGlCodeId().shortValue());
GLCodeEntity principalGlCode = this.generalLedgerDao.findGlCodeById(loanProductRequest.getAccountDetails().getPrincipalClCodeId().shortValue());
String globalProductId = generateProductGlobalNum(user);
LoanOfferingBO loanProduct = LoanOfferingBO.createNew(userId, globalProductId, name, shortName, description, productCategory, startDate, endDate, applicableToEntity, currency, interestTypeEntity, minRate, maxRate, defaultRate, recurrence, recurEvery, interestGlCode, principalGlCode, activeStatus, inActiveStatus, gracePeriodTypeEntity, gracePeriodDuration, waiverInterest, loanCycleCounter, loanAmountCalculation, loanInstallmentCalculation, applicableFees, applicableFunds, applicablePenalties);
loanProduct.updateStatus(selectedStatus);
return loanProduct;
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
Aggregations