Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void addToBasket (model_D.Product product)
- {
- if(quantity >0)
- {
- if(basket.containsKey(product.getReference()))
- {
- int quantityUpdate = basket.get(product.getReference()).getQuantity();
- quantityUpdate++;
- basket.get(product.getReference()).setQuantity((short)quantityUpdate);
- double priceUpdate = basket.get(product.getReference()).getPrice().doubleValue();
- priceUpdate += basket.get(product.getReference()).getProductRef().getPrice().doubleValue();
- BigDecimal price = new BigDecimal(priceUpdate);
- basket.get(product.getReference()).setPrice(price.setScale(2, BigDecimal.ROUND_CEILING));
- totalPrice = this.calculePrice();
- }
- else
- {
- Double p = product.getPrice().doubleValue() * quantity;
- BigDecimal price = new BigDecimal(p);
- model_D.Line line = new model_D.Line();
- line.setProductRef(product);
- line.setQuantity((short)quantity);
- line.setPrice(price.setScale(2, BigDecimal.ROUND_CEILING));
- basket.put(product.getReference(), line);
- totalPrice = this.calculePrice();
- }
- quantity = 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement