List of usage examples for java.math BigDecimal ONE
BigDecimal ONE
To view the source code for java.math BigDecimal ONE.
Click Source Link
From source file:org.openvpms.esci.adapter.map.order.OrderMapperImpl.java
/** * Returns a <tt>PriceType</tt> for the specified price and unit code. * * @param price the price//w w w .j a va 2 s . c om * @param unitCode the quantity unit code (UN/CEFACT). May be <tt>null</tt> * @param currency the currency * @return the corresponding <tt>PriceType</tt> for price and unitCode */ private PriceType getPrice(BigDecimal price, String unitCode, Currency currency) { PriceType result = new PriceType(); PriceAmountType priceAmount = UBLHelper.initAmount(new PriceAmountType(), price, currency); result.setPriceAmount(priceAmount); result.setBaseQuantity(UBLHelper.initQuantity(new BaseQuantityType(), BigDecimal.ONE, unitCode)); return result; }
From source file:org.jrecruiter.service.JobServiceUnitTest.java
private Job getJob(Long jobId) { Job job = new Job(jobId); job.setBusinessAddress1("businessAddress1"); job.setBusinessAddress2("businessAddress2"); job.setBusinessCity("businessCity"); job.setBusinessEmail("businessEmail"); job.setRegionOther("businessLocation"); job.setBusinessName("businessName"); job.setBusinessPhone("businessPhone"); job.setBusinessState("businessState"); job.setBusinessZip("businessZip"); job.setDescription("description"); job.setJobRestrictions("jobRestrictions"); job.setJobTitle("jobTitle"); job.setLatitude(BigDecimal.ONE); job.setLongitude(BigDecimal.ZERO); job.setOfferedBy(OfferedBy.RECRUITER); job.setRegistrationDate(new Date()); job.setSalary("10000"); job.setStatus(JobStatus.ACTIVE); job.setUpdateDate(new Date()); job.setWebsite("www.google.com"); return job;/* w w w. ja v a 2s . com*/ }
From source file:com.acc.fulfilmentprocess.test.FraudCheckIntegrationTest.java
protected void placeTestOrder() throws InvalidCartException, CalculationException { final CartModel cart = cartService.getSessionCart(); final UserModel user = userService.getCurrentUser(); cartService.addNewEntry(cart, productService.getProductForCode("testProduct1"), 1, null); cartService.addNewEntry(cart, productService.getProductForCode("testProduct2"), 2, null); cartService.addNewEntry(cart, productService.getProductForCode("testProduct3"), 3, null); final AddressModel deliveryAddress = new AddressModel(); deliveryAddress.setOwner(user);// w w w. j a v a2s . com deliveryAddress.setFirstname("Der"); deliveryAddress.setLastname("Buck"); deliveryAddress.setTown("Muenchen"); deliveryAddress.setCountry(commonI18NService.getCountry("DE")); modelService.save(deliveryAddress); final DebitPaymentInfoModel paymentInfo = new DebitPaymentInfoModel(); paymentInfo.setOwner(cart); paymentInfo.setBank("MeineBank"); paymentInfo.setUser(user); paymentInfo.setAccountNumber("34434"); paymentInfo.setBankIDNumber("1111112"); paymentInfo.setBaOwner("Ich"); paymentInfo.setCode("testPaymentInfo1"); modelService.save(paymentInfo); final ZoneDeliveryModeModel zoneDeliveryModeModel = new ZoneDeliveryModeModel(); zoneDeliveryModeModel.setCode("free"); zoneDeliveryModeModel.setNet(Boolean.TRUE); final ZoneDeliveryModeValueModel zoneDeliveryModeValueModel = new ZoneDeliveryModeValueModel(); zoneDeliveryModeValueModel.setDeliveryMode(zoneDeliveryModeModel); zoneDeliveryModeValueModel.setValue(Double.valueOf(0.00)); zoneDeliveryModeValueModel.setCurrency(commonI18NService.getCurrency("EUR")); zoneDeliveryModeValueModel.setMinimum(Double.valueOf(0.00)); final ZoneModel zoneModel = new ZoneModel(); zoneModel.setCode("de"); zoneModel.setCountries(Collections.singleton(commonI18NService.getCountry("DE"))); modelService.save(zoneModel); zoneDeliveryModeValueModel.setZone(zoneModel); modelService.save(zoneDeliveryModeModel); zoneDeliveryModeModel.setValues(Collections.singleton(zoneDeliveryModeValueModel)); modelService.save(zoneDeliveryModeValueModel); modelService.save(zoneDeliveryModeModel); cart.setDeliveryMode(zoneDeliveryModeModel); cart.setDeliveryAddress(deliveryAddress); cart.setPaymentInfo(paymentInfo); final CardInfo card = new CardInfo(); card.setCardType(CreditCardType.VISA); card.setCardNumber("4111111111111111"); card.setExpirationMonth(Integer.valueOf(12)); card.setExpirationYear(Integer.valueOf(Calendar.getInstance().get(Calendar.YEAR) + 2)); card.setCv2Number("123"); final PaymentTransactionModel paymentTransaction = paymentService.authorize("code3" + codeNo++, BigDecimal.ONE, Currency.getInstance("EUR"), deliveryAddress, deliveryAddress, card) .getPaymentTransaction(); cart.setPaymentTransactions(Collections.singletonList(paymentTransaction)); modelService.save(cart); calculationService.calculate(cart); order = commerceCheckoutService.placeOrder(cart); }
From source file:org.openvpms.archetype.rules.supplier.OrderGeneratorTestCase.java
/** * Verifies that when the idealQty is less the than the package size, an order for a single package will be * created./*from ww w.j ava 2s .com*/ */ @Test public void testCreateOrderForQuantityLessThanPackageSize() { OrderGenerator generator = new OrderGenerator(taxRules, getArchetypeService()); Party stockLocation = SupplierTestHelper.createStockLocation(); Party supplier = TestHelper.createSupplier(); Product product1 = TestHelper.createProduct(); addRelationships(product1, stockLocation, supplier, true, 0, 2, 2, new BigDecimal("2.0"), 10); List<FinancialAct> order = generator.createOrder(supplier, stockLocation, false); assertEquals(2, order.size()); save(order); BigDecimal total = new BigDecimal("2.20"); BigDecimal tax = new BigDecimal("0.20"); checkOrder(order.get(0), supplier, stockLocation, total, tax); checkOrderItem(order.get(1), product1, BigDecimal.ONE, total, tax); }
From source file:pe.gob.mef.gescon.hibernate.impl.ConsultaDaoImpl.java
/** * * @param filters//from w ww . j a va 2s. c om * @return */ @Override public List<HashMap> getDestacadosByTipoConocimiento(HashMap filters) { String ntipoconocimientoid = ((BigDecimal) filters.get("ntipoconocimientoid")).toString(); final StringBuilder sql = new StringBuilder(); Object object = null; try { if (StringUtils.isNotBlank(ntipoconocimientoid) && ntipoconocimientoid.equals("1")) { sql.append("SELECT "); sql.append(" a.nbaselegalid AS ID, a.vnumero AS NOMBRE, a.vnombre AS SUMILLA, "); sql.append( " a.ncategoriaid AS IDCATEGORIA, b.vnombre AS CATEGORIA, a.dfechapublicacion AS FECHA, "); sql.append( " 1 AS IDTIPOCONOCIMIENTO, 'Base Legal' AS TIPOCONOCIMIENTO, a.nestadoid AS IDESTADO, c.vnombre AS ESTADO "); sql.append("FROM TBASELEGAL a "); sql.append(" INNER JOIN MTCATEGORIA b ON a.ncategoriaid = b.ncategoriaid "); sql.append(" INNER JOIN MTESTADO_BASELEGAL c ON a.nestadoid = c.nestadoid "); sql.append("WHERE a.nactivo = :ACTIVO "); sql.append("AND a.ndestacado = :DESTACADO "); sql.append("AND a.nestadoid IN (3,5,6) "); // Publicada, Concordada y Modificada. } if (StringUtils.isNotBlank(ntipoconocimientoid) && ntipoconocimientoid.equals("2")) { sql.append("SELECT "); sql.append(" a.npreguntaid AS ID, a.vasunto AS NOMBRE, a.vrespuesta AS SUMILLA, "); sql.append( " a.ncategoriaid AS IDCATEGORIA, b.vnombre AS CATEGORIA, a.dfechapublicacion AS FECHA, "); sql.append(" 2 AS IDTIPOCONOCIMIENTO, 'Preguntas y Respuestas' AS TIPOCONOCIMIENTO, "); sql.append(" a.nsituacionid AS IDESTADO, c.vnombre AS ESTADO "); sql.append("FROM TPREGUNTA a "); sql.append(" INNER JOIN MTCATEGORIA b ON a.ncategoriaid = b.ncategoriaid "); sql.append(" INNER JOIN MTSITUACION c ON a.nsituacionid = c.nsituacionid "); sql.append("WHERE a.nactivo = :ACTIVO "); sql.append("AND a.ndestacado = :DESTACADO "); sql.append("AND a.nsituacionid = 6 "); // Publicada } if (StringUtils.isNotBlank(ntipoconocimientoid) && (ntipoconocimientoid.equals("3") || ntipoconocimientoid.equals("4") || ntipoconocimientoid.equals("5") || ntipoconocimientoid.equals("6"))) { sql.append("SELECT "); sql.append(" a.nconocimientoid AS ID, a.vtitulo AS NOMBRE, a.vdescripcion AS SUMILLA, "); sql.append( " a.ncategoriaid AS IDCATEGORIA, b.vnombre AS CATEGORIA, a.dfechapublicacion AS FECHA, "); sql.append(" a.ntpoconocimientoid AS IDTIPOCONOCIMIENTO, d.vnombre AS TIPOCONOCIMIENTO, "); sql.append(" a.nsituacionid AS IDESTADO, c.vnombre AS ESTADO "); sql.append("FROM TCONOCIMIENTO a "); sql.append(" INNER JOIN MTCATEGORIA b ON a.ncategoriaid = b.ncategoriaid "); sql.append(" INNER JOIN MTSITUACION c ON a.nsituacionid = c.nsituacionid "); sql.append(" INNER JOIN MTTIPO_CONOCIMIENTO d ON a.ntpoconocimientoid = d.ntpoconocimientoid "); sql.append("WHERE a.nactivo = :ACTIVO "); sql.append("AND a.ndestacado = :DESTACADO "); sql.append("AND a.nsituacionid = 6 AND a.NTPOCONOCIMIENTOID= ").append(ntipoconocimientoid) .append(" "); // Publicado } sql.append("ORDER BY 5, 7 DESC "); object = getHibernateTemplate().execute(new HibernateCallback() { @Override public Object doInHibernate(Session session) throws HibernateException { Query query = session.createSQLQuery(sql.toString()); query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP); query.setParameter("ACTIVO", BigDecimal.ONE); query.setParameter("DESTACADO", BigDecimal.ONE); return query.list(); } }); } catch (DataAccessException e) { e.getMessage(); e.printStackTrace(); } return (List<HashMap>) object; }
From source file:pe.gob.mef.gescon.web.ui.MaestroMB.java
public void saveDetail(ActionEvent event) { try {//ww w. j av a2s .com if (CollectionUtils.isEmpty(this.getListaMaestroDetalle())) { this.setListaMaestroDetalle(Collections.EMPTY_LIST); } MaestroDetalle maestroDetalle = new MaestroDetalle(); maestroDetalle.setVnombre(this.getNombre().trim().toUpperCase()); maestroDetalle.setVdescripcion(StringUtils.capitalize(this.getDescripcion().trim())); if (!errorValidationDetail(maestroDetalle)) { LoginMB loginMB = (LoginMB) JSFUtils.getSessionAttribute("loginMB"); User user = loginMB.getUser(); MaestroDetalleService service = (MaestroDetalleService) ServiceFinder .findBean("MaestroDetalleService"); maestroDetalle.setNdetalleid(service.getNextPK()); maestroDetalle.setNmaestroid(this.getSelectedMaestro().getNmaestroid()); maestroDetalle.setNactivo(BigDecimal.ONE); maestroDetalle.setDfechacreacion(new Date()); maestroDetalle.setVusuariocreacion(user.getVlogin()); service.saveOrUpdate(maestroDetalle); this.setListaMaestroDetalle(service.getDetallesByMaestro(this.getSelectedMaestro())); this.cleanAttributes(); RequestContext.getCurrentInstance().execute("PF('newdDialog').hide();"); } } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } }
From source file:pe.gob.mef.gescon.hibernate.impl.ConocimientoDaoImpl.java
@Override public List<HashMap> getConcimientosByVinculoBaseLegalId(final BigDecimal id) { final StringBuilder sql = new StringBuilder(); Object object = null;/*from w w w .j ava 2 s . c om*/ try { sql.append("SELECT t.nconocimientoid AS ID "); sql.append("FROM tconocimiento t "); sql.append("INNER JOIN tvinculo x "); sql.append("ON x.nconocimientoid = t.nconocimientoid "); sql.append("AND x.nconocimientovinc = :IDCONOCIMIENTO "); sql.append("AND x.ntipoconocimientovinc = :TIPO "); object = getHibernateTemplate().execute(new HibernateCallback() { @Override public Object doInHibernate(Session session) throws HibernateException { Query query = session.createSQLQuery(sql.toString()); query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP); query.setParameter("IDCONOCIMIENTO", id); query.setParameter("TIPO", BigDecimal.ONE); return query.list(); } }); } catch (DataAccessException e) { e.getMessage(); e.printStackTrace(); } return (List<HashMap>) object; }
From source file:com.mitre.fulfilmentprocess.test.FraudCheckIntegrationTest.java
protected void placeTestOrder() throws InvalidCartException, CalculationException { final CartModel cart = cartService.getSessionCart(); final UserModel user = userService.getCurrentUser(); cartService.addNewEntry(cart, productService.getProductForCode("testProduct1"), 1, null); cartService.addNewEntry(cart, productService.getProductForCode("testProduct2"), 2, null); cartService.addNewEntry(cart, productService.getProductForCode("testProduct3"), 3, null); final AddressModel deliveryAddress = new AddressModel(); deliveryAddress.setOwner(user);/*from w w w .j a v a2 s . c o m*/ deliveryAddress.setFirstname("Der"); deliveryAddress.setLastname("Buck"); deliveryAddress.setTown("Muenchen"); deliveryAddress.setCountry(commonI18NService.getCountry("DE")); modelService.save(deliveryAddress); final DebitPaymentInfoModel paymentInfo = new DebitPaymentInfoModel(); paymentInfo.setOwner(cart); paymentInfo.setBank("MeineBank"); paymentInfo.setUser(user); paymentInfo.setAccountNumber("34434"); paymentInfo.setBankIDNumber("1111112"); paymentInfo.setBaOwner("Ich"); paymentInfo.setCode("testPaymentInfo1"); modelService.save(paymentInfo); final ZoneDeliveryModeModel zoneDeliveryModeModel = new ZoneDeliveryModeModel(); zoneDeliveryModeModel.setCode("free"); zoneDeliveryModeModel.setNet(Boolean.TRUE); final ZoneDeliveryModeValueModel zoneDeliveryModeValueModel = new ZoneDeliveryModeValueModel(); zoneDeliveryModeValueModel.setDeliveryMode(zoneDeliveryModeModel); zoneDeliveryModeValueModel.setValue(Double.valueOf(0.00)); zoneDeliveryModeValueModel.setCurrency(commonI18NService.getCurrency("EUR")); zoneDeliveryModeValueModel.setMinimum(Double.valueOf(0.00)); final ZoneModel zoneModel = new ZoneModel(); zoneModel.setCode("de"); zoneModel.setCountries(Collections.singleton(commonI18NService.getCountry("DE"))); modelService.save(zoneModel); zoneDeliveryModeValueModel.setZone(zoneModel); modelService.save(zoneDeliveryModeModel); zoneDeliveryModeModel.setValues(Collections.singleton(zoneDeliveryModeValueModel)); modelService.save(zoneDeliveryModeValueModel); modelService.save(zoneDeliveryModeModel); cart.setDeliveryMode(zoneDeliveryModeModel); cart.setDeliveryAddress(deliveryAddress); cart.setPaymentInfo(paymentInfo); final CardInfo card = new CardInfo(); card.setCardType(CreditCardType.VISA); card.setCardNumber("4111111111111111"); card.setExpirationMonth(Integer.valueOf(12)); card.setExpirationYear(Integer.valueOf(Calendar.getInstance().get(Calendar.YEAR) + 2)); card.setCv2Number("123"); final PaymentTransactionModel paymentTransaction = paymentService.authorize("code3" + codeNo++, BigDecimal.ONE, Currency.getInstance("EUR"), deliveryAddress, deliveryAddress, card) .getPaymentTransaction(); cart.setPaymentTransactions(Collections.singletonList(paymentTransaction)); modelService.save(cart); calculationService.calculate(cart); final CommerceCheckoutParameter parameter = new CommerceCheckoutParameter(); parameter.setEnableHooks(true); parameter.setCart(cart); parameter.setSalesApplication(SalesApplication.WEB); order = commerceCheckoutService.placeOrder(parameter).getOrder(); }
From source file:adalid.commons.util.ObjUtils.java
public static BigDecimal product(Object... objects) { BigDecimal result = BigDecimal.ONE; BigDecimal multiplicand;//from w w w.j av a2 s . c o m int i = 0; for (Object obj : objects) { multiplicand = NumUtils.numberToBigDecimal(obj); if (multiplicand == null) { return null; } i++; result.multiply(multiplicand); } return i > 1 ? result : null; }
From source file:org.efaps.esjp.accounting.transaction.Transaction_Base.java
/** * Get a rate Object from the user interface. * * @param _parameter Parameter as passed from the eFaps API. * @param _postfix postfix for the fields. * @param _index index of the rate.//from w w w . java2s .c o m * @return Object[] a new object. * @throws EFapsException on error. */ public Object[] getRateObject(final Parameter _parameter, final String _postfix, final int _index) throws EFapsException { BigDecimal rate = BigDecimal.ONE; try { final String[] rates = _parameter.getParameterValues("rate" + _postfix); rate = (BigDecimal) RateFormatter.get().getFrmt4Rate().parse(rates[_index]); } catch (final ParseException e) { throw new EFapsException(AbstractDocument_Base.class, "analyzeRate.ParseException", e); } final boolean rInv = "true" .equalsIgnoreCase(_parameter.getParameterValues("rate" + _postfix + RateUI.INVERTEDSUFFIX)[_index]); return new Object[] { rInv ? BigDecimal.ONE : rate, rInv ? rate : BigDecimal.ONE }; }