List of usage examples for java.math BigDecimal toString
@Override
public String toString()
From source file:org.egov.egf.web.actions.budget.BudgetProposalAction.java
private void populateBudgetProposalBean(final BudgetProposalBean bpbean, final BudgetDetail bd) { if (LOGGER.isInfoEnabled()) LOGGER.info("Starting populateBudgetProposalBean..... "); bpbean.setRowType(DETAIL);//w w w . ja va2s . co m bpbean.setId(bd.getId()); bpbean.setNextYrId(bd.getNextYrId()); bpbean.setBudget(topBudget.getName()); bpbean.setFund(fundMap.get(bd.getFund().getId()).getName()); bpbean.setFunction(functionMap.get(bd.getFunction().getId()).getName()); bpbean.setBudgetGroup(budgetGroupMap.get(bd.getBudgetGroup().getId()).getName()); bpbean.setExecutingDepartment(deptMap.get(bd.getExecutingDepartment().getId()).getCode()); bpbean.setPreviousYearActuals(previousYearBudgetDetailIdsAndAmount.get(bd.getUniqueNo()) == null ? BigDecimal.ZERO.setScale(2).toString() : previousYearBudgetDetailIdsAndAmount.get(bd.getUniqueNo()).toString()); bpbean.setTwoPreviousYearActuals(twopreviousYearBudgetDetailIdsAndAmount.get(bd.getUniqueNo()) == null ? BigDecimal.ZERO.setScale(2).toString() : twopreviousYearBudgetDetailIdsAndAmount.get(bd.getUniqueNo()).toString()); bpbean.setCurrentYearActuals( budgetDetailIdsAndAmount.get(bd.getUniqueNo()) == null ? BigDecimal.ZERO.setScale(2).toString() : budgetDetailIdsAndAmount.get(bd.getUniqueNo()).toString()); final BigDecimal lastBEAmount = uniqueNoAndBEMap.get(bd.getUniqueNo()) == null ? BigDecimal.ZERO.setScale(2) : uniqueNoAndBEMap.get(bd.getUniqueNo()); final BigDecimal approvedReAppropriationsTotal = uniqueNoAndApprMap.get(bd.getUniqueNo()) == null ? BigDecimal.ZERO.setScale(2) : uniqueNoAndApprMap.get(bd.getUniqueNo()); bpbean.setCurrentYearBE(lastBEAmount.toString()); bpbean.setReappropriation(approvedReAppropriationsTotal.toString()); bpbean.setTotal(lastBEAmount.add(approvedReAppropriationsTotal).toString()); bpbean.setAnticipatory(bd.getAnticipatoryAmount().setScale(2).toString()); bpbean.setProposedRE(bd.getOriginalAmount().setScale(2)); bpbean.setProposedBE(bd.getNextYroriginalAmount().setScale(2)); bpbean.setApprovedRE(bd.getApprovedAmount().setScale(2)); bpbean.setApprovedBE(bd.getNextYrapprovedAmount().setScale(2)); if (LOGGER.isInfoEnabled()) LOGGER.info("before bd.getstate().getExtraInfo1()"); if (LOGGER.isInfoEnabled()) LOGGER.info("Finished populateBudgetProposalBean..... "); }
From source file:org.egov.works.web.actions.reports.ContractorwiseAbstractReportAction.java
private List<CommonDrillDownReportBean> generateEstimateList(final List<Object[]> objArrList) { final List<CommonDrillDownReportBean> beanList = new LinkedList<CommonDrillDownReportBean>(); CommonDrillDownReportBean bean = null; BigDecimal amount = null; for (final Object[] objArr : objArrList) { bean = new CommonDrillDownReportBean(); bean.setEstimateId(((BigDecimal) objArr[0]).longValue()); bean.setEstNumber(objArr[1].toString()); bean.setEstDate((Date) objArr[2]); bean.setEstName(objArr[3].toString()); bean.setWardName(objArr[4].toString()); bean.setEstApprovedDate((Date) objArr[5]); amount = (BigDecimal) objArr[6]; if (amount != null) bean.setEstAmount(new BigDecimal(amount.toString()).setScale(2, RoundingMode.HALF_UP)); beanList.add(bean);//from w w w .j a va 2s .c o m } return beanList; }
From source file:org.apache.ofbiz.accounting.thirdparty.verisign.PayflowPro.java
public static Map<String, Object> ccVoid(DispatchContext dctx, Map<String, ? extends Object> context) { Delegator delegator = dctx.getDelegator(); GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference"); GenericValue authTrans = (GenericValue) context.get("authTrans"); BigDecimal amount = (BigDecimal) context.get("releaseAmount"); String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId"); String configString = (String) context.get("paymentConfig"); Locale locale = (Locale) context.get("locale"); if (configString == null) { configString = "payment.properties"; }/* ww w . ja v a 2s .c o m*/ if (authTrans == null) { authTrans = PaymentGatewayServices.getAuthTransaction(paymentPref); } if (authTrans == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "AccountingPaymentTransactionAuthorizationNotFoundCannotRelease", locale)); } boolean isPayPal = false; // Are we doing a cc or a paypal payment? if ("EXT_PAYPAL".equals(paymentPref.getString("paymentMethodTypeId"))) { isPayPal = true; } // auth ref number String refNum = authTrans.getString("referenceNum"); Map<String, String> data = UtilMisc.toMap("ORIGID", refNum); // tx type (Void) data.put("TRXTYPE", "V"); // get the orderID String orderId = paymentPref.getString("orderId"); if (isPayPal) { data.put("TENDER", "P"); data.put("NOTE", orderId); } else { // credit card tender data.put("TENDER", "C"); data.put("COMMENT1", orderId); // amount to void data.put("AMT", amount.toString()); } PayflowAPI pfp = init(delegator, paymentGatewayConfigId, configString, context); // get the base params StringBuilder params = makeBaseParams(delegator, paymentGatewayConfigId, configString); // parse the context parameters params.append("&").append(parseContext(data)); // transmit the request if (Debug.verboseOn()) Debug.logVerbose("Sending to Verisign: " + params.toString(), module); String resp; if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) { resp = pfp.submitTransaction(params.toString(), pfp.generateRequestId()); } else { resp = "RESULT=0&AUTHCODE=T&PNREF=" + (new Date()).getTime() + "&RESPMSG=Testing"; } if (Debug.verboseOn()) Debug.logVerbose("Response from Verisign: " + resp, module); // check the response Map<String, Object> result = ServiceUtil.returnSuccess(); parseVoidResponse(resp, result); result.put("releaseAmount", amount); return result; }
From source file:org.efaps.esjp.accounting.transaction.FieldValue_Base.java
/** * Internal method for {@link #getDocumentFieldValue(Parameter)}. * * @param _parameter Parameter as passed from eFaps to an esjp * @param _table the table/* ww w . j ava2s.co m*/ * @param _doc Document * @param _js the javascript * @throws EFapsException on error */ @SuppressWarnings("checkstyle:methodlength") protected void addDocumentInfo(final Parameter _parameter, final Table _table, final DocumentInfo _doc, final StringBuilder _js) throws EFapsException { final boolean showNetTotal = !"true".equalsIgnoreCase(getProperty(_parameter, "NoNetTotal")); final boolean showAction = !"true".equalsIgnoreCase(getProperty(_parameter, "NoAction")); final boolean showLabel = !"true".equalsIgnoreCase(getProperty(_parameter, "NoLabel")); final boolean showNote = "true".equalsIgnoreCase(getProperty(_parameter, "ShowNote")); final boolean showSwap = !"true".equalsIgnoreCase(getProperty(_parameter, "NoSwap")); final boolean showContact = !"true".equalsIgnoreCase(getProperty(_parameter, "NoContact")); final String[] origSel = _parameter.getParameterValues("originalSelected"); _doc.setFormater(NumberFormatter.get().getTwoDigitsFormatter()); final SelectBuilder accSel = new SelectBuilder().linkto(CISales.DocumentSumAbstract.Contact) .clazz(CIContacts.ClassClient) .linkfrom(CIAccounting.AccountCurrentDebtor2ContactClassClient, CIAccounting.AccountCurrentDebtor2ContactClassClient.ToClassClientLink) .linkto(CIAccounting.AccountCurrentDebtor2ContactClassClient.FromAccountLink); final SelectBuilder accInstSel = new SelectBuilder(accSel).instance(); final SelectBuilder accNameSel = new SelectBuilder(accSel).attribute(CIAccounting.AccountAbstract.Name); final SelectBuilder accDescSel = new SelectBuilder(accSel) .attribute(CIAccounting.AccountAbstract.Description); final SelectBuilder currSymbSel = new SelectBuilder().linkto(CISales.DocumentSumAbstract.CurrencyId) .attribute(CIERP.Currency.Symbol); final SelectBuilder rateCurrSymbSel = new SelectBuilder().linkto(CISales.DocumentSumAbstract.RateCurrencyId) .attribute(CIERP.Currency.Symbol); final SelectBuilder contNameSel = new SelectBuilder().linkto(CISales.DocumentSumAbstract.Contact) .attribute(CIContacts.Contact.Name); final SelectBuilder rateLabelSel = new SelectBuilder().attribute(CISales.DocumentSumAbstract.Rate).label(); final SelectBuilder currSymbSel4Pay = new SelectBuilder() .linkto(CISales.PaymentDocumentAbstract.CurrencyLink).attribute(CIERP.Currency.Symbol); final SelectBuilder rateCurrSymbSel4Pay = new SelectBuilder() .linkto(CISales.PaymentDocumentAbstract.RateCurrencyLink).attribute(CIERP.Currency.Symbol); final SelectBuilder docTypeSel = new SelectBuilder().linkfrom(CISales.Document2DocumentType.DocumentLink) .linkto(CISales.Document2DocumentType.DocumentTypeLink).attribute(CIERP.DocumentType.Name); final PrintQuery print = new PrintQuery(_doc.getInstance()); if (_doc.isSumsDoc()) { print.addAttribute(CISales.DocumentSumAbstract.CrossTotal, CISales.DocumentSumAbstract.NetTotal, CISales.DocumentSumAbstract.RateCrossTotal, CISales.DocumentSumAbstract.RateNetTotal); print.addSelect(rateLabelSel, currSymbSel, rateCurrSymbSel, docTypeSel); } if (_doc.isPaymentDoc()) { print.addAttribute(CISales.PaymentDocumentAbstract.Note, CISales.PaymentDocumentAbstract.Amount); print.addSelect(rateLabelSel, currSymbSel4Pay, rateCurrSymbSel4Pay); } print.addAttribute(CISales.DocumentAbstract.Name, CISales.DocumentAbstract.Date, CISales.DocumentAbstract.StatusAbstract, CISales.DocumentAbstract.Note); print.addSelect(accDescSel, accNameSel, accInstSel, contNameSel); print.execute(); String docType = null; if (_doc.isSumsDoc()) { docType = print.getSelect(docTypeSel); } _doc.setDate(print.<DateTime>getAttribute(CISales.DocumentAbstract.Date)); //Basic information for all documents final String name = print.<String>getAttribute(CISales.DocumentAbstract.Name); final String contactName = print.<String>getSelect(contNameSel); final Long statusId = print.<Long>getAttribute(CISales.DocumentAbstract.StatusAbstract); final AccountInfo account = new AccountInfo(print.<Instance>getSelect(accInstSel)); if (account.getInstance() == null) { setAccounts4Debit(_parameter, _doc); } final StringBuilder label = new StringBuilder().append(_doc.getInstance().getType().getLabel()) .append(docType == null ? "" : " - " + CIERP.DocumentType.getType().getLabel() + ": " + docType) .append("<input type=\"hidden\" name=\"document\" value=\"").append(_doc.getInstance().getOid()) .append("\"/>"); if (!ArrayUtils.isEmpty(origSel) && !ArrayUtils.contains(origSel, _doc.getInstance().getOid())) { label.append(getRemoveBtn(_parameter, _js)); } _table.addRow().addColumn(label).getCurrentColumn().setStyle("font-weight: bold").getCurrentTable().addRow() .addColumn(getLabel(_doc.getInstance(), CISales.DocumentAbstract.Name)).addColumn(name) .addColumn(getLabel(_doc.getInstance(), CISales.DocumentAbstract.Date)) .addColumn(_doc.getDateString()); if (showContact) { _table.addRow().addColumn(getLabel(_doc.getInstance(), CISales.DocumentAbstract.Contact)); if (_doc.getDebtorAccount() == null) { _table.addColumn(contactName); } else { _table.addColumn(new StringBuilder().append(contactName).append(" -> ") .append(CIAccounting.AccountCurrentDebtor.getType().getLabel()).append(": ") .append(_doc.getDebtorAccount().getName())); } } _table.addRow().addColumn(getLabel(_doc.getInstance(), "Status")).addColumn(Status.get(statusId).getLabel()) .getCurrentColumn().setColSpan(_doc.isSumsDoc() || _doc.isPaymentDoc() ? 1 : 3); if (_doc.isSumsDoc()) { final BigDecimal crossTotal = print.<BigDecimal>getAttribute(CISales.DocumentSumAbstract.CrossTotal); final BigDecimal netTotal = print.<BigDecimal>getAttribute(CISales.DocumentSumAbstract.NetTotal); final BigDecimal rateCrossTot = print .<BigDecimal>getAttribute(CISales.DocumentSumAbstract.RateCrossTotal); final BigDecimal rateNetTotal = print .<BigDecimal>getAttribute(CISales.DocumentSumAbstract.RateNetTotal); final String currSymbol = print.<String>getSelect(currSymbSel); final String rateCurrSymbol = print.<String>getSelect(rateCurrSymbSel); final BigDecimal rate = print.<BigDecimal>getSelect(rateLabelSel); _table.addColumn(getLabel(_doc.getInstance(), CISales.DocumentSumAbstract.Rate)) .addColumn(rate.toString()); if (showNetTotal) { _table.addRow().addColumn(getLabel(_doc.getInstance(), CISales.DocumentSumAbstract.NetTotal)) .addColumn( NumberFormatter.get().getTwoDigitsFormatter().format(netTotal) + " " + currSymbol) .addColumn(getLabel(_doc.getInstance(), CISales.DocumentSumAbstract.RateNetTotal)) .addColumn(NumberFormatter.get().getTwoDigitsFormatter().format(rateNetTotal) + " " + rateCurrSymbol); } _table.addRow().addColumn(getLabel(_doc.getInstance(), CISales.DocumentSumAbstract.CrossTotal)) .addColumn(NumberFormatter.get().getTwoDigitsFormatter().format(crossTotal) + " " + currSymbol) .addColumn(getLabel(_doc.getInstance(), CISales.DocumentSumAbstract.RateCrossTotal)) .addColumn(NumberFormatter.get().getTwoDigitsFormatter().format(rateCrossTot) + " " + rateCurrSymbol); } if (_doc.isPaymentDoc()) { final BigDecimal amount = print.<BigDecimal>getAttribute(CISales.PaymentDocumentAbstract.Amount); final String rateCurrSymbol = print.<String>getSelect(rateCurrSymbSel4Pay); final BigDecimal rate = print.<BigDecimal>getSelect(rateLabelSel); _table.addRow().addColumn(getLabel(_doc.getInstance(), CISales.DocumentSumAbstract.Rate)) .addColumn(rate.toString()) .addColumn(getLabel(_doc.getInstance(), CISales.PaymentDocumentAbstract.Amount)) .addColumn(NumberFormatter.get().getTwoDigitsFormatter().format(amount) + " " + rateCurrSymbol) .addColumn(getLabel(_doc.getInstance(), CISales.DocumentSumAbstract.Note)) .addColumn(print.<String>getAttribute(CISales.PaymentDocumentAbstract.Note)); final QueryBuilder queryBldr = new QueryBuilder(CIERP.Document2PaymentDocumentAbstract); queryBldr.addWhereAttrEqValue(CIERP.Document2PaymentDocumentAbstract.ToAbstractLink, _doc.getInstance()); final MultiPrintQuery multi = queryBldr.getPrint(); final SelectBuilder selDoc = new SelectBuilder() .linkto(CIERP.Document2PaymentDocumentAbstract.FromAbstractLink); final SelectBuilder selDocInst = new SelectBuilder(selDoc).instance(); multi.addSelect(selDocInst); multi.execute(); final SelectBuilder selCurInst = new SelectBuilder().linkto(CISales.DocumentSumAbstract.RateCurrencyId) .instance(); while (multi.next()) { final Instance docInst = multi.<Instance>getSelect(selDocInst); if (docInst.isValid()) { final PrintQuery print2 = new PrintQuery(docInst); print2.addAttribute(CISales.DocumentSumAbstract.RateCrossTotal, CISales.DocumentSumAbstract.Name); print2.addSelect(selCurInst); print2.execute(); final Instance curInst = print2.<Instance>getSelect(selCurInst); final BigDecimal rateCross = print2 .<BigDecimal>getAttribute(CISales.DocumentSumAbstract.RateCrossTotal); final String docName = print2.<String>getAttribute(CISales.DocumentSumAbstract.Name); _table.addRow().addColumn(docInst.getType().getLabel()).addColumn(docName) .addColumn(getLabel(docInst, CISales.DocumentSumAbstract.RateCrossTotal)) .addColumn(rateCross + " " + new CurrencyInst(curInst).getSymbol()); } } } if (showAction && !_doc.isPaymentDoc()) { final QueryBuilder actionQueryBldr = new QueryBuilder(CIERP.ActionDefinition2DocumentAbstract); actionQueryBldr.addWhereAttrEqValue(CIERP.ActionDefinition2DocumentAbstract.ToLinkAbstract, _doc.getInstance()); final MultiPrintQuery actionMulti = actionQueryBldr.getPrint(); final SelectBuilder selName = SelectBuilder.get() .linkto(CIERP.ActionDefinition2DocumentAbstract.FromLinkAbstract) .attribute(CIERP.ActionDefinitionAbstract.Name); actionMulti.addSelect(selName); actionMulti.execute(); while (actionMulti.next()) { _table.addRow() .addColumn(DBProperties.getProperty( org.efaps.esjp.accounting.transaction.FieldValue.class.getName() + ".ActionInfo")) .addColumn(actionMulti.<String>getSelect(selName)); } } if (showLabel) { final List<Instance> labelInsts = new Label().getLabelInst4Documents(_parameter, _doc.getInstance()); if (labelInsts != null) { final MultiPrintQuery labelMulti = new MultiPrintQuery(labelInsts); final SelectBuilder selPeriodName = SelectBuilder.get() .linkto(CIAccounting.LabelAbstract.PeriodAbstractLink).attribute(CIAccounting.Period.Name); final SelectBuilder selPeriodInst = SelectBuilder.get() .linkto(CIAccounting.LabelAbstract.PeriodAbstractLink).instance(); labelMulti.addSelect(selPeriodInst, selPeriodName); labelMulti.addAttribute(CIAccounting.LabelAbstract.Name); labelMulti.execute(); while (labelMulti.next()) { _table.addRow().addColumn(DBProperties.getProperty( org.efaps.esjp.accounting.transaction.FieldValue.class.getName() + ".LabelInfo")) .addColumn(labelMulti.<String>getAttribute(CIAccounting.LabelAbstract.Name)); final Instance periodInst = labelMulti.getSelect(selPeriodInst); if (!periodInst.equals(new Period().evaluateCurrentPeriod(_parameter))) { _table.addColumn(CIAccounting.Period.getType().getLabel()) .addColumn(labelMulti.<String>getSelect(selPeriodName)); } } } } if (showSwap && !_doc.isPaymentDoc()) { final QueryBuilder swapQueryBldr = new QueryBuilder(CISales.Document2Document4Swap); swapQueryBldr.setOr(true); swapQueryBldr.addWhereAttrEqValue(CISales.Document2Document4Swap.FromLink, _doc.getInstance()); swapQueryBldr.addWhereAttrEqValue(CISales.Document2Document4Swap.ToLink, _doc.getInstance()); final InstanceQuery swapQuery = swapQueryBldr.getQuery(); final List<Instance> relInst = swapQuery.execute(); if (!relInst.isEmpty()) { for (final SwapInfo info : Swap.getSwapInfos(_parameter, _doc.getInstance(), relInst).values()) { final StringBuilder swapLabel = new StringBuilder().append(info.getDocument()) .append("<input type=\"hidden\" name=\"swapDocument\" value=\"") .append(info.getDocInst().getOid()).append("\"/>"); _table.addRow().addColumn(info.getDirection()).addColumn(swapLabel).addColumn( info.getAmount() + " " + CurrencyInst.get(info.getCurrencyInstance()).getSymbol()); } } } if (showNote) { final String note = print.<String>getAttribute(CISales.DocumentAbstract.Note); _table.addRow().addColumn(note); } }
From source file:org.apache.ofbiz.accounting.thirdparty.verisign.PayflowPro.java
public static Map<String, Object> ccCapture(DispatchContext dctx, Map<String, ? extends Object> context) { Delegator delegator = dctx.getDelegator(); GenericValue paymentPref = (GenericValue) context.get("orderPaymentPreference"); GenericValue authTrans = (GenericValue) context.get("authTrans"); BigDecimal amount = (BigDecimal) context.get("captureAmount"); String paymentGatewayConfigId = (String) context.get("paymentGatewayConfigId"); String configString = (String) context.get("paymentConfig"); Locale locale = (Locale) context.get("locale"); if (configString == null) { configString = "payment.properties"; }/* w ww.ja va2 s .c om*/ boolean isPayPal = false; // Are we doing a cc or a paypal payment? if ("EXT_PAYPAL".equals(paymentPref.getString("paymentMethodTypeId"))) { isPayPal = true; } if (authTrans == null) { authTrans = PaymentGatewayServices.getAuthTransaction(paymentPref); } if (authTrans == null) { return ServiceUtil.returnError(UtilProperties.getMessage(resource, "AccountingPaymentTransactionAuthorizationNotFoundCannotCapture", locale)); } // auth ref number String refNum = authTrans.getString("referenceNum"); Map<String, String> data = UtilMisc.toMap("ORIGID", refNum); // tx type (Delayed Capture) data.put("TRXTYPE", "D"); if (isPayPal) { // paypal tender data.put("TENDER", "P"); data.put("CAPTURECOMPLETE", "N"); } else { // credit card tender data.put("TENDER", "C"); // get the orderID String orderId = paymentPref.getString("orderId"); data.put("COMMENT1", orderId); } // amount to capture data.put("AMT", amount.toString()); PayflowAPI pfp = init(delegator, paymentGatewayConfigId, configString, context); // get the base params StringBuilder params = makeBaseParams(delegator, paymentGatewayConfigId, configString); // parse the context parameters params.append("&").append(parseContext(data)); // transmit the request if (Debug.verboseOn()) Debug.logVerbose("Sending to Verisign: " + params.toString(), module); String resp; if (!comparePaymentGatewayConfigValue(delegator, paymentGatewayConfigId, "enableTransmit", configString, "payment.verisign.enable_transmit", "false")) { resp = pfp.submitTransaction(params.toString(), pfp.generateRequestId()); } else { resp = "RESULT=0&AUTHCODE=T&PNREF=" + (new Date()).getTime() + "&RESPMSG=Testing"; } if (Debug.verboseOn()) Debug.logVerbose("Response from Verisign: " + resp, module); // check the response Map<String, Object> result = ServiceUtil.returnSuccess(); parseCaptureResponse(resp, result); result.put("captureAmount", amount); return result; }
From source file:org.egov.wtms.application.service.ConnectionDemandService.java
public Map<String, String> getMonthlyWaterChargesDue(WaterConnectionDetails waterConnectionDetails) { Map<String, String> resultMap = new HashMap<>(); BigDecimal amount = ZERO; EgDemand currentDemand = waterTaxUtils.getCurrentDemand(waterConnectionDetails).getDemand(); for (EgDemandDetails demandDetails : currentDemand.getEgDemandDetails()) if (WATERTAXREASONCODE .equalsIgnoreCase(demandDetails.getEgDemandReason().getEgDemandReasonMaster().getCode()) || METERED_CHARGES_REASON_CODE.equalsIgnoreCase( demandDetails.getEgDemandReason().getEgDemandReasonMaster().getCode())) amount = amount.add(demandDetails.getAmount()); List<EgDemandDetails> demandDetailList = new ArrayList<>(currentDemand.getEgDemandDetails()); DemandComparatorByInstallmentStartDate demandComparatorByInstallmentStartDate = new DemandComparatorByInstallmentStartDate(); Collections.sort(demandDetailList, demandComparatorByInstallmentStartDate); resultMap.put(WATER_CHARGES, amount.toString()); Boolean isInstallmentSet = false; for (EgDemandDetails demandDetails : demandDetailList) if (!isInstallmentSet && WATERTAXREASONCODE .equalsIgnoreCase(demandDetails.getEgDemandReason().getEgDemandReasonMaster().getCode())) { resultMap.put(FROM_INSTALLMENT, demandDetails.getEgDemandReason().getEgInstallmentMaster().getDescription()); resultMap.put(TO_INSTALLMENT, demandDetailList.get(demandDetailList.size() - 1).getEgDemandReason() .getEgInstallmentMaster().getDescription()); isInstallmentSet = true;//from w ww.j av a 2 s .com } else if (!isInstallmentSet && METERED_CHARGES_REASON_CODE .equalsIgnoreCase(demandDetails.getEgDemandReason().getEgDemandReasonMaster().getCode())) { resultMap.put(FROM_INSTALLMENT, demandDetails.getEgDemandReason().getEgInstallmentMaster() .getDescription().replace("WT_MC-", "")); resultMap.put(TO_INSTALLMENT, demandDetailList.get(demandDetailList.size() - 1).getEgDemandReason() .getEgInstallmentMaster().getDescription().replace("WT_MC-", "")); isInstallmentSet = true; } return resultMap; }
From source file:org.mifosplatform.infrastructure.dataqueries.service.ReadWriteNonCoreDataServiceImpl.java
private String validateColumn(final ResultsetColumnHeaderData columnHeader, final String pValue, final String dateFormat, final Locale clientApplicationLocale) { String paramValue = pValue;//from ww w .ja v a2 s. com if (columnHeader.isDateDisplayType() || columnHeader.isIntegerDisplayType() || columnHeader.isDecimalDisplayType()) { paramValue = paramValue.trim(); } if (StringUtils.isEmpty(paramValue) && columnHeader.isMandatory()) { final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); final ApiParameterError error = ApiParameterError.parameterError("error.msg.column.mandatory", "Mandatory", columnHeader.getColumnName()); dataValidationErrors.add(error); throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } if (StringUtils.isNotEmpty(paramValue)) { if (columnHeader.hasColumnValues()) { if (columnHeader.isCodeValueDisplayType()) { if (columnHeader.isColumnValueNotAllowed(paramValue)) { final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); final ApiParameterError error = ApiParameterError.parameterError( "error.msg.invalid.columnValue", "Value not found in Allowed Value list", columnHeader.getColumnName(), paramValue); dataValidationErrors.add(error); throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } return paramValue; } else if (columnHeader.isCodeLookupDisplayType()) { final Integer codeLookup = Integer.valueOf(paramValue); if (columnHeader.isColumnCodeNotAllowed(codeLookup)) { final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); final ApiParameterError error = ApiParameterError.parameterError( "error.msg.invalid.columnValue", "Value not found in Allowed Value list", columnHeader.getColumnName(), paramValue); dataValidationErrors.add(error); throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } return paramValue; } else { throw new PlatformDataIntegrityException("error.msg.invalid.columnType.", "Code: " + columnHeader.getColumnName() + " - Invalid Type " + columnHeader.getColumnType() + " (neither varchar nor int)"); } } if (columnHeader.isDateDisplayType()) { final LocalDate tmpDate = JsonParserHelper.convertFrom(paramValue, columnHeader.getColumnName(), dateFormat, clientApplicationLocale); if (tmpDate == null) { paramValue = null; } else { paramValue = tmpDate.toString(); } } else if (columnHeader.isIntegerDisplayType()) { final Integer tmpInt = this.helper.convertToInteger(paramValue, columnHeader.getColumnName(), clientApplicationLocale); if (tmpInt == null) { paramValue = null; } else { paramValue = tmpInt.toString(); } } else if (columnHeader.isDecimalDisplayType()) { final BigDecimal tmpDecimal = this.helper.convertFrom(paramValue, columnHeader.getColumnName(), clientApplicationLocale); if (tmpDecimal == null) { paramValue = null; } else { paramValue = tmpDecimal.toString(); } } else if (columnHeader.isString()) { if (paramValue.length() > columnHeader.getColumnLength()) { final ApiParameterError error = ApiParameterError.parameterError( "validation.msg.datatable.entry.column.exceeds.maxlength", "The column `" + columnHeader.getColumnName() + "` exceeds its defined max-length ", columnHeader.getColumnName(), paramValue); final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>(); dataValidationErrors.add(error); throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors); } } } return paramValue; }
From source file:er.extensions.foundation.ERXProperties.java
/** * <div class="en">/*from w w w.j a v a 2s . c om*/ * Cover method for returning a BigDecimal for a * given system property or a default value. This method uses the * method <code>bigDecimalValueWithDefault</code> from * {@link ERXValueUtilities}. * </div> * * <div class="ja"> * ?? BigDecimal ???? * </div> * * @param s <div class="en">system property</div> * <div class="ja"></div> * @param defaultValue <div class="en">default value</div> * <div class="ja"></div> * * @return <div class="en">BigDecimal value of the string in the system properties. Scale is controlled by the string, ie "4.400" will have a scale of 3.</div> * <div class="ja">BigDecimal ???</div> */ public static BigDecimal bigDecimalForKeyWithDefault(String s, BigDecimal defaultValue) { final String propertyName = getApplicationSpecificPropertyName(s); Object value = _cache.get(propertyName); if (UndefinedMarker.equals(value)) { return defaultValue; } if (value instanceof BigDecimal) { return (BigDecimal) value; } String propertyValue = ERXSystem.getProperty(propertyName); final BigDecimal bigDecimal = ERXValueUtilities.bigDecimalValueWithDefault(propertyValue, defaultValue); if (retainDefaultsEnabled() && propertyValue == null && bigDecimal != null) { propertyValue = bigDecimal.toString(); System.setProperty(propertyName, propertyValue); } _cache.put(propertyName, propertyValue == null ? (Object) UndefinedMarker : bigDecimal); return bigDecimal; }
From source file:it.geosolutions.geobatch.destination.vulnerability.VulnerabilityComputation.java
/** * Calculate all the buffers geometries for the next batchSize set of arcs. * //from w ww . j a v a 2s .c o m * @param batchSize * @param arcIdsSet * @param vse * @param allDistances * @param monitor * @param targetID * @param x * @param y * @param arcList * @param arcIds * @param bufferList * @return */ private int calculateBuffersOnBatch(int batchSize, ConcurrentSkipListSet<BigDecimal> arcIdsSet, VulnerabilityStatsEngine vse, List<Double> allDistances, VulnerabilityMonitor monitor, String targetID, int x, int y, List<SimpleFeature> arcList, List<String> arcIds, List<MultipleBufferMap> bufferList) { int batchCounter = 0; try { while (batchCounter < batchSize && hasMoreInput(true)) { SimpleFeature inputFeature = readInput(); BigDecimal arcId = ((BigDecimal) inputFeature.getAttribute(ID_GEO_ARCO)); // Check if the feature has been already // taken boolean newArc = arcIdsSet.add(arcId); if (newArc) { try { MultipleBufferMap mbm = vse.computeBuffersOnArcs(Collections.singletonList(inputFeature), allDistances); bufferList.add(mbm); arcList.add(inputFeature); arcIds.add(arcId.toString()); } catch (Exception e) { monitor.incrementErrors(); monitor.newMessage(new VulnerabilityMonitor.Message(TYPE.ERROR, "Error calculating buffers for arc " + arcId, e)); LOGGER.error("Error calculating buffers for arc " + arcId, e); } } batchCounter++; } } catch (Exception e1) { monitor.incrementErrors(); monitor.newMessage(new VulnerabilityMonitor.Message(TYPE.ERROR, "Raster=" + targetID + ", TILE=(" + x + "," + y + ") Error reading arcs", e1)); LOGGER.error("Raster=" + targetID + ", TILE=(" + x + "," + y + ") Error reading arcs batch", e1); } return batchCounter; }
From source file:com.konakartadmin.modules.payment.authorizenet.AdminPayment.java
/** * This method executes the transaction with the payment gateway. The action attribute of the * options object instructs the method as to what transaction should be executed. E.g. It could * be a payment or a payment confirmation for a transaction that has already been authorized * etc.//from w w w .java2s. c o m * * @param options * @return Returns an array of NameValue objects that may contain any return information * considered useful by the caller. * @throws Exception */ public NameValue[] execute(PaymentOptions options) throws Exception { checkRequired(options, "PaymentOptions", "options"); // Read the configuration variables ConfigVariables configs = getConfigVariables(); /* * Decide what to do based on the action. We could be using this class to manage * subscriptions */ if (options.getAction() == KKConstants.ACTION_CREATE_SUBSCRIPTION) { return createSubscription(options); } else if (options.getAction() == KKConstants.ACTION_UPDATE_SUBSCRIPTION) { return updateSubscription(options); } else if (options.getAction() == KKConstants.ACTION_CANCEL_SUBSCRIPTION) { return cancelSubscription(options); } else if (options.getAction() == KKConstants.ACTION_GET_SUBSCRIPTION_STATUS) { return getSubscriptionStatus(options); } String errorDesc = null; String gatewayResult = null; String transactionId = null; AdminIpnHistory ipnHistory = new AdminIpnHistory(); ipnHistory.setModuleCode(code); AdminOrder order = getAdminOrderMgr().getOrderForOrderId(options.getOrderId()); if (order == null) { throw new KKAdminException("An order does not exist for id = " + options.getOrderId()); } // Get the scale for currency calculations AdminCurrency currency = getAdminCurrMgr().getCurrency(order.getCurrencyCode()); if (currency == null) { throw new KKAdminException("A currency does not exist for code = " + order.getCurrencyCode()); } int scale = new Integer(currency.getDecimalPlaces()).intValue(); List<NameValue> parmList = new ArrayList<NameValue>(); parmList.add(new NameValue("x_delim_data", "True")); parmList.add(new NameValue("x_relay_response", "False")); parmList.add(new NameValue("x_login", configs.getAuthorizeNetLoginId())); parmList.add(new NameValue("x_tran_key", configs.getAuthorizeNetTxnKey())); parmList.add(new NameValue("x_delim_char", ",")); parmList.add(new NameValue("x_encap_char", "")); parmList.add(new NameValue("x_method", "CC")); // AuthorizeNet requires details of the final price - inclusive of tax. BigDecimal total = null; for (int i = 0; i < order.getOrderTotals().length; i++) { AdminOrderTotal ot = order.getOrderTotals()[i]; if (ot.getClassName().equals(OrderTotalMgr.ot_total)) { total = ot.getValue().setScale(scale, BigDecimal.ROUND_HALF_UP); } } if (total == null) { throw new KKAdminException("An Order Total was not found"); } parmList.add(new NameValue("x_amount", total.toString())); parmList.add(new NameValue("x_currency_code", currency.getCode())); parmList.add(new NameValue("x_invoice_num", order.getId())); // TODO parmList.add(new NameValue("x_test_request", (configs.isTestMode() ? "TRUE" : "FALSE"))); // Set the billing address // Set the billing name. If the name field consists of more than two strings, we take the // last one as being the surname. String bName = order.getBillingName(); if (bName != null) { String[] names = bName.split(" "); int len = names.length; if (len >= 2) { StringBuffer firstName = new StringBuffer(); for (int i = 0; i < len - 1; i++) { if (firstName.length() == 0) { firstName.append(names[i]); } else { firstName.append(" "); firstName.append(names[i]); } } parmList.add(new NameValue("x_first_name", firstName.toString())); parmList.add(new NameValue("x_last_name", names[len - 1])); } } parmList.add(new NameValue("x_company", order.getBillingCompany())); parmList.add(new NameValue("x_city", order.getBillingCity())); parmList.add(new NameValue("x_state", order.getBillingState())); parmList.add(new NameValue("x_zip", order.getBillingPostcode())); parmList.add(new NameValue("x_phone", order.getCustomerTelephone())); parmList.add(new NameValue("x_cust_id", order.getCustomerId())); parmList.add(new NameValue("x_email", order.getCustomerEmail())); StringBuffer addrSB = new StringBuffer(); addrSB.append(order.getBillingStreetAddress()); if (order.getBillingSuburb() != null && order.getBillingSuburb().length() > 0) { addrSB.append(", "); addrSB.append(order.getBillingSuburb()); } if (addrSB.length() > 60) { parmList.add(new NameValue("x_address", addrSB.substring(0, 56) + "...")); } else { parmList.add(new NameValue("x_address", addrSB.toString())); } // Country requires the two letter country code AdminCountry country = getAdminTaxMgr().getCountryByName(order.getBillingCountry()); if (country != null) { parmList.add(new NameValue("x_country", country.getIsoCode2())); } /* * The following code may be customized depending on the process which could be any of the * following: */ int mode = 1; if (mode == 1 && options.getCreditCard() != null) { /* * 1 . Credit card details have been passed into the method and so we use those for the * payment. */ parmList.add(new NameValue("x_card_num", options.getCreditCard().getCcNumber())); parmList.add(new NameValue("x_card_code", options.getCreditCard().getCcCVV())); parmList.add(new NameValue("x_exp_date", options.getCreditCard().getCcExpires())); parmList.add(new NameValue("x_type", "AUTH_CAPTURE")); } else if (mode == 2) { /* * 2 . We get the Credit card details from the order since they were encrypted and saved * on the order. */ parmList.add(new NameValue("x_card_num", order.getCcNumber())); parmList.add(new NameValue("x_card_code", order.getCcCVV())); parmList.add(new NameValue("x_exp_date", order.getCcExpires())); parmList.add(new NameValue("x_type", "AUTH_CAPTURE")); } else if (mode == 3) { /* * 3.If when the products were ordered through the store front application, an AUTH_ONLY * transaction was done instead of an AUTH_CAPTURE transaction and so now we need to do * a PRIOR_AUTH_CAPTURE transaction using the transaction id that was saved on the order * when the status was set. */ /* * Get the transaction id from the status trail of the order. This bit of code will have * to be customized because it depends which state was used to capture the transaction * id and whether the transaction id is the only string in the comments field or whether * it has to be parsed out. The transaction id may also have been stored in an Order * custom field in which case it can be retrieved directly from there. */ String authTransId = null; if (order.getStatusTrail() != null) { for (int i = 0; i < order.getStatusTrail().length; i++) { AdminOrderStatusHistory sh = order.getStatusTrail()[i]; if (sh.getOrderStatus().equals("ENTER_THE_STATUS_WHERE_THE_AUTH_TRANS_ID_WAS SAVED")) { authTransId = sh.getComments(); } } } if (authTransId == null) { throw new KKAdminException( "The authorized transaction cannot be confirmed since a transaction id cannot be found on the order"); } parmList.add(new NameValue("x_type", "PRIOR_AUTH_CAPTURE")); parmList.add(new NameValue("x_trans_id", authTransId)); } AdminPaymentDetails pDetails = new AdminPaymentDetails(); pDetails.setParmList(parmList); pDetails.setRequestUrl(configs.getAuthorizeNetRequestUrl()); // Do the post String gatewayResp = postData(pDetails); gatewayResp = URLDecoder.decode(gatewayResp, "UTF-8"); if (log.isDebugEnabled()) { log.debug("Unformatted GatewayResp = \n" + gatewayResp); } // Process the parameters sent in the callback StringBuffer sb = new StringBuffer(); String[] parms = gatewayResp.split(","); if (parms != null) { for (int i = 0; i < parms.length; i++) { String parm = parms[i]; sb.append(getRespDesc(i + 1)); sb.append("="); sb.append(parm); sb.append("\n"); if (i + 1 == respTextPosition) { errorDesc = parm; } else if (i + 1 == respCodePosition) { gatewayResult = parm; ipnHistory.setGatewayResult(parm); } else if (i + 1 == txnIdPosition) { ipnHistory.setGatewayTransactionId(parm); transactionId = parm; } } } // Put the response in the ipnHistory record ipnHistory.setGatewayFullResponse(sb.toString()); if (log.isDebugEnabled()) { log.debug("Formatted Authorize.net response data:"); log.debug(sb.toString()); } AdminOrderUpdate updateOrder = new AdminOrderUpdate(); updateOrder.setUpdatedById(order.getCustomerId()); // Determine whether the request was successful or not. if (gatewayResult != null && gatewayResult.equals(approved)) { String comment = ORDER_HISTORY_COMMENT_OK + transactionId; getAdminOrderMgr().updateOrder(order.getId(), com.konakart.bl.OrderMgr.PAYMENT_RECEIVED_STATUS, comment, /* notifyCustomer */ false, updateOrder); // Save the ipnHistory ipnHistory.setKonakartResultDescription(RET0_DESC); ipnHistory.setKonakartResultId(RET0); ipnHistory.setOrderId(order.getId()); ipnHistory.setCustomerId(order.getCustomerId()); getAdminOrderMgr().insertIpnHistory(ipnHistory); } else if (gatewayResult != null && (gatewayResult.equals(declined) || gatewayResult.equals(error))) { String comment = ORDER_HISTORY_COMMENT_KO + errorDesc; getAdminOrderMgr().updateOrder(order.getId(), com.konakart.bl.OrderMgr.PAYMENT_DECLINED_STATUS, comment, /* notifyCustomer */ false, updateOrder); // Save the ipnHistory ipnHistory.setKonakartResultDescription(RET0_DESC); ipnHistory.setKonakartResultId(RET0); ipnHistory.setOrderId(order.getId()); ipnHistory.setCustomerId(order.getCustomerId()); getAdminOrderMgr().insertIpnHistory(ipnHistory); } else { /* * We only get to here if there was an unknown response from the gateway */ String comment = RET1_DESC + gatewayResult; getAdminOrderMgr().updateOrder(order.getId(), com.konakart.bl.OrderMgr.PAYMENT_DECLINED_STATUS, comment, /* notifyCustomer */ false, updateOrder); // Save the ipnHistory ipnHistory.setKonakartResultDescription(RET1_DESC + gatewayResult); ipnHistory.setKonakartResultId(RET1); ipnHistory.setOrderId(order.getId()); ipnHistory.setCustomerId(order.getCustomerId()); getAdminOrderMgr().insertIpnHistory(ipnHistory); } return new NameValue[] { new NameValue("ret", "0") }; }