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:org.fineract.module.stellar.TestPaymentInSimpleNetwork.java
@Test public void paymentSumApproachesCreditLimit() throws Exception { logger.info("paymentSumApproachesCreditLimit test begin"); final BigDecimal transferIncrement = BigDecimal.valueOf(99.99); final BigDecimal lastBit = BigDecimal.valueOf(0.1); final AccountListener accountListener = new AccountListener(serverAddress, firstTenantId, secondTenantId); //Approach the creditMatcher limit, then go back down to zero. Collections.nCopies(10, transferIncrement).parallelStream() .forEach((transferAmount) -> makePayment(firstTenantId, firstTenantApiKey, secondTenantId, ASSET_CODE, transferAmount)); {//from w w w.j ava 2 s .c om final List<AccountListener.CreditMatcher> transfers = new ArrayList<>(); transfers.addAll(Collections.nCopies(10, creditMatcher(secondTenantId, transferIncrement, ASSET_CODE, firstTenantId))); accountListener.waitForCredits(PAY_WAIT * 3, transfers); } checkBalance(secondTenantId, secondTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(secondTenantId), VAULT_BALANCE); checkBalance(secondTenantId, secondTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId), transferIncrement.multiply(BigDecimal.TEN)); logger.info("paymentSumApproachesCreditLimit transfers back"); Collections.nCopies(10, transferIncrement).parallelStream() .forEach((transferAmount) -> makePayment(secondTenantId, secondTenantApiKey, firstTenantId, ASSET_CODE, transferAmount)); { final List<AccountListener.CreditMatcher> transfers = new ArrayList<>(); transfers.addAll(Collections.nCopies(10, creditMatcher(firstTenantId, transferIncrement, ASSET_CODE, vaultMatcher(firstTenantId, secondTenantId)))); accountListener.waitForCredits(PAY_WAIT * 3, transfers); accountListener.waitForCreditsToAccumulate(PAY_WAIT * 3, creditMatcher(secondTenantId, transferIncrement.multiply(BigDecimal.TEN), ASSET_CODE, vaultMatcher(firstTenantId, secondTenantId))); accountListener.waitForCreditsToAccumulate(PAY_WAIT * 3, creditMatcher(firstTenantId, transferIncrement.multiply(BigDecimal.TEN), ASSET_CODE, vaultMatcher(firstTenantId, secondTenantId))); } checkBalance(firstTenantId, firstTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(secondTenantId), BigDecimal.ZERO); checkBalance(secondTenantId, secondTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId), BigDecimal.ZERO); //Approach the creditMatcher limit again, then go to exactly the creditMatcher limit Collections.nCopies(10, transferIncrement).parallelStream() .forEach((transferAmount) -> makePayment(firstTenantId, firstTenantApiKey, secondTenantId, ASSET_CODE, transferAmount)); makePayment(firstTenantId, firstTenantApiKey, secondTenantId, ASSET_CODE, lastBit); { final List<AccountListener.CreditMatcher> transfers = new ArrayList<>(); transfers.addAll(Collections.nCopies(10, creditMatcher(secondTenantId, transferIncrement, ASSET_CODE, firstTenantId))); transfers.add(creditMatcher(secondTenantId, lastBit, ASSET_CODE, firstTenantId)); accountListener.waitForCredits(PAY_WAIT * 3, transfers); } checkBalance(secondTenantId, secondTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId), TRUST_LIMIT); //Now try to go over the creditMatcher limit. makePayment(firstTenantId, firstTenantApiKey, secondTenantId, ASSET_CODE, lastBit); accountListener.waitForCredits(PAY_WAIT, creditMatcher(secondTenantId, lastBit, ASSET_CODE, vaultMatcher(firstTenantId, secondTenantId))); checkBalance(secondTenantId, secondTenantApiKey, ASSET_CODE, tenantVaultStellarAddress(firstTenantId), TRUST_LIMIT); //Zero out balance for next test. makePayment(secondTenantId, secondTenantApiKey, firstTenantId, ASSET_CODE, TRUST_LIMIT); accountListener.waitForCredits(PAY_WAIT, creditMatcher(firstTenantId, TRUST_LIMIT, ASSET_CODE, vaultMatcher(firstTenantId, secondTenantId))); }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRFedNonFedBudgetV1_2Generator.java
private BudgetYearDataType getBudgetYearDataType(BudgetPeriodDto periodInfo) { ScaleTwoDecimal totalDirectCostSharing = ScaleTwoDecimal.ZERO; ScaleTwoDecimal totalIndirectCostSharing = ScaleTwoDecimal.ZERO; ScaleTwoDecimal directCostsTotal = ScaleTwoDecimal.ZERO; BudgetYearDataType budgetYear = Factory.newInstance(); if (periodInfo != null) { budgetYear// w ww . j av a 2 s .c o m .setBudgetPeriodStartDate(s2SDateTimeService.convertDateToCalendar(periodInfo.getStartDate())); budgetYear.setBudgetPeriodEndDate(s2SDateTimeService.convertDateToCalendar(periodInfo.getEndDate())); BudgetPeriod.Enum budgetPeriodEnum = 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); } final SummaryDataType totalCostsFee = SummaryDataType.Factory.newInstance(); if (budgetYear.getFee() != null) { totalCostsFee.setTotalFedNonFedSummary( budgetYear.getFee().add(budgetYear.getTotalCosts().getTotalFedNonFedSummary())); totalCostsFee.setFederalSummary(budgetYear.getTotalCosts().getFederalSummary()); totalCostsFee.setNonFederalSummary(budgetYear.getTotalCosts().getNonFederalSummary()); } else { totalCostsFee.setTotalFedNonFedSummary(budgetYear.getTotalCosts().getTotalFedNonFedSummary()); totalCostsFee.setFederalSummary(budgetYear.getTotalCosts().getFederalSummary()); totalCostsFee.setNonFederalSummary(budgetYear.getTotalCosts().getNonFederalSummary()); } budgetYear.setTotalCostsFee(totalCostsFee); return budgetYear; }
From source file:com.artivisi.biller.simulator.gateway.pln.PlnGateway.java
private boolean handleInquiryPostpaid(ISOSource src, ISOMsg msg, ISOMsg response) throws ISOException, IOException, VetoException { String bit48Request = msg.getString(48); if (bit48Request.length() != 19) { logger.error("[POSTPAID] - [INQ-REQ] - Invalid bit 48 [{}]", bit48Request); response.set(39, ResponseCode.ERROR_INVALID_MESSAGE); src.send(response);//from www. j a v a 2 s . co m return true; } String mitra = bit48Request.substring(0, 7); if (billerSimulatorService.findMitraByKode(mitra.trim()) == null) { logger.debug("[POSTPAID] - [INQ-REQ] - Mitra [{}]", mitra); logger.error("[POSTPAID] - [INQ-REQ] - Kode mitra tidak ditemukan [{}]", mitra); response.set(39, ResponseCode.ERROR_UNREGISTERED_SWITCHING); src.send(response); return true; } String idpel = bit48Request.substring(7); Pelanggan p = plnSimulatorService.findPelangganByIdpel(idpel); if (p == null) { logger.error("[POSTPAID] - [INQ-REQ] - IDPEL tidak ditemukan [{}]", idpel); response.set(39, ResponseCode.ERROR_UNKNOWN_SUBSCRIBER); src.send(response); return true; } if (!ResponseCode.SUCCESSFUL.equals(p.getResponseCode())) { logger.error("[POSTPAID] - [INQ-REQ] - Pelanggan diset untuk RC [{}]", p.getResponseCode()); response.set(39, p.getResponseCode()); src.send(response); return true; } List<TagihanPascabayar> daftarTagihan = plnSimulatorService.findTagihan(p); if (daftarTagihan.size() < 1) { logger.error("[POSTPAID] - [INQ-REQ] - Tagihan untuk idpel [{}] tidak ada", idpel); response.set(39, ResponseCode.ERROR_CURRENT_BILL_IS_NOT_AVAILABLE); src.send(response); return true; } List<TagihanPascabayar> tagihanDikirim; if (daftarTagihan.size() > 4) { tagihanDikirim = daftarTagihan.subList(0, 4); } else { tagihanDikirim = daftarTagihan; } BigDecimal amount = BigDecimal.ZERO; for (TagihanPascabayar tagihanPascabayar : tagihanDikirim) { amount = amount.add(tagihanPascabayar.getBill()); amount = amount.add(tagihanPascabayar.getDenda()); } response.set(4, "360" + "0" + StringUtils.leftPad(amount.setScale(0, RoundingMode.HALF_EVEN).toString(), 12, "0")); InquiryPostpaidResponse ipr = new InquiryPostpaidResponse(); ipr.setBank(msg.getString(32)); ipr.setSwitcher(mitra); ipr.setStan(msg.getString(11)); for (TagihanPascabayar tagihanPascabayar : tagihanDikirim) { InquiryPostpaidResponseDetail detail = new InquiryPostpaidResponseDetail(); detail.setTagihanPascabayar(tagihanPascabayar); detail.setInquiryPostpaidResponse(ipr); ipr.getDetails().add(detail); } plnService.save(ipr); StringBuffer bit48Response = createBit48InquiryPostpaidResponse(bit48Request, p, daftarTagihan, tagihanDikirim, ipr); response.set(39, ResponseCode.SUCCESSFUL); response.set(48, bit48Response.toString()); try { logger.info("[POSTPAID] - [INQ-REQ] - Pelanggan diset untuk hold [{}]", p.getHoldResponse()); Thread.sleep(p.getHoldResponse()); } catch (Exception e) { logger.error(e.getMessage(), e); } src.send(response); return true; }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424V1_1Generator.java
/** * /* w w w . j av a 2s . c o m*/ * This method is to get estimated project funds for RRSF424 * * @return EstimatedProjectFunding estimated total cost for the project. */ private EstimatedProjectFunding getProjectFunding() throws S2SException { ProposalDevelopmentBudgetExtContract budget = s2SCommonBudgetService .getBudget(pdDoc.getDevelopmentProposal()); EstimatedProjectFunding funding = EstimatedProjectFunding.Factory.newInstance(); funding.setTotalEstimatedAmount(BigDecimal.ZERO); funding.setTotalfedNonfedrequested(BigDecimal.ZERO); funding.setEstimatedProgramIncome(BigDecimal.ZERO); boolean hasBudgetLineItem = false; if (budget != null) { ScaleTwoDecimal totalCost = ScaleTwoDecimal.ZERO; if (budget.getModularBudgetFlag()) { ScaleTwoDecimal fundsRequested = ScaleTwoDecimal.ZERO; ScaleTwoDecimal totalDirectCost = ScaleTwoDecimal.ZERO; // get modular budget amounts instead of budget detail amounts for (BudgetPeriodContract budgetPeriod : budget.getBudgetPeriods()) { totalDirectCost = totalDirectCost.add(budgetPeriod.getBudgetModular().getTotalDirectCost()); for (BudgetModularIdcContract budgetModularIdc : budgetPeriod.getBudgetModular() .getBudgetModularIdcs()) { fundsRequested = fundsRequested.add(budgetModularIdc.getFundsRequested()); } } totalCost = totalCost.add(totalDirectCost); totalCost = totalCost.add(fundsRequested); } else { totalCost = budget.getTotalCost(); } ScaleTwoDecimal fedNonFedCost = totalCost; BigDecimal totalProjectIncome = BigDecimal.ZERO; ScaleTwoDecimal costSharingAmount = ScaleTwoDecimal.ZERO; for (BudgetPeriodContract budgetPeriod : budget.getBudgetPeriods()) { for (BudgetLineItemContract lineItem : budgetPeriod.getBudgetLineItems()) { hasBudgetLineItem = true; if (budget.getSubmitCostSharingFlag() && lineItem.getSubmitCostSharingFlag()) { costSharingAmount = costSharingAmount.add(lineItem.getCostSharingAmount()); List<? extends BudgetLineItemCalculatedAmountContract> calculatedAmounts = lineItem .getBudgetLineItemCalculatedAmounts(); for (BudgetLineItemCalculatedAmountContract budgetLineItemCalculatedAmount : calculatedAmounts) { costSharingAmount = costSharingAmount .add(budgetLineItemCalculatedAmount.getCalculatedCostSharing()); } } } } if (!hasBudgetLineItem && budget.getSubmitCostSharingFlag()) { costSharingAmount = budget.getCostSharingAmount(); } fedNonFedCost = fedNonFedCost.add(costSharingAmount); for (BudgetProjectIncomeContract budgetProjectIncome : budget.getBudgetProjectIncomes()) { totalProjectIncome = totalProjectIncome .add(budgetProjectIncome.getProjectIncome().bigDecimalValue()); } funding = EstimatedProjectFunding.Factory.newInstance(); funding.setTotalEstimatedAmount(totalCost.bigDecimalValue()); funding.setTotalfedNonfedrequested(fedNonFedCost.bigDecimalValue()); funding.setEstimatedProgramIncome(totalProjectIncome); } return funding; }
From source file:com.roncoo.pay.account.service.impl.RpAccountTransactionServiceImpl.java
/** * ? ?+?/*from w w w . j av a2s.c o m*/ * * @param userNo * ? * @param amount * ?? * @param requestNo * ?? * @param trxType * * @param remark * */ @Transactional(rollbackFor = Exception.class) public RpAccount unFreezeAmount(String userNo, BigDecimal amount, String requestNo, String trxType, String remark) { 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); account.setTodayExpend(amount); } else { account.setTodayExpend(account.getTodayExpend().add(amount)); } account.setTotalExpend(account.getTodayExpend().add(amount)); // ?? if (account.getUnbalance().subtract(amount).compareTo(BigDecimal.ZERO) == -1) { // ?? throw AccountBizException.ACCOUNT_UN_FROZEN_AMOUNT_OUTLIMIT; } account.setEditTime(new Date()); account.setBalance(account.getBalance().subtract(amount));// ? account.setUnbalance(account.getUnbalance().subtract(amount));// account.setSettAmount(account.getSettAmount().subtract(amount));// ??? String isAllowSett = PublicEnum.NO.name(); String completeSett = PublicEnum.NO.name(); // ? RpAccountHistory accountHistoryEntity = new RpAccountHistory(); accountHistoryEntity.setCreateTime(new Date()); accountHistoryEntity.setEditTime(new Date()); accountHistoryEntity.setIsAllowSett(isAllowSett); accountHistoryEntity.setAmount(amount); accountHistoryEntity.setBalance(account.getBalance()); accountHistoryEntity.setRequestNo(requestNo); accountHistoryEntity.setIsCompleteSett(completeSett); accountHistoryEntity.setRemark(remark); accountHistoryEntity.setFundDirection(AccountFundDirectionEnum.SUB.name()); accountHistoryEntity.setAccountNo(account.getAccountNo()); accountHistoryEntity.setTrxType(trxType); accountHistoryEntity.setUserNo(userNo); this.rpAccountHistoryDao.insert(accountHistoryEntity); this.rpAccountDao.update(account); return account; }
From source file:fragment.web.BillingControllerTest.java
@Test @SuppressWarnings("unchecked") public void usageTest() throws ConnectorManagementServiceException { Tenant tenant = createTestTenant(accountTypeDAO.getDefaultRegistrationAccountType()); User user = createTestUserInTenant(tenant); tenantService.setOwner(tenant, user); asUser(tenant.getOwner());/*w ww. j a v a 2s . c om*/ String view = controller.usageBilling(tenant, null, null, "1", null, null, map, request); Assert.assertEquals("billing.usageBilling", view); Assert.assertEquals(true, map.containsAttribute("userHasCloudServiceAccount")); Assert.assertEquals(false, map.containsAttribute("showUserProfile")); Assert.assertEquals(true, map.containsAttribute("accountStatements")); Assert.assertEquals(true, map.containsAttribute("accountStatementUuid")); Assert.assertEquals(true, map.containsAttribute("accountStatementState")); Assert.assertEquals(true, map.containsAttribute("payments")); Assert.assertEquals(true, map.containsAttribute("creditsIssued")); Assert.assertEquals(true, map.containsAttribute("bigPaymentsSum")); Assert.assertEquals(map.get("isSystemProviderUser"), new String("N")); Assert.assertEquals(map.get("userHasCloudServiceAccount"), Boolean.valueOf(false)); List<AccountStatement> accountStatements = (List<AccountStatement>) map.get("accountStatements"); Assert.assertEquals(accountStatements.size(), Integer.parseInt("1")); Assert.assertEquals(map.get("accountStatementUuid"), accountStatements.get(0).getUuid()); Assert.assertEquals(map.get("accountStatementState"), accountStatements.get(0).getState().name()); Assert.assertEquals(map.get("newBigAmount"), BigDecimal.ZERO); List<InvoiceItem> items = new ArrayList<InvoiceItem>(); InvoiceItem invoiceItem = new InvoiceItem(); invoiceItem.setDescription("Testing"); items.add(invoiceItem); }
From source file:org.openhab.binding.daikin.internal.DaikinBinding.java
private BigDecimal parseDecimal(String value) { if (value.equals("NONE")) return BigDecimal.ZERO; try {// ww w.j a v a2 s . com return new BigDecimal(numberFormat.parse(value).doubleValue()); } catch (java.text.ParseException e) { logger.error("Failed to parse number: {}", value); return BigDecimal.ZERO; } }
From source file:net.shopxx.dao.impl.OrderDaoImpl.java
public Page<Order> findPage(Order.Type type, Order.Status status, Member member, Goods goods, Boolean isPendingReceive, Boolean isPendingRefunds, Boolean isUseCouponCode, Boolean isExchangePoint, Boolean isAllocatedStock, Boolean hasExpired, Pageable pageable) { CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<Order> criteriaQuery = criteriaBuilder.createQuery(Order.class); Root<Order> root = criteriaQuery.from(Order.class); criteriaQuery.select(root);//from ww w . ja va2s .c o m Predicate restrictions = criteriaBuilder.conjunction(); if (type != null) { restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(root.get("type"), type)); } if (status != null) { restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(root.get("status"), status)); } if (member != null) { restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(root.get("member"), member)); } if (goods != null) { Subquery<Product> productSubquery = criteriaQuery.subquery(Product.class); Root<Product> productSubqueryRoot = productSubquery.from(Product.class); productSubquery.select(productSubqueryRoot); productSubquery.where(criteriaBuilder.equal(productSubqueryRoot.get("goods"), goods)); Subquery<OrderItem> orderItemSubquery = criteriaQuery.subquery(OrderItem.class); Root<OrderItem> orderItemSubqueryRoot = orderItemSubquery.from(OrderItem.class); orderItemSubquery.select(orderItemSubqueryRoot); orderItemSubquery.where(criteriaBuilder.equal(orderItemSubqueryRoot.get("order"), root), criteriaBuilder.in(orderItemSubqueryRoot.get("product")).value(productSubquery)); restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.exists(orderItemSubquery)); } if (isPendingReceive != null) { Predicate predicate = criteriaBuilder.and( criteriaBuilder.or(root.get("expire").isNull(), criteriaBuilder.greaterThan(root.<Date>get("expire"), new Date())), criteriaBuilder.equal(root.get("paymentMethodType"), PaymentMethod.Type.cashOnDelivery), criteriaBuilder.notEqual(root.get("status"), Order.Status.completed), criteriaBuilder.notEqual(root.get("status"), Order.Status.failed), criteriaBuilder.notEqual(root.get("status"), Order.Status.canceled), criteriaBuilder.notEqual(root.get("status"), Order.Status.denied), criteriaBuilder.lessThan(root.<BigDecimal>get("amountPaid"), root.<BigDecimal>get("amount"))); if (isPendingReceive) { restrictions = criteriaBuilder.and(restrictions, predicate); } else { restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.not(predicate)); } } if (isPendingRefunds != null) { Predicate predicate = criteriaBuilder.or( criteriaBuilder.and( criteriaBuilder.or( criteriaBuilder.and(root.get("expire").isNotNull(), criteriaBuilder.lessThanOrEqualTo(root.<Date>get("expire"), new Date())), criteriaBuilder.equal(root.get("status"), Order.Status.failed), criteriaBuilder.equal(root.get("status"), Order.Status.canceled), criteriaBuilder.equal(root.get("status"), Order.Status.denied)), criteriaBuilder.greaterThan(root.<BigDecimal>get("amountPaid"), BigDecimal.ZERO)), criteriaBuilder.and(criteriaBuilder.equal(root.get("status"), Order.Status.completed), criteriaBuilder.greaterThan(root.<BigDecimal>get("amountPaid"), root.<BigDecimal>get("amount")))); if (isPendingRefunds) { restrictions = criteriaBuilder.and(restrictions, predicate); } else { restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.not(predicate)); } } if (isUseCouponCode != null) { restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(root.get("isUseCouponCode"), isUseCouponCode)); } if (isExchangePoint != null) { restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(root.get("isExchangePoint"), isExchangePoint)); } if (isAllocatedStock != null) { restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(root.get("isAllocatedStock"), isAllocatedStock)); } if (hasExpired != null) { if (hasExpired) { restrictions = criteriaBuilder.and(restrictions, root.get("expire").isNotNull(), criteriaBuilder.lessThanOrEqualTo(root.<Date>get("expire"), new Date())); } else { restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.or(root.get("expire").isNull(), criteriaBuilder.greaterThan(root.<Date>get("expire"), new Date()))); } } criteriaQuery.where(restrictions); return super.findPage(criteriaQuery, pageable); }
From source file:org.kuali.coeus.s2sgen.impl.generate.support.RRSF424V1_0Generator.java
/** * * This method is to get estimated project funds for RRSF424 * * @return EstimatedProjectFunding estimated total cost for the project. *//*from w w w . j a va2 s. co m*/ private EstimatedProjectFunding getProjectFunding() throws S2SException { ProposalDevelopmentBudgetExtContract budget = s2SCommonBudgetService .getBudget(pdDoc.getDevelopmentProposal()); EstimatedProjectFunding funding = EstimatedProjectFunding.Factory.newInstance(); funding.setTotalEstimatedAmount(BigDecimal.ZERO); funding.setTotalfedNonfedrequested(BigDecimal.ZERO); funding.setEstimatedProgramIncome(BigDecimal.ZERO); ScaleTwoDecimal totalCost = ScaleTwoDecimal.ZERO; if (budget != null) { if (budget.getModularBudgetFlag()) { ScaleTwoDecimal fundsRequested = ScaleTwoDecimal.ZERO; ScaleTwoDecimal totalDirectCost = ScaleTwoDecimal.ZERO; // get modular budget amounts instead of budget detail amounts for (BudgetPeriodContract budgetPeriod : budget.getBudgetPeriods()) { totalDirectCost = totalDirectCost.add(budgetPeriod.getBudgetModular().getTotalDirectCost()); for (BudgetModularIdcContract budgetModularIdc : budgetPeriod.getBudgetModular() .getBudgetModularIdcs()) { fundsRequested = fundsRequested.add(budgetModularIdc.getFundsRequested()); } } totalCost = totalCost.add(totalDirectCost); totalCost = totalCost.add(fundsRequested); } else { totalCost = budget.getTotalCost(); } ScaleTwoDecimal fedNonFedCost = ScaleTwoDecimal.ZERO; fedNonFedCost = fedNonFedCost.add(totalCost); fedNonFedCost = fedNonFedCost.add(budget.getCostSharingAmount()); BigDecimal totalProjectIncome = BigDecimal.ZERO; for (BudgetProjectIncomeContract budgetProjectIncome : budget.getBudgetProjectIncomes()) { if (budgetProjectIncome.getProjectIncome() != null) { totalProjectIncome = totalProjectIncome .add(budgetProjectIncome.getProjectIncome().bigDecimalValue()); } } funding.setTotalEstimatedAmount(totalCost.bigDecimalValue()); funding.setTotalfedNonfedrequested(fedNonFedCost.bigDecimalValue()); funding.setEstimatedProgramIncome(totalProjectIncome); } return funding; }
From source file:org.openvpms.archetype.rules.stock.ChargeStockUpdaterTestCase.java
/** * Verifies that stock is updated when a charge is removed. * * @param acts the charge act and item/*from w ww . j ava2 s .c o m*/ */ private void checkChargeRemoval(List<FinancialAct> acts) { BigDecimal quantity = new BigDecimal(10); FinancialAct act = acts.get(0); FinancialAct item = acts.get(1); item.setQuantity(quantity); save(acts); BigDecimal expected = getQuantity(BigDecimal.ZERO, quantity, act.isCredit()); checkEquals(expected, getStock(stockLocation, product)); // now remove the charge remove(act); checkEquals(BigDecimal.ZERO, getStock(stockLocation, product)); }