Example usage for java.math BigDecimal add

List of usage examples for java.math BigDecimal add

Introduction

In this page you can find the example usage for java.math BigDecimal add.

Prototype

public BigDecimal add(BigDecimal augend) 

Source Link

Document

Returns a BigDecimal whose value is (this + augend) , and whose scale is max(this.scale(), augend.scale()) .

Usage

From source file:org.kuali.coeus.s2sgen.impl.generate.support.SF424V1_0Generator.java

/**
 * //from w  w w  . j  av  a 2 s .  c om
 * This method get budget informations.Budget informations includes
 * FederalEstimatedAmount,LocalEstimatedAmount
 * ProgramIncomeEstimatedAmount,OtherEstimatedAmount and
 * TotalEstimatedAmount
 *
 * @return Budget total estimated budget details.
 */
private Budget getBudget() throws S2SException {

    Budget budget = Budget.Factory.newInstance();
    CurrencyCodeType.Enum currencyEnum = CurrencyCodeType.USD;
    budget.setCurrencyCode(currencyEnum);
    budget.setFederalEstimatedAmount(BigDecimal.ZERO);
    budget.setTotalEstimatedAmount(BigDecimal.ZERO);

    ProposalDevelopmentBudgetExtContract pBudget = s2SCommonBudgetService
            .getBudget(pdDoc.getDevelopmentProposal());

    if (pBudget != null) {
        budget.setFederalEstimatedAmount(pBudget.getTotalCost().bigDecimalValue());
        budget.setApplicantEstimatedAmount(pBudget.getCostSharingAmount().bigDecimalValue());
        // Following values hardcoded as in coeus
        budget.setStateEstimatedAmount(BigDecimal.ZERO);
        budget.setLocalEstimatedAmount(BigDecimal.ZERO);
        budget.setOtherEstimatedAmount(BigDecimal.ZERO);
        BigDecimal projectIncome = BigDecimal.ZERO;
        for (BudgetProjectIncomeContract budgetProjectIncome : pBudget.getBudgetProjectIncomes()) {
            if (budgetProjectIncome.getProjectIncome() != null) {
                projectIncome = projectIncome.add(budgetProjectIncome.getProjectIncome().bigDecimalValue());
            }
        }
        budget.setProgramIncomeEstimatedAmount(projectIncome);
        ScaleTwoDecimal totalEstimatedAmount = ScaleTwoDecimal.ZERO;
        if (pBudget.getTotalCost() != null) {
            totalEstimatedAmount = totalEstimatedAmount.add(pBudget.getTotalCost());
        }
        if (pBudget.getCostSharingAmount() != null) {
            totalEstimatedAmount = totalEstimatedAmount.add(pBudget.getCostSharingAmount());
        }
        budget.setTotalEstimatedAmount(totalEstimatedAmount.bigDecimalValue().add(projectIncome));
    }
    return budget;
}

From source file:br.com.hslife.orcamento.controller.ArquivoController.java

public String find() {
    initializeEntity();//from   w  w  w  .j av  a2  s .com

    // Invoca o Garbage Collector
    System.gc();

    try {
        criterio.setUsuario(getUsuarioLogado());
        listEntity = getService().buscarPorCriterioArquivo(criterio);

        // Varivel que contabiliza quantos arquivos podem ser descartados
        int quantDescartar = 0;
        BigDecimal bytesALiberar = new BigDecimal(0);

        // Calcula o espao ocupado e injeta as opes do sistema nas entidades
        espacoOcupado = new BigDecimal(0);
        Map<String, Integer> opcoesSistema = getOpcoesSistema().getOpcoesArquivosAnexados(getUsuarioLogado());
        for (Arquivo a : listEntity) {
            espacoOcupado = espacoOcupado.add(new BigDecimal(a.getTamanho()));
            a.setOpcoesSistema(opcoesSistema);
            if (a.isPrazoExpirado()) {
                quantDescartar++;
                bytesALiberar = bytesALiberar.add(new BigDecimal(a.getTamanho()));
            }
        }

        // Retorna uma mensagem informando quandos arquivos podem ser excludos
        if (quantDescartar != 0) {
            warnMessage(quantDescartar + " arquivo(s) pode(m) ser descartado(s), liberando "
                    + new DecimalFormat("#,##0.##").format(bytesALiberar) + " bytes no disco.");
        }
    } catch (ValidationException | BusinessException be) {
        errorMessage(be.getMessage());
    }

    return "";
}

From source file:com.etiansoft.haier.service.ManagerService.java

/**
 * // w w w .  ja  va  2 s .  c  o m
 * @Title: ???
 * @Description: TODO
 * @param @param page
 * @param @param name
 * @param @param phone
 * @param @param status
 * @param @return
 * @param @throws Exception
 * @return DataTablePage
 * @throws
 */
public DataTablePage getData(DataTablePage page, String name, String phone, String status, String merchant_num,
        String order_id) throws Exception {
    DataTablePage dataTable = null;

    dataTable = udsService.findPage(page, Merchant.class, MerchantVo.class, tableName, "create_date", "desc",
            makeParam(name, phone, status, merchant_num));

    List<MerchantVo> datas = (List<MerchantVo>) dataTable.getAaData();

    for (MerchantVo dataMerchant : datas) {
        Map<String, Object> mapm = new HashMap<String, Object>();
        mapm.put("merchant_id", dataMerchant.getMerchantId());
        List<Order> listm = (List<Order>) udsService.findByTimeForOrder2("order", Order.class, mapm);

        BigDecimal num = new BigDecimal(0);

        if (listm != null && listm.size() > 0) {
            for (Order or : listm) {
                if (or.getStatus().intValue() == 2 || or.getStatus().intValue() == 3
                        || or.getStatus().intValue() == 4 || or.getStatus().intValue() == 5) {
                    num = num.add(new BigDecimal(or.getFavored_amount()).add(new BigDecimal(or.getFreight())));
                }
            }
        }
        dataMerchant.setSaleVolum(num.setScale(2, RoundingMode.HALF_UP).doubleValue());
        Mpromotion promotion = (Mpromotion) udsService.findById("mpromotion", "merchant_id_",
                dataMerchant.getMerchantId(), Mpromotion.class);
        if (promotion != null) {
            dataMerchant.setPromotion_sort(promotion.getSort());
            dataMerchant.setPromotion_tag(promotion.getPromotion_tag());
        }

    }

    return dataTable;

}

From source file:com.ocs.dynamo.ui.composite.table.CustomTreeTable.java

/**
 * Updates a calculated field in response to a change
 * // w w w .  j  a  v a2  s  .c  om
 * @param rowId
 *            the ID of the row to update
 * @param propertyId
 *            the property ID
 * @param delta
 *            the change
 */
private void updateTableField(String rowId, String propertyId, BigDecimal delta) {
    Number value = (Number) getItem(rowId).getItemProperty(propertyId).getValue();
    BigDecimal bd = value == null ? BigDecimal.ZERO : toBigDecimal(value);
    bd = bd.add(delta);
    getItem(rowId).getItemProperty(propertyId).setValue(convertNumber(bd, propertyId));
}

From source file:com.salesmanager.core.module.impl.application.shipping.CalculateBoxPackingModule.java

public Collection<PackageDetail> calculatePacking(Collection<OrderProduct> products,
        MerchantConfiguration config, int merchantId) throws Exception {

    if (products == null) {
        throw new Exception("Product list cannot be null !!");
    }/*from  w  w  w.  j a va2s  .  com*/

    double width = 0;
    double length = 0;
    double height = 0;
    double weight = 0;
    double maxweight = 0;

    int treshold = 0;

    // get box details from merchantconfiguration
    String values = config.getConfigurationValue1();
    if (!StringUtils.isBlank(values)) {
        StringTokenizer st = new StringTokenizer(config.getConfigurationValue1(), "|");

        Map parseTokens = new HashMap();

        int i = 1;
        while (st.hasMoreTokens()) {
            String token = st.nextToken();
            if (i == 1) {

                width = new BigDecimal(token).doubleValue();

            } else if (i == 2) {
                height = new BigDecimal(token).doubleValue();

            } else if (i == 3) {
                length = new BigDecimal(token).doubleValue();

            } else if (i == 4) {
                weight = new BigDecimal(token).doubleValue();

            } else if (i == 5) {

                maxweight = new BigDecimal(token).doubleValue();

            } else if (i == 6) {

                treshold = Integer.parseInt(token);

            }
            i++;
        }

    } else {
        LogMerchantUtil.log(merchantId, "Shipping Box information is not configured adequatly");
        throw new Exception("Cannot determine box size");
    }

    List boxes = new ArrayList();

    // maximum number of boxes
    int maxBox = 100;
    int iterCount = 0;

    Collection leftProducts = new ArrayList();

    // need to put items individualy
    Iterator prodIter = products.iterator();
    while (prodIter.hasNext()) {
        OrderProduct op = (OrderProduct) prodIter.next();

        if (!op.isShipping()) {
            continue;
        }

        int qty = op.getProductQuantity();

        Set attrs = op.getOrderattributes();

        // set attributes values
        BigDecimal w = op.getProductWeight();
        if (attrs != null && attrs.size() > 0) {
            Iterator attributesIterator = attrs.iterator();
            OrderProductAttribute opa = (OrderProductAttribute) attributesIterator.next();
            w = w.add(opa.getProductAttributeWeight());
        }

        if (qty > 1) {

            for (int i = 1; i <= qty; i++) {
                OrderProduct tempop = new OrderProduct();
                tempop.setProductHeight(op.getProductHeight());
                tempop.setProductLength(op.getProductLength());
                tempop.setProductWidth(op.getProductWidth());
                tempop.setProductWeight(w);
                tempop.setProductQuantity(1);
                tempop.setOrderattributes(attrs);
                leftProducts.add(tempop);
            }
        } else {
            op.setProductWeight(w);
            leftProducts.add(op);
        }
        iterCount++;
    }

    if (iterCount == 0) {
        return null;
    }

    int productCount = leftProducts.size();

    if (productCount < treshold) {
        throw new Exception("Number of item smaller than treshold");
    }

    List usedBoxesList = new ArrayList();

    PackingBox b = new PackingBox();
    // set box max volume
    double maxVolume = width * length * height;

    if (maxVolume == 0 || maxweight == 0) {
        LogMerchantUtil.log(merchantId, "Check shipping box configuration, it has a volume of " + maxVolume
                + " and a maximum weight of " + maxweight + ". Those values must be greater than 0.");
    }
    b.setVolumeLeft(maxVolume);
    b.setWeightLeft(maxweight);

    usedBoxesList.add(b);

    int boxCount = 1;
    Collection assignedProducts = new ArrayList();

    // calculate the volume for the next object
    if (assignedProducts.size() > 0) {
        leftProducts.removeAll(assignedProducts);
        assignedProducts = new ArrayList();
    }
    Iterator prodIterator = leftProducts.iterator();

    boolean productAssigned = false;

    while (prodIterator.hasNext()) {
        OrderProduct op = (OrderProduct) prodIterator.next();
        Collection attributes = op.getOrderattributes();
        productAssigned = false;

        double productWeight = op.getProductWeight().doubleValue();

        // validate if product fits in the box
        if (op.getProductWidth().doubleValue() > width || op.getProductHeight().doubleValue() > height
                || op.getProductLength().doubleValue() > length) {
            // log message to customer
            LogMerchantUtil.log(merchantId, "Product " + op.getProductId()
                    + " has a demension larger than the box size specified. Will use per item calculation.");
            // exit this process and let shipping calculator calculate
            // individual items
            throw new Exception("Product configuration exceeds box configuraton");
        }

        if (productWeight > maxweight) {
            LogMerchantUtil.log(merchantId, "Product " + op.getProductId()
                    + " has a weight larger than the box maximum weight specified. Will use per item calculation.");
            throw new Exception("Product weight exceeds box maximum weight");
        }

        double productVolume = (op.getProductWidth().doubleValue() * op.getProductHeight().doubleValue()
                * op.getProductLength().doubleValue());

        if (productVolume == 0) {
            LogMerchantUtil.log(merchantId, "Product " + op.getProductId()
                    + " has one of the dimension set to 0 and therefore cannot calculate the volume");
            throw new Exception("Cannot calculate volume");
        }

        List boxesList = usedBoxesList;

        // try each box
        Iterator boxIter = boxesList.iterator();
        while (boxIter.hasNext()) {
            PackingBox pb = (PackingBox) boxIter.next();
            double volumeLeft = pb.getVolumeLeft();
            double weightLeft = pb.getWeightLeft();

            if (pb.getVolumeLeft() >= productVolume && pb.getWeightLeft() >= productWeight) {// fit the item
                // in this
                // box
                // fit in the current box
                volumeLeft = volumeLeft - productVolume;
                pb.setVolumeLeft(volumeLeft);
                weightLeft = weightLeft - productWeight;
                pb.setWeightLeft(weightLeft);

                assignedProducts.add(op);
                productCount--;

                double w = pb.getWeight();
                w = w + productWeight;
                pb.setWeight(w);
                productAssigned = true;
                maxBox--;
                break;

            }

        }

        if (!productAssigned) {// create a new box

            b = new PackingBox();
            // set box max volume
            b.setVolumeLeft(maxVolume);
            b.setWeightLeft(maxweight);

            usedBoxesList.add(b);

            double volumeLeft = b.getVolumeLeft() - productVolume;
            b.setVolumeLeft(volumeLeft);
            double weightLeft = b.getWeightLeft() - productWeight;
            b.setWeightLeft(weightLeft);
            assignedProducts.add(op);
            productCount--;
            double w = b.getWeight();
            w = w + productWeight;
            b.setWeight(w);
            maxBox--;
        }

    }

    // now prepare the shipping info

    // number of boxes

    Iterator ubIt = usedBoxesList.iterator();

    System.out.println("###################################");
    System.out.println("Number of boxex " + usedBoxesList.size());
    System.out.println("###################################");

    while (ubIt.hasNext()) {
        PackingBox box = (PackingBox) ubIt.next();
        PackageDetail details = new PackageDetail();
        details.setShippingHeight(height);
        details.setShippingLength(length);
        details.setShippingWeight(weight + box.getWeight());
        details.setShippingWidth(width);
        boxes.add(details);
    }

    return boxes;

}

From source file:com.ocs.dynamo.ui.composite.table.CustomTreeTable.java

/**
 * Updates parent and footer totals in response to a change
 * //from w  ww  .ja va2  s.c  o m
 * @param parentRowId
 *            the row ID of the parent row
 * @param propertyId
 *            the ID of the property to update
 * @param delta
 *            the change
 */
private void updateParentAndFooter(String parentRowId, String propertyId, BigDecimal delta) {
    updateTableField(parentRowId, propertyId, delta);
    String footerString = this.getColumnFooter(propertyId);
    Number footerValue = convertFromString(footerString, propertyId);
    BigDecimal bd = footerValue == null ? BigDecimal.ZERO : toBigDecimal(footerValue);
    bd = bd.add(delta);
    this.setColumnFooter(propertyId, convertToString(bd, propertyId));
}

From source file:com.matel.service.impl.ShoppingCartServiceImpl.java

private void mapCartData(ShoppingCart cart, ShoppingCartData cartData) {
    cartData.setCartId(cart.getShpCartId());
    cartData.setCustomer(cart.getUserId());
    BigDecimal totalAmount = BigDecimal.ZERO;
    for (ShoppingCartItem shoppingCartItem : cart.getShoppingCartItemSet()) {
        ShoppingCartItemData cartItemData = new ShoppingCartItemData();
        cartItemData.setName(shoppingCartItem.getProductId().getProductName());
        cartItemData.setProductPrice(shoppingCartItem.getItemPrice());
        cartItemData.setQuantity(shoppingCartItem.getQuantity());
        cartItemData.setFinishedProductId(shoppingCartItem.getFinishId());
        cartItemData.setFinishedProductName(shoppingCartItem.getFinishName());
        shoppingCartItem.getProductId().getQboProduct();
        cartItemData.setProduct(shoppingCartItem.getProductId());
        totalAmount = totalAmount
                .add(cartItemData.getProductPrice().multiply(new BigDecimal(cartItemData.getQuantity())));
        cartData.getCartItems().add(cartItemData);
    }//www .jav  a 2 s. c om
    cartData.setSubTotal(totalAmount);
}

From source file:com.gst.accounting.journalentry.service.JournalEntryWritePlatformServiceJpaRepositoryImpl.java

@Override
public String createProvisioningJournalEntries(ProvisioningEntry provisioningEntry) {
    Collection<LoanProductProvisioningEntry> provisioningEntries = provisioningEntry
            .getLoanProductProvisioningEntries();
    Map<OfficeCurrencyKey, List<LoanProductProvisioningEntry>> officeMap = new HashMap<>();

    for (LoanProductProvisioningEntry entry : provisioningEntries) {
        OfficeCurrencyKey key = new OfficeCurrencyKey(entry.getOffice(), entry.getCurrencyCode());
        if (officeMap.containsKey(key)) {
            List<LoanProductProvisioningEntry> list = officeMap.get(key);
            list.add(entry);// ww  w .j  a va 2  s.  co  m
        } else {
            List<LoanProductProvisioningEntry> list = new ArrayList<>();
            list.add(entry);
            officeMap.put(key, list);
        }
    }

    Set<OfficeCurrencyKey> officeSet = officeMap.keySet();
    Map<GLAccount, BigDecimal> liabilityMap = new HashMap<>();
    Map<GLAccount, BigDecimal> expenseMap = new HashMap<>();

    for (OfficeCurrencyKey key : officeSet) {
        liabilityMap.clear();
        expenseMap.clear();
        List<LoanProductProvisioningEntry> entries = officeMap.get(key);
        for (LoanProductProvisioningEntry entry : entries) {
            if (liabilityMap.containsKey(entry.getLiabilityAccount())) {
                BigDecimal amount = liabilityMap.get(entry.getLiabilityAccount());
                amount = amount.add(entry.getReservedAmount());
                liabilityMap.put(entry.getLiabilityAccount(), amount);
            } else {
                BigDecimal amount = BigDecimal.ZERO.add(entry.getReservedAmount());
                liabilityMap.put(entry.getLiabilityAccount(), amount);
            }

            if (expenseMap.containsKey(entry.getExpenseAccount())) {
                BigDecimal amount = expenseMap.get(entry.getExpenseAccount());
                amount = amount.add(entry.getReservedAmount());
                expenseMap.put(entry.getExpenseAccount(), amount);
            } else {
                BigDecimal amount = BigDecimal.ZERO.add(entry.getReservedAmount());
                expenseMap.put(entry.getExpenseAccount(), amount);
            }
        }
        createJournalEnry(provisioningEntry.getCreatedDate(), provisioningEntry.getId(), key.office,
                key.currency, liabilityMap, expenseMap);
    }
    return "P" + provisioningEntry.getId();
}

From source file:org.kuali.coeus.s2sgen.impl.generate.support.PHS398ChecklistV1_1Generator.java

private void setProjectIncome(PHS398Checklist phsChecklist, BudgetContract budget) {
    Map<Integer, IncomeBudgetPeriod> incomeBudgetPeriodMap = new TreeMap<>();
    BigDecimal anticipatedAmount;
    for (BudgetProjectIncomeContract projectIncome : budget.getBudgetProjectIncomes()) {
        Integer budgetPeriodNumber = projectIncome.getBudgetPeriodNumber();
        IncomeBudgetPeriod incomeBudgPeriod = incomeBudgetPeriodMap.get(budgetPeriodNumber);
        if (incomeBudgPeriod == null) {
            incomeBudgPeriod = IncomeBudgetPeriod.Factory.newInstance();
            incomeBudgPeriod.setBudgetPeriod(budgetPeriodNumber);
            anticipatedAmount = BigDecimal.ZERO;
        } else {/*from  w w w. ja v a  2s  . c o m*/
            anticipatedAmount = incomeBudgPeriod.getAnticipatedAmount();
        }
        anticipatedAmount = anticipatedAmount.add(projectIncome.getProjectIncome().bigDecimalValue());
        incomeBudgPeriod.setAnticipatedAmount(anticipatedAmount);
        String description = getProjectIncomeDescription(projectIncome);
        if (description != null) {
            if (incomeBudgPeriod.getSource() != null) {
                incomeBudgPeriod.setSource(incomeBudgPeriod.getSource() + ";" + description);
            } else {
                incomeBudgPeriod.setSource(description);
            }
        }
        incomeBudgetPeriodMap.put(budgetPeriodNumber, incomeBudgPeriod);
    }
    Collection<IncomeBudgetPeriod> incomeBudgetPeriodCollection = incomeBudgetPeriodMap.values();
    phsChecklist.setIncomeBudgetPeriodArray(incomeBudgetPeriodCollection.toArray(new IncomeBudgetPeriod[0]));
}

From source file:com.salesmanager.checkout.cart.ShoppingCartAction.java

protected void assembleItems(List<CheckoutParams> params) throws Exception {

    // create an order with merchantId and all dates
    // will need to create a new order id when submited
    Order order = SessionUtil.getOrder(getServletRequest());
    if (order == null) {
        order = new Order();
        order.setMerchantId(store.getMerchantId());
        order.setDatePurchased(new Date());
        order.setCurrency(store.getCurrency());
    }/*w  w w.  ja v a 2 s . c  om*/

    SessionUtil.setOrder(order, getServletRequest());

    if (params != null & params.size() > 0) {

        Iterator i = params.iterator();
        while (i.hasNext()) {

            CheckoutParams v = (CheckoutParams) i.next();

            boolean quantityUpdated = false;

            // check if order product already exist. If that orderproduct
            // already exist
            // and has no ptoperties, so just update the quantity
            if (v.getAttributeId() == null || (v.getAttributeId() != null && v.getAttributeId().size() == 0)) {
                Map savedProducts = SessionUtil.getOrderProducts(getServletRequest());
                if (savedProducts != null) {
                    Iterator it = savedProducts.keySet().iterator();
                    while (it.hasNext()) {
                        String line = (String) it.next();
                        OrderProduct op = (OrderProduct) savedProducts.get(line);
                        if (op.getProductId() == v.getProductId()) {
                            Set attrs = op.getOrderattributes();
                            if (attrs.size() == 0) {
                                int qty = op.getProductQuantity();
                                qty = qty + v.getQty();
                                op.setProductQuantity(qty);
                                quantityUpdated = true;
                                break;
                            }
                        }
                    }
                }
            }

            if (!quantityUpdated) {// new submission

                // Prepare order
                OrderProduct orderProduct = CheckoutUtil.createOrderProduct(v.getProductId(), getLocale(),
                        store.getCurrency());
                if (orderProduct.getProductQuantityOrderMax() > 1) {
                    orderProduct.setProductQuantity(v.getQty());
                } else {
                    orderProduct.setProductQuantity(1);
                }

                orderProduct.setProductId(v.getProductId());

                List<OrderProductAttribute> attributes = new ArrayList<OrderProductAttribute>();
                if (v.getAttributeId() != null && v.getAttributeId().size() > 0) {
                    for (Long attrId : v.getAttributeId()) {
                        if (attrId != null && attrId != 0) {
                            ProductAttribute pAttr = cservice.getProductAttribute(attrId,
                                    super.getLocale().getLanguage());
                            if (pAttr != null && pAttr.getProductId() != orderProduct.getProductId()) {
                                LogMerchantUtil.log(v.getMerchantId(),
                                        getText("error.validation.product.attributes.ids", new String[] {
                                                String.valueOf(attrId), String.valueOf(v.getProductId()) }));
                                continue;
                            }

                            if (pAttr != null && pAttr.getProductId() == v.getProductId()) {
                                OrderProductAttribute orderAttr = new OrderProductAttribute();
                                orderAttr.setProductOptionValueId(pAttr.getOptionValueId());
                                attributes.add(orderAttr);

                                // get order product value
                                ProductOptionValue pov = pAttr.getProductOptionValue();
                                if (pov != null) {
                                    orderAttr.setProductOptionValue(pov.getName());
                                }

                                BigDecimal attrPrice = pAttr.getOptionValuePrice();

                                BigDecimal price = orderProduct.getProductPrice();
                                if (attrPrice != null && attrPrice.longValue() > 0) {
                                    price = price.add(attrPrice);
                                }

                                // string values
                                if (v.getAttributeValue() != null) {

                                    Map attrValues = v.getAttributeValue();
                                    String sValue = (String) attrValues.get(attrId);
                                    if (!StringUtils.isBlank(sValue)) {
                                        orderAttr.setProductOptionValue(sValue);
                                    }
                                }
                            } else {
                                LogMerchantUtil.log(v.getMerchantId(),
                                        getText("error.validation.product.attributes.ids", new String[] {
                                                String.valueOf(attrId), String.valueOf(v.getProductId()) }));
                            }
                        }
                    }

                    BigDecimal price = orderProduct.getProductPrice();
                    orderProduct.setFinalPrice(price);
                    orderProduct.setProductPrice(price);
                    orderProduct.setPriceText(
                            CurrencyUtil.displayFormatedAmountNoCurrency(price, store.getCurrency()));
                    orderProduct.setPriceFormated(
                            CurrencyUtil.displayFormatedAmountWithCurrency(price, store.getCurrency()));

                    // original price
                    orderProduct.setOriginalProductPrice(price);

                }

                if (!attributes.isEmpty()) {
                    CheckoutUtil.addAttributesToProduct(attributes, orderProduct, store.getCurrency(),
                            getLocale());
                }

                Set attributesSet = new HashSet(attributes);
                orderProduct.setOrderattributes(attributesSet);

                SessionUtil.addOrderProduct(orderProduct, getServletRequest());

            }

        }

    }

    // because this is a submission, cannot continue browsing, so that's it
    // for the OrderProduct
    Map orderProducts = SessionUtil.getOrderProducts(super.getServletRequest());

    // transform to a list
    List products = new ArrayList();
    if (orderProducts != null) {
        Iterator ii = orderProducts.keySet().iterator();
        while (ii.hasNext()) {
            String line = (String) ii.next();
            OrderProduct op = (OrderProduct) orderProducts.get(line);
            products.add(op);
        }
    }

    /**
     * Order total calculation
     */
    OrderTotalSummary summary = super.updateOrderTotal(order, products, store);

    this.setSummary(summary);
    ActionContext.getContext().getSession().put("TOKEN", String.valueOf(store.getMerchantId()));// set session token

}