List of usage examples for java.math BigDecimal ZERO
BigDecimal ZERO
To view the source code for java.math BigDecimal ZERO.
Click Source Link
From source file:jgnash.ui.report.compiled.IncomeExpensePieChart.java
private PieDataset createPieDataSet(Account a) { DefaultPieDataset returnValue = new DefaultPieDataset(); if (a != null) { BigDecimal total = a.getTreeBalance(startField.getLocalDate(), endField.getLocalDate(), a.getCurrencyNode());//from w w w.j a va 2s . co m // abs() on all values won't work if children aren't of uniform sign, // then again, this chart is not right to display those trees boolean negate = total != null && total.floatValue() < 0; // accounts may have balances independent of their children BigDecimal value = a.getBalance(startField.getLocalDate(), endField.getLocalDate()); if (value.compareTo(BigDecimal.ZERO) != 0) { returnValue.setValue(a, negate ? value.negate() : value); } for (final Account child : a.getChildren(Comparators.getAccountByCode())) { value = child.getTreeBalance(startField.getLocalDate(), endField.getLocalDate(), a.getCurrencyNode()); if (showEmptyCheck.isSelected() || value.compareTo(BigDecimal.ZERO) != 0) { returnValue.setValue(child, negate ? value.negate() : value); } } } return returnValue; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRFedNonFedBudgetV1_1Generator.java
/** * This method gets BudgetYearDataType details like BudgetPeriodStartDate,BudgetPeriodEndDate,BudgetPeriod * KeyPersons,OtherPersonnel,TotalCompensation,Equipment,ParticipantTraineeSupportCosts,Travel,OtherDirectCosts * DirectCosts,IndirectCosts,CognizantFederalAgency,TotalCosts based on BudgetPeriodInfo for the RRFedNonFedBudget. * /*from w w w. j a va2s . com*/ * @param periodInfo (BudgetPeriodInfo) budget period entry. * @return BudgetYearDataType corresponding to the BudgetSummaryInfo object. */ private BudgetYearDataType getBudgetYearDataType(BudgetPeriodDto periodInfo) { ScaleTwoDecimal totalDirectCostSharing = ScaleTwoDecimal.ZERO; ScaleTwoDecimal totalIndirectCostSharing = ScaleTwoDecimal.ZERO; ScaleTwoDecimal directCostsTotal = ScaleTwoDecimal.ZERO; BudgetYearDataType budgetYear = BudgetYearDataType.Factory.newInstance(); if (periodInfo != null) { budgetYear .setBudgetPeriodStartDate(s2SDateTimeService.convertDateToCalendar(periodInfo.getStartDate())); budgetYear.setBudgetPeriodEndDate(s2SDateTimeService.convertDateToCalendar(periodInfo.getEndDate())); gov.grants.apply.forms.rrFedNonFedBudgetV11.BudgetYearDataType.BudgetPeriod.Enum budgetPeriodEnum = gov.grants.apply.forms.rrFedNonFedBudgetV11.BudgetYearDataType.BudgetPeriod.Enum .forInt(periodInfo.getBudgetPeriod()); budgetYear.setBudgetPeriod(budgetPeriodEnum); budgetYear.setKeyPersons(getKeyPersons(periodInfo)); budgetYear.setOtherPersonnel(getOtherPersonnel(periodInfo)); SummaryDataType summary = SummaryDataType.Factory.newInstance(); if (periodInfo.getTotalCompensation() != null) { summary.setFederalSummary(periodInfo.getTotalCompensation().bigDecimalValue()); } if (periodInfo.getTotalCompensationCostSharing() != null) { if (budget.getSubmitCostSharingFlag()) { summary.setNonFederalSummary(periodInfo.getTotalCompensationCostSharing().bigDecimalValue()); if (periodInfo.getTotalCompensation() != null) { summary.setTotalFedNonFedSummary(periodInfo.getTotalCompensation() .add(periodInfo.getTotalCompensationCostSharing()).bigDecimalValue()); } else { summary.setTotalFedNonFedSummary( periodInfo.getTotalCompensationCostSharing().bigDecimalValue()); } } else { summary.setNonFederalSummary(BigDecimal.ZERO); if (periodInfo.getTotalCompensation() != null) { summary.setTotalFedNonFedSummary(periodInfo.getTotalCompensation().bigDecimalValue()); } else { summary.setTotalFedNonFedSummary(BigDecimal.ZERO); } } } budgetYear.setTotalCompensation(summary); budgetYear.setEquipment(getEquipment(periodInfo)); budgetYear.setTravel(getTravel(periodInfo)); budgetYear.setParticipantTraineeSupportCosts(getParticipantTraineeSupportCosts(periodInfo)); budgetYear.setOtherDirectCosts(getOtherDirectCosts(periodInfo)); SummaryDataType summaryDirect = SummaryDataType.Factory.newInstance(); if (periodInfo.getDirectCostsTotal() != null) { directCostsTotal = periodInfo.getDirectCostsTotal(); summaryDirect.setFederalSummary(directCostsTotal.bigDecimalValue()); } if (periodInfo.getTotalDirectCostSharing() != null) { totalDirectCostSharing = periodInfo.getTotalDirectCostSharing(); } summaryDirect.setNonFederalSummary(totalDirectCostSharing.bigDecimalValue()); if (directCostsTotal != null) { summaryDirect .setTotalFedNonFedSummary(directCostsTotal.add(totalDirectCostSharing).bigDecimalValue()); } else { summaryDirect.setTotalFedNonFedSummary(totalDirectCostSharing.bigDecimalValue()); } budgetYear.setDirectCosts(summaryDirect); IndirectCosts indirectCosts = getIndirectCosts(periodInfo); if (indirectCosts != null) { budgetYear.setIndirectCosts(indirectCosts); } budgetYear.setCognizantFederalAgency(periodInfo.getCognizantFedAgency()); if (periodInfo.getIndirectCosts().getTotalIndirectCostSharing() != null) { totalIndirectCostSharing = periodInfo.getIndirectCosts().getTotalIndirectCostSharing(); } SummaryDataType summaryTotal = SummaryDataType.Factory.newInstance(); if (periodInfo.getTotalCosts() != null) { summaryTotal.setFederalSummary(periodInfo.getTotalCosts().bigDecimalValue()); } summaryTotal.setNonFederalSummary( totalDirectCostSharing.bigDecimalValue().add(totalIndirectCostSharing.bigDecimalValue())); if (periodInfo.getTotalCosts() != null) { summaryTotal.setTotalFedNonFedSummary(periodInfo.getTotalCosts().add(totalDirectCostSharing) .bigDecimalValue().add(totalIndirectCostSharing.bigDecimalValue())); } else { summaryTotal.setTotalFedNonFedSummary( totalDirectCostSharing.bigDecimalValue().add(totalIndirectCostSharing.bigDecimalValue())); } budgetYear.setTotalCosts(summaryTotal); } return budgetYear; }
From source file:com.iskyshop.manage.buyer.action.OrderBuyerAction.java
@SecurityMapping(title = "?", value = "/buyer/order.htm*", rtype = "buyer", rname = "", rcode = "user_center", rgroup = "") @RequestMapping("/buyer/order.htm") public ModelAndView order(HttpServletRequest request, HttpServletResponse response, String currentPage, String order_id, String beginTime, String endTime, String order_status) { ModelAndView mv = new JModelAndView("user/default/usercenter/buyer_order.html", configService.getSysConfig(), this.userConfigService.getUserConfig(), 0, request, response); OrderFormQueryObject ofqo = new OrderFormQueryObject(currentPage, mv, "addTime", "desc"); User user = this.userService.getObjById(SecurityUserHolder.getCurrentUser().getId()); ofqo.addQuery("obj.user_id", new SysMap("user_id", SecurityUserHolder.getCurrentUser().getId().toString()), "="); ofqo.addQuery("obj.order_main", new SysMap("order_main", 1), "=");// ??,???? ofqo.addQuery("obj.order_cat", new SysMap("order_cat", 2), "!="); if (!CommUtil.null2String(order_id).equals("")) { ofqo.addQuery("obj.order_id", new SysMap("order_id", "%" + order_id + "%"), "like"); mv.addObject("order_id", order_id); }//from w ww . j a va 2 s.c o m if (!CommUtil.null2String(beginTime).equals("")) { ofqo.addQuery("obj.addTime", new SysMap("beginTime", CommUtil.formatDate(beginTime)), ">="); mv.addObject("beginTime", beginTime); } if (!CommUtil.null2String(endTime).equals("")) { String ends = endTime + " 23:59:59"; ofqo.addQuery("obj.addTime", new SysMap("endTime", CommUtil.formatDate(ends, "yyyy-MM-dd hh:mm:ss")), "<="); mv.addObject("endTime", endTime); } if (!CommUtil.null2String(order_status).equals("")) { if (order_status.equals("order_submit")) {// ??? ofqo.addQuery("obj.order_status", new SysMap("order_status", 10), "="); } if (order_status.equals("order_pay")) {// ? ofqo.addQuery("obj.order_status", new SysMap("order_status", 20), "="); } if (order_status.equals("order_shipping")) {// ?? ofqo.addQuery("obj.order_status", new SysMap("order_status", 30), "="); } if (order_status.equals("order_receive")) {// ? ofqo.addQuery("obj.order_status", new SysMap("order_status", 40), "="); } if (order_status.equals("order_finish")) {// ?? ofqo.addQuery("obj.order_status", new SysMap("order_status", 50), "="); } if (order_status.equals("order_cancel")) {// ?? ofqo.addQuery("obj.order_status", new SysMap("order_status", 0), "="); } } mv.addObject("orderFormTools", orderFormTools); mv.addObject("order_status", order_status); IPageList pList = this.orderFormService.list(ofqo); List<OrderForm> orderForms = pList.getResult(); //??? orderFormService.changPhotoByJson(orderForms); CommUtil.saveIPageList2ModelAndView("", "", "", pList, mv); List<Object> result = dataProcess(pList.getResult()); mv.addObject("data", result); // ?? int[] status = new int[] { 10, 30, 50 }; // ?? ? ? String[] string_status = new String[] { "order_submit", "order_shipping", "order_finish" }; Map orders_status = new LinkedHashMap(); BigDecimal totleAmount = new BigDecimal(0); for (int i = 0; i < status.length; i++) { int size = this.orderFormService .query("select obj.id,obj.totalPrice from OrderForm obj where obj.user_id=" + user.getId().toString() + " and obj.order_status =" + status[i] + "", null, -1, -1) .size(); mv.addObject("order_size_" + status[i], size); orders_status.put(string_status[i], size); } //? List list = this.orderFormService.query("select sum(obj.totalPrice) from OrderForm obj where obj.user_id=" + user.getId().toString() + " and obj.order_status >=40", null, -1, -1); BigDecimal amountTotle = BigDecimal.ZERO; if (list != null && list.size() > 0 && list.get(0) != null) { amountTotle = (BigDecimal) list.get(0); } mv.addObject("amountTotle", amountTotle); mv.addObject("orders_status", orders_status); mv.addObject("orderFormTools", this.orderFormTools); // ?cookie? ? cookie? List<Goods> your_like_goods = new ArrayList<Goods>(); Long your_like_GoodsClass = null; Cookie[] cookies = request.getCookies(); if (cookies != null) { for (Cookie cookie : cookies) { if (cookie.getName().equals("goodscookie")) { String[] like_gcid = cookie.getValue().split(",", 2); Goods goods = this.goodsService.getObjById(CommUtil.null2Long(like_gcid[0])); if (goods == null) break; your_like_GoodsClass = goods.getGc().getId(); your_like_goods = this.goodsService .query("select obj from Goods obj where obj.goods_status=0 and obj.gc.id = " + your_like_GoodsClass + " and obj.id is not " + goods.getId() + " order by obj.goods_salenum desc", null, 0, 20); int gcs_size = your_like_goods.size(); if (gcs_size < 20) { List<Goods> like_goods = this.goodsService.query( "select obj from Goods obj where obj.goods_status=0 and obj.id is not " + goods.getId() + " order by obj.goods_salenum desc", null, 0, 20 - gcs_size); for (int i = 0; i < like_goods.size(); i++) { // ??? int k = 0; for (int j = 0; j < your_like_goods.size(); j++) { if (like_goods.get(i).getId().equals(your_like_goods.get(j).getId())) { k++; } } if (k == 0) { your_like_goods.add(like_goods.get(i)); } } } break; } else { your_like_goods = this.goodsService.query( "select obj from Goods obj where obj.goods_status=0 order by obj.goods_salenum desc", null, 0, 20); } } } else { your_like_goods = this.goodsService.query( "select obj from Goods obj where obj.goods_status=0 order by obj.goods_salenum desc", null, 0, 20); } mv.addObject("your_like_goods", your_like_goods); return mv; }
From source file:com.heliumv.api.inventory.InventoryApi.java
/** * Mengen überprüfen</b> * <p>Die Gesamtsumme der identity.amount muss ident mit der angegebenen Menge sein<p> * <p>Es dürfen nur positive Mengen in den identities vorhanden sein.</p> * <p>Seriennummernbehaftete Artikel dürfen nur die Menge 1.0 haben</p> * @param amount/* ww w .j a v a 2s . c om*/ * @param identities * @return */ private boolean verifyAmounts(ArtikelDto itemDto, BigDecimal amount, List<IdentityAmountEntry> identities) { if (!itemDto.istArtikelSnrOderchargentragend()) return true; if (identities == null || identities.size() == 0) { respondBadRequestValueMissing("identities"); return false; } BigDecimal amountIdentities = BigDecimal.ZERO; for (IdentityAmountEntry entry : identities) { if (entry.getAmount() == null) { respondBadRequestValueMissing("amount"); appendBadRequestData(entry.getIdentity(), "amount missing"); return false; } if (entry.getAmount().signum() != 1) { respondBadRequest("amount", "positive"); appendBadRequestData(entry.getIdentity(), entry.getAmount().toPlainString()); return false; } if (itemDto.isSeriennrtragend()) { if (BigDecimal.ONE.compareTo(entry.getAmount()) != 0) { respondBadRequest("snr-amount", "1 (is: " + entry.getAmount().toPlainString() + ")"); return false; } } amountIdentities = amountIdentities.add(entry.getAmount()); } if (amountIdentities.compareTo(amount.abs()) != 0) { respondBadRequest("totalamount != identityamount", amount.toPlainString()); appendBadRequestData("identityamount", amountIdentities.toPlainString()); return false; } return true; }
From source file:it.newfammulfin.api.EntryResource.java
private <K> boolean checkAndBalanceZeroShares(final Map<K, BigDecimal> shares, BigDecimal expectedSum) { if (shares.isEmpty()) { return false; }/* www. ja v a 2 s . c o m*/ boolean equalShares = false; if (!Util.containsNotZero(shares.values())) { equalShares = true; expectedSum = expectedSum.setScale(Math.max(DEFAULT_SHARE_SCALE, expectedSum.scale())); for (Map.Entry<K, BigDecimal> shareEntry : shares.entrySet()) { shareEntry.setValue(expectedSum.divide(BigDecimal.valueOf(shares.size()), RoundingMode.DOWN)); } } K largestKey = shares.keySet().iterator().next(); for (Map.Entry<K, BigDecimal> share : shares.entrySet()) { if (share.getValue().abs().compareTo(shares.get(largestKey).abs()) > 0) { largestKey = share.getKey(); } } BigDecimal remainder = Util.remainder(shares.values(), expectedSum); if (remainder.compareTo(BigDecimal.ZERO) != 0) { shares.put(largestKey, shares.get(largestKey).add(remainder)); } return equalShares; }
From source file:org.openvpms.archetype.rules.stock.ChargeStockUpdaterTestCase.java
private BigDecimal getStock(Party location, Product product) { product = get(product);/*w w w . j av a 2s .co m*/ EntityBean prodBean = new EntityBean(product); EntityRelationship rel = prodBean.getRelationship(location); if (rel != null) { IMObjectBean relBean = new IMObjectBean(rel); return relBean.getBigDecimal("quantity"); } return BigDecimal.ZERO; }
From source file:com.roncoo.pay.account.service.impl.RpAccountTransactionServiceImpl.java
/** * ?//from w w w . java 2s . c o m * * @param userNo * ? * @param amount * ?? * @param requestNo * ?? * @param trxType * * @param remark * */ @Transactional(rollbackFor = Exception.class) public RpAccount unFreezeSettAmount(String userNo, BigDecimal amount) { RpAccount account = this.getByUserNo_IsPessimist(userNo, true); if (account == null) { throw AccountBizException.ACCOUNT_NOT_EXIT; } Date lastModifyDate = account.getEditTime(); // ??0 if (!DateUtils.isSameDayWithToday(lastModifyDate)) { account.setTodayExpend(BigDecimal.ZERO); account.setTodayIncome(BigDecimal.ZERO); } // ?? if (account.getUnbalance().subtract(amount).compareTo(BigDecimal.ZERO) == -1) { // ?? throw AccountBizException.ACCOUNT_UN_FROZEN_AMOUNT_OUTLIMIT; } account.setEditTime(new Date()); account.setUnbalance(account.getUnbalance().subtract(amount));// this.rpAccountDao.update(account); return account; }
From source file:net.shopxx.controller.shop.OrderController.java
@RequestMapping(value = "/calculate", params = "type=exchange", method = RequestMethod.GET) public @ResponseBody Map<String, Object> calculate(Long productId, Integer quantity, Long receiverId, Long paymentMethodId, Long shippingMethodId, BigDecimal balance, String memo) { Map<String, Object> data = new HashMap<String, Object>(); if (quantity == null || quantity < 1) { data.put("message", ERROR_MESSAGE); return data; }/*from w w w . ja v a 2 s . co m*/ Product product = productService.find(productId); if (product == null) { data.put("message", ERROR_MESSAGE); return data; } Member member = memberService.getCurrent(); Receiver receiver = receiverService.find(receiverId); if (receiver != null && !member.equals(receiver.getMember())) { data.put("message", ERROR_MESSAGE); return data; } if (balance != null && balance.compareTo(BigDecimal.ZERO) < 0) { data.put("message", ERROR_MESSAGE); return data; } if (balance != null && balance.compareTo(member.getBalance()) > 0) { data.put("message", Message.warn("shop.order.insufficientBalance")); return data; } PaymentMethod paymentMethod = paymentMethodService.find(paymentMethodId); ShippingMethod shippingMethod = shippingMethodService.find(shippingMethodId); Set<CartItem> cartItems = new HashSet<CartItem>(); CartItem cartItem = new CartItem(); cartItem.setProduct(product); cartItem.setQuantity(quantity); cartItems.add(cartItem); Cart cart = new Cart(); cart.setMember(member); cart.setCartItems(cartItems); Order order = orderService.generate(Order.Type.general, cart, receiver, paymentMethod, shippingMethod, null, null, balance, null); data.put("message", SUCCESS_MESSAGE); data.put("price", order.getPrice()); data.put("fee", order.getFee()); data.put("freight", order.getFreight()); data.put("tax", order.getTax()); data.put("promotionDiscount", order.getPromotionDiscount()); data.put("couponDiscount", order.getCouponDiscount()); data.put("amount", order.getAmount()); data.put("amountPayable", order.getAmountPayable()); return data; }
From source file:com.gst.portfolio.savings.domain.SavingsAccountCharge.java
public void undoPayment(final MonetaryCurrency currency, final Money transactionAmount) { Money amountPaid = getAmountPaid(currency); amountPaid = amountPaid.minus(transactionAmount); this.amountPaid = amountPaid.getAmount(); this.amountOutstanding = calculateAmountOutstanding(currency); if (this.isWithdrawalFee()) { this.amountOutstanding = BigDecimal.ZERO; }//from w w w .java 2 s . c om // to reset amount outstanding for annual and monthly fee resetPropertiesForRecurringFees(); updateToPreviousDueDate();// reset annual and monthly due date. this.paid = false; this.status = true; }