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.yes.cart.web.support.service.impl.ProductServiceFacadeImplTest.java
@Test public void testGetSkuPriceSearchAndProductDetailsEmptyPriceWithTaxInfoNet() throws Exception { final PriceService priceService = context.mock(PriceService.class, "priceService"); final PricingPolicyProvider pricingPolicyProvider = context.mock(PricingPolicyProvider.class, "pricingPolicyProvider"); final ShopService shopService = context.mock(ShopService.class, "shopService"); final ShoppingCart cart = context.mock(ShoppingCart.class, "cart"); final ShoppingContext cartCtx = context.mock(ShoppingContext.class, "cartCtx"); final PricingPolicyProvider.PricingPolicy policy = context.mock(PricingPolicyProvider.PricingPolicy.class, "policy"); final SkuPrice skuPrice = context.mock(SkuPrice.class, "skuPrice"); final Shop shop = context.mock(Shop.class, "shop"); context.checking(new Expectations() { {// w ww . j ava2s .co m allowing(cart).getShoppingContext(); will(returnValue(cartCtx)); allowing(cartCtx).getShopId(); will(returnValue(234L)); allowing(cartCtx).getCustomerShopId(); will(returnValue(234L)); allowing(cartCtx).getShopCode(); will(returnValue("SHOP10")); allowing(cartCtx).getCountryCode(); will(returnValue("GB")); allowing(cartCtx).getStateCode(); will(returnValue("GB-LON")); allowing(cart).getCustomerEmail(); will(returnValue("bob@doe.com")); allowing(cart).getCurrencyCode(); will(returnValue("EUR")); allowing(pricingPolicyProvider).determinePricingPolicy("SHOP10", "EUR", "bob@doe.com", "GB", "GB-LON"); will(returnValue(policy)); allowing(policy).getID(); will(returnValue("P1")); allowing(priceService).getMinimalPrice(123L, "ABC", 234L, null, "EUR", BigDecimal.ONE, false, "P1"); will(returnValue(skuPrice)); allowing(skuPrice).getSkuCode(); will(returnValue(null)); allowing(skuPrice).getQuantity(); will(returnValue(null)); allowing(skuPrice).getRegularPrice(); will(returnValue(null)); allowing(skuPrice).getSalePriceForCalculation(); will(returnValue(null)); allowing(shopService).getById(234L); will(returnValue(shop)); allowing(cartCtx).isTaxInfoEnabled(); will(returnValue(true)); allowing(cartCtx).isTaxInfoUseNet(); will(returnValue(true)); allowing(cartCtx).isTaxInfoShowAmount(); will(returnValue(true)); } }); final ProductServiceFacade facade = new ProductServiceFacadeImpl(null, null, null, null, null, null, pricingPolicyProvider, priceService, null, null, null, shopService, null); final ProductPriceModel model = facade.getSkuPrice(cart, 123L, "ABC", BigDecimal.ONE); assertNotNull(model); assertNull(model.getRef()); assertEquals("EUR", model.getCurrency()); assertNull(model.getQuantity()); assertNull(model.getRegularPrice()); assertNull(model.getSalePrice()); assertFalse(model.isTaxInfoEnabled()); assertFalse(model.isTaxInfoUseNet()); assertFalse(model.isTaxInfoShowAmount()); assertNull(model.getPriceTaxCode()); assertNull(model.getPriceTaxRate()); assertFalse(model.isPriceTaxExclusive()); assertNull(model.getPriceTax()); context.assertIsSatisfied(); }
From source file:org.openvpms.web.workspace.workflow.checkin.CheckInWorkflowTestCase.java
/** * Verify that the workflow cancels if document selection is cancelled via the cancel button. * * @param userClose if <tt>true</tt> cancel the selection by the 'user close' button otherwise via the cancel button *//*from ww w. j a v a 2 s.c om*/ private void checkCancelSelectDialog(boolean userClose) { Act appointment = createAppointment(customer, patient, clinician); CheckInWorkflowRunner workflow = new CheckInWorkflowRunner(appointment, getPractice(), context); runCheckInToWeight(workflow); workflow.addWeight(patient, BigDecimal.ONE, clinician); BrowserDialog<Entity> dialog = workflow.getPrintDocumentsDialog(); WorkflowTestHelper.cancelDialog(dialog, userClose); workflow.checkComplete(false, null, null, context); }
From source file:org.finra.dm.service.helper.DmHelperTest.java
/** * Tests case where validation is run against the definition generated by createValidEmrClusterDefinition() The master instance max search price is * specified The definition should be valid because max search price is allowed when no instance spot price is specified. *//*from www .ja v a 2 s . c om*/ @Test public void testValidateEmrClusterDefinitionConfigurationMasterMaxSearchPriceSpecified() { EmrClusterDefinition emrClusterDefinition = createValidEmrClusterDefinition(); emrClusterDefinition.getInstanceDefinitions().getMasterInstances() .setInstanceMaxSearchPrice(BigDecimal.ONE); try { dmHelper.validateEmrClusterDefinitionConfiguration(emrClusterDefinition); } catch (Exception e) { fail("expected no exception, but " + e.getClass() + " was thrown. " + e); } }
From source file:org.nd4j.linalg.util.BigDecimalMath.java
/** * The natural logarithm./* ww w . j a v a 2s.c om*/ * * @param x the argument. * @return ln(x). * The precision of the result is implicitly defined by the precision in the argument. */ static public BigDecimal log(BigDecimal x) { /* the value is undefined if x is negative. */ if (x.compareTo(BigDecimal.ZERO) < 0) { throw new ArithmeticException("Cannot take log of negative " + x.toString()); } else if (x.compareTo(BigDecimal.ONE) == 0) { /* log 1. = 0. */ return scalePrec(BigDecimal.ZERO, x.precision() - 1); } else if (Math.abs(x.doubleValue() - 1.0) <= 0.3) { /* The standard Taylor series around x=1, z=0, z=x-1. Abramowitz-Stegun 4.124. * The absolute error is err(z)/(1+z) = err(x)/x. */ BigDecimal z = scalePrec(x.subtract(BigDecimal.ONE), 2); BigDecimal zpown = z; double eps = 0.5 * x.ulp().doubleValue() / Math.abs(x.doubleValue()); BigDecimal resul = z; for (int k = 2;; k++) { zpown = multiplyRound(zpown, z); BigDecimal c = divideRound(zpown, k); if (k % 2 == 0) { resul = resul.subtract(c); } else { resul = resul.add(c); } if (Math.abs(c.doubleValue()) < eps) { break; } } MathContext mc = new MathContext(err2prec(resul.doubleValue(), eps)); return resul.round(mc); } else { final double xDbl = x.doubleValue(); final double xUlpDbl = x.ulp().doubleValue(); /* Map log(x) = log root[r](x)^r = r*log( root[r](x)) with the aim * to move roor[r](x) near to 1.2 (that is, below the 0.3 appearing above), where log(1.2) is roughly 0.2. */ int r = (int) (Math.log(xDbl) / 0.2); /* Since the actual requirement is a function of the value 0.3 appearing above, * we avoid the hypothetical case of endless recurrence by ensuring that r >= 2. */ r = Math.max(2, r); /* Compute r-th root with 2 additional digits of precision */ BigDecimal xhighpr = scalePrec(x, 2); BigDecimal resul = root(r, xhighpr); resul = log(resul).multiply(new BigDecimal(r)); /* error propagation: log(x+errx) = log(x)+errx/x, so the absolute error * in the result equals the relative error in the input, xUlpDbl/xDbl . */ MathContext mc = new MathContext(err2prec(resul.doubleValue(), xUlpDbl / xDbl)); return resul.round(mc); } }
From source file:org.yes.cart.payment.impl.PaymentProcessorSurrogate.java
private void fillPaymentShipment(final CustomerOrder order, final CustomerOrderDelivery delivery, final Payment payment) { payment.getOrderItems().add(new PaymentLineImpl( delivery.getCarrierSla() == null ? "N/A" : String.valueOf(delivery.getCarrierSla().getCarrierslaId()), delivery.getCarrierSla() == null ? "No SLA" : new FailoverStringI18NModel(delivery.getCarrierSla().getDisplayName(), delivery.getCarrierSla().getName()).getValue(order.getLocale()), BigDecimal.ONE, delivery.getGrossPrice(), delivery.getGrossPrice().subtract(delivery.getNetPrice()), true));/* w w w . j a va 2s.c o m*/ }
From source file:net.sourceforge.fenixedu.presentationTier.Action.directiveCouncil.SummariesControlAction.java
private BigDecimal getSummariesGiven(Professorship professorship, Shift shift, BigDecimal summariesGiven, LocalDate oneWeekBeforeToday) { for (Summary summary : shift.getAssociatedSummariesSet()) { if (summary.getProfessorship() != null && summary.getProfessorship() == professorship && !summary.getIsExtraLesson() && !summary.getLessonInstance().getBeginDateTime().toLocalDate().isAfter(oneWeekBeforeToday)) { summariesGiven = summariesGiven.add(BigDecimal.ONE); }/*from w ww. jav a 2s . co m*/ } return summariesGiven; }
From source file:org.finra.herd.service.helper.HerdHelperTest.java
/** * Tests case where validation is run against the definition generated by createValidEmrClusterDefinition() The master instance max search price and * on-demand threshold is specified The definition should be valid because on-demand threshold can be used with max search price. *//*from w ww . ja v a 2s . c o m*/ @Test public void testValidateEmrClusterDefinitionConfigurationMasterMaxSearchPriceAndOnDemandThresholdSpecified() { EmrClusterDefinition emrClusterDefinition = createValidEmrClusterDefinition(); emrClusterDefinition.getInstanceDefinitions().getMasterInstances() .setInstanceMaxSearchPrice(BigDecimal.ONE); emrClusterDefinition.getInstanceDefinitions().getMasterInstances() .setInstanceOnDemandThreshold(BigDecimal.ONE); try { herdHelper.validateEmrClusterDefinitionConfiguration(emrClusterDefinition); } catch (Exception e) { fail("expected no exception, but " + e.getClass() + " was thrown. " + e); } }
From source file:org.apache.calcite.test.MaterializationTest.java
/** Unit test for logic functions * {@link org.apache.calcite.plan.SubstitutionVisitor#mayBeSatisfiable} and * {@link RexUtil#simplify}. *//*from ww w. j a v a2s . c o m*/ @Test public void testSatisfiable() { // TRUE may be satisfiable checkSatisfiable(rexBuilder.makeLiteral(true), "true"); // FALSE is not satisfiable checkNotSatisfiable(rexBuilder.makeLiteral(false)); // The expression "$0 = 1". final RexNode i0_eq_0 = rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, rexBuilder.makeInputRef(typeFactory.createType(int.class), 0), rexBuilder.makeExactLiteral(BigDecimal.ZERO)); // "$0 = 1" may be satisfiable checkSatisfiable(i0_eq_0, "=($0, 0)"); // "$0 = 1 AND TRUE" may be satisfiable final RexNode e0 = rexBuilder.makeCall(SqlStdOperatorTable.AND, i0_eq_0, rexBuilder.makeLiteral(true)); checkSatisfiable(e0, "=($0, 0)"); // "$0 = 1 AND FALSE" is not satisfiable final RexNode e1 = rexBuilder.makeCall(SqlStdOperatorTable.AND, i0_eq_0, rexBuilder.makeLiteral(false)); checkNotSatisfiable(e1); // "$0 = 0 AND NOT $0 = 0" is not satisfiable final RexNode e2 = rexBuilder.makeCall(SqlStdOperatorTable.AND, i0_eq_0, rexBuilder.makeCall(SqlStdOperatorTable.NOT, i0_eq_0)); checkNotSatisfiable(e2); // "TRUE AND NOT $0 = 0" may be satisfiable. Can simplify. final RexNode e3 = rexBuilder.makeCall(SqlStdOperatorTable.AND, rexBuilder.makeLiteral(true), rexBuilder.makeCall(SqlStdOperatorTable.NOT, i0_eq_0)); checkSatisfiable(e3, "NOT(=($0, 0))"); // The expression "$1 = 1". final RexNode i1_eq_1 = rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, rexBuilder.makeInputRef(typeFactory.createType(int.class), 1), rexBuilder.makeExactLiteral(BigDecimal.ONE)); // "$0 = 0 AND $1 = 1 AND NOT $0 = 0" is not satisfiable final RexNode e4 = rexBuilder.makeCall(SqlStdOperatorTable.AND, i0_eq_0, rexBuilder .makeCall(SqlStdOperatorTable.AND, i1_eq_1, rexBuilder.makeCall(SqlStdOperatorTable.NOT, i0_eq_0))); checkNotSatisfiable(e4); // "$0 = 0 AND NOT $1 = 1" may be satisfiable. Can't simplify. final RexNode e5 = rexBuilder.makeCall(SqlStdOperatorTable.AND, i0_eq_0, rexBuilder.makeCall(SqlStdOperatorTable.NOT, i1_eq_1)); checkSatisfiable(e5, "AND(=($0, 0), NOT(=($1, 1)))"); // "$0 = 0 AND NOT ($0 = 0 AND $1 = 1)" may be satisfiable. Can simplify. final RexNode e6 = rexBuilder.makeCall(SqlStdOperatorTable.AND, i0_eq_0, rexBuilder .makeCall(SqlStdOperatorTable.NOT, rexBuilder.makeCall(SqlStdOperatorTable.AND, i0_eq_0, i1_eq_1))); checkSatisfiable(e6, "AND(=($0, 0), NOT(AND(=($0, 0), =($1, 1))))"); // "$0 = 0 AND ($1 = 1 AND NOT ($0 = 0))" is not satisfiable. final RexNode e7 = rexBuilder.makeCall(SqlStdOperatorTable.AND, i0_eq_0, rexBuilder .makeCall(SqlStdOperatorTable.AND, i1_eq_1, rexBuilder.makeCall(SqlStdOperatorTable.NOT, i0_eq_0))); checkNotSatisfiable(e7); // The expression "$2". final RexInputRef i2 = rexBuilder.makeInputRef(typeFactory.createType(boolean.class), 2); // The expression "$3". final RexInputRef i3 = rexBuilder.makeInputRef(typeFactory.createType(boolean.class), 3); // The expression "$4". final RexInputRef i4 = rexBuilder.makeInputRef(typeFactory.createType(boolean.class), 4); // "$0 = 0 AND $2 AND $3 AND NOT ($2 AND $3 AND $4) AND NOT ($2 AND $4)" may // be satisfiable. Can't simplify. final RexNode e8 = rexBuilder.makeCall(SqlStdOperatorTable.AND, i0_eq_0, rexBuilder.makeCall(SqlStdOperatorTable.AND, i2, rexBuilder.makeCall(SqlStdOperatorTable.AND, i3, rexBuilder.makeCall(SqlStdOperatorTable.NOT, rexBuilder.makeCall(SqlStdOperatorTable.AND, i2, i3, i4)), rexBuilder.makeCall(SqlStdOperatorTable.NOT, i4)))); checkSatisfiable(e8, "AND(=($0, 0), $2, $3, NOT(AND($2, $3, $4)), NOT($4))"); }
From source file:org.egov.dao.budget.BudgetDetailsHibernateDAO.java
private BigDecimal getDetails(final Map<String, Object> detailsMap) { Long financialyearid = null;/*from w w w.jav a 2s .c om*/ Integer moduleid = null; String referencenumber = null; Integer departmentid = null; Long functionid = null; Integer functionaryid = null; Integer schemeid = null; Integer subschemeid = null; Integer boundaryid = null; List<Long> budgetheadid = null; Integer fundid = null; double amount = 0.0d; String appropriationnumber = null; Boolean consumeOrRelease = null; if (detailsMap.containsKey(Constants.FINANCIALYEARID)) financialyearid = (Long) detailsMap.get(Constants.FINANCIALYEARID); if (detailsMap.containsKey(Constants.MODULEID)) moduleid = (Integer) detailsMap.get(Constants.MODULEID); if (detailsMap.containsKey(Constants.REFERENCENUMBER)) referencenumber = (String) detailsMap.get(Constants.REFERENCENUMBER); if (detailsMap.containsKey(Constants.DEPARTMENTID)) departmentid = (Integer) detailsMap.get(Constants.DEPARTMENTID); if (detailsMap.containsKey(Constants.FUNCTIONID)) functionid = (Long) detailsMap.get(Constants.FUNCTIONID); if (detailsMap.containsKey(Constants.FUNCTIONARYID)) functionaryid = (Integer) detailsMap.get(Constants.FUNCTIONARYID); if (detailsMap.containsKey(Constants.SCHEMEID)) schemeid = (Integer) detailsMap.get(Constants.SCHEMEID); if (detailsMap.containsKey(Constants.SUBSCHEMEID)) subschemeid = (Integer) detailsMap.get(Constants.SUBSCHEMEID); if (detailsMap.containsKey(Constants.BOUNDARYID)) boundaryid = (Integer) detailsMap.get(Constants.BOUNDARYID); if (detailsMap.containsKey(Constants.BUDGETHEAD)) budgetheadid = (List<Long>) detailsMap.get(Constants.BUDGETHEAD); if (detailsMap.containsKey(Constants.FUNDID)) fundid = (Integer) detailsMap.get(Constants.FUNDID); if (detailsMap.containsKey(Constants.AMOUNT)) amount = (Double) detailsMap.get(Constants.AMOUNT); if (detailsMap.containsKey(Constants.APPROPRIATIONNUMBER)) appropriationnumber = (String) detailsMap.get(Constants.APPROPRIATIONNUMBER); if (detailsMap.containsKey(Constants.CONSUMEORRELEASE)) consumeOrRelease = (Boolean) detailsMap.get(Constants.CONSUMEORRELEASE); try { if (LOGGER.isDebugEnabled()) LOGGER.debug("financialyearid==" + financialyearid + ",moduleid==" + moduleid + ",referencenumber==" + referencenumber + ",departmentid==" + departmentid + ",functionid==" + functionid + ",functionaryid==" + functionaryid + ",schemeid==" + schemeid + ",subschemeid==" + subschemeid + ",boundaryid==" + boundaryid + ",budgetheadid==" + budgetheadid + ",amount==" + amount); validateMandatoryParameters(moduleid, referencenumber); BigDecimal amtavailable = getPlanningBudgetAvailable(financialyearid, departmentid, functionid, functionaryid, schemeid, subschemeid, boundaryid, budgetheadid, fundid); if (consumeOrRelease) amtavailable = amtavailable.subtract(BigDecimal.valueOf(amount)); else amtavailable = amtavailable.add(BigDecimal.valueOf(amount)); if (LOGGER.isDebugEnabled()) LOGGER.debug("budget available after consuming/releasing=" + amtavailable); if (amtavailable != null && amtavailable.compareTo(BigDecimal.ZERO) >= 0) { // need to update budget details final String query = prepareQuery(departmentid, functionid, functionaryid, schemeid, subschemeid, boundaryid, fundid); final Query q = getCurrentSession().createQuery( " from BudgetDetail bd where bd.budget.financialYear.id=:finYearId and bd.budget.isbere=:type and bd.budgetGroup.id in (:bgId)" + query); if (budgetService.hasApprovedReForYear(financialyearid)) q.setParameter("type", "RE"); else q.setParameter("type", "BE"); q.setParameter("finYearId", financialyearid); q.setParameterList("bgId", budgetheadid); final List<BudgetDetail> bdList = q.list(); if (bdList == null || bdList.size() == 0) { if (LOGGER.isDebugEnabled()) LOGGER.debug( "IN consumeEncumbranceBudget()-getDetail() - No budget detail item defined for RE or BE for this combination!!"); if (LOGGER.isDebugEnabled()) LOGGER.debug("financial year id - " + financialyearid.toString() + " Budget Group - " + budgetheadid.toString() + " Query - " + query); throw new ValidationException(EMPTY_STRING, "Budgetary Check Failed"); } final BudgetDetail bd = bdList.get(0); bd.setBudgetAvailable(amtavailable); update(bd); final BudgetUsage budgetUsage = new BudgetUsage(); budgetUsage.setFinancialYearId(financialyearid.intValue()); budgetUsage.setModuleId(moduleid); budgetUsage.setReferenceNumber(referencenumber); budgetUsage.setBudgetDetail(bd); budgetUsage.setAppropriationnumber(appropriationnumber); if (consumeOrRelease) { budgetUsage.setConsumedAmount(amount); budgetUsage.setReleasedAmount(0.0); } else { budgetUsage.setConsumedAmount(0.0); budgetUsage.setReleasedAmount(amount); } budgetUsage.setCreatedby(ApplicationThreadLocals.getUserId().intValue()); budgetUsageService.create(budgetUsage); return BigDecimal.ONE; } else return BigDecimal.ZERO; } catch (final ValidationException v) { LOGGER.error("Exp in consumeEncumbranceBudget API()===" + v.getErrors()); throw new ValidationException(v.getErrors()); } catch (final Exception e) { LOGGER.error("Exception in consumeEncumbranceBudget API()=" + e.getMessage()); throw new ValidationException(EMPTY_STRING, e.getMessage()); } }
From source file:org.ofbiz.order.shoppingcart.CheckOutHelper.java
public Map<String, Object> checkGiftCard(Map<String, Object> params, Map<String, Map<String, Object>> selectedPaymentMethods) { List<String> errorMessages = new ArrayList<String>(); Map<String, Object> errorMaps = new HashMap<String, Object>(); Map<String, Object> result = new HashMap<String, Object>(); String errMsg = null;/* w w w .ja v a2 s . c o m*/ // handle gift card payment // SCIPIO: This is too sensitive. Make a check for "Y" instead. //if (params.get("addGiftCard") != null) { if ("Y".equals(params.get("addGiftCard"))) { String gcNum = (String) params.get("giftCardNumber"); String gcPin = (String) params.get("giftCardPin"); String gcAmt = (String) params.get("giftCardAmount"); BigDecimal gcAmount = BigDecimal.ONE.negate(); boolean gcFieldsOkay = true; if (UtilValidate.isEmpty(gcNum)) { errMsg = UtilProperties.getMessage(resource_error, "checkhelper.enter_gift_card_number", (cart != null ? cart.getLocale() : Locale.getDefault())); errorMessages.add(errMsg); gcFieldsOkay = false; } if (cart.isPinRequiredForGC(delegator)) { // if a PIN is required, make sure the PIN is valid if (UtilValidate.isEmpty(gcPin)) { errMsg = UtilProperties.getMessage(resource_error, "checkhelper.enter_gift_card_pin_number", (cart != null ? cart.getLocale() : Locale.getDefault())); errorMessages.add(errMsg); gcFieldsOkay = false; } } // See if we should validate gift card code against FinAccount's accountCode if (cart.isValidateGCFinAccount(delegator)) { try { // No PIN required - validate gift card number against account code if (!cart.isPinRequiredForGC(delegator)) { GenericValue finAccount = FinAccountHelper.getFinAccountFromCode(gcNum, delegator); if (finAccount == null) { errMsg = UtilProperties.getMessage(resource_error, "checkhelper.gift_card_does_not_exist", (cart != null ? cart.getLocale() : Locale.getDefault())); errorMessages.add(errMsg); gcFieldsOkay = false; } else if ((finAccount.getBigDecimal("availableBalance") == null) || !((finAccount.getBigDecimal("availableBalance")) .compareTo(FinAccountHelper.ZERO) > 0)) { // if account's available balance (including authorizations) is not greater than zero, then return an error errMsg = UtilProperties.getMessage(resource_error, "checkhelper.gift_card_has_no_value", (cart != null ? cart.getLocale() : Locale.getDefault())); errorMessages.add(errMsg); gcFieldsOkay = false; } } // TODO: else case when pin is required - we should validate gcNum and gcPin } catch (GenericEntityException ex) { errorMessages.add(ex.getMessage()); gcFieldsOkay = false; } } if (UtilValidate.isNotEmpty(selectedPaymentMethods)) { if (UtilValidate.isEmpty(gcAmt)) { errMsg = UtilProperties.getMessage(resource_error, "checkhelper.enter_amount_to_place_on_gift_card", (cart != null ? cart.getLocale() : Locale.getDefault())); errorMessages.add(errMsg); gcFieldsOkay = false; } } if (UtilValidate.isNotEmpty(gcAmt)) { try { gcAmount = new BigDecimal(gcAmt); } catch (NumberFormatException e) { Debug.logError(e, module); errMsg = UtilProperties.getMessage(resource_error, "checkhelper.invalid_amount_for_gift_card", (cart != null ? cart.getLocale() : Locale.getDefault())); errorMessages.add(errMsg); gcFieldsOkay = false; } } if (gcFieldsOkay) { // store the gift card Map<String, Object> gcCtx = new HashMap<String, Object>(); gcCtx.put("partyId", params.get("partyId")); gcCtx.put("cardNumber", gcNum); if (cart.isPinRequiredForGC(delegator)) { gcCtx.put("pinNumber", gcPin); } gcCtx.put("userLogin", cart.getUserLogin()); Map<String, Object> gcResult = null; try { gcResult = dispatcher.runSync("createGiftCard", gcCtx); } catch (GenericServiceException e) { Debug.logError(e, module); errorMessages.add(e.getMessage()); } if (gcResult != null) { ServiceUtil.addErrors(errorMessages, errorMaps, gcResult); if (errorMessages.size() == 0 && errorMaps.size() == 0) { // set the GC payment method BigDecimal giftCardAmount = null; if (gcAmount.compareTo(BigDecimal.ZERO) > 0) { giftCardAmount = gcAmount; } String gcPaymentMethodId = (String) gcResult.get("paymentMethodId"); result = ServiceUtil.returnSuccess(); result.put("paymentMethodId", gcPaymentMethodId); result.put("amount", giftCardAmount); } } else { errMsg = UtilProperties.getMessage(resource_error, "checkhelper.problem_with_gift_card_information", (cart != null ? cart.getLocale() : Locale.getDefault())); errorMessages.add(errMsg); } } } else { result = ServiceUtil.returnSuccess(); } // see whether we need to return an error or not if (errorMessages.size() > 0) { result.put(ModelService.ERROR_MESSAGE_LIST, errorMessages); result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); } if (errorMaps.size() > 0) { result.put(ModelService.ERROR_MESSAGE_MAP, errorMaps); result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_ERROR); } return result; }