fix [ 2133188 ] QtyOrdered do not is update in Distribution Order

http://sourceforge.net/tracker/index.php?func=detail&aid=2133188&group_id=176962&atid=879332
This commit is contained in:
vpj-cd 2008-09-28 01:29:10 +00:00
parent 636b1175e4
commit 515ee6640a
4 changed files with 85 additions and 56 deletions

View File

@ -23,6 +23,7 @@ import java.util.Properties;
import org.compiere.model.CalloutEngine; import org.compiere.model.CalloutEngine;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.MLocator;
import org.compiere.model.MOrderLine; import org.compiere.model.MOrderLine;
import org.compiere.model.MProduct; import org.compiere.model.MProduct;
import org.compiere.model.MStorage; import org.compiere.model.MStorage;
@ -156,8 +157,10 @@ public class CalloutDistributionOrder extends CalloutEngine
MProduct product = MProduct.get (ctx, M_Product_ID); MProduct product = MProduct.get (ctx, M_Product_ID);
if (product.isStocked()) if (product.isStocked())
{ {
int M_Warehouse_ID = Env.getContextAsInt(ctx, WindowNo, "M_Warehouse_ID"); int M_Locator_ID = Env.getContextAsInt(ctx, WindowNo, "M_Locator_ID");
int M_AttributeSetInstance_ID = Env.getContextAsInt(ctx, WindowNo, "M_AttributeSetInstance_ID"); int M_AttributeSetInstance_ID = Env.getContextAsInt(ctx, WindowNo, "M_AttributeSetInstance_ID");
int M_Warehouse_ID = MLocator.get(ctx, M_Locator_ID).getM_Warehouse_ID();
BigDecimal available = MStorage.getQtyAvailable BigDecimal available = MStorage.getQtyAvailable
(M_Warehouse_ID, 0, M_Product_ID, M_AttributeSetInstance_ID, null); (M_Warehouse_ID, 0, M_Product_ID, M_AttributeSetInstance_ID, null);
if (available == null) if (available == null)
@ -168,12 +171,12 @@ public class CalloutDistributionOrder extends CalloutEngine
mTab.fireDataStatusEEvent ("InsufficientQtyAvailable", available.toString(), false); mTab.fireDataStatusEEvent ("InsufficientQtyAvailable", available.toString(), false);
else else
{ {
Integer C_OrderLine_ID = (Integer)mTab.getValue("C_OrderLine_ID"); Integer DD_OrderLine_ID = (Integer)mTab.getValue("DD_OrderLine_ID");
if (C_OrderLine_ID == null) if (DD_OrderLine_ID == null)
C_OrderLine_ID = new Integer(0); DD_OrderLine_ID = new Integer(0);
BigDecimal notReserved = MOrderLine.getNotReserved(ctx, BigDecimal notReserved = MDDOrderLine.getNotReserved(ctx,
M_Warehouse_ID, M_Product_ID, M_AttributeSetInstance_ID, M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID,
C_OrderLine_ID.intValue()); DD_OrderLine_ID.intValue());
if (notReserved == null) if (notReserved == null)
notReserved = Env.ZERO; notReserved = Env.ZERO;
BigDecimal total = available.subtract(notReserved); BigDecimal total = available.subtract(notReserved);

View File

@ -43,62 +43,36 @@ public class MDDOrderLine extends X_DD_OrderLine
/** /**
* Get Order Unreserved Qty * Get Order Unreserved Qty
* @param ctx context * @param ctx context
* @param M_Warehouse_ID wh * @param M_Locator_ID wh
* @param M_Product_ID product * @param M_Product_ID product
* @param M_AttributeSetInstance_ID asi * @param M_AttributeSetInstance_ID asi
* @param excludeC_OrderLine_ID exclude C_OrderLine_ID * @param excludeC_OrderLine_ID exclude C_OrderLine_ID
* @return Unreserved Qty * @return Unreserved Qty
*/ */
public static BigDecimal getNotReserved (Properties ctx, int M_Warehouse_ID, public static BigDecimal getNotReserved (Properties ctx, int M_Locator_ID,
int M_Product_ID, int M_AttributeSetInstance_ID, int excludeC_OrderLine_ID) int M_Product_ID, int M_AttributeSetInstance_ID, int excludeDD_OrderLine_ID)
{ {
BigDecimal retValue = Env.ZERO;
String sql = "SELECT SUM(QtyOrdered-QtyDelivered-QtyReserved) "
+ "FROM C_OrderLine ol"
+ " INNER JOIN C_Order o ON (ol.C_Order_ID=o.C_Order_ID) "
+ "WHERE ol.M_Warehouse_ID=?" // #1
+ " AND M_Product_ID=?" // #2
+ " AND o.IsSOTrx='Y' AND o.DocStatus='DR'"
+ " AND QtyOrdered-QtyDelivered-QtyReserved<>0"
+ " AND ol.C_OrderLine_ID<>?";
if (M_AttributeSetInstance_ID != 0)
sql += " AND M_AttributeSetInstance_ID=?";
PreparedStatement pstmt = null; ArrayList<Object> params = new ArrayList<Object>();
try params.add(M_Locator_ID);
{ params.add(M_Product_ID);
pstmt = DB.prepareStatement (sql, null); params.add(excludeDD_OrderLine_ID);
pstmt.setInt (1, M_Warehouse_ID);
pstmt.setInt (2, M_Product_ID); String sql = "SELECT SUM(QtyOrdered-QtyDelivered-QtyReserved) "
pstmt.setInt (3, excludeC_OrderLine_ID); + "FROM DD_OrderLine ol"
if (M_AttributeSetInstance_ID != 0) + " INNER JOIN DD_Order o ON (ol.DD_Order_ID=o.DD_Order_ID) "
pstmt.setInt (4, M_AttributeSetInstance_ID); + "WHERE ol.M_Locator_ID=?" // #1
ResultSet rs = pstmt.executeQuery (); + " AND M_Product_ID=?" // #2
if (rs.next ()) + " AND o.IsSOTrx='N' AND o.DocStatus='DR'"
retValue = rs.getBigDecimal(1); + " AND QtyOrdered-QtyDelivered-QtyReserved<>0"
rs.close (); + " AND ol.DD_OrderLine_ID<>?";
pstmt.close ();
pstmt = null; if (M_AttributeSetInstance_ID != 0)
} {
catch (Exception e) sql += " AND M_AttributeSetInstance_ID=?";
{ params.add(M_AttributeSetInstance_ID);
s_log.log (Level.SEVERE, sql, e); }
} return DB.getSQLValueBD(null, sql.toString(), params);
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
if (retValue == null)
s_log.fine("-");
else
s_log.fine(retValue.toString());
return retValue;
} // getNotReserved } // getNotReserved
/** Logger */ /** Logger */

View File

@ -0,0 +1,26 @@
-- Sep 27, 2008 7:46:26 PM CDT
-- Fix Call out Distribution Order
UPDATE AD_Column SET Callout='org.eevolution.model.CalloutDistributionOrder.qty',Updated=TO_DATE('2008-09-27 19:46:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=53928
;
-- Sep 27, 2008 7:46:42 PM CDT
-- Fix Call out Distribution Order
UPDATE AD_Column SET Callout='org.eevolution.model.CalloutDistributionOrder.qty',Updated=TO_DATE('2008-09-27 19:46:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=53954
;
-- Sep 27, 2008 7:46:44 PM CDT
-- Fix Call out Distribution Order
UPDATE AD_Column SET Callout='org.eevolution.model.CalloutDistributionOrder.qty',Updated=TO_DATE('2008-09-27 19:46:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=53948
;
-- Sep 27, 2008 7:46:50 PM CDT
-- Fix Call out Distribution Order
UPDATE AD_Column SET Callout='org.eevolution.model.CalloutDistributionOrder.qty',Updated=TO_DATE('2008-09-27 19:46:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=53947
;
-- Sep 27, 2008 7:46:53 PM CDT
-- Fix Call out Distribution Order
UPDATE AD_Column SET Callout=NULL,Updated=TO_DATE('2008-09-27 19:46:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=53946
;

View File

@ -0,0 +1,26 @@
-- Sep 27, 2008 7:46:26 PM CDT
-- Fix Call out Distribution Order
UPDATE AD_Column SET Callout='org.eevolution.model.CalloutDistributionOrder.qty',Updated=TO_TIMESTAMP('2008-09-27 19:46:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=53928
;
-- Sep 27, 2008 7:46:42 PM CDT
-- Fix Call out Distribution Order
UPDATE AD_Column SET Callout='org.eevolution.model.CalloutDistributionOrder.qty',Updated=TO_TIMESTAMP('2008-09-27 19:46:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=53954
;
-- Sep 27, 2008 7:46:44 PM CDT
-- Fix Call out Distribution Order
UPDATE AD_Column SET Callout='org.eevolution.model.CalloutDistributionOrder.qty',Updated=TO_TIMESTAMP('2008-09-27 19:46:44','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=53948
;
-- Sep 27, 2008 7:46:50 PM CDT
-- Fix Call out Distribution Order
UPDATE AD_Column SET Callout='org.eevolution.model.CalloutDistributionOrder.qty',Updated=TO_TIMESTAMP('2008-09-27 19:46:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=53947
;
-- Sep 27, 2008 7:46:53 PM CDT
-- Fix Call out Distribution Order
UPDATE AD_Column SET Callout=NULL,Updated=TO_TIMESTAMP('2008-09-27 19:46:53','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=53946
;