From 300ae850ace7fbaef18b31d9d2782b3c69831a66 Mon Sep 17 00:00:00 2001 From: Elaine Tan Date: Wed, 16 Jul 2014 17:49:03 +0800 Subject: [PATCH] IDEMPIERE-2063 Ticket #1004146: cannot remove reserve quantity off order --- .../src/org/compiere/model/MOrder.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index d72e3eb1f7..07640eb37d 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -1722,15 +1722,23 @@ public class MOrder extends X_C_Order implements DocAction BigDecimal difference = target .subtract(line.getQtyReserved()) .subtract(line.getQtyDelivered()); - if (difference.signum() <= 0) + + if (difference.signum() == 0 || line.getQtyOrdered().signum() < 0) { - MProduct product = line.getProduct(); - if (product != null) + if (difference.signum() == 0 || line.getQtyReserved().signum() == 0) { - Volume = Volume.add(product.getVolume().multiply(line.getQtyOrdered())); - Weight = Weight.add(product.getWeight().multiply(line.getQtyOrdered())); + MProduct product = line.getProduct(); + if (product != null) + { + Volume = Volume.add(product.getVolume().multiply(line.getQtyOrdered())); + Weight = Weight.add(product.getWeight().multiply(line.getQtyOrdered())); + } + continue; + } + else if (line.getQtyOrdered().signum() < 0 && line.getQtyReserved().signum() > 0) + { + difference = line.getQtyReserved().negate(); } - continue; } if (log.isLoggable(Level.FINE)) log.fine("Line=" + line.getLine()