List of usage examples for java.lang Short valueOf
@HotSpotIntrinsicCandidate public static Short valueOf(short s)
From source file:org.ednovo.gooru.domain.service.resource.ResourceServiceImpl.java
public Resource buildResourceFromInputParameters(final String data, final User user) { final Resource resource = JsonDeserializer.deserialize(data, Resource.class); resource.setGooruOid(UUID.randomUUID().toString()); final ContentType contentType = getContentType(ContentType.RESOURCE); resource.setContentType(contentType); resource.setLastModified(new Date(System.currentTimeMillis())); resource.setCreatedOn(new Date(System.currentTimeMillis())); if (!hasUnrestrictedContentAccess()) { resource.setSharing(Sharing.PUBLIC.getSharing()); } else {//from w ww .j a v a 2s. c o m resource.setSharing(resource.getSharing() != null && (resource.getSharing().equalsIgnoreCase(Sharing.PRIVATE.getSharing()) || resource.getSharing().equalsIgnoreCase(Sharing.PUBLIC.getSharing()) || resource.getSharing().equalsIgnoreCase(Sharing.ANYONEWITHLINK.getSharing())) ? resource.getSharing() : Sharing.PUBLIC.getSharing()); } resource.setUser(user); resource.setOrganization(user.getPrimaryOrganization()); resource.setCreator(user); resource.setDistinguish(Short.valueOf("0")); resource.setRecordSource(NOT_ADDED); resource.setIsFeatured(0); resource.setLastUpdatedUserUid(user.getGooruUId()); return resource; }
From source file:org.apache.openjpa.kernel.StateManagerImpl.java
public void storeShort(int field, short externalVal) { FieldMetaData fmd = _meta.getField(field); if (!fmd.isExternalized()) storeShortField(field, externalVal); else//from w w w .j a v a 2s. com storeField(field, fmd.getFieldValue(Short.valueOf(externalVal), _broker)); }
From source file:com.datatorrent.lib.appdata.gpo.GPOUtils.java
public static Map<String, Object> getDestringedData(FieldsDescriptor fd, Map<String, String> stringMap) { Map<String, Object> fieldToData = Maps.newHashMap(); Map<String, Type> fieldToType = fd.getFieldToType(); for (Map.Entry<String, String> entry : stringMap.entrySet()) { Object objValue;//from www.ja v a2 s . c o m String valueString = entry.getValue(); Type valueType = fieldToType.get(entry.getKey()); switch (valueType) { case BOOLEAN: { objValue = Boolean.valueOf(valueString); break; } case BYTE: { objValue = Byte.valueOf(valueString); break; } case SHORT: { objValue = Short.valueOf(valueString); break; } case INTEGER: { objValue = Integer.valueOf(valueString); break; } case LONG: { objValue = Long.valueOf(valueString); break; } case FLOAT: { objValue = Float.valueOf(valueString); break; } case DOUBLE: { objValue = Double.valueOf(valueString); break; } case STRING: { objValue = valueString; break; } case OBJECT: throw new UnsupportedOperationException("The given type " + entry.getValue() + " is unsupported."); default: throw new UnsupportedOperationException("The given type " + entry.getValue() + " is unsupported."); } fieldToData.put(entry.getKey(), objValue); } return fieldToData; }
From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java
public void testApplyRoundingAfterAddMiscFee() throws Exception { Date startDate = new Date(System.currentTimeMillis()); MeetingBO meeting = TestObjectFactory.createMeeting( TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_SECOND_WEEK, CUSTOMER_MEETING)); center = TestObjectFactory.createWeeklyFeeCenter(this.getClass().getSimpleName() + " Center", meeting); group = TestObjectFactory.createWeeklyFeeGroupUnderCenter(this.getClass().getSimpleName() + " Group", CustomerStatus.GROUP_ACTIVE, center); LoanOfferingBO loanOffering = createOfferingNoPrincipalInLastInstallment(startDate, center.getCustomerMeeting().getMeeting()); UserContext userContext = TestUtils.makeUser(); userContext.setLocaleId(null);//from w w w. jav a 2 s . c o m List<FeeView> feeViewList = new ArrayList<FeeView>(); FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("Periodic Fee", FeeCategory.LOAN, "33", RecurrenceType.WEEKLY, Short.valueOf("1")); feeViewList.add(new FeeView(userContext, periodicFee)); // 20% of 300 = 60.0, applied to first installment FeeBO upfrontFee = TestObjectFactory.createOneTimeRateFee("Upfront Fee", FeeCategory.LOAN, Double.valueOf("20"), FeeFormula.AMOUNT, FeePayment.UPFRONT); feeViewList.add(new FeeView(userContext, upfrontFee)); LoanOfferingInstallmentRange eligibleInstallmentRange = loanOffering.getEligibleInstallmentSameForAllLoan(); accountBO = LoanBO.createLoan(TestUtils.makeUser(), loanOffering, group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, new Money(getCurrency(), "300.0"), Short.valueOf("6"), startDate, false, 0.0, (short) 0, null, feeViewList, null, DEFAULT_LOAN_AMOUNT, DEFAULT_LOAN_AMOUNT, eligibleInstallmentRange.getMaxNoOfInstall(), eligibleInstallmentRange.getMinNoOfInstall(), false, null); new TestObjectPersistence().persist(accountBO); Assert.assertEquals(6, accountBO.getAccountActionDates().size()); /* * StaticHibernateUtil.closeSession(); * * accountBO = (AccountBO) StaticHibernateUtil.getSessionTL().get( * AccountBO.class, accountBO.getAccountId()); * accountBO.applyPaymentWithPersist(TestObjectFactory * .getLoanAccountPaymentData(null, new Money(getCurrency(), "180.1"), * accountBO .getCustomer(), accountBO.getPersonnel(), "432423", (short) * 1, startDate, startDate)); * * StaticHibernateUtil.commitTransaction(); * StaticHibernateUtil.closeSession(); accountBO = (AccountBO) * StaticHibernateUtil.getSessionTL().get( AccountBO.class, * accountBO.getAccountId());Assert.assertEquals(new * Money(getCurrency()), ((LoanBO) accountBO).getTotalPaymentDue()); */ LoanBO loanBO = (LoanBO) accountBO; Assert.assertEquals(new Money(getCurrency(), "300.0"), loanBO.getLoanAmount()); for (AccountActionDateEntity accountActionDateEntity : accountBO.getAccountActionDates()) { LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) accountActionDateEntity; if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("1"))) { Assert.assertEquals(new Money(getCurrency(), "50.0"), loanScheduleEntity.getPrincipal()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getMiscFeeDue()); Assert.assertEquals(new Money(getCurrency(), "93.0"), loanScheduleEntity.getTotalFeeDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getInterestDue()); } else if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("2"))) { // periodic fee applies every 2nd week so no payments in even // weeks Assert.assertEquals(new Money(getCurrency(), "50.0"), loanScheduleEntity.getPrincipalDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getMiscFeeDue()); Assert.assertEquals(new Money(getCurrency(), "66.0"), loanScheduleEntity.getTotalFeeDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getInterestDue()); } else if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("3"))) { // pay periodic fee in 1st, 3rd, and 5th week Assert.assertEquals(new Money(getCurrency(), "50.0"), loanScheduleEntity.getPrincipalDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getMiscFeeDue()); Assert.assertEquals(new Money(getCurrency(), "66.0"), loanScheduleEntity.getTotalFeeDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getInterestDue()); } else if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("4"))) { // pay periodic fee in 1st, 3rd, and 5th week Assert.assertEquals(new Money(getCurrency(), "50.0"), loanScheduleEntity.getPrincipalDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getMiscFeeDue()); Assert.assertEquals(new Money(getCurrency(), "66.0"), loanScheduleEntity.getTotalFeeDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getInterestDue()); } else if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("5"))) { // pay periodic fee in 1st, 3rd, and 5th week Assert.assertEquals(new Money(getCurrency(), "50.0"), loanScheduleEntity.getPrincipalDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getMiscFeeDue()); Assert.assertEquals(new Money(getCurrency(), "66.0"), loanScheduleEntity.getTotalFeeDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getInterestDue()); } else if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("6"))) { // pay periodic fee in 1st, 3rd, and 5th week Assert.assertEquals(new Money(getCurrency(), "50.0"), loanScheduleEntity.getPrincipalDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getMiscFeeDue()); Assert.assertEquals(new Money(getCurrency(), "66.0"), loanScheduleEntity.getTotalFeeDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getInterestDue()); } } accountBO.applyCharge(Short.valueOf(AccountConstants.MISC_FEES), new Double("10.0")); accountBO.applyCharge(Short.valueOf(AccountConstants.MISC_PENALTY), new Double("2")); for (AccountActionDateEntity accountActionDateEntity : accountBO.getAccountActionDates()) { LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) accountActionDateEntity; if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("1"))) { Assert.assertEquals(new Money(getCurrency(), "50.0"), loanScheduleEntity.getPrincipal()); Assert.assertEquals(new Money(getCurrency(), "10.0"), loanScheduleEntity.getMiscFeeDue()); Assert.assertEquals(new Money(getCurrency(), "93.0"), loanScheduleEntity.getTotalFeeDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getInterestDue()); Assert.assertEquals(new Money(getCurrency(), "2.0"), loanScheduleEntity.getMiscPenaltyDue()); } else if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("2"))) { // periodic fee applies every week so double fee payment (66) // due Assert.assertEquals(new Money(getCurrency(), "50.0"), loanScheduleEntity.getPrincipalDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getMiscFeeDue()); Assert.assertEquals(new Money(getCurrency(), "66.0"), loanScheduleEntity.getTotalFeeDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getInterestDue()); } else if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("3"))) { Assert.assertEquals(new Money(getCurrency(), "50.0"), loanScheduleEntity.getPrincipalDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getMiscFeeDue()); Assert.assertEquals(new Money(getCurrency(), "66.0"), loanScheduleEntity.getTotalFeeDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getInterestDue()); } else if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("4"))) { Assert.assertEquals(new Money(getCurrency(), "50.0"), loanScheduleEntity.getPrincipalDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getMiscFeeDue()); Assert.assertEquals(new Money(getCurrency(), "66.0"), loanScheduleEntity.getTotalFeeDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getInterestDue()); } else if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("5"))) { Assert.assertEquals(new Money(getCurrency(), "50.0"), loanScheduleEntity.getPrincipalDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getMiscFeeDue()); Assert.assertEquals(new Money(getCurrency(), "66.0"), loanScheduleEntity.getTotalFeeDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getInterestDue()); } else if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("6"))) { // pay periodic fee in 1st, 3rd, and 5th week Assert.assertEquals(new Money(getCurrency(), "50.0"), loanScheduleEntity.getPrincipalDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getMiscFeeDue()); Assert.assertEquals(new Money(getCurrency(), "66.0"), loanScheduleEntity.getTotalFeeDue()); Assert.assertEquals(new Money(getCurrency(), "0.0"), loanScheduleEntity.getInterestDue()); } } }
From source file:hydrograph.ui.propertywindow.widgets.customwidgets.operational.TransformDialog.java
private boolean validate(String value, String dataType) { if (StringUtils.isNotBlank(value)) { try {//from w w w .j a va2 s . c o m if (dataType.equals(Messages.DATATYPE_INTEGER)) { Integer.valueOf(value); return true; } else if (dataType.equals(Messages.DATATYPE_STRING)) { String.valueOf(value); return true; } else if (dataType.equals(Messages.DATATYPE_DOUBLE)) { Double.valueOf(value); return true; } else if (dataType.equals(Messages.DATATYPE_FLOAT)) { Float.valueOf(value); return true; } else if (dataType.equals(Messages.DATATYPE_SHORT)) { Short.valueOf(value); return true; } else if (Boolean.FALSE.toString().equalsIgnoreCase(value) || Boolean.TRUE.toString().equalsIgnoreCase(value)) { return true; } else if (dataType.equals(Messages.DATATYPE_BIGDECIMAL)) { new BigDecimal(value); return true; } else if (dataType.equals(Messages.DATATYPE_LONG)) { Long.valueOf(value); return true; } else if (dataType.equals(Messages.DATATYPE_DATE)) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); sdf.setLenient(false); sdf.parse(value); return true; } else { return false; } } catch (Exception exception) { return false; } } else { return false; } }
From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java
public void testMakeEarlyRepaymentOnPartiallyPaidPricipal() throws Exception { Date startDate = new Date(System.currentTimeMillis()); MeetingBO meeting = TestObjectFactory.createMeeting( TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_SECOND_WEEK, CUSTOMER_MEETING)); center = TestObjectFactory.createWeeklyFeeCenter(this.getClass().getSimpleName() + " Center", meeting); group = TestObjectFactory.createWeeklyFeeGroupUnderCenter(this.getClass().getSimpleName() + " Group", CustomerStatus.GROUP_ACTIVE, center); LoanOfferingBO loanOffering = createOfferingNoPrincipalInLastInstallment(startDate, center.getCustomerMeeting().getMeeting()); UserContext userContext = TestUtils.makeUser(); userContext.setLocaleId(null);/*from www. ja v a2 s . c om*/ List<FeeView> feeViewList = new ArrayList<FeeView>(); FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("Periodic Fee", FeeCategory.LOAN, "100", RecurrenceType.WEEKLY, Short.valueOf("1")); feeViewList.add(new FeeView(userContext, periodicFee)); FeeBO upfrontFee = TestObjectFactory.createOneTimeRateFee("Upfront Fee", FeeCategory.LOAN, Double.valueOf("20"), FeeFormula.AMOUNT, FeePayment.UPFRONT); feeViewList.add(new FeeView(userContext, upfrontFee)); LoanOfferingInstallmentRange eligibleInstallmentRange = loanOffering.getEligibleInstallmentSameForAllLoan(); accountBO = LoanBO.createLoan(TestUtils.makeUser(), loanOffering, group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, new Money(getCurrency(), "300.0"), Short.valueOf("6"), startDate, false, 1.2, (short) 0, null, feeViewList, null, DEFAULT_LOAN_AMOUNT, DEFAULT_LOAN_AMOUNT, eligibleInstallmentRange.getMaxNoOfInstall(), eligibleInstallmentRange.getMinNoOfInstall(), false, null); new TestObjectPersistence().persist(accountBO); Assert.assertEquals(6, accountBO.getAccountActionDates().size()); StaticHibernateUtil.closeSession(); accountBO = (AccountBO) StaticHibernateUtil.getSessionTL().get(AccountBO.class, accountBO.getAccountId()); accountBO.applyPaymentWithPersist(TestObjectFactory.getLoanAccountPaymentData(null, new Money(getCurrency(), "180.1"), accountBO.getCustomer(), accountBO.getPersonnel(), "432423", (short) 1, startDate, startDate)); StaticHibernateUtil.commitTransaction(); StaticHibernateUtil.closeSession(); accountBO = (AccountBO) StaticHibernateUtil.getSessionTL().get(AccountBO.class, accountBO.getAccountId()); Assert.assertEquals(new Money(getCurrency()), ((LoanBO) accountBO).getTotalPaymentDue()); LoanBO loanBO = (LoanBO) accountBO; UserContext uc = TestUtils.makeUser(); Money totalRepaymentAmount = loanBO.getTotalEarlyRepayAmount(); Assert.assertEquals(new Money(getCurrency(), "280.1"), totalRepaymentAmount); loanBO.makeEarlyRepayment(loanBO.getTotalEarlyRepayAmount(), null, null, "1", uc.getId()); StaticHibernateUtil.commitTransaction(); StaticHibernateUtil.closeSession(); accountBO = (AccountBO) StaticHibernateUtil.getSessionTL().get(AccountBO.class, accountBO.getAccountId()); Assert.assertEquals(accountBO.getAccountState().getId(), Short.valueOf(AccountStates.LOANACC_OBLIGATIONSMET)); LoanSummaryEntity loanSummaryEntity = loanBO.getLoanSummary(); Assert.assertEquals(new Money(getCurrency()), loanSummaryEntity.getPrincipalDue().add(loanSummaryEntity.getFeesDue()) .add(loanSummaryEntity.getInterestDue()).add(loanSummaryEntity.getPenaltyDue())); Assert.assertEquals(2, accountBO.getAccountPayments().size()); AccountPaymentEntity accountPaymentEntity = (AccountPaymentEntity) Arrays .asList(accountBO.getAccountPayments().toArray()).get(0); Assert.assertEquals(6, accountPaymentEntity.getAccountTrxns().size()); // Change this to more clearly separate what we are testing for from the // machinery needed to get that data? for (AccountTrxnEntity accountTrxnEntity : accountPaymentEntity.getAccountTrxns()) { if (accountTrxnEntity.getInstallmentId().equals(Short.valueOf("6"))) { LoanTrxnDetailEntity loanTrxnDetailEntity = (LoanTrxnDetailEntity) accountTrxnEntity; Assert.assertEquals(new Money(getCurrency(), "46.0"), accountTrxnEntity.getAmount()); Assert.assertEquals(new Money(getCurrency()), loanTrxnDetailEntity.getInterestAmount()); Assert.assertEquals(new Money(getCurrency()), loanTrxnDetailEntity.getMiscFeeAmount()); Assert.assertEquals(new Money(getCurrency()), loanTrxnDetailEntity.getMiscPenaltyAmount()); Assert.assertEquals(new Money(getCurrency()), loanTrxnDetailEntity.getPenaltyAmount()); Assert.assertEquals(2, accountTrxnEntity.getFinancialTransactions().size()); Assert.assertEquals(0, loanTrxnDetailEntity.getFeesTrxnDetails().size()); } else if (accountTrxnEntity.getInstallmentId().equals(Short.valueOf("1"))) { LoanTrxnDetailEntity loanTrxnDetailEntity = (LoanTrxnDetailEntity) accountTrxnEntity; Assert.assertEquals(new Money(getCurrency(), "30.9"), accountTrxnEntity.getAmount()); Assert.assertEquals(new Money(getCurrency()), loanTrxnDetailEntity.getInterestAmount()); Assert.assertEquals(new Money(getCurrency()), loanTrxnDetailEntity.getMiscFeeAmount()); Assert.assertEquals(new Money(getCurrency()), loanTrxnDetailEntity.getMiscPenaltyAmount()); Assert.assertEquals(new Money(getCurrency()), loanTrxnDetailEntity.getPenaltyAmount()); Assert.assertEquals(2, accountTrxnEntity.getFinancialTransactions().size()); Assert.assertEquals(0, loanTrxnDetailEntity.getFeesTrxnDetails().size()); } else { LoanTrxnDetailEntity loanTrxnDetailEntity = (LoanTrxnDetailEntity) accountTrxnEntity; Assert.assertEquals(new Money(getCurrency(), "50.8"), accountTrxnEntity.getAmount()); Assert.assertEquals(new Money(getCurrency()), loanTrxnDetailEntity.getInterestAmount()); Assert.assertEquals(new Money(getCurrency()), loanTrxnDetailEntity.getMiscFeeAmount()); Assert.assertEquals(new Money(getCurrency()), loanTrxnDetailEntity.getMiscPenaltyAmount()); Assert.assertEquals(new Money(getCurrency()), loanTrxnDetailEntity.getPenaltyAmount()); Assert.assertEquals(2, accountTrxnEntity.getFinancialTransactions().size()); Assert.assertEquals(0, loanTrxnDetailEntity.getFeesTrxnDetails().size()); } } }
From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java
public void testDisburseLoanWithFeeAtDisbursement() throws Exception { Date startDate = new Date(System.currentTimeMillis()); Money miscFee = new Money(getCurrency(), "20"); Money miscPenalty = new Money(getCurrency(), "50"); accountBO = getLoanAccountWithMiscFeeAndPenalty(AccountState.LOAN_APPROVED, startDate, 1, miscFee, miscPenalty);/*from www . ja v a 2 s .com*/ // disburse loan ((LoanBO) accountBO).disburseLoan("1234", startDate, Short.valueOf("1"), accountBO.getPersonnel(), startDate, Short.valueOf("1")); Session session = StaticHibernateUtil.getSessionTL(); StaticHibernateUtil.startTransaction(); session.save(accountBO); StaticHibernateUtil.getTransaction().commit(); for (AccountActionDateEntity accountAction : accountBO.getAccountActionDates()) { LoanScheduleEntity accountActionDateEntity = (LoanScheduleEntity) accountAction; if (accountActionDateEntity.getInstallmentId().equals(Short.valueOf("1"))) { Assert.assertEquals(miscPenalty, accountActionDateEntity.getMiscPenalty()); Assert.assertEquals(miscFee, accountActionDateEntity.getMiscFee()); break; } } List<AccountPaymentEntity> accountpayments = accountBO.getAccountPayments(); Assert.assertEquals(1, accountpayments.size()); for (AccountPaymentEntity entity : accountpayments) { Assert.assertEquals("1234", entity.getReceiptNumber()); // asssert loan trxns Set<AccountTrxnEntity> accountTrxns = entity.getAccountTrxns(); Assert.assertEquals(2, accountTrxns.size()); for (AccountTrxnEntity transaction : accountTrxns) { if (transaction.getAccountAction() == AccountActionTypes.FEE_REPAYMENT) { Assert.assertEquals(TestUtils.createMoney(30.0), transaction.getAmount()); // it should have two feetrxn's Set<FeesTrxnDetailEntity> feesTrxnDetails = ((LoanTrxnDetailEntity) transaction) .getFeesTrxnDetails(); Assert.assertEquals(2, feesTrxnDetails.size()); } if (transaction.getAccountAction() == AccountActionTypes.DISBURSAL) { Assert.assertEquals(TestUtils.createMoney(300.0), transaction.getAmount()); } Assert.assertEquals(accountBO.getAccountId(), transaction.getAccount().getAccountId()); } // check loan summary fee paid should be updated LoanSummaryEntity loanSummaryEntity = ((LoanBO) accountBO).getLoanSummary(); Assert.assertEquals(TestUtils.createMoney(30.0), loanSummaryEntity.getFeesPaid()); // check the loan object for the disbursal date Assert.assertEquals(startDate, ((LoanBO) accountBO).getDisbursementDate()); // check new account state Assert.assertEquals(AccountStates.LOANACC_ACTIVEINGOODSTANDING, ((LoanBO) accountBO).getAccountState().getId().shortValue()); } LoanSummaryEntity loanSummary = ((LoanBO) accountBO).getLoanSummary(); for (LoanActivityEntity loanActivityEntity : ((LoanBO) accountBO).getLoanActivityDetails()) { if (loanActivityEntity.getComments().equalsIgnoreCase("Loan Disbursal")) { Assert.assertEquals(loanSummary.getOriginalPrincipal(), loanActivityEntity.getPrincipalOutstanding()); Assert.assertEquals(loanSummary.getOriginalFees(), loanActivityEntity.getFeeOutstanding()); break; } } accountBO = TestObjectFactory.getObject(LoanBO.class, accountBO.getAccountId()); }
From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java
public void testDisbursalLoanNoFeeOrInterestAtDisbursal() throws Exception { Date startDate = new Date(System.currentTimeMillis()); accountBO = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 3); // disburse loan ((LoanBO) accountBO).disburseLoan("1234", startDate, Short.valueOf("1"), accountBO.getPersonnel(), startDate, Short.valueOf("1")); Session session = StaticHibernateUtil.getSessionTL(); StaticHibernateUtil.startTransaction(); session.save(accountBO);/*from w w w. j a v a2 s . co m*/ StaticHibernateUtil.getTransaction().commit(); ((LoanBO) accountBO).setLoanMeeting(null); List<AccountPaymentEntity> accountpayments = accountBO.getAccountPayments(); Assert.assertEquals(1, accountpayments.size()); for (AccountPaymentEntity entity : accountpayments) { Assert.assertEquals("1234", entity.getReceiptNumber()); // asssert loan trxns Set<AccountTrxnEntity> accountTrxns = entity.getAccountTrxns(); Assert.assertEquals(1, accountTrxns.size()); AccountTrxnEntity accountTrxn = accountTrxns.iterator().next(); Assert.assertEquals(AccountActionTypes.DISBURSAL, accountTrxn.getAccountAction()); Assert.assertEquals(TestUtils.createMoney(300.0), accountTrxn.getAmount()); Assert.assertEquals(accountBO.getAccountId(), accountTrxn.getAccount().getAccountId()); } }
From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java
public void testDisbursalLoanRegeneteRepaymentScheduleWithInvalidDisbDate() throws Exception { // Allowing loan disbursal dates to become independent of meeting // schedules. Date startDate = new Date(System.currentTimeMillis()); accountBO = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 3); // disburse loan Calendar disbDate = new GregorianCalendar(); disbDate.setTimeInMillis(startDate.getTime()); disbDate.roll(Calendar.DATE, 1); Date disbursalDate = new Date(disbDate.getTimeInMillis()); try {/*from w w w. ja v a2s. co m*/ ((LoanBO) accountBO).disburseLoan("1234", disbursalDate, Short.valueOf("1"), accountBO.getPersonnel(), startDate, Short.valueOf("1")); Assert.assertEquals(true, true); } catch (ApplicationException rse) { Assert.assertEquals(true, false); } finally { Session session = StaticHibernateUtil.getSessionTL(); StaticHibernateUtil.startTransaction(); ((LoanBO) accountBO).setLoanMeeting(null); session.update(accountBO); StaticHibernateUtil.getTransaction().commit(); } }
From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java
public void testDisbursalLoanRegeneteRepaymentSchedule() throws Exception { Date startDate = new Date(System.currentTimeMillis()); accountBO = getLoanAccountWithMiscFeeAndPenalty(AccountState.LOAN_APPROVED, startDate, 3, new Money(getCurrency(), "20"), new Money(getCurrency(), "30")); Set<AccountActionDateEntity> intallments = accountBO.getAccountActionDates(); AccountActionDateEntity firstInstallment = null; for (AccountActionDateEntity entity : intallments) { if (entity.getInstallmentId().intValue() == 1) { firstInstallment = entity;/*from w w w. java 2 s .c o m*/ break; } } Calendar disbursalDate = new GregorianCalendar(); disbursalDate.setTimeInMillis(firstInstallment.getActionDate().getTime()); Calendar cal = new GregorianCalendar(disbursalDate.get(Calendar.YEAR), disbursalDate.get(Calendar.MONTH), disbursalDate.get(Calendar.DATE), 0, 0); ((LoanBO) accountBO).disburseLoan("1234", cal.getTime(), Short.valueOf("1"), accountBO.getPersonnel(), startDate, Short.valueOf("1")); Set<AccountActionDateEntity> actionDateEntities = accountBO.getAccountActionDates(); LoanScheduleEntity[] paymentsArray = LoanBOTestUtils.getSortedAccountActionDateEntity(actionDateEntities); checkLoanScheduleEntity(null, null, null, "20", "30", null, null, null, null, null, paymentsArray[0]); Session session = StaticHibernateUtil.getSessionTL(); StaticHibernateUtil.startTransaction(); ((LoanBO) accountBO).setLoanMeeting(null); session.update(accountBO); StaticHibernateUtil.getTransaction().commit(); Assert.assertEquals(true, true); }