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:
parent
636b1175e4
commit
515ee6640a
|
@ -23,6 +23,7 @@ import java.util.Properties;
|
|||
import org.compiere.model.CalloutEngine;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.MLocator;
|
||||
import org.compiere.model.MOrderLine;
|
||||
import org.compiere.model.MProduct;
|
||||
import org.compiere.model.MStorage;
|
||||
|
@ -156,8 +157,10 @@ public class CalloutDistributionOrder extends CalloutEngine
|
|||
MProduct product = MProduct.get (ctx, M_Product_ID);
|
||||
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_Warehouse_ID = MLocator.get(ctx, M_Locator_ID).getM_Warehouse_ID();
|
||||
|
||||
BigDecimal available = MStorage.getQtyAvailable
|
||||
(M_Warehouse_ID, 0, M_Product_ID, M_AttributeSetInstance_ID, null);
|
||||
if (available == null)
|
||||
|
@ -168,12 +171,12 @@ public class CalloutDistributionOrder extends CalloutEngine
|
|||
mTab.fireDataStatusEEvent ("InsufficientQtyAvailable", available.toString(), false);
|
||||
else
|
||||
{
|
||||
Integer C_OrderLine_ID = (Integer)mTab.getValue("C_OrderLine_ID");
|
||||
if (C_OrderLine_ID == null)
|
||||
C_OrderLine_ID = new Integer(0);
|
||||
BigDecimal notReserved = MOrderLine.getNotReserved(ctx,
|
||||
M_Warehouse_ID, M_Product_ID, M_AttributeSetInstance_ID,
|
||||
C_OrderLine_ID.intValue());
|
||||
Integer DD_OrderLine_ID = (Integer)mTab.getValue("DD_OrderLine_ID");
|
||||
if (DD_OrderLine_ID == null)
|
||||
DD_OrderLine_ID = new Integer(0);
|
||||
BigDecimal notReserved = MDDOrderLine.getNotReserved(ctx,
|
||||
M_Locator_ID, M_Product_ID, M_AttributeSetInstance_ID,
|
||||
DD_OrderLine_ID.intValue());
|
||||
if (notReserved == null)
|
||||
notReserved = Env.ZERO;
|
||||
BigDecimal total = available.subtract(notReserved);
|
||||
|
|
|
@ -43,62 +43,36 @@ public class MDDOrderLine extends X_DD_OrderLine
|
|||
/**
|
||||
* Get Order Unreserved Qty
|
||||
* @param ctx context
|
||||
* @param M_Warehouse_ID wh
|
||||
* @param M_Locator_ID wh
|
||||
* @param M_Product_ID product
|
||||
* @param M_AttributeSetInstance_ID asi
|
||||
* @param excludeC_OrderLine_ID exclude C_OrderLine_ID
|
||||
* @return Unreserved Qty
|
||||
*/
|
||||
public static BigDecimal getNotReserved (Properties ctx, int M_Warehouse_ID,
|
||||
int M_Product_ID, int M_AttributeSetInstance_ID, int excludeC_OrderLine_ID)
|
||||
public static BigDecimal getNotReserved (Properties ctx, int M_Locator_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;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
pstmt.setInt (1, M_Warehouse_ID);
|
||||
pstmt.setInt (2, M_Product_ID);
|
||||
pstmt.setInt (3, excludeC_OrderLine_ID);
|
||||
if (M_AttributeSetInstance_ID != 0)
|
||||
pstmt.setInt (4, M_AttributeSetInstance_ID);
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
if (rs.next ())
|
||||
retValue = rs.getBigDecimal(1);
|
||||
rs.close ();
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
s_log.log (Level.SEVERE, sql, e);
|
||||
}
|
||||
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;
|
||||
ArrayList<Object> params = new ArrayList<Object>();
|
||||
params.add(M_Locator_ID);
|
||||
params.add(M_Product_ID);
|
||||
params.add(excludeDD_OrderLine_ID);
|
||||
|
||||
String sql = "SELECT SUM(QtyOrdered-QtyDelivered-QtyReserved) "
|
||||
+ "FROM DD_OrderLine ol"
|
||||
+ " INNER JOIN DD_Order o ON (ol.DD_Order_ID=o.DD_Order_ID) "
|
||||
+ "WHERE ol.M_Locator_ID=?" // #1
|
||||
+ " AND M_Product_ID=?" // #2
|
||||
+ " AND o.IsSOTrx='N' AND o.DocStatus='DR'"
|
||||
+ " AND QtyOrdered-QtyDelivered-QtyReserved<>0"
|
||||
+ " AND ol.DD_OrderLine_ID<>?";
|
||||
|
||||
if (M_AttributeSetInstance_ID != 0)
|
||||
{
|
||||
sql += " AND M_AttributeSetInstance_ID=?";
|
||||
params.add(M_AttributeSetInstance_ID);
|
||||
}
|
||||
return DB.getSQLValueBD(null, sql.toString(), params);
|
||||
} // getNotReserved
|
||||
|
||||
/** Logger */
|
||||
|
|
|
@ -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
|
||||
;
|
||||
|
|
@ -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
|
||||
;
|
||||
|
Loading…
Reference in New Issue