Bring in Manufacturing Light code from Adaxa / Paul Bowden
Merge Production line MA fix. Fixes #93. changeset 6228 6b74072a4797
This commit is contained in:
parent
354bb3cef1
commit
7775f04a14
|
|
@ -31,7 +31,6 @@ public class ProductionProcess extends SvrProcess {
|
||||||
|
|
||||||
protected void prepare() {
|
protected void prepare() {
|
||||||
|
|
||||||
log.severe("In prepare method");
|
|
||||||
ProcessInfoParameter[] para = getParameter();
|
ProcessInfoParameter[] para = getParameter();
|
||||||
for (int i = 0; i < para.length; i++)
|
for (int i = 0; i < para.length; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -72,7 +71,6 @@ public class ProductionProcess extends SvrProcess {
|
||||||
|
|
||||||
int processed = 0;
|
int processed = 0;
|
||||||
m_production.setMovementDate(p_MovementDate);
|
m_production.setMovementDate(p_MovementDate);
|
||||||
System.err.println(m_production.getMovementDate());
|
|
||||||
MProductionLine[] lines = m_production.getLines();
|
MProductionLine[] lines = m_production.getLines();
|
||||||
StringBuffer errors = new StringBuffer();
|
StringBuffer errors = new StringBuffer();
|
||||||
for ( int i = 0; i<lines.length; i++) {
|
for ( int i = 0; i<lines.length; i++) {
|
||||||
|
|
@ -83,7 +81,6 @@ public class ProductionProcess extends SvrProcess {
|
||||||
processed++;
|
processed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( errors.toString().compareTo("") != 0 ) {
|
if ( errors.toString().compareTo("") != 0 ) {
|
||||||
log.log(Level.WARNING, errors.toString() );
|
log.log(Level.WARNING, errors.toString() );
|
||||||
throw new AdempiereSystemError(errors.toString());
|
throw new AdempiereSystemError(errors.toString());
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ public class MProductionLine extends X_M_ProductionLine {
|
||||||
if ( asiString == null )
|
if ( asiString == null )
|
||||||
asiString = "";
|
asiString = "";
|
||||||
|
|
||||||
log.log(Level.WARNING, "asi Description is: " + asiString);
|
log.log(Level.FINEST, "asi Description is: " + asiString);
|
||||||
// create transactions for finished goods
|
// create transactions for finished goods
|
||||||
if ( getMovementQty().compareTo(Env.ZERO) > 0 ) {
|
if ( getMovementQty().compareTo(Env.ZERO) > 0 ) {
|
||||||
MProductionLineMA lineMA = new MProductionLineMA( this,
|
MProductionLineMA lineMA = new MProductionLineMA( this,
|
||||||
|
|
@ -129,8 +129,6 @@ public class MProductionLine extends X_M_ProductionLine {
|
||||||
MStorage[] storages = MStorage.getAll( getCtx(), getM_Product_ID(),
|
MStorage[] storages = MStorage.getAll( getCtx(), getM_Product_ID(),
|
||||||
getM_Locator_ID(), get_TrxName());
|
getM_Locator_ID(), get_TrxName());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MProductionLineMA lineMA = null;
|
MProductionLineMA lineMA = null;
|
||||||
MTransaction matTrx = null;
|
MTransaction matTrx = null;
|
||||||
BigDecimal qtyToMove = getMovementQty().negate();
|
BigDecimal qtyToMove = getMovementQty().negate();
|
||||||
|
|
@ -152,16 +150,15 @@ public class MProductionLine extends X_M_ProductionLine {
|
||||||
if (slASIString == null)
|
if (slASIString == null)
|
||||||
slASIString = "";
|
slASIString = "";
|
||||||
|
|
||||||
log.log(Level.WARNING,"slASI-Description =" + slASIString);
|
log.log(Level.FINEST,"slASI-Description =" + slASIString);
|
||||||
|
|
||||||
if ( slASIString.compareTo(asiString) == 0
|
if ( slASIString.compareTo(asiString) == 0
|
||||||
|| asi.getM_AttributeSet_ID() == 0 )
|
|| asi.getM_AttributeSet_ID() == 0 )
|
||||||
//storage matches specified ASI or is a costing asi (inc. 0)
|
//storage matches specified ASI or is a costing asi (inc. 0)
|
||||||
// This process will move negative stock on hand quantities
|
// This process will move negative stock on hand quantities
|
||||||
{
|
{
|
||||||
lineMA = new MProductionLineMA( this,
|
lineMA = MProductionLineMA.get(this,storages[sl].getM_AttributeSetInstance_ID());
|
||||||
storages[sl].getM_AttributeSetInstance_ID(),
|
lineMA.setMovementQty(lineMA.getMovementQty().add(lineQty.negate()));
|
||||||
lineQty.negate());
|
|
||||||
if ( !lineMA.save(get_TrxName()) ) {
|
if ( !lineMA.save(get_TrxName()) ) {
|
||||||
log.log(Level.SEVERE, "Could not save MA for " + toString());
|
log.log(Level.SEVERE, "Could not save MA for " + toString());
|
||||||
errorString.append("Could not save MA for " + toString() + "\n" );
|
errorString.append("Could not save MA for " + toString() + "\n" );
|
||||||
|
|
@ -185,9 +182,7 @@ public class MProductionLine extends X_M_ProductionLine {
|
||||||
errorString.append("Could not update storage for " + toString() + "\n");
|
errorString.append("Could not update storage for " + toString() + "\n");
|
||||||
}
|
}
|
||||||
qtyToMove = qtyToMove.subtract(lineQty);
|
qtyToMove = qtyToMove.subtract(lineQty);
|
||||||
System.err.println("Qty Moved = " + lineQty);
|
log.log(Level.FINE, getLine() + " Qty moved = " + lineQty + ", Remaining = " + qtyToMove );
|
||||||
log.log(Level.WARNING, "Qty moved = " + lineQty );
|
|
||||||
log.log(Level.WARNING, getLine() + " Qty to move: " + qtyToMove );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -206,13 +201,11 @@ public class MProductionLine extends X_M_ProductionLine {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MProduct product = new MProduct(Env.getCtx(), getM_Product_ID(), get_TrxName());
|
MStorage storage = MStorage.get(Env.getCtx(), getM_Locator_ID(), getM_Product_ID(), 0, get_TrxName());
|
||||||
int defaultLocator = product.getM_Locator_ID();
|
|
||||||
MStorage storage = MStorage.get(Env.getCtx(), defaultLocator, getM_Product_ID(), 0, get_TrxName());
|
|
||||||
if (storage == null)
|
if (storage == null)
|
||||||
{
|
{
|
||||||
storage = new MStorage(Env.getCtx(), 0, get_TrxName());
|
storage = new MStorage(Env.getCtx(), 0, get_TrxName());
|
||||||
storage.setM_Locator_ID(defaultLocator);
|
storage.setM_Locator_ID(getM_Locator_ID());
|
||||||
storage.setM_Product_ID(getM_Product_ID());
|
storage.setM_Product_ID(getM_Product_ID());
|
||||||
storage.setM_AttributeSetInstance_ID(0);
|
storage.setM_AttributeSetInstance_ID(0);
|
||||||
storage.save();
|
storage.save();
|
||||||
|
|
@ -226,16 +219,19 @@ public class MProductionLine extends X_M_ProductionLine {
|
||||||
if (slASIString == null)
|
if (slASIString == null)
|
||||||
slASIString = "";
|
slASIString = "";
|
||||||
|
|
||||||
log.log(Level.WARNING,"slASI-Description =" + slASIString);
|
log.log(Level.FINEST,"slASI-Description =" + slASIString);
|
||||||
|
|
||||||
if ( slASIString.compareTo(asiString) == 0
|
if ( slASIString.compareTo(asiString) == 0
|
||||||
|| asi.getM_AttributeSet_ID() == 0 )
|
|| asi.getM_AttributeSet_ID() == 0 )
|
||||||
//storage matches specified ASI or is a costing asi (inc. 0)
|
//storage matches specified ASI or is a costing asi (inc. 0)
|
||||||
// This process will move negative stock on hand quantities
|
// This process will move negative stock on hand quantities
|
||||||
{
|
{
|
||||||
lineMA = new MProductionLineMA( this,
|
//lineMA = new MProductionLineMA( this,
|
||||||
storage.getM_AttributeSetInstance_ID(),
|
// storage.getM_AttributeSetInstance_ID(),
|
||||||
lineQty.negate());
|
// lineQty.negate());
|
||||||
|
lineMA = MProductionLineMA.get(this,storage.getM_AttributeSetInstance_ID());
|
||||||
|
lineMA.setMovementQty(lineMA.getMovementQty().add(lineQty.negate()));
|
||||||
|
|
||||||
if ( !lineMA.save(get_TrxName()) ) {
|
if ( !lineMA.save(get_TrxName()) ) {
|
||||||
log.log(Level.SEVERE, "Could not save MA for " + toString());
|
log.log(Level.SEVERE, "Could not save MA for " + toString());
|
||||||
errorString.append("Could not save MA for " + toString() + "\n" );
|
errorString.append("Could not save MA for " + toString() + "\n" );
|
||||||
|
|
@ -259,9 +255,7 @@ public class MProductionLine extends X_M_ProductionLine {
|
||||||
errorString.append("Could not update storage for " + toString() + "\n");
|
errorString.append("Could not update storage for " + toString() + "\n");
|
||||||
}
|
}
|
||||||
qtyToMove = qtyToMove.subtract(lineQty);
|
qtyToMove = qtyToMove.subtract(lineQty);
|
||||||
System.err.println("Qty Moved = " + lineQty);
|
log.log(Level.FINE, getLine() + " Qty moved = " + lineQty + ", Remaining = " + qtyToMove );
|
||||||
log.log(Level.WARNING, "Qty moved = " + lineQty );
|
|
||||||
log.log(Level.WARNING, getLine() + " Qty to move: " + qtyToMove );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import java.sql.ResultSet;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.compiere.model.X_M_ProductionLineMA;
|
import org.compiere.model.X_M_ProductionLineMA;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
|
||||||
public class MProductionLineMA extends X_M_ProductionLineMA {
|
public class MProductionLineMA extends X_M_ProductionLineMA {
|
||||||
|
|
||||||
|
|
@ -40,5 +41,20 @@ public class MProductionLineMA extends X_M_ProductionLineMA {
|
||||||
setMovementQty(qty);
|
setMovementQty(qty);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static MProductionLineMA get( MProductionLine parent, int asi ) {
|
||||||
|
|
||||||
|
String where = " M_ProductionLine_ID = ? AND M_AttributeSetInstance_ID = ? ";
|
||||||
|
|
||||||
|
MProductionLineMA lineMA = MTable.get(parent.getCtx(), MProductionLineMA.Table_Name).createQuery(where, parent.get_TrxName())
|
||||||
|
.setParameters(parent.getM_ProductionLine_ID(), asi).firstOnly();
|
||||||
|
|
||||||
|
if (lineMA != null)
|
||||||
|
return lineMA;
|
||||||
|
else
|
||||||
|
return new MProductionLineMA( parent,
|
||||||
|
asi,
|
||||||
|
Env.ZERO);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue