Example usage for java.math RoundingMode HALF_UP

List of usage examples for java.math RoundingMode HALF_UP

Introduction

In this page you can find the example usage for java.math RoundingMode HALF_UP.

Prototype

RoundingMode HALF_UP

To view the source code for java.math RoundingMode HALF_UP.

Click Source Link

Document

Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.

Usage

From source file:au.org.ala.biocache.dao.SearchDAOImpl.java

private String getUpperRange(String lower, Number gap, boolean addGap) {
    if (gap instanceof Integer) {
        Integer upper = Integer.parseInt(lower) - 1;
        if (addGap)
            upper += (Integer) gap;
        return upper.toString();
    } else if (gap instanceof Double) {
        BigDecimal upper = new BigDecimal(lower).add(new BigDecimal(-0.001));
        if (addGap) {
            upper = upper.add(new BigDecimal(gap.doubleValue()));
        }//from w w w  .  ja  va2s.c o m
        return upper.setScale(3, RoundingMode.HALF_UP).toString();
    } else {
        return lower;
    }
}

From source file:org.openbravo.advpaymentmngt.process.FIN_PaymentProcess.java

private BigDecimal getConversionRate(String strOrgId, String strFromCurrencyId, String strToCurrencyId,
        Date conversionDate) {/* w  w w  .j  av a2 s .  c  om*/
    BigDecimal exchangeRate = BigDecimal.ZERO;
    // Apply default conversion rate
    int conversionRatePrecision = FIN_Utility
            .getConversionRatePrecision(RequestContext.get().getVariablesSecureApp());
    Organization organization = OBDal.getInstance().get(Organization.class, strOrgId);
    Currency fromCurrency = OBDal.getInstance().get(Currency.class, strFromCurrencyId);
    Currency toCurrency = OBDal.getInstance().get(Currency.class, strToCurrencyId);
    final ConversionRate conversionRate = FIN_Utility.getConversionRate(fromCurrency, toCurrency,
            conversionDate, organization);
    if (conversionRate != null) {
        exchangeRate = conversionRate.getMultipleRateBy().setScale(conversionRatePrecision,
                RoundingMode.HALF_UP);
    } else {
        exchangeRate = BigDecimal.ZERO;
    }
    return exchangeRate;
}

From source file:mx.edu.um.mateo.activos.dao.impl.ActivoDaoHibernate.java

@Override
@SuppressWarnings("unchecked")
@Transactional(readOnly = true)/*from   ww  w  . j  a v a2  s  .  c om*/
public Map<String, Object> depreciacionAcumuladaPorTipoActivo(Map<String, Object> params) {
    Usuario usuario = (Usuario) params.get("usuario");
    Query tiposDeActivoQuery = currentSession().createQuery(
            "select new map(ta.nombre as nombre, ta.cuenta.id.idCtaMayor as cuenta, ta.id as id) from TipoActivo ta where ta.cuenta.id.ejercicio.id.idEjercicio = :ejercicioId and ta.cuenta.id.ejercicio.id.organizacion.id = :organizacionId order by ta.cuenta.id.idCtaMayor");
    tiposDeActivoQuery.setString("ejercicioId", usuario.getEjercicio().getId().getIdEjercicio());
    tiposDeActivoQuery.setLong("organizacionId", usuario.getEjercicio().getId().getOrganizacion().getId());
    List<Map<String, Object>> tiposDeActivo = tiposDeActivoQuery.list();
    Map<String, Map<String, Object>> tiposDeActivoMap = new HashMap<>();
    for (Map<String, Object> tipoActivo : tiposDeActivo) {
        tipoActivo.put("ACUMULADA", BigDecimal.ZERO);
        tipoActivo.put("MENSUAL", BigDecimal.ZERO);
        tiposDeActivoMap.put((String) tipoActivo.get("cuenta"), tipoActivo);
    }
    log.trace("TiposDeActivoMap: {}", tiposDeActivoMap);

    params.put("tiposDeActivo", tiposDeActivo);

    Map<String, BigDecimal> totales = new HashMap<>();
    totales.put("ACUMULADA", BigDecimal.ZERO);
    totales.put("MENSUAL", BigDecimal.ZERO);

    Date fecha = (Date) params.get("fecha");

    MathContext mc = new MathContext(16, RoundingMode.HALF_UP);
    Query query = currentSession().createQuery(
            "select new Activo(a.id, a.version, a.moi, a.fechaCompra, a.tipoActivo.porciento, a.tipoActivo.vidaUtil, a.inactivo, a.fechaInactivo, a.fechaReubicado, a.tipoActivo.cuenta.id.idCtaMayor, a.centroCosto.id.idCosto, a.centroCosto.nombre) from Activo a inner join a.tipoActivo where a.empresa.id = :empresaId and a.fechaCompra <= :fecha");
    query.setLong("empresaId", usuario.getEmpresa().getId());
    query.setDate("fecha", fecha);
    List<Activo> activos = query.list();
    for (Activo activo : activos) {
        log.trace("Depreciando activo {}", activo.getId());
        activo = this.deprecia(activo, fecha);

        Map<String, Object> tipoActivo = (Map<String, Object>) tiposDeActivoMap
                .get(activo.getTipoActivoCuenta());
        BigDecimal acumulada = (BigDecimal) tipoActivo.get("ACUMULADA");
        acumulada = acumulada.add(activo.getDepreciacionAcumulada(), mc);
        tipoActivo.put("ACUMULADA", acumulada);

        BigDecimal totalAcumulada = (BigDecimal) totales.get("ACUMULADA");
        totalAcumulada = totalAcumulada.add(activo.getDepreciacionAcumulada(), mc);
        totales.put("ACUMULADA", totalAcumulada);

        BigDecimal mensual = (BigDecimal) tipoActivo.get("MENSUAL");
        mensual = mensual.add(activo.getDepreciacionMensual(), mc);
        tipoActivo.put("MENSUAL", mensual);

        BigDecimal totalMensual = (BigDecimal) totales.get("MENSUAL");
        totalMensual = totalMensual.add(activo.getDepreciacionMensual(), mc);
        totales.put("MENSUAL", totalMensual);
    }

    if (log.isTraceEnabled()) {
        for (Map<String, Object> tipoActivo : tiposDeActivo) {
            log.trace("TipoActivo: {} : {} : {}", new Object[] { tipoActivo.get("nombre"),
                    tipoActivo.get("ACUMULADA"), tipoActivo.get("MENSUAL") });
        }

        log.trace("Totales: {}", totales);
    }

    params.put("totales", totales);

    return params;
}

From source file:mx.edu.um.mateo.activos.dao.impl.ActivoDaoHibernate.java

@Override
@SuppressWarnings("unchecked")
@Transactional(readOnly = true)/*from  w  w w  .  j a v a 2s.  co m*/
public Map<String, Object> depreciacionAcumuladaPorTipoActivoDetalle(Map<String, Object> params) {
    MathContext mc = new MathContext(16, RoundingMode.HALF_UP);
    Map<String, BigDecimal> totales = new HashMap<>();
    totales.put("ACUMULADA", BigDecimal.ZERO);
    totales.put("MENSUAL", BigDecimal.ZERO);
    totales.put("ANUAL", BigDecimal.ZERO);
    totales.put("NETO", BigDecimal.ZERO);
    Usuario usuario = (Usuario) params.get("usuario");
    String tipoActivoId = (String) params.get("tipoActivoId");
    Date fecha = (Date) params.get("fecha");
    Query query = currentSession().createQuery(
            "select ta from TipoActivo ta where ta.cuenta.id.idCtaMayor = :tipoActivoId and ta.cuenta.id.ejercicio.id.idEjercicio = :ejercicioId and ta.cuenta.id.ejercicio.id.organizacion.id = :organizacionId");
    query.setString("tipoActivoId", tipoActivoId);
    query.setString("ejercicioId", usuario.getEjercicio().getId().getIdEjercicio());
    query.setLong("organizacionId", usuario.getEjercicio().getId().getOrganizacion().getId());
    TipoActivo tipoActivo = (TipoActivo) query.uniqueResult();
    if (tipoActivo != null) {
        params.put("tipoActivo", tipoActivo);
        Criteria criteria = currentSession().createCriteria(Activo.class);
        criteria.add(Restrictions.eq("empresa.id", usuario.getEmpresa().getId()));
        criteria.add(Restrictions.eq("tipoActivo.id", tipoActivo.getId()));
        criteria.add(Restrictions.le("fechaCompra", fecha));
        List<Activo> activos = criteria.list();
        for (Activo activo : activos) {
            log.trace("Depreciando activo {}", activo.getId());
            activo = this.deprecia(activo, fecha);

            BigDecimal total = totales.get("ACUMULADA");
            total = total.add(activo.getDepreciacionAcumulada(), mc);
            totales.put("ACUMULADA", total);

            total = totales.get("MENSUAL");
            total = total.add(activo.getDepreciacionMensual(), mc);
            totales.put("MENSUAL", total);

            total = totales.get("ANUAL");
            total = total.add(activo.getDepreciacionAnual(), mc);
            totales.put("ANUAL", total);

            total = totales.get("NETO");
            total = total.add(activo.getValorNeto(), mc);
            totales.put("NETO", total);
        }
        params.put("activos", activos);
        params.put("totales", totales);

    }
    return params;
}

From source file:mx.edu.um.mateo.activos.dao.impl.ActivoDaoHibernate.java

@Override
@SuppressWarnings("unchecked")
@Transactional(readOnly = true)//from ww w  .jav a  2  s  . com
public Map<String, Object> reporteDIA(Integer anio, Usuario usuario) {
    Map<String, Object> resultado = new HashMap<>();
    Calendar fecha = Calendar.getInstance();
    fecha.setTimeInMillis(0);
    fecha.set(Calendar.DAY_OF_YEAR, 1);
    fecha.set(Calendar.YEAR, anio);
    fecha.set(Calendar.HOUR_OF_DAY, 0);

    Calendar fecha2 = Calendar.getInstance();
    fecha2.setTime(fecha.getTime());
    fecha2.add(Calendar.YEAR, 1);
    log.debug("Armando reporte dia de {} a {}", fecha, fecha2);

    MathContext mc = new MathContext(16, RoundingMode.HALF_UP);
    Map<String, Map<String, Object>> grupos = new TreeMap<>();
    BigDecimal totalCosto = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
    BigDecimal totalCompras = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
    BigDecimal totalBajas = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
    BigDecimal costoFinal = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
    BigDecimal totalDepreciacionAcumulada = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
    BigDecimal totalComprasAcumuladas = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
    BigDecimal totalBajasAcumuladas = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
    BigDecimal totalDepreciacionFinal = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
    BigDecimal valorNeto = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);

    Criteria criteria = currentSession().createCriteria(TipoActivo.class);
    criteria.add(Restrictions.eq("empresa.id", usuario.getEmpresa().getId()));
    List<TipoActivo> tiposDeActivo = criteria.list();
    for (TipoActivo tipoActivo : tiposDeActivo) {
        Map<String, Object> ta = new HashMap<>();
        ta.put("cuenta", tipoActivo.getCuenta().getId().getIdCtaMayor());
        ta.put("nombre", tipoActivo.getNombre());
        ta.put("costo", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP));
        ta.put("compras", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP));
        ta.put("bajas", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP));
        ta.put("costoFinal", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP));
        ta.put("depreciacionAcumulada", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP));
        ta.put("comprasAcumuladas", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP));
        ta.put("bajasAcumuladas", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP));
        ta.put("depreciacionFinal", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP));
        ta.put("valorNeto", BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP));
        grupos.put(tipoActivo.getCuenta().getId().getIdCtaMayor(), ta);
    }

    log.debug("Activos");
    Query query = currentSession().createQuery(
            "select new Activo(a.id, a.version, a.moi, a.fechaCompra, a.tipoActivo.porciento, a.tipoActivo.vidaUtil, a.inactivo, a.fechaInactivo, a.fechaReubicado, a.tipoActivo.cuenta.id.idCtaMayor, a.centroCosto.id.idCosto, a.centroCosto.nombre) "
                    + "from Activo a inner join a.tipoActivo " + "where a.empresa.id = :empresaId "
                    + "and a.fechaCompra <= :fecha " + "and (a.inactivo = false or a.fechaInactivo > :fecha)");
    query.setLong("empresaId", usuario.getEmpresa().getId());
    query.setDate("fecha", fecha.getTime());
    for (Activo activo : (List<Activo>) query.list()) {
        activo = this.deprecia(activo, fecha.getTime());
        Map<String, Object> ta = grupos.get(activo.getTipoActivoCuenta());
        BigDecimal costo = (BigDecimal) ta.get("costo");
        costo = costo.add(activo.getMoi(), mc);
        ta.put("costo", costo);

        BigDecimal depreciacionAcumulada = (BigDecimal) ta.get("depreciacionAcumulada");
        depreciacionAcumulada = depreciacionAcumulada.add(activo.getDepreciacionAcumulada(), mc);
        ta.put("depreciacionAcumulada", depreciacionAcumulada);

        totalCosto = totalCosto.add(activo.getMoi());
        totalDepreciacionAcumulada = totalDepreciacionAcumulada.add(activo.getDepreciacionAcumulada(), mc);

        activo = this.deprecia(activo, fecha2.getTime());
        BigDecimal depreciacionFinal = (BigDecimal) ta.get("depreciacionFinal");
        depreciacionFinal = depreciacionFinal.add(activo.getDepreciacionAcumulada(), mc);
        ta.put("depreciacionFinal", depreciacionFinal);

        totalDepreciacionFinal = totalDepreciacionFinal.add(activo.getDepreciacionAcumulada(), mc);
    }

    // Compras
    query = currentSession().createQuery(
            "select new Activo(a.id, a.version, a.moi, a.fechaCompra, a.tipoActivo.porciento, a.tipoActivo.vidaUtil, a.inactivo, a.fechaInactivo, a.fechaReubicado, a.tipoActivo.cuenta.id.idCtaMayor, a.centroCosto.id.idCosto, a.centroCosto.nombre) "
                    + "from Activo a inner join a.tipoActivo " + "where a.empresa.id = :empresaId "
                    + "and a.fechaCompra between :fecha and :fecha2 "
                    + "and (a.inactivo = false or a.fechaInactivo > :fecha)");
    query.setLong("empresaId", usuario.getEmpresa().getId());
    query.setDate("fecha", fecha.getTime());
    query.setDate("fecha2", fecha2.getTime());
    for (Activo activo : (List<Activo>) query.list()) {
        activo = this.deprecia(activo, fecha.getTime());
        Map<String, Object> ta = grupos.get(activo.getTipoActivoCuenta());
        BigDecimal compras = (BigDecimal) ta.get("compras");
        compras = compras.add(activo.getMoi(), mc);
        ta.put("compras", compras);
        totalCompras = totalCompras.add(activo.getMoi(), mc);

        activo = this.deprecia(activo, fecha2.getTime());
        BigDecimal comprasAcumuladas = (BigDecimal) ta.get("comprasAcumuladas");
        comprasAcumuladas = comprasAcumuladas.add(activo.getDepreciacionAcumulada(), mc);
        ta.put("comprasAcumuladas", comprasAcumuladas);

        totalComprasAcumuladas = totalComprasAcumuladas.add(activo.getDepreciacionAcumulada(), mc);
        totalDepreciacionFinal = totalDepreciacionFinal.add(activo.getDepreciacionAcumulada(), mc);
    }

    // Bajas
    query = currentSession().createQuery(
            "select new Activo(a.id, a.version, a.moi, a.fechaCompra, a.tipoActivo.porciento, a.tipoActivo.vidaUtil, a.inactivo, a.fechaInactivo, a.fechaReubicado, a.tipoActivo.cuenta.id.idCtaMayor, a.centroCosto.id.idCosto, a.centroCosto.nombre) "
                    + "from Activo a inner join a.tipoActivo " + "where a.empresa.id = :empresaId "
                    + "and a.inactivo = true and a.fechaInactivo between :fecha and :fecha2");
    query.setLong("empresaId", usuario.getEmpresa().getId());
    query.setDate("fecha", fecha.getTime());
    query.setDate("fecha2", fecha2.getTime());
    for (Activo activo : (List<Activo>) query.list()) {
        activo = this.deprecia(activo, fecha.getTime());
        Map<String, Object> ta = grupos.get(activo.getTipoActivoCuenta());
        BigDecimal bajas = (BigDecimal) ta.get("bajas");
        bajas = bajas.add(activo.getMoi(), mc);
        ta.put("bajas", bajas);

        BigDecimal bajasAcumuladas = (BigDecimal) ta.get("bajasAcumuladas");
        bajasAcumuladas = bajasAcumuladas.add(activo.getDepreciacionAcumulada(), mc);
        ta.put("bajasAcumuladas", bajasAcumuladas);

        totalBajas = totalBajas.add(activo.getMoi(), mc);
        totalBajasAcumuladas = totalBajasAcumuladas.add(activo.getDepreciacionAcumulada(), mc);
    }

    for (TipoActivo tipoActivo : tiposDeActivo) {
        Map<String, Object> grupo = grupos.get(tipoActivo.getCuenta().getId().getIdCtaMayor());
        BigDecimal costo = (BigDecimal) grupo.get("costo");
        BigDecimal compras = (BigDecimal) grupo.get("compras");
        BigDecimal bajas = (BigDecimal) grupo.get("bajas");
        BigDecimal grupoCostoFinal = costo.add(compras.subtract(bajas, mc), mc);
        grupo.put("costoFinal", grupoCostoFinal);
        costoFinal = costoFinal.add(grupoCostoFinal, mc);

        BigDecimal depreciacionFinal = (BigDecimal) grupo.get("depreciacionFinal");
        BigDecimal depreciacionAcumulada = (BigDecimal) grupo.get("depreciacionAcumulada");
        grupo.put("comprasAcumuladas", depreciacionFinal.subtract(depreciacionAcumulada, mc));
        totalComprasAcumuladas = totalDepreciacionFinal.subtract(totalDepreciacionAcumulada, mc);

        BigDecimal grupoValorNeto = grupoCostoFinal.subtract(depreciacionFinal, mc);
        grupo.put("valorNeto", grupoValorNeto);
        valorNeto = valorNeto.add(grupoValorNeto, mc);
        log.debug("{} : {} : {} : {} : {}", new Object[] { tipoActivo.getNombre(), costoFinal,
                depreciacionFinal, grupoValorNeto, valorNeto });
    }

    resultado.put("lista", grupos.values());
    resultado.put("totalCosto", totalCosto);
    resultado.put("totalCompras", totalCompras);
    resultado.put("totalBajas", totalBajas);
    resultado.put("costoFinal", costoFinal);
    resultado.put("totalDepreciacionAcumulada", totalDepreciacionAcumulada);
    resultado.put("totalComprasAcumuladas", totalComprasAcumuladas);
    resultado.put("totalBajasAcumuladas", totalBajasAcumuladas);
    resultado.put("totalDepreciacionFinal", totalDepreciacionFinal);
    resultado.put("valorNeto", valorNeto);
    return resultado;
}

From source file:org.wso2.carbon.appmgt.impl.utils.AppManagerUtil.java

/**
 * This method used to get WebApp from governance artifact specific to
 * copyAPI//from w  w  w  .j a va 2s. c o m
 * 
 * @param artifact
 *            WebApp artifact
 * @param registry
 *            Registry
 * @return WebApp
 * @throws org.wso2.carbon.appmgt.api.AppManagementException
 *             if failed to get WebApp from artifact
 */
public static WebApp getAPI(GovernanceArtifact artifact, Registry registry, APIIdentifier oldId)
        throws AppManagementException {

    WebApp api;
    try {
        String providerName = artifact.getAttribute(AppMConstants.API_OVERVIEW_PROVIDER);
        String apiName = artifact.getAttribute(AppMConstants.API_OVERVIEW_NAME);
        String apiVersion = artifact.getAttribute(AppMConstants.API_OVERVIEW_VERSION);
        api = new WebApp(new APIIdentifier(providerName, apiName, apiVersion));
        // set rating
        String artifactPath = GovernanceUtils.getArtifactPath(registry, artifact.getId());
        BigDecimal bigDecimal = new BigDecimal(registry.getAverageRating(artifactPath));
        BigDecimal res = bigDecimal.setScale(1, RoundingMode.HALF_UP);
        api.setRating(res.floatValue());
        // set description
        api.setDescription(artifact.getAttribute(AppMConstants.API_OVERVIEW_DESCRIPTION));
        // set last access time
        api.setLastUpdated(registry.get(artifactPath).getLastModified());
        // set url
        api.setUrl(artifact.getAttribute(AppMConstants.API_OVERVIEW_ENDPOINT_URL));
        api.setLogoutURL(artifact.getAttribute(AppMConstants.API_OVERVIEW_LOGOUT_URL));
        api.setSandboxUrl(artifact.getAttribute(AppMConstants.API_OVERVIEW_SANDBOX_URL));
        api.setStatus(getApiStatus(artifact.getAttribute(AppMConstants.API_OVERVIEW_STATUS)));
        api.setThumbnailUrl(artifact.getAttribute(AppMConstants.API_OVERVIEW_THUMBNAIL_URL));
        api.setWsdlUrl(artifact.getAttribute(AppMConstants.API_OVERVIEW_WSDL));
        api.setWadlUrl(artifact.getAttribute(AppMConstants.API_OVERVIEW_WADL));
        api.setTechnicalOwner(artifact.getAttribute(AppMConstants.API_OVERVIEW_TEC_OWNER));
        api.setTechnicalOwnerEmail(artifact.getAttribute(AppMConstants.API_OVERVIEW_TEC_OWNER_EMAIL));
        api.setBusinessOwner(artifact.getAttribute(AppMConstants.API_OVERVIEW_BUSS_OWNER));
        api.setBusinessOwnerEmail(artifact.getAttribute(AppMConstants.API_OVERVIEW_BUSS_OWNER_EMAIL));
        api.setEndpointSecured(
                Boolean.parseBoolean(artifact.getAttribute(AppMConstants.API_OVERVIEW_ENDPOINT_SECURED)));
        api.setEndpointUTUsername(artifact.getAttribute(AppMConstants.API_OVERVIEW_ENDPOINT_USERNAME));
        api.setEndpointUTPassword(artifact.getAttribute(AppMConstants.API_OVERVIEW_ENDPOINT_PASSWORD));
        api.setTransports(artifact.getAttribute(AppMConstants.API_OVERVIEW_TRANSPORTS));

        api.setEndpointConfig(artifact.getAttribute(AppMConstants.API_OVERVIEW_ENDPOINT_CONFIG));

        api.setRedirectURL(artifact.getAttribute(AppMConstants.API_OVERVIEW_REDIRECT_URL));
        api.setAppOwner(artifact.getAttribute(AppMConstants.API_OVERVIEW_OWNER));
        api.setAdvertiseOnly(
                Boolean.parseBoolean(artifact.getAttribute(AppMConstants.API_OVERVIEW_ADVERTISE_ONLY)));

        api.setSubscriptionAvailability(
                artifact.getAttribute(AppMConstants.API_OVERVIEW_SUBSCRIPTION_AVAILABILITY));
        api.setSubscriptionAvailableTenants(
                artifact.getAttribute(AppMConstants.API_OVERVIEW_SUBSCRIPTION_AVAILABLE_TENANTS));

        api.setResponseCache(artifact.getAttribute(AppMConstants.API_OVERVIEW_RESPONSE_CACHING));

        api.setSsoEnabled(artifact.getAttribute("sso_enableSso"));
        api.setUUID(artifact.getId());
        api.setThumbnailUrl(artifact.getAttribute(AppMConstants.APP_IMAGES_THUMBNAIL));

        int cacheTimeout = AppMConstants.API_RESPONSE_CACHE_TIMEOUT;
        try {
            cacheTimeout = Integer.parseInt(artifact.getAttribute(AppMConstants.API_OVERVIEW_CACHE_TIMEOUT));
        } catch (NumberFormatException e) {
            // ignore
        }

        String tenantDomainName = MultitenantUtils.getTenantDomain(replaceEmailDomainBack(providerName));
        int tenantId = ServiceReferenceHolder.getInstance().getRealmService().getTenantManager()
                .getTenantId(tenantDomainName);

        Set<Tier> availableTier = new HashSet<Tier>();
        String tiers = artifact.getAttribute(AppMConstants.API_OVERVIEW_TIER);
        Map<String, Tier> definedTiers = getTiers(tenantId);
        if (tiers != null && !"".equals(tiers)) {
            String[] tierNames = tiers.split("\\|\\|");
            for (String tierName : tierNames) {
                Tier definedTier = definedTiers.get(tierName);
                if (definedTier != null) {
                    availableTier.add(definedTier);
                } else {
                    log.warn("Unknown tier: " + tierName + " found on WebApp: " + apiName);
                }
            }
        }
        api.addAvailableTiers(availableTier);
        api.setContext(artifact.getAttribute(AppMConstants.API_OVERVIEW_CONTEXT));
        api.setLatest(Boolean.valueOf(artifact.getAttribute(AppMConstants.API_OVERVIEW_IS_LATEST)));
        ArrayList<URITemplate> urlPatternsList;

        urlPatternsList = AppMDAO.getAllURITemplates(api.getContext(), oldId.getVersion());
        Set<URITemplate> uriTemplates = new HashSet<URITemplate>(urlPatternsList);

        for (URITemplate uriTemplate : uriTemplates) {
            uriTemplate.setResourceURI(api.getUrl());
            uriTemplate.setResourceSandboxURI(api.getSandboxUrl());

        }
        api.setUriTemplates(uriTemplates);

        Set<String> tags = new HashSet<String>();
        org.wso2.carbon.registry.core.Tag[] tag = registry.getTags(artifactPath);
        for (Tag tag1 : tag) {
            tags.add(tag1.getTagName());
        }
        api.addTags(tags);
        api.setLastUpdated(registry.get(artifactPath).getLastModified());

        //Set Lifecycle status
        if (artifact.getLifecycleState() != null && artifact.getLifecycleState() != "") {
            if (artifact.getLifecycleState().toUpperCase().equalsIgnoreCase(APIStatus.INREVIEW.getStatus())) {
                api.setLifeCycleStatus(APIStatus.INREVIEW);
            } else {
                api.setLifeCycleStatus(APIStatus.valueOf(artifact.getLifecycleState().toUpperCase()));
            }
        }
        api.setLifeCycleName(artifact.getLifecycleName());

    } catch (GovernanceException e) {
        String msg = "Failed to get WebApp fro artifact ";
        throw new AppManagementException(msg, e);
    } catch (RegistryException e) {
        String msg = "Failed to get LastAccess time or Rating";
        throw new AppManagementException(msg, e);
    } catch (UserStoreException e) {
        String msg = "Failed to get User Realm of WebApp Provider";
        throw new AppManagementException(msg, e);
    }
    return api;
}

From source file:org.oscm.serviceprovisioningservice.bean.ServiceProvisioningServiceBean.java

/**
 * Loop through the list of stepped prices and update the values for free
 * amount and additional price (the limit of the predecessor defines the
 * values).// w  w  w  . ja  va 2  s  . co  m
 * 
 * @param list
 *            the list to update
 */
void updateFreeAmountAndAdditionalPrice(List<SteppedPrice> list) {

    Collections.sort(list, new SteppedPriceComparator());
    int size = list.size();
    for (int i = 1; i < size; i++) {
        SteppedPrice prevStep = list.get(i - 1);
        if (prevStep.getLimit() == null) {
            list.get(i).setFreeEntityCount(0);
            list.get(i).setAdditionalPrice(BigDecimal.ZERO.setScale(PriceConverter.NORMALIZED_PRICE_SCALING));
        } else {
            list.get(i).setFreeEntityCount(prevStep.getLimit().longValue());
            list.get(i)
                    .setAdditionalPrice((BigDecimal.valueOf(prevStep.getLimit().longValue())
                            .subtract(BigDecimal.valueOf(prevStep.getFreeEntityCount())))
                                    .multiply(prevStep.getPrice()).add(prevStep.getAdditionalPrice())
                                    .setScale(PriceConverter.NORMALIZED_PRICE_SCALING, RoundingMode.HALF_UP));
        }
    }
    if (size > 0) {
        list.get(0).setFreeEntityCount(0);
        list.get(0).setAdditionalPrice(BigDecimal.ZERO.setScale(PriceConverter.NORMALIZED_PRICE_SCALING));
        list.get(size - 1).setLimit(null);
    }

}

From source file:org.kuali.coeus.propdev.impl.print.NIHResearchAndRelatedXmlStream.java

private BigDecimal calculateFundingMonths(DevelopmentProposal developmentProposal,
        BudgetPersonnelDetails budgetPersonnelDetails, String budgetPeriodType) {
    BigDecimal fundingMonths = ScaleTwoDecimal.ZERO.bigDecimalValue();
    if (personExistsInProposal(developmentProposal, budgetPersonnelDetails)
            && budgetPeriodType.equals(budgetPersonnelDetails.getPeriodTypeCode())) {
        if (budgetPersonnelDetails != null) {
            BigDecimal totalMonths = getMonthsBetweenDates(budgetPersonnelDetails.getStartDate(),
                    budgetPersonnelDetails.getEndDate());
            fundingMonths = budgetPersonnelDetails.getPercentEffort().bigDecimalValue()
                    .multiply(new ScaleTwoDecimal(totalMonths).bigDecimalValue());
            fundingMonths = fundingMonths.divide(new ScaleTwoDecimal(100).bigDecimalValue(),
                    RoundingMode.HALF_UP);
        }/*from   w  w w.j a  v a 2s . c  om*/
    }
    return fundingMonths.setScale(0);
}

From source file:com.sdcs.courierbooking.service.UserServiceImpl.java

@Override
public String paymentUpdate(String restaurantId) {
    // TODO Auto-generated method stub

    JSONObject deliveredList = new JSONObject();

    ResultSet updatePaymentDetails = userDao.paymentUpdate(restaurantId);

    Timestamp name = null;//from  ww w.j av a  2  s  . co  m

    String name2 = "0";

    int number = 0;

    double damount = 0.00;
    double totalamount = 0.00;
    double tamount1 = 0.00;

    String address = "0";

    String lastbookingid = "";

    String rest_name = "";

    String phone = "0";
    int trackingId = 0;

    String date = "";
    if (updatePaymentDetails != null) {
        try {

            JSONArray couriersArray = new JSONArray();
            while (updatePaymentDetails.next()) {

                JSONObject couriersObject = new JSONObject();

                name = updatePaymentDetails.getTimestamp("time_of_booking");
                String amounta = updatePaymentDetails.getString("total_amount");

                address = updatePaymentDetails.getString("restaurant_address");

                phone = updatePaymentDetails.getString("restaurant_contact");

                trackingId = updatePaymentDetails.getInt("booking_id");
                lastbookingid = "" + trackingId;
                rest_name = updatePaymentDetails.getString("restaurant_name");

                damount = Double.parseDouble(amounta);
                /*   extraDistance = updatePaymentDetails.getDouble("extra_distance");
                        
                */ String DATE_FORMAT = "yyyy/MM/dd";
                SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);

                date = sdf.format(name);

                if (date.equals(name2)) {

                    tamount1 = damount + tamount1;

                    number = number + 1;
                } else if (name2 != "0") {

                    couriersObject.put("time_of_booking", name2);

                    couriersObject.put("number_of_couriers", number);

                    couriersObject.put("amount", totalamount);
                    couriersObject.put("tracking_number", lastbookingid);

                    couriersArray.put(couriersObject);
                    totalamount += tamount1;
                    tamount1 = damount;

                    number = 1;

                    name2 = date;

                } else {

                    tamount1 = damount;

                    number = 1;

                    name2 = date;

                }

            }
            JSONObject couriersObject = new JSONObject();

            couriersObject.put("time_of_booking", rest_name);

            couriersObject.put("number_of_couriers", number);

            double roundOff1 = Math.round(tamount1 * 100.0) / 100.0;

            couriersObject.put("amount", roundOff1);

            couriersArray.put(couriersObject);
            totalamount += tamount1;
            String referenceNumber = "" + trackingId;
            deliveredList.put("result", true);
            deliveredList.put("all_couriers", couriersArray);
            Date date1 = new Date();
            String referenceNo = "00" + trackingId + date1.getTime();

            deliveredList.put("account_id", SdcsPaymentGatewayConstants.ACCOUNT_ID);
            deliveredList.put("address", address);
            double roundOff = Math.round(totalamount * 100.0) / 100.0;
            deliveredList.put("amount", roundOff);
            //newBookingJsonData.put("amount", "13.0");
            deliveredList.put("channel", SdcsPaymentGatewayConstants.CHANNEL);
            deliveredList.put("city", lastbookingid);
            deliveredList.put("country", SdcsPaymentGatewayConstants.COUNTRY);
            deliveredList.put("currency", SdcsPaymentGatewayConstants.CURRENCY);
            deliveredList.put("description", "Make payment for new courier");
            deliveredList.put("email", "manjunathdl@gmail.com");
            deliveredList.put("mode", SdcsPaymentGatewayConstants.MODE);
            deliveredList.put("name", rest_name);
            deliveredList.put("page_id", "2197");
            deliveredList.put("phone", phone);
            deliveredList.put("postal_code", "560072");
            deliveredList.put("reference_no", referenceNo);
            deliveredList.put("return_url", SdcsPaymentGatewayConstants.RETURN_URL);
            deliveredList.put("state", "Karnataka");

            String md5HashData = SdcsPaymentGatewayConstants.SECRET_KEY + "|"
                    + SdcsPaymentGatewayConstants.ACCOUNT_ID + "|" + address + "|" + roundOff
                    //+ "|" + "13.0" 
                    + "|" + SdcsPaymentGatewayConstants.CHANNEL + "|" + lastbookingid + "|"
                    + SdcsPaymentGatewayConstants.COUNTRY + "|" + SdcsPaymentGatewayConstants.CURRENCY + "|"
                    + "Make payment for new courier" + "|" + "manjunathdl@gmail.com" + "|"
                    + SdcsPaymentGatewayConstants.MODE + "|" + rest_name + "|" + "2197" + "|" + phone + "|"
                    + "560072" + "|" + referenceNo + "|" + SdcsPaymentGatewayConstants.RETURN_URL + "|"
                    + "Karnataka";

            String UserId = "ff";

            System.out.println("Values Before Hashing:" + md5HashData);

            SdcsPersistantValues.setPersistantValues(rest_name, "manjunathdl@gmail.com", phone, trackingId + "",
                    UserId);

            deliveredList.put("hash_values", md5HashData);

            String hasedValue;
            try {
                hasedValue = SdcsHashProvider.generateMd5Hash(md5HashData);
                deliveredList.put("secure_hash", hasedValue);
                System.out.println("Values After Hashing:" + hasedValue);
            } catch (NoSuchAlgorithmException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            /*String referenceNo = "00"+ trackingId+ date1.getTime();
                    
            deliveredList.put("account_id", SdcsPaymentGatewayConstants.ACCOUNT_ID);
            deliveredList.put("address",address );
            //deliveredList.put("amount", ""+tamount);
            couriersObject.put("amount", "130.0");
            deliveredList.put("channel", SdcsPaymentGatewayConstants.CHANNEL);
            deliveredList.put("city","bangalore");
            deliveredList.put("country", SdcsPaymentGatewayConstants.COUNTRY);
            deliveredList.put("currency", SdcsPaymentGatewayConstants.CURRENCY);
            deliveredList.put("description", "Make payment for new courier");
            deliveredList.put("email", "manjunathdl@gmail.com");
            deliveredList.put("mode", SdcsPaymentGatewayConstants.MODE);
            deliveredList.put("name", rest_name);
            deliveredList.put("page_id", "2197");
            deliveredList.put("phone", phone);
            deliveredList.put("postal_code", "560072");
            deliveredList.put("reference_no", referenceNo);
            deliveredList.put("return_url", SdcsPaymentGatewayConstants.RETURN_URL);
            deliveredList.put("state", "temple");
                    
                    
            String md5HashData = SdcsPaymentGatewayConstants.SECRET_KEY
                   + "|" + SdcsPaymentGatewayConstants.ACCOUNT_ID
                   + "|" + address
                   + "|" + "130.0"
                   + "|" + SdcsPaymentGatewayConstants.CHANNEL
                   + "|" + "temple"
                   + "|" + SdcsPaymentGatewayConstants.COUNTRY
                   + "|" + SdcsPaymentGatewayConstants.CURRENCY
                   + "|" + "Make payment for new courier"
                   + "|" + "manjunathdl@gmail.com"
                   + "|" + SdcsPaymentGatewayConstants.MODE
                   + "|" + rest_name
                   + "|" + "2197"
                   + "|" + phone
                   + "|" + "560072"
                   + "|" + referenceNo
                   + "|" + SdcsPaymentGatewayConstants.RETURN_URL
                   + "|" + "temple";
                    
                    
            SdcsPersistantValues.setPersistantValues(rest_name,"sdcs.info24@gmail.com", phone,trackingId+"", "Courier");
                    
            deliveredList.put("hash_values", md5HashData);
                           
            String hasedValue;
            try {
               hasedValue = SdcsHashProvider.generateMd5Hash(md5HashData);
               deliveredList.put("secure_hash", hasedValue);
                       
            } catch (NoSuchAlgorithmException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
            }*/

            System.out.println(md5HashData);

            DecimalFormat df = new DecimalFormat("#.##");
            df.setRoundingMode(RoundingMode.HALF_UP);
            String tamount2 = df.format(totalamount); // 0.91239

            deliveredList.put("total_Amount", tamount2);
            deliveredList.put("refferenceId", referenceNumber);

        } catch (SQLException e) {
            deliveredList.put("result", false);

            try {
                updatePaymentDetails.close();
            } catch (SQLException sqlEx) {
                System.out.println("Exception in QuickHistoryServerImpl");

            }

        } finally {
            try {
                updatePaymentDetails.close();
            } catch (SQLException e) {
                System.out.println("Exception in QuickHistoryServerImpl");
            }
        }

    } else {
        deliveredList.put("result", false);
    }

    return deliveredList.toString();
}

From source file:org.kuali.ole.select.document.service.impl.OleInvoiceServiceImpl.java

public OleInvoiceDocument populateInvoiceDocument(OleInvoiceDocument invoiceDocument) {
    Boolean isItemLevelDebit = null;
    Boolean isAdditionalChargeLevelDebit = null;
    Boolean isItemLevelCredit = null;
    Boolean isAdditionalChargeLevelCredit = null;
    if (invoiceDocument.getPurchaseOrderDocuments() != null
            && invoiceDocument.getPurchaseOrderDocuments().size() > 0) {
        for (OleInvoiceItem invoiceItem : (List<OleInvoiceItem>) invoiceDocument.getItems()) {
            if (invoiceItem.getItemType().isAdditionalChargeIndicator()
                    && invoiceItem.getItemUnitPrice() != null)
                invoiceItem.setPurchaseOrderIdentifier(
                        invoiceDocument.getPurchaseOrderDocuments().get(0).getPurapDocumentIdentifier());
        }/* ww  w .j a v  a 2s.c o m*/
    }
    Integer poIdentifier = null;
    for (OleInvoiceItem invoiceItem : (List<OleInvoiceItem>) invoiceDocument.getItems()) {
        if (invoiceItem.isDebitItem()
                && (invoiceItem.getItemListPrice().isNonZero() || (invoiceItem.getItemUnitPrice() != null
                        && invoiceItem.getItemUnitPrice().compareTo(BigDecimal.ZERO) != 0))) {
            if (invoiceItem.getItemType().isQuantityBasedGeneralLedgerIndicator()) {
                if (isItemLevelDebit == null) {
                    isItemLevelDebit = true;
                }
                isItemLevelDebit &= invoiceItem.isDebitItem();
            }
            if (invoiceItem.getItemType().isAdditionalChargeIndicator()) {
                if (isAdditionalChargeLevelDebit == null) {
                    isAdditionalChargeLevelDebit = true;
                }
                isAdditionalChargeLevelDebit &= invoiceItem.isDebitItem();
            }

        } else if (!invoiceItem.isDebitItem()
                && (invoiceItem.getItemListPrice().isNonZero() || (invoiceItem.getItemUnitPrice() != null
                        && invoiceItem.getItemUnitPrice().compareTo(BigDecimal.ZERO) != 0))) {
            if (invoiceItem.getItemType().isQuantityBasedGeneralLedgerIndicator()) {
                if (isItemLevelCredit == null) {
                    isItemLevelCredit = true;
                }
                isItemLevelCredit &= !invoiceItem.isDebitItem();
            }
            if (invoiceItem.getItemType().isAdditionalChargeIndicator()) {
                if (isAdditionalChargeLevelCredit == null) {
                    isAdditionalChargeLevelCredit = true;
                }
                isAdditionalChargeLevelCredit &= !invoiceItem.isDebitItem();
            }
        }
        if (invoiceItem.getItemType().isQuantityBasedGeneralLedgerIndicator()
                && invoiceItem.getItemListPrice().isNonZero() && poIdentifier == null) {
            poIdentifier = invoiceItem.getPurchaseOrderIdentifier();
        }
    }
    boolean flag = (isItemLevelDebit == null && isAdditionalChargeLevelDebit != null
            && isAdditionalChargeLevelDebit)
            || (isAdditionalChargeLevelDebit == null && isItemLevelDebit != null && isItemLevelDebit)
            || (isItemLevelCredit == null && isAdditionalChargeLevelCredit != null
                    && isAdditionalChargeLevelCredit)
            || (isAdditionalChargeLevelCredit == null && isItemLevelCredit != null && isItemLevelCredit)
                    && !(isItemLevelCredit != null && isItemLevelCredit && isItemLevelDebit != null
                            && isItemLevelDebit);
    if (!flag) {
        Integer poIdentifierForCredit = null;
        Integer poIdentifierForDebit = null;
        if (invoiceDocument.getItems() != null && invoiceDocument.getItems().size() > 0) {
            for (OleInvoiceItem invoiceItem : (List<OleInvoiceItem>) invoiceDocument.getItems()) {
                if (invoiceItem.getItemType().isQuantityBasedGeneralLedgerIndicator()
                        && invoiceItem.isDebitItem() && invoiceItem.getItemListPrice().isNonZero()) {
                    poIdentifierForDebit = invoiceItem.getPurchaseOrderIdentifier();
                    break;
                }
            }
        }
        if (invoiceDocument.getItems() != null && invoiceDocument.getItems().size() > 0) {
            for (OleInvoiceItem invoiceItem : (List<OleInvoiceItem>) invoiceDocument.getItems()) {
                if (invoiceItem.getItemType().isQuantityBasedGeneralLedgerIndicator()
                        && !invoiceItem.isDebitItem() && invoiceItem.getItemListPrice().isNonZero()) {
                    poIdentifierForCredit = invoiceItem.getPurchaseOrderIdentifier();
                    break;
                }
            }
        }

        //if (invoiceDocument.getPurchaseOrderDocuments() != null && invoiceDocument.getPurchaseOrderDocuments().size() > 0) {
        for (OleInvoiceItem invoiceItem : (List<OleInvoiceItem>) invoiceDocument.getItems()) {
            if (invoiceItem.getItemType().isAdditionalChargeIndicator()
                    && invoiceItem.getItemUnitPrice() != null && invoiceItem.isDebitItem()) {
                invoiceItem.setPurchaseOrderIdentifier(poIdentifierForDebit);
            }
            if (invoiceItem.getItemType().isAdditionalChargeIndicator()
                    && invoiceItem.getItemUnitPrice() != null && !invoiceItem.isDebitItem()) {
                invoiceItem.setPurchaseOrderIdentifier(poIdentifierForCredit);
            }
        }
    } else {
        for (OleInvoiceItem invoiceItem : (List<OleInvoiceItem>) invoiceDocument.getItems()) {
            if (invoiceItem.getItemType().isAdditionalChargeIndicator()
                    && invoiceItem.getItemUnitPrice() != null) {
                invoiceItem.setPurchaseOrderIdentifier(poIdentifier);
            }
        }
    }
    //}

    invoiceDocument.setInvoicePayDate(
            calculatePayDate(invoiceDocument.getInvoiceDate(), invoiceDocument.getVendorPaymentTerms()));
    //invoiceDocument.setTotalDollarAmount(invoiceDocument.getTotalDollarAmount().add(po.getTotalDollarAmount()));

    if (invoiceDocument.getInvoiceTypeHdnId() != null && !invoiceDocument.getInvoiceTypeHdnId().isEmpty()) {
        invoiceDocument.setInvoiceTypeId(Integer.valueOf(invoiceDocument.getInvoiceTypeHdnId()));
    }
    if (invoiceDocument.getPaymentMethodIdentifier() != null
            && !invoiceDocument.getPaymentMethodIdentifier().isEmpty()) {
        invoiceDocument.setPaymentMethodId(Integer.valueOf(invoiceDocument.getPaymentMethodIdentifier()));
    }
    if (invoiceDocument.getInvoiceSubTypeHdnId() != null
            && !invoiceDocument.getInvoiceSubTypeHdnId().isEmpty()) {
        invoiceDocument.setInvoiceSubTypeId(Integer.valueOf(invoiceDocument.getInvoiceSubTypeHdnId()));
    }

    if (invoiceDocument.getInvoiceAmount() != null && !invoiceDocument.getInvoiceAmount().isEmpty()) {
        invoiceDocument.setVendorInvoiceAmount(new KualiDecimal(invoiceDocument.getInvoiceAmount()));
    }

    if (invoiceDocument.getForeignInvoiceAmount() != null
            && !invoiceDocument.getForeignInvoiceAmount().isEmpty()) {
        invoiceDocument.setForeignVendorInvoiceAmount(
                new KualiDecimal(invoiceDocument.getForeignInvoiceAmount()).bigDecimalValue());
        if (StringUtils.isNotBlank(invoiceDocument.getInvoiceCurrencyType())) {
            if (StringUtils.isNotBlank(invoiceDocument.getInvoiceCurrencyExchangeRate())) {
                try {
                    Double.parseDouble(invoiceDocument.getInvoiceCurrencyExchangeRate());
                } catch (NumberFormatException nfe) {
                    throw new RuntimeException("Invalid Exchange Rate", nfe);
                }
                invoiceDocument
                        .setVendorInvoiceAmount(new KualiDecimal(invoiceDocument.getForeignVendorInvoiceAmount()
                                .divide(new BigDecimal(invoiceDocument.getInvoiceCurrencyExchangeRate()), 4,
                                        RoundingMode.HALF_UP)));
                invoiceDocument.setInvoiceAmount(invoiceDocument.getVendorInvoiceAmount().toString());
            } else {
                BigDecimal exchangeRate = getExchangeRate(invoiceDocument.getInvoiceCurrencyType())
                        .getExchangeRate();
                invoiceDocument.setVendorInvoiceAmount(new KualiDecimal(invoiceDocument
                        .getForeignVendorInvoiceAmount().divide(exchangeRate, 4, RoundingMode.HALF_UP)));
                invoiceDocument.setInvoiceAmount(invoiceDocument.getVendorInvoiceAmount().toString());
            }

        }
    }

    Bank defaultBank = SpringContext.getBean(BankService.class)
            .getDefaultBankByDocType(invoiceDocument.getClass());
    if (defaultBank != null) {
        invoiceDocument.setBankCode(defaultBank.getBankCode());
        invoiceDocument.setBank(defaultBank);
    }

    invoiceDocument.setInvoicePayDate(
            this.calculatePayDate(invoiceDocument.getInvoiceDate(), invoiceDocument.getVendorPaymentTerms()));

    /* invoice total */

    BigDecimal addChargeItem = BigDecimal.ZERO;
    List<OleInvoiceItem> item = invoiceDocument.getItems();
    for (OleInvoiceItem invoiceditem : item) {
        if (invoiceditem.getItemType().isAdditionalChargeIndicator()
                && invoiceditem.getExtendedPrice() != null) {
            addChargeItem = addChargeItem.add(invoiceditem.getExtendedPrice().bigDecimalValue());
        }
    }
    if (invoiceDocument.getTotalDollarAmount() != null) {
        invoiceDocument.setInvoiceItemTotal(
                invoiceDocument.getTotalDollarAmount().subtract(new KualiDecimal(addChargeItem)).toString());
        invoiceDocument.setDocumentTotalAmount(invoiceDocument.getTotalDollarAmount().toString());
    }
    return invoiceDocument;
}