1002617 IDEMPIERE-1158: Allow Create Lines From on Invoice (Customer).

This commit is contained in:
Heng Sin Low 2013-10-11 14:33:49 +08:00
parent 390bd08f78
commit 11041a4a4d
5 changed files with 278 additions and 25 deletions

View File

@ -0,0 +1,115 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=240,IsDisplayed='Y' WHERE AD_Field_ID=4244
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=250,IsDisplayed='Y' WHERE AD_Field_ID=2775
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=260,IsDisplayed='Y' WHERE AD_Field_ID=2764
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=270,IsDisplayed='Y' WHERE AD_Field_ID=2768
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=280,IsDisplayed='Y' WHERE AD_Field_ID=6935
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=290,IsDisplayed='Y' WHERE AD_Field_ID=7794
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=300,IsDisplayed='Y' WHERE AD_Field_ID=7795
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=310,IsDisplayed='Y' WHERE AD_Field_ID=2786
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=320,IsDisplayed='Y' WHERE AD_Field_ID=2780
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=330,IsDisplayed='Y' WHERE AD_Field_ID=2778
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=340,IsDisplayed='Y' WHERE AD_Field_ID=2771
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=350,IsDisplayed='Y' WHERE AD_Field_ID=8657
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=360,IsDisplayed='Y' WHERE AD_Field_ID=10485
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=370,IsDisplayed='Y' WHERE AD_Field_ID=6564
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=380,IsDisplayed='Y' WHERE AD_Field_ID=2777
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=390,IsDisplayed='Y' WHERE AD_Field_ID=3663
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=400,IsDisplayed='Y' WHERE AD_Field_ID=3899
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=410,IsDisplayed='Y' WHERE AD_Field_ID=13700
;
-- May 2, 2013 5:27:49 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=420,IsDisplayed='Y' WHERE AD_Field_ID=53257
;
-- May 2, 2013 5:27:49 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=430,IsDisplayed='Y' WHERE AD_Field_ID=53258
;
-- May 2, 2013 5:27:49 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=440,IsDisplayed='Y' WHERE AD_Field_ID=60970
;
-- May 2, 2013 5:27:49 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=450,IsDisplayed='Y' WHERE AD_Field_ID=200050
;
SELECT register_migration_script('201310110610_IDEMPIERE-1158.sql') FROM dual
;

View File

@ -0,0 +1,112 @@
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=240,IsDisplayed='Y' WHERE AD_Field_ID=4244
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=250,IsDisplayed='Y' WHERE AD_Field_ID=2775
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=260,IsDisplayed='Y' WHERE AD_Field_ID=2764
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=270,IsDisplayed='Y' WHERE AD_Field_ID=2768
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=280,IsDisplayed='Y' WHERE AD_Field_ID=6935
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=290,IsDisplayed='Y' WHERE AD_Field_ID=7794
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=300,IsDisplayed='Y' WHERE AD_Field_ID=7795
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=310,IsDisplayed='Y' WHERE AD_Field_ID=2786
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=320,IsDisplayed='Y' WHERE AD_Field_ID=2780
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=330,IsDisplayed='Y' WHERE AD_Field_ID=2778
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=340,IsDisplayed='Y' WHERE AD_Field_ID=2771
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=350,IsDisplayed='Y' WHERE AD_Field_ID=8657
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=360,IsDisplayed='Y' WHERE AD_Field_ID=10485
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=370,IsDisplayed='Y' WHERE AD_Field_ID=6564
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=380,IsDisplayed='Y' WHERE AD_Field_ID=2777
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=390,IsDisplayed='Y' WHERE AD_Field_ID=3663
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=400,IsDisplayed='Y' WHERE AD_Field_ID=3899
;
-- May 2, 2013 5:27:48 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=410,IsDisplayed='Y' WHERE AD_Field_ID=13700
;
-- May 2, 2013 5:27:49 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=420,IsDisplayed='Y' WHERE AD_Field_ID=53257
;
-- May 2, 2013 5:27:49 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=430,IsDisplayed='Y' WHERE AD_Field_ID=53258
;
-- May 2, 2013 5:27:49 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=440,IsDisplayed='Y' WHERE AD_Field_ID=60970
;
-- May 2, 2013 5:27:49 PM IST
-- Enabling 'Create Lines from' button on invoice (Customer)
UPDATE AD_Field SET SeqNo=450,IsDisplayed='Y' WHERE AD_Field_ID=200050
;
SELECT register_migration_script('201310110610_IDEMPIERE-1158.sql') FROM dual
;

View File

@ -128,8 +128,8 @@ public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventList
protected void zkInit() throws Exception
{
bPartnerLabel.setText(Msg.getElement(Env.getCtx(), "C_BPartner_ID"));
orderLabel.setText(Msg.getElement(Env.getCtx(), "C_Order_ID", false));
shipmentLabel.setText(Msg.getElement(Env.getCtx(), "M_InOut_ID", false));
orderLabel.setText(Msg.getElement(Env.getCtx(), "C_Order_ID", isSOTrx));
shipmentLabel.setText(Msg.getElement(Env.getCtx(), "M_InOut_ID", isSOTrx));
rmaLabel.setText(Msg.translate(Env.getCtx(), "M_RMA_ID"));
Borderlayout parameterLayout = new Borderlayout();

View File

@ -49,8 +49,11 @@ public abstract class CreateFrom implements ICreateFrom
private boolean initOK = false;
protected boolean isSOTrx = false;
public CreateFrom(GridTab gridTab) {
this.gridTab = gridTab;
isSOTrx = (Boolean) gridTab.getField("isSoTrx").getValue();
}
public abstract boolean dynInit() throws Exception;
@ -82,6 +85,7 @@ public abstract class CreateFrom implements ICreateFrom
{
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
String isSOTrxParam = isSOTrx ? "Y":"N";
// Display
StringBuffer display = new StringBuffer("o.DocumentNo||' - ' ||")
.append(DB.TO_CHAR("o.DateOrdered", DisplayType.Date, Env.getAD_Language(Env.getCtx())))
@ -93,7 +97,7 @@ public abstract class CreateFrom implements ICreateFrom
column = "ol.QtyInvoiced";
StringBuffer sql = new StringBuffer("SELECT o.C_Order_ID,").append(display)
.append(" FROM C_Order o "
+ "WHERE o.C_BPartner_ID=? AND o.IsSOTrx='N' AND o.DocStatus IN ('CL','CO')"
+ "WHERE o.C_BPartner_ID=? 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) ");
@ -109,10 +113,11 @@ public abstract class CreateFrom implements ICreateFrom
{
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, C_BPartner_ID);
pstmt.setString(2, isSOTrxParam);
if(sameWarehouseOnly)
{
//only active for material receipts
pstmt.setInt(2, getM_Warehouse_ID());
pstmt.setInt(3, getM_Warehouse_ID());
}
rs = pstmt.executeQuery();
while (rs.next())

View File

@ -84,6 +84,7 @@ public abstract class CreateFromInvoice extends CreateFrom
*/
protected ArrayList<KeyNamePair> loadShipmentData (int C_BPartner_ID)
{
String isSOTrxParam = isSOTrx ? "Y":"N";
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
// Display
@ -92,23 +93,32 @@ public abstract class CreateFromInvoice extends CreateFrom
//
StringBuffer sql = new StringBuffer("SELECT s.M_InOut_ID,").append(display)
.append(" FROM M_InOut s "
+ "WHERE s.C_BPartner_ID=? AND s.IsSOTrx='N' AND s.DocStatus IN ('CL','CO')"
+ "WHERE s.C_BPartner_ID=? AND s.IsSOTrx=? AND s.DocStatus IN ('CL','CO')"
+ " 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) "
+ "(SELECT sl.M_InOut_ID FROM M_InOutLine sl");
if(!isSOTrx)
sql.append(" 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) "
+ "ORDER BY s.MovementDate");
+ " WHERE s2.C_BPartner_ID=? AND s2.IsSOTrx=? AND s2.DocStatus IN ('CL','CO') "
+ " GROUP BY sl.M_InOut_ID,sl.MovementQty,mi.M_InOutLine_ID"
+ " HAVING (sl.MovementQty<>SUM(mi.Qty) AND mi.M_InOutLine_ID IS NOT NULL)"
+ " OR mi.M_InOutLine_ID IS NULL ");
else
sql.append(" INNER JOIN M_InOut s2 ON (sl.M_InOut_ID=s2.M_InOut_ID)"
+ " LEFT JOIN C_InvoiceLine il ON sl.M_InOutLine_ID = il.M_InOutLine_ID"
+ " WHERE s2.C_BPartner_ID=? AND s2.IsSOTrx=? AND s2.DocStatus IN ('CL','CO')"
+ " GROUP BY sl.M_InOutLine_ID"
+ " HAVING sl.MovementQty - sum(COALESCE(il.QtyInvoiced,0)) > 0");
sql.append(") ORDER BY s.MovementDate");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, C_BPartner_ID);
pstmt.setInt(2, C_BPartner_ID);
pstmt.setString(2, isSOTrxParam);
pstmt.setInt(3, C_BPartner_ID);
pstmt.setString(4, isSOTrxParam);
rs = pstmt.executeQuery();
while (rs.next())
{
@ -180,8 +190,12 @@ public abstract class CreateFromInvoice extends CreateFrom
//
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
StringBuilder sql = new StringBuilder("SELECT " // QtyEntered
+ "l.MovementQty-SUM(NVL(mi.Qty, 0)), l.QtyEntered/l.MovementQty,"
StringBuilder sql = new StringBuilder("SELECT "); // QtyEntered
if(!isSOTrx)
sql.append("l.MovementQty-SUM(COALESCE(mi.Qty, 0)),");
else
sql.append("l.MovementQty-SUM(COALESCE(il.QtyInvoiced,0)),");
sql.append(" l.QtyEntered/l.MovementQty,"
+ " l.C_UOM_ID, COALESCE(uom.UOMSymbol, uom.Name)," // 3..4
+ " l.M_Product_ID, p.Name, po.VendorProductNo, l.M_InOutLine_ID, l.Line," // 5..9
+ " l.C_OrderLine_ID " // 10
@ -194,15 +208,22 @@ public abstract class CreateFromInvoice extends CreateFrom
.append(Env.getAD_Language(Env.getCtx())).append("')");
sql.append(" LEFT OUTER JOIN M_Product p ON (l.M_Product_ID=p.M_Product_ID)")
.append(" INNER JOIN M_InOut io ON (l.M_InOut_ID=io.M_InOut_ID)")
.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(" INNER JOIN M_InOut io ON (l.M_InOut_ID=io.M_InOut_ID)");
if(!isSOTrx)
sql.append(" LEFT OUTER JOIN M_MatchInv mi ON (l.M_InOutLine_ID=mi.M_InOutLine_ID)");
else
sql.append(" LEFT JOIN C_InvoiceLine il ON l.M_InOutLine_ID = il.M_InOutLine_ID");
sql.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(" 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 ")
.append("ORDER BY l.Line");
+ "l.M_Product_ID, p.Name, po.VendorProductNo, l.M_InOutLine_ID, l.Line, l.C_OrderLine_ID ");
if(!isSOTrx)
sql.append(" HAVING l.MovementQty-SUM(COALESCE(mi.Qty, 0)) <>0");
else
sql.append(" HAVING l.MovementQty-SUM(COALESCE(il.QtyInvoiced,0)) <>0");
sql.append("ORDER BY l.Line");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
@ -594,10 +615,10 @@ public abstract class CreateFromInvoice extends CreateFrom
columnNames.add(Msg.translate(Env.getCtx(), "Quantity"));
columnNames.add(Msg.translate(Env.getCtx(), "C_UOM_ID"));
columnNames.add(Msg.translate(Env.getCtx(), "M_Product_ID"));
columnNames.add(Msg.getElement(Env.getCtx(), "VendorProductNo", false));
columnNames.add(Msg.getElement(Env.getCtx(), "C_Order_ID", false));
columnNames.add(Msg.getElement(Env.getCtx(), "M_InOut_ID", false));
columnNames.add(Msg.getElement(Env.getCtx(), "M_RMA_ID", false));
columnNames.add(Msg.getElement(Env.getCtx(), "VendorProductNo", isSOTrx));
columnNames.add(Msg.getElement(Env.getCtx(), "C_Order_ID", isSOTrx));
columnNames.add(Msg.getElement(Env.getCtx(), "M_InOut_ID", isSOTrx));
columnNames.add(Msg.getElement(Env.getCtx(), "M_RMA_ID", isSOTrx));
return columnNames;
}