IDEMPIERE-3739 Create lines from on Invoice is wrongly pointing to Ship BP instead of Bill BP

This commit is contained in:
Carlos Ruiz 2018-07-05 16:32:33 +02:00
parent a96208dd2a
commit a293cb6a05
1 changed files with 11 additions and 6 deletions

View File

@ -99,14 +99,19 @@ public abstract class CreateFrom implements ICreateFrom
.append(DB.TO_CHAR("o.GrandTotal", DisplayType.Amount, Env.getAD_Language(Env.getCtx()))); .append(DB.TO_CHAR("o.GrandTotal", DisplayType.Amount, Env.getAD_Language(Env.getCtx())));
// //
String column = "ol.QtyDelivered"; String column = "ol.QtyDelivered";
String colBP = "o.C_BPartner_ID";
if (forInvoice) if (forInvoice)
{
column = "ol.QtyInvoiced"; column = "ol.QtyInvoiced";
StringBuffer sql = new StringBuffer("SELECT o.C_Order_ID,").append(display) colBP = "o.Bill_BPartner_ID";
.append(" FROM C_Order o " }
+ "WHERE o.C_BPartner_ID=? AND o.IsSOTrx=? AND o.DocStatus IN ('CL','CO')" StringBuffer sql = new StringBuffer("SELECT o.C_Order_ID,")
+ " AND o.C_Order_ID IN " .append(display)
+ "(SELECT ol.C_Order_ID FROM C_OrderLine ol" .append(" FROM C_Order o WHERE ")
+ " WHERE ol.QtyOrdered - ").append(column).append(" != 0) "); .append(colBP)
.append("=? AND o.IsSOTrx=? AND o.DocStatus IN ('CL','CO') AND o.C_Order_ID IN (SELECT ol.C_Order_ID FROM C_OrderLine ol WHERE ol.QtyOrdered-")
.append(column)
.append("!=0) ");
if(sameWarehouseOnly) if(sameWarehouseOnly)
{ {
sql = sql.append(" AND o.M_Warehouse_ID=? "); sql = sql.append(" AND o.M_Warehouse_ID=? ");