Fix VCreateFromShipment/Invoice division by zero - ID: 2373546
This commit is contained in:
parent
45e6cfaf8e
commit
8b0ea3e307
|
@ -117,6 +117,8 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
+ " AND s.M_InOut_ID IN "
|
||||
+ "(SELECT sl.M_InOut_ID FROM M_InOutLine sl"
|
||||
+ " LEFT OUTER JOIN M_MatchInv mi ON (sl.M_InOutLine_ID=mi.M_InOutLine_ID) "
|
||||
+ " JOIN M_InOut s2 ON (sl.M_InOut_ID=s2.M_InOut_ID) "
|
||||
+ " WHERE s2.C_BPartner_ID=? AND s2.IsSOTrx='N' AND s2.DocStatus IN ('CL','CO') "
|
||||
+ "GROUP BY sl.M_InOut_ID,mi.M_InOutLine_ID,sl.MovementQty "
|
||||
+ "HAVING (sl.MovementQty<>SUM(mi.Qty) AND mi.M_InOutLine_ID IS NOT NULL)"
|
||||
+ " OR mi.M_InOutLine_ID IS NULL) "
|
||||
|
@ -125,6 +127,7 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
pstmt.setInt(1, C_BPartner_ID);
|
||||
pstmt.setInt(2, C_BPartner_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
|
@ -298,7 +301,7 @@ public class VCreateFromInvoice extends VCreateFrom implements VetoableChangeLis
|
|||
.append(" LEFT OUTER JOIN M_Product_PO po ON (l.M_Product_ID = po.M_Product_ID AND io.C_BPartner_ID = po.C_BPartner_ID)")
|
||||
.append(" LEFT OUTER JOIN M_MatchInv mi ON (l.M_InOutLine_ID=mi.M_InOutLine_ID)")
|
||||
|
||||
.append(" WHERE l.M_InOut_ID=? ")
|
||||
.append(" WHERE l.M_InOut_ID=? AND l.MovementQty<>0 ")
|
||||
.append("GROUP BY l.MovementQty, l.QtyEntered/l.MovementQty, "
|
||||
+ "l.C_UOM_ID, COALESCE(uom.UOMSymbol, uom.Name), "
|
||||
+ "l.M_Product_ID, p.Name, po.VendorProductNo, l.M_InOutLine_ID, l.Line, l.C_OrderLine_ID ")
|
||||
|
|
|
@ -149,6 +149,8 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
+ " AND i.C_Invoice_ID IN "
|
||||
+ "(SELECT il.C_Invoice_ID FROM C_InvoiceLine il"
|
||||
+ " LEFT OUTER JOIN M_MatchInv mi ON (il.C_InvoiceLine_ID=mi.C_InvoiceLine_ID) "
|
||||
+ " JOIN C_Invoice i2 ON (il.C_Invoice_ID = i2.C_Invoice_ID) "
|
||||
+ " WHERE i2.C_BPartner_ID=? AND i2.IsSOTrx='N' AND i2.DocStatus IN ('CL','CO') "
|
||||
+ "GROUP BY il.C_Invoice_ID,mi.C_InvoiceLine_ID,il.QtyInvoiced "
|
||||
+ "HAVING (il.QtyInvoiced<>SUM(mi.Qty) AND mi.C_InvoiceLine_ID IS NOT NULL)"
|
||||
+ " OR mi.C_InvoiceLine_ID IS NULL) "
|
||||
|
@ -158,6 +160,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
{
|
||||
PreparedStatement pstmt = DB.prepareStatement(sql.toString(), null);
|
||||
pstmt.setInt(1, C_BPartner_ID);
|
||||
pstmt.setInt(2, C_BPartner_ID);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next())
|
||||
{
|
||||
|
@ -342,7 +345,7 @@ public class VCreateFromShipment extends VCreateFrom implements VetoableChangeLi
|
|||
.append(" LEFT OUTER JOIN M_Product_PO po ON (l.M_Product_ID = po.M_Product_ID AND inv.C_BPartner_ID = po.C_BPartner_ID)")
|
||||
.append(" LEFT OUTER JOIN M_MatchInv mi ON (l.C_InvoiceLine_ID=mi.C_InvoiceLine_ID)")
|
||||
|
||||
.append(" WHERE l.C_Invoice_ID=? ")
|
||||
.append(" WHERE l.C_Invoice_ID=? AND l.QtyInvoiced<>0 ")
|
||||
.append("GROUP BY l.QtyInvoiced,l.QtyEntered/l.QtyInvoiced,"
|
||||
+ "l.C_UOM_ID,COALESCE(uom.UOMSymbol,uom.Name),"
|
||||
+ "l.M_Product_ID,p.Name, po.VendorProductNo, l.C_InvoiceLine_ID,l.Line,l.C_OrderLine_ID ")
|
||||
|
|
Loading…
Reference in New Issue