Commit 198da055 by Tuomas Riihimäki

Bugfixes...

1 parent 4c45791b
...@@ -372,7 +372,8 @@ public class BillBean implements BillBeanLocal { ...@@ -372,7 +372,8 @@ public class BillBean implements BillBeanLocal {
BigDecimal discountPrice = product.getPrice(); BigDecimal discountPrice = product.getPrice();
for (Discount disc : discountBean.getActiveDiscountsByProduct(product, count, bill.getSentDate(), bill.getUser())) { for (Discount disc : discountBean.getActiveDiscountsByProduct(product, count, bill.getSentDate(), bill.getUser())) {
BillLine line = new BillLine(bill, product, disc,discountPrice, count); BillLine line = new BillLine(bill, product, disc,discountPrice, count);
discountPrice = discountPrice.subtract(line.getUnitPrice()); // unitPrice is negative, so add. Do not subtract
discountPrice = discountPrice.add(line.getUnitPrice());
bill.getBillLines().add(line); bill.getBillLines().add(line);
} }
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
<p:commandButton <p:commandButton
rendered="#{ajaxMapView.canUserBuy()}" rendered="#{ajaxMapView.canUserBuy()}"
value="#{i18n['mapPlacechange.commitMove']}" value="#{i18n['mapPlacechange.commitMove']}"
actionListener="#{mapPlacechangeView.commitMove()}" /> action="#{mapPlacechangeView.commitMove()}" />
</h:form> </h:form>
......
...@@ -107,6 +107,9 @@ public class MapPlacechangeView extends GenericCDIView { ...@@ -107,6 +107,9 @@ public class MapPlacechangeView extends GenericCDIView {
} }
} }
placebean.movePlaces(change); placebean.movePlaces(change);
slots = null;
initView();
} }
public void toggleDstPlace() { public void toggleDstPlace() {
......
...@@ -45,18 +45,22 @@ public class ProductShopItemHelper extends GenericCDIView { ...@@ -45,18 +45,22 @@ public class ProductShopItemHelper extends GenericCDIView {
public void updateProductShopItemCount(ProductShopItem item) { public void updateProductShopItemCount(ProductShopItem item) {
if (item.getProduct().getMinBuyCount() > 0 && item.getCount().compareTo(BigDecimal.ZERO) > 0
&& item.getCount().compareTo(BigDecimal.valueOf(item.getProduct().getMinBuyCount())) < 0) {
item.setCount(BigDecimal.valueOf(item.getProduct().getMinBuyCount()));
}
// Discounts or overridden price, you cannot get both // Discounts or overridden price, you cannot get both
if (item.isOverrideUnitPrice()) { if (item.isOverrideUnitPrice()) {
item.setInternalPrice(item.getOverriddenUnitPrice().multiply(item.getCount())); item.setInternalPrice(item.getOverriddenUnitPrice().multiply(item.getCount()));
} else { } else {
item.setInternalPrice(item.getProduct().getPrice().abs().multiply(item.getCount())); item.setInternalPrice(item.getProduct().getPrice().abs().multiply(item.getCount()));
item.setInternalDiscounts(discountBean.getActiveDiscountsByProduct(item.getProduct(), item.getCount(), new Date(), item.getUser())); item.setInternalDiscounts(discountBean.getActiveDiscountsByProduct(item.getProduct(), item.getCount(),
new Date(), item.getUser()));
item.setInternalDiscountValues(new HashMap<Integer, BigDecimal>()); item.setInternalDiscountValues(new HashMap<Integer, BigDecimal>());
for (Discount d : item.getDiscounts()) for (Discount d : item.getDiscounts()) {
{
BigDecimal newprice = item.getPrice().multiply(d.getPercentage()); BigDecimal newprice = item.getPrice().multiply(d.getPercentage());
item.getInternalDiscountValues().put(d.getId(), item.getPrice().subtract(newprice)); item.getInternalDiscountValues().put(d.getId(), item.getPrice().subtract(newprice));
item.setInternalPrice(newprice); item.setInternalPrice(newprice);
...@@ -67,14 +71,10 @@ public class ProductShopItemHelper extends GenericCDIView { ...@@ -67,14 +71,10 @@ public class ProductShopItemHelper extends GenericCDIView {
public void setProductShopItemCount(ProductShopItem item, BigDecimal count) { public void setProductShopItemCount(ProductShopItem item, BigDecimal count) {
if (count == null || count.compareTo(BigDecimal.ZERO) < 0) if (count == null || count.compareTo(BigDecimal.ZERO) < 0) {
{
count = BigDecimal.ZERO; count = BigDecimal.ZERO;
} else if(item.getProduct().getMinBuyCount() > 0 && count.compareTo(BigDecimal.ZERO) > 0 && count.compareTo(BigDecimal.valueOf(item.getProduct().getMinBuyCount())) < 0) {
count = BigDecimal.valueOf(item.getProduct().getMinBuyCount());
} }
item.setCount(count); item.setCount(count);
updateProductShopItemCount(item); updateProductShopItemCount(item);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!