little fixed
This commit is contained in:
parent
23b4715fe9
commit
1672bf5c18
|
|
@ -542,16 +542,15 @@ public class MPPMRP extends X_PP_MRP
|
||||||
* @param ctx
|
* @param ctx
|
||||||
* @param M_Warehouse_ID
|
* @param M_Warehouse_ID
|
||||||
* @param M_Product_ID
|
* @param M_Product_ID
|
||||||
* @param to
|
* @param To
|
||||||
* @param Ordertype separate for SOO,POO,
|
|
||||||
* @param trxName
|
* @param trxName
|
||||||
* @return BibDecimal
|
* @return BibDecimal
|
||||||
*/
|
*/
|
||||||
public static BigDecimal getQtyReserved(Properties ctx, int M_Warehouse_ID ,int M_Product_ID, Timestamp to,String trxName)
|
public static BigDecimal getQtyReserved(Properties ctx, int M_Warehouse_ID ,int M_Product_ID, Timestamp To,String trxName)
|
||||||
{
|
{
|
||||||
StringBuffer sql = new StringBuffer("SELECT SUM(Qty) FROM PP_MRP WHERE TypeMRP='D' AND DocStatus IN ('IN','CO')");
|
StringBuffer sql = new StringBuffer("SELECT SUM(Qty) FROM PP_MRP WHERE TypeMRP='D' AND DocStatus IN ('IN','CO')");
|
||||||
sql.append("AND OrderType IN ('SOO','MOP','DOO') AD_Client_ID= ? AND DatePromised <=? AND M_Warehouse_ID =? AND M_Product_ID=?");
|
sql.append(" AND OrderType IN ('SOO','MOP','DOO') AND AD_Client_ID= ? AND DatePromised <=? AND M_Warehouse_ID =? AND M_Product_ID=?");
|
||||||
BigDecimal qty = DB.getSQLValueBD(trxName, sql.toString(), new Object[]{Env.getAD_Client_ID(ctx), to , M_Warehouse_ID, M_Product_ID});
|
BigDecimal qty = DB.getSQLValueBD(trxName, sql.toString(), new Object[]{Env.getAD_Client_ID(ctx), To , M_Warehouse_ID, M_Product_ID});
|
||||||
// SQL may return no rows or null
|
// SQL may return no rows or null
|
||||||
if (qty == null)
|
if (qty == null)
|
||||||
return Env.ZERO;
|
return Env.ZERO;
|
||||||
|
|
@ -564,8 +563,6 @@ public class MPPMRP extends X_PP_MRP
|
||||||
* @param ctx
|
* @param ctx
|
||||||
* @param M_Warehouse_ID
|
* @param M_Warehouse_ID
|
||||||
* @param M_Product_ID
|
* @param M_Product_ID
|
||||||
* @param to
|
|
||||||
* @param Ordertype separate for SOO,POO,
|
|
||||||
* @param trxName
|
* @param trxName
|
||||||
* @return BibDecimal
|
* @return BibDecimal
|
||||||
*/
|
*/
|
||||||
|
|
@ -579,15 +576,15 @@ public class MPPMRP extends X_PP_MRP
|
||||||
* @param ctx
|
* @param ctx
|
||||||
* @param M_Warehouse_ID
|
* @param M_Warehouse_ID
|
||||||
* @param M_Product_ID
|
* @param M_Product_ID
|
||||||
* @param to
|
* @param To
|
||||||
* @param trxName
|
* @param trxName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static BigDecimal getQtyOrdered(Properties ctx, int M_Warehouse_ID ,int M_Product_ID, Timestamp to,String trxName)
|
public static BigDecimal getQtyOrdered(Properties ctx, int M_Warehouse_ID ,int M_Product_ID, Timestamp To,String trxName)
|
||||||
{
|
{
|
||||||
StringBuffer sql = new StringBuffer("SELECT SUM(Qty) FROM PP_MRP WHERE TypeMRP='S' AND DocStatus IN ('IN','CO')");
|
StringBuffer sql = new StringBuffer("SELECT SUM(Qty) FROM PP_MRP WHERE TypeMRP='S' AND DocStatus IN ('IN','CO')");
|
||||||
sql.append("AND OrderType IN ('POO','MOP','DOO') AD_Client_ID= ? AND DatePromised <=? AND M_Warehouse_ID =? AND M_Product_ID=?");
|
sql.append(" AND OrderType IN ('POO','MOP','DOO') AND AD_Client_ID= ? AND DatePromised <=? AND M_Warehouse_ID =? AND M_Product_ID=?");
|
||||||
BigDecimal qty = DB.getSQLValueBD(trxName, sql.toString(), new Object[]{Env.getAD_Client_ID(ctx), to , M_Warehouse_ID, M_Product_ID});
|
BigDecimal qty = DB.getSQLValueBD(trxName, sql.toString(), new Object[]{Env.getAD_Client_ID(ctx), To , M_Warehouse_ID, M_Product_ID});
|
||||||
// SQL may return no rows or null
|
// SQL may return no rows or null
|
||||||
if (qty == null)
|
if (qty == null)
|
||||||
return Env.ZERO;
|
return Env.ZERO;
|
||||||
|
|
@ -600,7 +597,6 @@ public class MPPMRP extends X_PP_MRP
|
||||||
* @param AD_Client_ID
|
* @param AD_Client_ID
|
||||||
* @param M_Warehouse_ID
|
* @param M_Warehouse_ID
|
||||||
* @param M_Product_ID
|
* @param M_Product_ID
|
||||||
* @param to
|
|
||||||
* @param trxName
|
* @param trxName
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,16 @@ public class DistributionRunOrders extends SvrProcess
|
||||||
{
|
{
|
||||||
int M_Product_ID = rs.getInt("M_Product_ID");
|
int M_Product_ID = rs.getInt("M_Product_ID");
|
||||||
BigDecimal QtyAvailable = MStorage.getQtyAvailable(p_M_Warehouse_ID,0 , M_Product_ID , 0, get_TrxName());
|
BigDecimal QtyAvailable = MStorage.getQtyAvailable(p_M_Warehouse_ID,0 , M_Product_ID , 0, get_TrxName());
|
||||||
|
if(QtyAvailable.signum()< 0)
|
||||||
|
continue;
|
||||||
BigDecimal QtyToDistribute = rs.getBigDecimal("TotalQty");
|
BigDecimal QtyToDistribute = rs.getBigDecimal("TotalQty");
|
||||||
|
if(QtyAvailable.compareTo(QtyToDistribute) >= 0)
|
||||||
|
QtyAvailable = QtyToDistribute;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BigDecimal QtyReserved = getTargetQty(M_Product_ID);
|
||||||
|
QtyToDistribute = QtyAvailable.subtract(QtyReserved);
|
||||||
|
}
|
||||||
|
|
||||||
MDistributionRunLine m_runLine = new MDistributionRunLine(getCtx(),0 ,get_TrxName());
|
MDistributionRunLine m_runLine = new MDistributionRunLine(getCtx(),0 ,get_TrxName());
|
||||||
m_runLine.setM_DistributionRun_ID(m_run.getM_DistributionRun_ID());
|
m_runLine.setM_DistributionRun_ID(m_run.getM_DistributionRun_ID());
|
||||||
|
|
@ -226,20 +235,9 @@ public class DistributionRunOrders extends SvrProcess
|
||||||
m_runLine.setDescription(Msg.translate(getCtx(), "QtyAvailable") +" : " + QtyAvailable + " " +Msg.translate(getCtx(), "QtyOrdered") + " : " + QtyToDistribute);
|
m_runLine.setDescription(Msg.translate(getCtx(), "QtyAvailable") +" : " + QtyAvailable + " " +Msg.translate(getCtx(), "QtyOrdered") + " : " + QtyToDistribute);
|
||||||
//m_runLine.setMinQty(rs.getBigDecimal("MinQty"));
|
//m_runLine.setMinQty(rs.getBigDecimal("MinQty"));
|
||||||
|
|
||||||
BigDecimal QtyReserved = getQtyReserved(M_Product_ID);
|
|
||||||
|
|
||||||
//if(QtyToDistribute.compareTo(QtyAvailable) > 0)
|
|
||||||
//{
|
|
||||||
/*if(QtyReserved.compareTo(QtyAvailable) > 0)
|
|
||||||
{
|
|
||||||
QtyToDistribute = QtyAvailable;
|
|
||||||
}
|
|
||||||
else*/
|
|
||||||
QtyToDistribute = QtyAvailable.subtract(QtyReserved);
|
|
||||||
//}
|
|
||||||
|
|
||||||
m_runLine.setTotalQty(QtyToDistribute);
|
m_runLine.setTotalQty(QtyToDistribute);
|
||||||
m_runLine.save();
|
m_runLine.saveEx();
|
||||||
line += 10;
|
line += 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -258,11 +256,11 @@ public class DistributionRunOrders extends SvrProcess
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Get Qty Reserved for a Warehouse
|
* Get Qty TargetQty for a Warehouse
|
||||||
* @param M_Product_ID
|
* @param M_Product_ID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private BigDecimal getQtyReserved(int M_Product_ID)
|
private BigDecimal getTargetQty(int M_Product_ID)
|
||||||
{
|
{
|
||||||
StringBuffer sql = new StringBuffer("SELECT SUM (TargetQty) FROM DD_OrderLine ol INNER JOIN M_Locator l ON (l.M_Locator_ID=ol.M_Locator_ID) INNER JOIN DD_Order o ON (o.DD_Order_ID=ol.DD_Order_ID) ");
|
StringBuffer sql = new StringBuffer("SELECT SUM (TargetQty) FROM DD_OrderLine ol INNER JOIN M_Locator l ON (l.M_Locator_ID=ol.M_Locator_ID) INNER JOIN DD_Order o ON (o.DD_Order_ID=ol.DD_Order_ID) ");
|
||||||
//sql.append(" WHERE o.DocStatus IN ('DR','IN') AND ol.DatePromised BETWEEN ? AND ? AND l.M_Warehouse_ID=? AND ol.M_Product_ID=? GROUP BY M_Product_ID, l.M_Warehouse_ID");
|
//sql.append(" WHERE o.DocStatus IN ('DR','IN') AND ol.DatePromised BETWEEN ? AND ? AND l.M_Warehouse_ID=? AND ol.M_Product_ID=? GROUP BY M_Product_ID, l.M_Warehouse_ID");
|
||||||
|
|
@ -275,6 +273,24 @@ public class DistributionRunOrders extends SvrProcess
|
||||||
return qty;
|
return qty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Qty TargetQty for a Warehouse
|
||||||
|
* @param M_Product_ID
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private BigDecimal setTargetQty(int M_Product_ID)
|
||||||
|
{
|
||||||
|
StringBuffer sql = new StringBuffer("SELECT SUM(Qty) FROM PP_MRP mrp "
|
||||||
|
+"WHERE TypeMRP='D' AND OrderType='SOO' AND DocStatus IN ('IN','CO') AND mrp.DatePromised <=? "
|
||||||
|
+"AND mrp.M_Warehouse_ID =? AND M_Product_ID=? GROUP BY M_Product_ID, l.M_Warehouse_ID");
|
||||||
|
BigDecimal qty = DB.getSQLValueBD(get_TrxName(), sql.toString(), new Object[]{p_DatePromised, p_M_Warehouse_ID, M_Product_ID});
|
||||||
|
// SQL may return no rows or null
|
||||||
|
if (qty == null)
|
||||||
|
return Env.ZERO;
|
||||||
|
|
||||||
|
return qty;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute Distribution Run
|
* Execute Distribution Run
|
||||||
* @return
|
* @return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue