MPPOrderBOMLine:
* fixed indentation * organized imports * removed unused code
This commit is contained in:
parent
e0605a3553
commit
cce7e13ae8
|
@ -15,25 +15,16 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.model;
|
package org.eevolution.model;
|
||||||
|
|
||||||
import java.util.*;
|
import java.math.BigDecimal;
|
||||||
import java.sql.*;
|
import java.sql.ResultSet;
|
||||||
import java.math.*;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.util.*;
|
import org.compiere.model.MProduct;
|
||||||
import org.compiere.model.*;
|
import org.compiere.util.Env;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order Line Model.
|
* PP Order BOM Line Model.
|
||||||
* <code>
|
*
|
||||||
* MOrderLine ol = new MOrderLine(m_order);
|
|
||||||
ol.setM_Product_ID(wbl.getM_Product_ID());
|
|
||||||
ol.setQtyOrdered(wbl.getQuantity());
|
|
||||||
ol.setPrice();
|
|
||||||
ol.setPriceActual(wbl.getPrice());
|
|
||||||
ol.setTax();
|
|
||||||
ol.save();
|
|
||||||
|
|
||||||
* </code>
|
|
||||||
* @author Victor Perez www.e-evolution.com
|
* @author Victor Perez www.e-evolution.com
|
||||||
* @version $Id: MOrderLine.java,v 1.22 2004/03/22 07:15:03 vpj-cd Exp $
|
* @version $Id: MOrderLine.java,v 1.22 2004/03/22 07:15:03 vpj-cd Exp $
|
||||||
*/
|
*/
|
||||||
|
@ -49,15 +40,15 @@ public class MPPOrderBOMLine extends X_PP_Order_BOMLine
|
||||||
super (ctx, PP_Order_BOMLine_ID,trxName);
|
super (ctx, PP_Order_BOMLine_ID,trxName);
|
||||||
if (PP_Order_BOMLine_ID == 0)
|
if (PP_Order_BOMLine_ID == 0)
|
||||||
{
|
{
|
||||||
setQtyDelivered(Env.ZERO);
|
setQtyDelivered(Env.ZERO);
|
||||||
setQtyPost(Env.ZERO);
|
setQtyPost(Env.ZERO);
|
||||||
setQtyReject(Env.ZERO);
|
setQtyReject(Env.ZERO);
|
||||||
setQtyRequiered(Env.ZERO);
|
setQtyRequiered(Env.ZERO);
|
||||||
setQtyReserved(Env.ZERO);
|
setQtyReserved(Env.ZERO);
|
||||||
setQtyScrap(Env.ZERO);
|
setQtyScrap(Env.ZERO);
|
||||||
}
|
}
|
||||||
} // PP_Order_BOMLine_ID
|
} // PP_Order_BOMLine_ID
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Constructor
|
* Load Constructor
|
||||||
|
@ -70,157 +61,105 @@ public class MPPOrderBOMLine extends X_PP_Order_BOMLine
|
||||||
} // MOrderLine
|
} // MOrderLine
|
||||||
|
|
||||||
private MPPOrder m_parent = null;
|
private MPPOrder m_parent = null;
|
||||||
|
private MProduct m_product = null;
|
||||||
|
|
||||||
/**
|
/**************************************************************************
|
||||||
* Set Defaults from Order.
|
* after Save
|
||||||
* Does not set Parent !!
|
* @param newRecord new
|
||||||
* @param order order
|
* @return save
|
||||||
*/
|
*/
|
||||||
public void setMPPOrderBOM (MPPOrderBOM bom)
|
@Override
|
||||||
{
|
protected boolean afterSave(boolean newRecord, boolean success) {
|
||||||
//setClientOrg(bom);
|
|
||||||
//setC_BPartner_ID(order.getC_BPartner_ID());
|
|
||||||
//setC_BPartner_Location_ID(order.getC_BPartner_Location_ID());
|
|
||||||
//setM_Warehouse_ID(order.getM_Warehouse_ID());
|
|
||||||
//setDateOrdered(order.getDateOrdered());
|
|
||||||
//setDatePromised(order.getDatePromised());
|
|
||||||
//m_M_PriceList_ID = order.getM_PriceList_ID();
|
|
||||||
//m_IsSOTrx = order.isSOTrx();
|
|
||||||
//setC_Currency_ID(order.getC_Currency_ID());
|
|
||||||
} // setOrder
|
|
||||||
|
|
||||||
|
|
||||||
private MProduct m_product = null;
|
|
||||||
private int m_M_Locator_ID = 0;
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* after Save
|
|
||||||
* @param newRecord new
|
|
||||||
* @return save
|
|
||||||
*/
|
|
||||||
protected boolean afterSave(boolean newRecord, boolean success) {
|
|
||||||
|
|
||||||
if (!newRecord)
|
if (!newRecord)
|
||||||
return success;
|
return success;
|
||||||
//Qty Ordered to Phantom
|
//Qty Ordered to Phantom
|
||||||
BigDecimal QtyOrdered = getQtyRequiered();
|
BigDecimal QtyOrdered = getQtyRequiered();
|
||||||
System.out.println(" Padre Product" + getM_Product_ID() + " getQtyBatch" + getQtyBatch() + " getQtyRequiered" + getQtyRequiered() + " QtyScrap" + getQtyScrap());
|
System.out.println(" Padre Product" + getM_Product_ID() + " getQtyBatch" + getQtyBatch() + " getQtyRequiered" + getQtyRequiered() + " QtyScrap" + getQtyScrap());
|
||||||
//Phantom
|
//Phantom
|
||||||
if(getComponentType().equals(MPPProductBOMLine.COMPONENTTYPE_Phantom))
|
if(getComponentType().equals(MPPProductBOMLine.COMPONENTTYPE_Phantom))
|
||||||
{
|
{
|
||||||
|
|
||||||
int PP_Product_BOM_ID = MPPProductBOM.getBOMSearchKey(getM_Product_ID());
|
|
||||||
if (PP_Product_BOM_ID==0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
MPPProductBOM bom = new MPPProductBOM(getCtx(),PP_Product_BOM_ID,get_TrxName());
|
|
||||||
if (bom!= null)
|
|
||||||
{
|
|
||||||
MPPProductBOMLine[] PP_Product_BOMline = bom.getLines();
|
|
||||||
|
|
||||||
if (PP_Product_BOMline == null)
|
|
||||||
return true;
|
|
||||||
for(int i = 0 ; i < PP_Product_BOMline.length ; i++ )
|
|
||||||
{
|
|
||||||
MPPOrderBOMLine PP_Order_BOMLine = new MPPOrderBOMLine(getCtx(),0,get_TrxName());
|
|
||||||
MProduct product = new MProduct(getCtx(),PP_Product_BOMline[i].getM_Product_ID(),get_TrxName());
|
|
||||||
PP_Order_BOMLine.setDescription(PP_Product_BOMline[i].getDescription());
|
|
||||||
PP_Order_BOMLine.setHelp(PP_Product_BOMline[i].getHelp());
|
|
||||||
PP_Order_BOMLine.setM_ChangeNotice_ID(PP_Product_BOMline[i].getM_ChangeNotice_ID());
|
|
||||||
PP_Order_BOMLine.setAssay(PP_Product_BOMline[i].getAssay());
|
|
||||||
PP_Order_BOMLine.setQtyBatch(PP_Product_BOMline[i].getQtyBatch());
|
|
||||||
PP_Order_BOMLine.setQtyBOM(PP_Product_BOMline[i].getQtyBOM());
|
|
||||||
PP_Order_BOMLine.setIsQtyPercentage(PP_Product_BOMline[i].isQtyPercentage());
|
|
||||||
PP_Order_BOMLine.setComponentType(PP_Product_BOMline[i].getComponentType());
|
|
||||||
PP_Order_BOMLine.setC_UOM_ID(PP_Product_BOMline[i].getC_UOM_ID());
|
|
||||||
PP_Order_BOMLine.setForecast(PP_Product_BOMline[i].getForecast());
|
|
||||||
PP_Order_BOMLine.setIsCritical(PP_Product_BOMline[i].isCritical());
|
|
||||||
PP_Order_BOMLine.setIssueMethod(PP_Product_BOMline[i].getIssueMethod());
|
|
||||||
PP_Order_BOMLine.setLine(MPPOrder.getLines(getPP_Order_ID()).length+10);
|
|
||||||
PP_Order_BOMLine.setLeadTimeOffset(PP_Product_BOMline[i].getLeadTimeOffset());
|
|
||||||
PP_Order_BOMLine.setM_AttributeSetInstance_ID(PP_Product_BOMline[i].getM_AttributeSetInstance_ID());
|
|
||||||
PP_Order_BOMLine.setPP_Order_BOM_ID(getPP_Order_BOM_ID());
|
|
||||||
PP_Order_BOMLine.setPP_Order_ID(getPP_Order_ID());
|
|
||||||
PP_Order_BOMLine.setM_Product_ID(PP_Product_BOMline[i].getM_Product_ID());
|
|
||||||
PP_Order_BOMLine.setScrap(PP_Product_BOMline[i].getScrap());
|
|
||||||
PP_Order_BOMLine.setValidFrom(PP_Product_BOMline[i].getValidFrom());
|
|
||||||
PP_Order_BOMLine.setValidTo(PP_Product_BOMline[i].getValidTo());
|
|
||||||
PP_Order_BOMLine.setM_Warehouse_ID(getM_Warehouse_ID());
|
|
||||||
|
|
||||||
if (PP_Order_BOMLine.isQtyPercentage())
|
|
||||||
{
|
|
||||||
BigDecimal qty = PP_Order_BOMLine.getQtyBatch().multiply(QtyOrdered);
|
|
||||||
System.out.println("product:"+product.getName() +" Qty:"+qty + " QtyOrdered:"+ QtyOrdered + " PP_Order_BOMLine.getQtyBatch():" + PP_Order_BOMLine.getQtyBatch());
|
|
||||||
if(PP_Order_BOMLine.getComponentType().equals(PP_Order_BOMLine.COMPONENTTYPE_Packing))
|
|
||||||
PP_Order_BOMLine.setQtyRequiered(qty.divide(new BigDecimal(100),8,qty.ROUND_UP));
|
|
||||||
else if (PP_Order_BOMLine.getComponentType().equals(PP_Order_BOMLine.COMPONENTTYPE_Component) || PP_Order_BOMLine.getComponentType().equals(PP_Order_BOMLine.COMPONENTTYPE_Phantom))
|
|
||||||
PP_Order_BOMLine.setQtyRequiered(qty.divide(new BigDecimal(100),8,qty.ROUND_UP));
|
|
||||||
else if (PP_Order_BOMLine.getComponentType().equals(PP_Order_BOMLine.COMPONENTTYPE_Tools))
|
|
||||||
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyBOM());
|
|
||||||
|
|
||||||
//System.out.println("PP_Order_BOMLinegetQtyRequiered" + PP_Order_BOMLine.getQtyRequiered());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//System.out.println("product: "+product.getName() + " QtyOrdered:"+ QtyOrdered + " PP_Order_BOMLine.getQtyBOM():" + PP_Order_BOMLine.getQtyBOM());
|
|
||||||
if (PP_Order_BOMLine.getComponentType().equals(PP_Order_BOMLine.COMPONENTTYPE_Component) || PP_Order_BOMLine.getComponentType().equals(PP_Order_BOMLine.COMPONENTTYPE_Phantom))
|
|
||||||
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyBOM().multiply(QtyOrdered));
|
|
||||||
else if (PP_Order_BOMLine.getComponentType().equals(PP_Order_BOMLine.COMPONENTTYPE_Packing))
|
|
||||||
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyBOM().multiply(QtyOrdered));
|
|
||||||
else if (PP_Order_BOMLine.getComponentType().equals(PP_Order_BOMLine.COMPONENTTYPE_Tools))
|
|
||||||
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyBOM());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set Scrap of Component
|
int PP_Product_BOM_ID = MPPProductBOM.getBOMSearchKey(getM_Product_ID());
|
||||||
BigDecimal Scrap = PP_Order_BOMLine.getScrap();
|
if (PP_Product_BOM_ID==0)
|
||||||
if (!Scrap.equals(Env.ZERO))
|
return true;
|
||||||
{
|
|
||||||
Scrap = Scrap.divide(new BigDecimal(100),8,BigDecimal.ROUND_UP);
|
MPPProductBOM bom = new MPPProductBOM(getCtx(),PP_Product_BOM_ID,get_TrxName());
|
||||||
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyRequiered().divide( Env.ONE.subtract(Scrap) , 8 ,BigDecimal.ROUND_HALF_UP ));
|
if (bom!= null)
|
||||||
}
|
{
|
||||||
System.out.println("Cantidad Requerida" + PP_Order_BOMLine.getQtyRequiered());
|
MPPProductBOMLine[] PP_Product_BOMline = bom.getLines();
|
||||||
PP_Order_BOMLine.save();
|
|
||||||
}
|
if (PP_Product_BOMline == null)
|
||||||
}
|
return true;
|
||||||
|
for(int i = 0 ; i < PP_Product_BOMline.length ; i++ )
|
||||||
}// end Phantom
|
{
|
||||||
return true;
|
MPPOrderBOMLine PP_Order_BOMLine = new MPPOrderBOMLine(getCtx(),0,get_TrxName());
|
||||||
|
MProduct product = new MProduct(getCtx(),PP_Product_BOMline[i].getM_Product_ID(),get_TrxName());
|
||||||
}
|
PP_Order_BOMLine.setDescription(PP_Product_BOMline[i].getDescription());
|
||||||
|
PP_Order_BOMLine.setHelp(PP_Product_BOMline[i].getHelp());
|
||||||
|
PP_Order_BOMLine.setM_ChangeNotice_ID(PP_Product_BOMline[i].getM_ChangeNotice_ID());
|
||||||
|
PP_Order_BOMLine.setAssay(PP_Product_BOMline[i].getAssay());
|
||||||
|
PP_Order_BOMLine.setQtyBatch(PP_Product_BOMline[i].getQtyBatch());
|
||||||
|
PP_Order_BOMLine.setQtyBOM(PP_Product_BOMline[i].getQtyBOM());
|
||||||
|
PP_Order_BOMLine.setIsQtyPercentage(PP_Product_BOMline[i].isQtyPercentage());
|
||||||
|
PP_Order_BOMLine.setComponentType(PP_Product_BOMline[i].getComponentType());
|
||||||
|
PP_Order_BOMLine.setC_UOM_ID(PP_Product_BOMline[i].getC_UOM_ID());
|
||||||
|
PP_Order_BOMLine.setForecast(PP_Product_BOMline[i].getForecast());
|
||||||
|
PP_Order_BOMLine.setIsCritical(PP_Product_BOMline[i].isCritical());
|
||||||
|
PP_Order_BOMLine.setIssueMethod(PP_Product_BOMline[i].getIssueMethod());
|
||||||
|
PP_Order_BOMLine.setLine(MPPOrder.getLines(getPP_Order_ID()).length+10);
|
||||||
|
PP_Order_BOMLine.setLeadTimeOffset(PP_Product_BOMline[i].getLeadTimeOffset());
|
||||||
|
PP_Order_BOMLine.setM_AttributeSetInstance_ID(PP_Product_BOMline[i].getM_AttributeSetInstance_ID());
|
||||||
|
PP_Order_BOMLine.setPP_Order_BOM_ID(getPP_Order_BOM_ID());
|
||||||
|
PP_Order_BOMLine.setPP_Order_ID(getPP_Order_ID());
|
||||||
|
PP_Order_BOMLine.setM_Product_ID(PP_Product_BOMline[i].getM_Product_ID());
|
||||||
|
PP_Order_BOMLine.setScrap(PP_Product_BOMline[i].getScrap());
|
||||||
|
PP_Order_BOMLine.setValidFrom(PP_Product_BOMline[i].getValidFrom());
|
||||||
|
PP_Order_BOMLine.setValidTo(PP_Product_BOMline[i].getValidTo());
|
||||||
|
PP_Order_BOMLine.setM_Warehouse_ID(getM_Warehouse_ID());
|
||||||
|
|
||||||
|
if (PP_Order_BOMLine.isQtyPercentage())
|
||||||
|
{
|
||||||
|
BigDecimal qty = PP_Order_BOMLine.getQtyBatch().multiply(QtyOrdered);
|
||||||
|
System.out.println("product:"+product.getName() +" Qty:"+qty + " QtyOrdered:"+ QtyOrdered + " PP_Order_BOMLine.getQtyBatch():" + PP_Order_BOMLine.getQtyBatch());
|
||||||
|
if(PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Packing))
|
||||||
|
PP_Order_BOMLine.setQtyRequiered(qty.divide(new BigDecimal(100),8,BigDecimal.ROUND_UP));
|
||||||
|
else if (PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Component) || PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Phantom))
|
||||||
|
PP_Order_BOMLine.setQtyRequiered(qty.divide(new BigDecimal(100),8,BigDecimal.ROUND_UP));
|
||||||
|
else if (PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Tools))
|
||||||
|
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyBOM());
|
||||||
|
|
||||||
|
//System.out.println("PP_Order_BOMLinegetQtyRequiered" + PP_Order_BOMLine.getQtyRequiered());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//System.out.println("product: "+product.getName() + " QtyOrdered:"+ QtyOrdered + " PP_Order_BOMLine.getQtyBOM():" + PP_Order_BOMLine.getQtyBOM());
|
||||||
|
if (PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Component) || PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Phantom))
|
||||||
|
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyBOM().multiply(QtyOrdered));
|
||||||
|
else if (PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Packing))
|
||||||
|
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyBOM().multiply(QtyOrdered));
|
||||||
|
else if (PP_Order_BOMLine.getComponentType().equals(COMPONENTTYPE_Tools))
|
||||||
|
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyBOM());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set Scrap of Component
|
||||||
|
BigDecimal Scrap = PP_Order_BOMLine.getScrap();
|
||||||
|
if (!Scrap.equals(Env.ZERO))
|
||||||
|
{
|
||||||
|
Scrap = Scrap.divide(new BigDecimal(100),8,BigDecimal.ROUND_UP);
|
||||||
|
PP_Order_BOMLine.setQtyRequiered(PP_Order_BOMLine.getQtyRequiered().divide( Env.ONE.subtract(Scrap) , 8 ,BigDecimal.ROUND_HALF_UP ));
|
||||||
|
}
|
||||||
|
System.out.println("Cantidad Requerida" + PP_Order_BOMLine.getQtyRequiered());
|
||||||
|
PP_Order_BOMLine.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}// end Phantom
|
||||||
|
return true;
|
||||||
|
|
||||||
/**
|
|
||||||
* String Representation
|
|
||||||
* @return info
|
|
||||||
*/
|
|
||||||
public String toString ()
|
|
||||||
{
|
|
||||||
StringBuffer sb = new StringBuffer ("PPProductBOMLine[")
|
|
||||||
.append(get_ID())
|
|
||||||
.append ("]");
|
|
||||||
return sb.toString ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set UOM.
|
|
||||||
* make access public
|
|
||||||
* @param C_UOM_ID uom
|
|
||||||
*/
|
|
||||||
public void setC_UOM_ID (int C_UOM_ID)
|
|
||||||
{
|
|
||||||
super.setC_UOM_ID (C_UOM_ID);
|
|
||||||
} // setC_UOM_ID
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Product
|
* Get Product
|
||||||
* @return product or null
|
* @return product or null
|
||||||
*/
|
*/
|
||||||
|
@ -230,17 +169,6 @@ public class MPPOrderBOMLine extends X_PP_Order_BOMLine
|
||||||
m_product = new MProduct (getCtx(), getM_Product_ID() ,get_TrxName());
|
m_product = new MProduct (getCtx(), getM_Product_ID() ,get_TrxName());
|
||||||
return m_product;
|
return m_product;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Save Temp M_Locator_ID
|
|
||||||
* @param M_Locator_ID id
|
|
||||||
*/
|
|
||||||
public void setTempM_Locator_ID (int M_Locator_ID)
|
|
||||||
{
|
|
||||||
m_M_Locator_ID = M_Locator_ID;
|
|
||||||
} // setTempM_Locator_ID
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Parent
|
* Get Parent
|
||||||
|
@ -248,9 +176,9 @@ public class MPPOrderBOMLine extends X_PP_Order_BOMLine
|
||||||
*/
|
*/
|
||||||
public MPPOrder getParent()
|
public MPPOrder getParent()
|
||||||
{
|
{
|
||||||
if (m_parent == null)
|
if (m_parent == null)
|
||||||
m_parent = new MPPOrder(getCtx(), getPP_Order_ID(), get_TrxName());
|
m_parent = new MPPOrder(getCtx(), getPP_Order_ID(), get_TrxName());
|
||||||
return m_parent;
|
return m_parent;
|
||||||
} // getParent
|
} // getParent
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue