List of usage examples for java.lang Short valueOf
@HotSpotIntrinsicCandidate public static Short valueOf(short s)
From source file:org.mifos.accounts.loan.business.LoanBORedoDisbursalIntegrationTest.java
private void applyPaymentForLoan(UserContext userContext, LoanBO loan, Date paymentDate, Money money) { loan.setUserContext(userContext);// w w w . j ava2 s .c om PersonnelBO loggedInUser = legacyPersonnelDao.findPersonnelById(userContext.getId()); List<AccountActionDateEntity> accntActionDates = new ArrayList<AccountActionDateEntity>(); accntActionDates.addAll(loan.getAccountActionDates()); PaymentData paymentData = loan.createPaymentData(money, paymentDate, null, null, Short.valueOf("1"), loggedInUser); IntegrationTestObjectMother.applyAccountPayment(loan, paymentData); new TestObjectPersistence().persist(loan); }
From source file:org.mifos.application.servicefacade.AdminServiceFacadeWebTier.java
@Override public LoanProductFormDto retrieveLoanProductFormReferenceData() { try {/*from ww w.j a va 2 s. c o m*/ LoanPrdBusinessService service = new LoanPrdBusinessService(); List<ListElement> productCategoryOptions = new ArrayList<ListElement>(); List<ProductCategoryBO> productCategories = service.getActiveLoanProductCategories(); for (ProductCategoryBO category : productCategories) { productCategoryOptions.add(new ListElement(category.getProductCategoryID().intValue(), category.getProductCategoryName())); } List<ListElement> applicableForOptions = new ArrayList<ListElement>(); List<PrdApplicableMasterEntity> applicableCustomerTypes = this.loanProductDao .retrieveLoanApplicableProductCategories(); for (PrdApplicableMasterEntity entity : applicableCustomerTypes) { applicableForOptions.add(new ListElement(entity.getId().intValue(), entity.getName())); } List<ListElement> gracePeriodTypeOptions = new ArrayList<ListElement>(); List<GracePeriodTypeEntity> gracePeriodTypes = this.loanProductDao.retrieveGracePeriodTypes(); for (GracePeriodTypeEntity gracePeriodTypeEntity : gracePeriodTypes) { gracePeriodTypeOptions.add( new ListElement(gracePeriodTypeEntity.getId().intValue(), gracePeriodTypeEntity.getName())); } List<ListElement> interestCalcTypesOptions = new ArrayList<ListElement>(); List<InterestTypesEntity> interestCalcTypes = this.loanProductDao.retrieveInterestTypes(); for (InterestTypesEntity entity : interestCalcTypes) { interestCalcTypesOptions.add(new ListElement(entity.getId().intValue(), entity.getName())); } List<ListElement> sourceOfFunds = new ArrayList<ListElement>(); List<FundBO> funds = this.fundDao.findAllFunds(); for (FundBO fund : funds) { sourceOfFunds.add(new ListElement(fund.getFundId().intValue(), fund.getFundName())); } List<ListElement> loanFee = new ArrayList<ListElement>(); List<FeeBO> fees = feeDao.getAllAppllicableFeeForLoanCreation(); for (FeeBO fee : fees) { loanFee.add(new ListElement(fee.getFeeId().intValue(), fee.getFeeName())); } List<ListElement> principalGlCodes = new ArrayList<ListElement>(); List<GLCodeEntity> principalGlCodeEntities = new FinancialBusinessService() .getGLCodes(FinancialActionConstants.PRINCIPALPOSTING, FinancialConstants.CREDIT); for (GLCodeEntity glCode : principalGlCodeEntities) { principalGlCodes.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode())); } List<ListElement> interestGlCodes = new ArrayList<ListElement>(); List<GLCodeEntity> interestGlCodeEntities = new FinancialBusinessService() .getGLCodes(FinancialActionConstants.INTERESTPOSTING, FinancialConstants.CREDIT); for (GLCodeEntity glCode : interestGlCodeEntities) { interestGlCodes.add(new ListElement(glCode.getGlcodeId().intValue(), glCode.getGlcode())); } List<ListElement> statusOptions = new ArrayList<ListElement>(); List<PrdStatusEntity> applicableStatuses = service.getApplicablePrdStatus(Short.valueOf("1")); for (PrdStatusEntity entity : applicableStatuses) { statusOptions.add( new ListElement(entity.getOfferingStatusId().intValue(), entity.getPrdState().getName())); } boolean multiCurrencyEnabled = AccountingRules.isMultiCurrencyEnabled(); List<ListElement> currencyOptions = new ArrayList<ListElement>(); if (multiCurrencyEnabled) { LinkedList<MifosCurrency> currencies = AccountingRules.getCurrencies(); for (MifosCurrency mifosCurrency : currencies) { currencyOptions.add(new ListElement(mifosCurrency.getCurrencyId().intValue(), mifosCurrency.getCurrencyCode())); } } return new LoanProductFormDto(productCategoryOptions, gracePeriodTypeOptions, sourceOfFunds, loanFee, principalGlCodes, interestGlCodes, interestCalcTypesOptions, applicableForOptions, statusOptions, currencyOptions, multiCurrencyEnabled); } catch (PersistenceException e) { throw new MifosRuntimeException(e); } catch (SystemException e) { throw new MifosRuntimeException(e); } catch (ApplicationException e) { throw new BusinessRuleException(e.getKey(), e); } }
From source file:org.mifos.customers.client.struts.action.ClientCustAction.java
@CloseSession @TransactionDemarcate(validateAndResetToken = true) public ActionForward updateMfiInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception { ClientCustActionForm actionForm = (ClientCustActionForm) form; ClientBO clientInSession = getClientFromSession(request); Integer clientId = clientInSession.getCustomerId(); Integer oldVersionNumber = clientInSession.getVersionNo(); boolean trained = false; if (trainedValue(actionForm) != null && trainedValue(actionForm).equals(YesNoFlag.YES.getValue())) { trained = true;/* w w w . jav a 2 s. c o m*/ } DateTime trainedDate = null; try { java.sql.Date inputDate = trainedDate(actionForm); if (inputDate != null) { trainedDate = new DateTime(trainedDate(actionForm)); } } catch (InvalidDateException e) { throw new CustomerException(ClientConstants.TRAINED_DATE_MANDATORY); } Short personnelId = Short.valueOf("-1"); if (groupFlagValue(actionForm).equals(YesNoFlag.NO.getValue())) { if (actionForm.getLoanOfficerIdValue() != null) { personnelId = actionForm.getLoanOfficerIdValue(); } } else if (groupFlagValue(actionForm).equals(YesNoFlag.YES.getValue())) { // TODO for an urgent fix this reads client to get personnelId. // Client is read again in updateClientMfiInfo. Refactor to only read in // updateClientMfiInfo. ClientBO client = (ClientBO) this.customerDao.findCustomerById(clientId); personnelId = client.getPersonnel().getPersonnelId(); } ClientMfiInfoUpdate clientMfiInfoUpdate = new ClientMfiInfoUpdate(clientId, oldVersionNumber, personnelId, externalId(actionForm), trained, trainedDate); this.clientServiceFacade.updateClientMfiInfo(clientMfiInfoUpdate); return mapping.findForward(ActionForwards.updateMfiInfo_success.toString()); }
From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java
/** * This test has been disabled until code is able to handle removing fees. * TODO: re-enable this test when loan schedule adjustments correctly handle * removing fees.//from w ww .j av a 2s. c om */ public void xtestSuccessRemoveFees() throws Exception { accountBO = getLoanAccount(); UserContext uc = TestUtils.makeUser(); Set<AccountFeesEntity> accountFeesEntitySet = accountBO.getAccountFees(); ((LoanBO) accountBO).getLoanOffering().setPrinDueLastInst(false); for (AccountActionDateEntity accountActionDateEntity : accountBO.getAccountActionDates()) { if (accountActionDateEntity.getInstallmentId().equals(Short.valueOf("2"))) { ((LoanScheduleEntity) accountActionDateEntity).setMiscFee(new Money(getCurrency(), "20.3")); } } Iterator<AccountFeesEntity> itr = accountFeesEntitySet.iterator(); while (itr.hasNext()) { accountBO.removeFees(itr.next().getFees().getFeeId(), uc.getId()); } StaticHibernateUtil.getTransaction().commit(); for (AccountFeesEntity accountFeesEntity : accountFeesEntitySet) { Assert.assertEquals(accountFeesEntity.getFeeStatusAsEnum(), FeeStatus.INACTIVE); } LoanSummaryEntity loanSummaryEntity = ((LoanBO) accountBO).getLoanSummary(); for (LoanActivityEntity accountNonTrxnEntity : ((LoanBO) accountBO).getLoanActivityDetails()) { Assert.assertEquals(loanSummaryEntity.getOriginalFees().subtract(loanSummaryEntity.getFeesPaid()), accountNonTrxnEntity.getFeeOutstanding()); Assert.assertEquals( loanSummaryEntity.getOriginalPrincipal().subtract(loanSummaryEntity.getPrincipalPaid()), accountNonTrxnEntity.getPrincipalOutstanding()); Assert.assertEquals( loanSummaryEntity.getOriginalInterest().subtract(loanSummaryEntity.getInterestPaid()), accountNonTrxnEntity.getInterestOutstanding()); Assert.assertEquals(loanSummaryEntity.getOriginalPenalty().subtract(loanSummaryEntity.getPenaltyPaid()), accountNonTrxnEntity.getPenaltyOutstanding()); break; } for (AccountActionDateEntity accountActionDate : accountBO.getAccountActionDates()) { LoanScheduleEntity loanScheduleEntity = (LoanScheduleEntity) accountActionDate; if (accountActionDate.getInstallmentId().equals(Short.valueOf("1"))) { Assert.assertEquals(new Money(getCurrency(), "212.0"), loanScheduleEntity.getTotalDueWithFees()); } else if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("2"))) { Assert.assertEquals(new Money(getCurrency(), "133.0"), loanScheduleEntity.getTotalDueWithFees()); } else if (loanScheduleEntity.getInstallmentId().equals(Short.valueOf("6"))) { Assert.assertEquals(new Money(getCurrency(), "111.3"), loanScheduleEntity.getTotalDueWithFees()); } else { Assert.assertEquals(new Money(getCurrency(), "112.0"), loanScheduleEntity.getTotalDueWithFees()); } } }
From source file:com.mimp.controllers.familia.java
@RequestMapping(value = "/FamiliaInscripcion", method = RequestMethod.GET) public ModelAndView FamiliaInscripcion_GET(ModelMap map, HttpSession session) { Familia usuario = (Familia) session.getAttribute("usuario"); if (usuario == null) { String mensaje = "La sesin ha finalizado. Favor identificarse nuevamente"; map.addAttribute("mensaje", mensaje); return new ModelAndView("login", map); }//from w w w . java 2 s.co m if (session.getAttribute("idTurno") != null) { long idTurno = (long) session.getAttribute("idTurno"); Turno temp = ServicioMain.getTurno(idTurno); int numAsist = ServicioFamilia.AsistentesPorFormulario(usuario.getIdfamilia()); int cont = 0; if (!temp.getAsistenciaFTs().isEmpty()) { cont = numAsist + temp.getAsistenciaFTs().size(); } if (temp.getAsistenciaFTs().isEmpty()) { cont = numAsist; } if (cont <= temp.getVacantes()) { map.put("mensaje", "inscrito"); map.put("sesion", temp.getSesion()); FormularioSesion antiguo = ServicioFamilia.ultimoFormulario(usuario.getIdfamilia()); FormularioSesion nuevo = new FormularioSesion(); AsistenciaFT aft = new AsistenciaFT(); AsistenciaFT aft2 = new AsistenciaFT(); aft.setTurno(temp); aft2.setTurno(temp); String asistencia = "F"; char asist = asistencia.charAt(0); aft.setAsistencia(asist); aft2.setAsistencia(asist); String inajust = "1"; Short i = Short.valueOf(inajust); aft.setInasJus(i); aft2.setInasJus(i); Asistente asis1 = new Asistente(); Asistente asis2 = new Asistente(); Date now = new Date(); if (antiguo.getAsistentes().size() == 1) { Asistente tempAsis = antiguo.getAsistentes().iterator().next(); asis1.setNombre(tempAsis.getNombre()); asis1.setApellidoP(tempAsis.getApellidoP()); asis1.setApellidoM(tempAsis.getApellidoM()); asis1.setSexo(tempAsis.getSexo()); asis1.setPaisNac(tempAsis.getPaisNac()); asis1.setDepNac(tempAsis.getDepNac()); asis1.setProvNac(tempAsis.getProvNac()); asis1.setEdad(tempAsis.getEdad()); asis1.setFechaNac(tempAsis.getFechaNac()); asis1.setTipoDoc(tempAsis.getTipoDoc()); asis1.setNDoc(tempAsis.getNDoc()); asis1.setProfesion(tempAsis.getProfesion()); asis1.setCelular(tempAsis.getCelular()); asis1.setCorreo(tempAsis.getCorreo()); nuevo.setFamilia(usuario); nuevo.setFechaSol(now); nuevo.setSesion(temp.getSesion()); nuevo.setPaisRes(antiguo.getPaisRes()); nuevo.setDepRes(antiguo.getDepRes()); nuevo.setProvRes(antiguo.getProvRes()); nuevo.setDistritoRes(antiguo.getDistritoRes()); nuevo.setDireccionRes(antiguo.getDireccionRes()); nuevo.setEstadoCivil(antiguo.getEstadoCivil()); nuevo.setTelefono(antiguo.getTelefono()); ServicioMain.InsertFormInd(asis1, nuevo, aft); } else { Asistente elTemp = new Asistente(); Asistente ellaTemp = new Asistente(); for (Asistente tempAsis : antiguo.getAsistentes()) { if (tempAsis.getSexo() == 109) { elTemp = tempAsis; } if (tempAsis.getSexo() == 102) { ellaTemp = tempAsis; } } asis1.setNombre(elTemp.getNombre()); asis1.setApellidoP(elTemp.getApellidoP()); asis1.setApellidoM(elTemp.getApellidoM()); asis1.setSexo(elTemp.getSexo()); asis1.setPaisNac(elTemp.getPaisNac()); asis1.setDepNac(elTemp.getDepNac()); asis1.setProvNac(elTemp.getProvNac()); asis1.setEdad(elTemp.getEdad()); asis1.setFechaNac(elTemp.getFechaNac()); asis1.setTipoDoc(elTemp.getTipoDoc()); asis1.setNDoc(elTemp.getNDoc()); asis1.setProfesion(elTemp.getProfesion()); asis1.setCelular(elTemp.getCelular()); asis1.setCorreo(elTemp.getCorreo()); asis2.setNombre(ellaTemp.getNombre()); asis2.setApellidoP(ellaTemp.getApellidoP()); asis2.setApellidoM(ellaTemp.getApellidoM()); asis2.setSexo(ellaTemp.getSexo()); asis2.setPaisNac(ellaTemp.getPaisNac()); asis2.setDepNac(ellaTemp.getDepNac()); asis2.setProvNac(ellaTemp.getProvNac()); asis2.setEdad(ellaTemp.getEdad()); asis2.setFechaNac(ellaTemp.getFechaNac()); asis2.setTipoDoc(ellaTemp.getTipoDoc()); asis2.setNDoc(ellaTemp.getNDoc()); asis2.setProfesion(ellaTemp.getProfesion()); asis2.setCelular(ellaTemp.getCelular()); asis2.setCorreo(ellaTemp.getCorreo()); nuevo.setFamilia(usuario); nuevo.setFechaSol(now); nuevo.setSesion(temp.getSesion()); nuevo.setPaisRes(antiguo.getPaisRes()); nuevo.setDepRes(antiguo.getDepRes()); nuevo.setProvRes(antiguo.getProvRes()); nuevo.setDistritoRes(antiguo.getDistritoRes()); nuevo.setDireccionRes(antiguo.getDireccionRes()); nuevo.setEstadoCivil(antiguo.getEstadoCivil()); nuevo.setTelefono(antiguo.getTelefono()); ServicioMain.InsertFormGrp(asis1, asis2, nuevo, aft, aft2); } } else { map.put("mensaje", "fallo"); } String pagina = "/Familia/Inscripcion/inscripcion_sesionInfo_afirm"; map.put("df", format); session.removeAttribute("idTurno"); return new ModelAndView(pagina, map); } else { String pagina = "/Familia/inicio_familia"; return new ModelAndView(pagina, map); } }
From source file:org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm.java
public Short getMinNoInstallmentsValue() { if (this.installmentRange != null) { return installmentRange.getMinNoOfInstall(); }//from w w w .j av a 2s. com return Short.valueOf("0"); }
From source file:org.mifos.accounts.loan.business.LoanBORedoDisbursalIntegrationTest.java
protected void removeAccountFee(LoanBO loan) throws Exception { for (AccountFeesEntity accountFeesEntity : loan.getAccountFees()) { loan.removeFeesAssociatedWithUpcomingAndAllKnownFutureInstallments( accountFeesEntity.getFees().getFeeId(), Short.valueOf("1")); }//from www. j a v a 2 s . c o m }
From source file:org.mifos.accounts.loan.struts.actionforms.LoanAccountActionForm.java
public Short getMaxNoInstallmentsValue() { if (this.installmentRange != null) { return installmentRange.getMaxNoOfInstall(); }/* w w w .j a v a 2 s . c om*/ return Short.valueOf("0"); }
From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java
public void testHandleArrearsAging_Create() throws Exception { Calendar calendar = new GregorianCalendar(); calendar.setTime(DateUtils.getCurrentDateWithoutTimeStamp()); calendar.add(calendar.WEEK_OF_MONTH, -2); java.sql.Date secondWeekDate = new java.sql.Date(calendar.getTimeInMillis()); accountBO = getLoanAccount();// ww w .ja va 2 s. com for (AccountActionDateEntity installment : accountBO.getAccountActionDates()) { if (installment.getInstallmentId().intValue() == 1) { ((LoanScheduleEntity) installment).setActionDate(secondWeekDate); } } TestObjectFactory.updateObject(accountBO); TestObjectFactory.flushandCloseSession(); accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId()); Assert.assertNull(((LoanBO) accountBO).getLoanArrearsAgingEntity()); ((LoanBO) accountBO).handleArrearsAging(); StaticHibernateUtil.commitTransaction(); StaticHibernateUtil.closeSession(); accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId()); LoanArrearsAgingEntity agingEntity = ((LoanBO) accountBO).getLoanArrearsAgingEntity(); Assert.assertNotNull(agingEntity); Assert.assertEquals(new Money(getCurrency(), "100"), agingEntity.getOverduePrincipal()); Assert.assertEquals(new Money(getCurrency(), "12"), agingEntity.getOverdueInterest()); Assert.assertEquals(new Money(getCurrency(), "112"), agingEntity.getOverdueBalance()); Assert.assertEquals(Short.valueOf("14"), agingEntity.getDaysInArrears()); Assert.assertEquals(((LoanBO) accountBO).getLoanSummary().getPrincipalDue(), agingEntity.getUnpaidPrincipal()); Assert.assertEquals(((LoanBO) accountBO).getLoanSummary().getInterestDue(), agingEntity.getUnpaidInterest()); Assert.assertEquals(((LoanBO) accountBO).getLoanSummary().getPrincipalDue() .add(((LoanBO) accountBO).getLoanSummary().getInterestDue()), agingEntity.getUnpaidBalance()); Assert.assertEquals(((LoanBO) accountBO).getTotalPrincipalAmountInArrears(), agingEntity.getOverduePrincipal()); Assert.assertEquals(((LoanBO) accountBO).getTotalInterestAmountInArrears(), agingEntity.getOverdueInterest()); Assert.assertEquals(((LoanBO) accountBO).getTotalPrincipalAmountInArrears() .add(((LoanBO) accountBO).getTotalInterestAmountInArrears()), agingEntity.getOverdueBalance()); }
From source file:org.mifos.accounts.loan.business.LoanBOIntegrationTest.java
public void testHandleArrearsAging_Update() throws Exception { testHandleArrearsAging_Create();//from w ww. j a v a 2 s.c o m Calendar calendar = new GregorianCalendar(); calendar.setTime(DateUtils.getCurrentDateWithoutTimeStamp()); calendar.add(calendar.WEEK_OF_MONTH, -1); java.sql.Date lastWeekDate = new java.sql.Date(calendar.getTimeInMillis()); for (AccountActionDateEntity installment : accountBO.getAccountActionDates()) { if (installment.getInstallmentId().intValue() == 2) { ((LoanScheduleEntity) installment).setActionDate(lastWeekDate); } } TestObjectFactory.updateObject(accountBO); TestObjectFactory.flushandCloseSession(); accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId()); Assert.assertNotNull(((LoanBO) accountBO).getLoanArrearsAgingEntity()); ((LoanBO) accountBO).handleArrearsAging(); StaticHibernateUtil.commitTransaction(); StaticHibernateUtil.closeSession(); accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId()); LoanArrearsAgingEntity agingEntity = ((LoanBO) accountBO).getLoanArrearsAgingEntity(); Assert.assertEquals(new Money(getCurrency(), "200"), agingEntity.getOverduePrincipal()); Assert.assertEquals(new Money(getCurrency(), "24"), agingEntity.getOverdueInterest()); Assert.assertEquals(new Money(getCurrency(), "224"), agingEntity.getOverdueBalance()); Assert.assertEquals(Short.valueOf("14"), agingEntity.getDaysInArrears()); Assert.assertEquals(((LoanBO) accountBO).getLoanSummary().getPrincipalDue(), agingEntity.getUnpaidPrincipal()); Assert.assertEquals(((LoanBO) accountBO).getLoanSummary().getInterestDue(), agingEntity.getUnpaidInterest()); Assert.assertEquals(((LoanBO) accountBO).getLoanSummary().getPrincipalDue() .add(((LoanBO) accountBO).getLoanSummary().getInterestDue()), agingEntity.getUnpaidBalance()); Assert.assertEquals(((LoanBO) accountBO).getTotalPrincipalAmountInArrears(), agingEntity.getOverduePrincipal()); Assert.assertEquals(((LoanBO) accountBO).getTotalInterestAmountInArrears(), agingEntity.getOverdueInterest()); Assert.assertEquals(((LoanBO) accountBO).getTotalPrincipalAmountInArrears() .add(((LoanBO) accountBO).getTotalInterestAmountInArrears()), agingEntity.getOverdueBalance()); }