IDEMPIERE-2889 Reservations wrong after a MR with three lines of same PO Line

This commit is contained in:
Carlos Ruiz 2015-10-14 19:51:32 -05:00
parent 51b8033632
commit 136b0f147d
3 changed files with 6 additions and 2 deletions

View File

@ -1350,6 +1350,8 @@ public class MInOut extends X_M_InOut implements DocAction
{
BigDecimal toDelivered = oLine.getQtyOrdered()
.subtract(oLine.getQtyDelivered());
if (toDelivered.signum() < 0) // IDEMPIERE-2889
toDelivered = Env.ZERO;
if (sLine.getMovementQty().compareTo(toDelivered) > 0)
overReceipt = sLine.getMovementQty().subtract(
toDelivered);

View File

@ -111,7 +111,7 @@ public abstract class CreateFrom implements ICreateFrom
{
sql = sql.append(" AND o.M_Warehouse_ID=? ");
}
sql = sql.append("ORDER BY o.DateOrdered");
sql = sql.append("ORDER BY o.DateOrdered,o.DocumentNo");
//
PreparedStatement pstmt = null;
ResultSet rs = null;

View File

@ -192,7 +192,9 @@ public abstract class CreateFromShipment extends CreateFrom
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
StringBuilder sql = new StringBuilder("SELECT "
+ "l.QtyOrdered-SUM(COALESCE(m.Qty,0))," // 1
+ "l.QtyOrdered-SUM(COALESCE(m.Qty,0))"
// subtract drafted lines from this or other orders IDEMPIERE-2889
+ "-COALESCE((SELECT SUM(MovementQty) FROM M_InOutLine iol JOIN M_InOut io ON iol.M_InOut_ID=io.M_InOut_ID WHERE l.C_OrderLine_ID=iol.C_OrderLine_ID AND io.Processed='N'),0)," // 1
+ "CASE WHEN l.QtyOrdered=0 THEN 0 ELSE l.QtyEntered/l.QtyOrdered END," // 2
+ " l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name)," // 3..4
+ " p.M_Locator_ID, loc.Value, " // 5..6