Refactoring
- organize imports - delete large commented code - improve indentation
This commit is contained in:
parent
577394612f
commit
e3f0d270bb
|
@ -29,7 +29,6 @@ import java.util.logging.Level;
|
|||
import org.compiere.print.ReportEngine;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.DocumentEngine;
|
||||
import org.compiere.report.MReportTree;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
|
|
@ -16,13 +16,21 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import org.compiere.process.*;
|
||||
import org.compiere.util.*;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.DocumentEngine;
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
/**
|
||||
* Physical Inventory Model
|
||||
|
@ -388,205 +396,6 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
approveIt();
|
||||
log.info(toString());
|
||||
|
||||
//vpj-cd begin e-evolution recalculate the attribute instances and qty.
|
||||
/*MInventoryLine[] linesup = getLines(false);
|
||||
for (int i = 0; i < linesup.length; i++)
|
||||
{
|
||||
MInventoryLine line = linesup[i];
|
||||
|
||||
String sql1 = "Delete From M_InventoryLineMA "
|
||||
+ " WHERE M_InventoryLine_ID=" +line.getM_InventoryLine_ID();
|
||||
int no = DB.executeUpdate(sql1, get_TrxName());
|
||||
log.info("MA deleted " + no);
|
||||
|
||||
StringBuffer sql = new StringBuffer(
|
||||
"SELECT s.M_Product_ID, s.M_Locator_ID, s.M_AttributeSetInstance_ID,"
|
||||
+ " s.QtyOnHand, p.M_AttributeSet_ID "
|
||||
+ "FROM M_Product p"
|
||||
+ " INNER JOIN M_Storage s ON (s.M_Product_ID=p.M_Product_ID)"
|
||||
+ " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID) "
|
||||
+ "WHERE l.M_Warehouse_ID=?"
|
||||
+ " AND p.IsActive='Y' AND p.IsStocked='Y' and p.ProductType='I'"
|
||||
+ " AND s.M_Locator_ID=" +line.getM_Locator_ID()
|
||||
+ " AND s.M_Product_ID=" +line.getM_Product_ID()
|
||||
+ " AND s.QtyOnHand <> 0 "
|
||||
);
|
||||
PreparedStatement pstmt = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
||||
int index = 1;
|
||||
pstmt.setInt (index++, getM_Warehouse_ID());
|
||||
ResultSet rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
{
|
||||
MInventoryLineMA maup = new MInventoryLineMA (line,
|
||||
rs.getInt(3), rs.getBigDecimal(4));
|
||||
|
||||
if (!maup.save())
|
||||
;
|
||||
}
|
||||
rs.close ();
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql.toString(), e);
|
||||
}
|
||||
try
|
||||
{
|
||||
if (pstmt != null)
|
||||
pstmt.close ();
|
||||
pstmt = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
pstmt = null;
|
||||
}
|
||||
}*/
|
||||
//vpj-cd e-evolution recalculate the attribute instances and qty END.
|
||||
/*
|
||||
//
|
||||
MInventoryLine[] lines = getLines(false);
|
||||
for (int i = 0; i < lines.length; i++)
|
||||
{
|
||||
MInventoryLine line = lines[i];
|
||||
if (!line.isActive())
|
||||
continue;
|
||||
|
||||
MTransaction trx = null;
|
||||
if (line.getM_AttributeSetInstance_ID() == 0)
|
||||
{
|
||||
BigDecimal qtyDiff = line.getQtyInternalUse().negate();
|
||||
if (qtyDiff.signum() == 0)
|
||||
qtyDiff = line.getQtyCount().subtract(line.getQtyBook());
|
||||
//
|
||||
if (qtyDiff.signum() > 0)
|
||||
{
|
||||
// Storage
|
||||
MStorage storage = MStorage.get(getCtx(), line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(), 0, get_TrxName());
|
||||
if (storage == null)
|
||||
storage = MStorage.getCreate(getCtx(), line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(), 0, get_TrxName());
|
||||
BigDecimal qtyNew = storage.getQtyOnHand().add(qtyDiff);
|
||||
log.fine("Diff=" + qtyDiff
|
||||
+ " - OnHand=" + storage.getQtyOnHand() + "->" + qtyNew);
|
||||
storage.setQtyOnHand(qtyNew);
|
||||
storage.setDateLastInventory(getMovementDate());
|
||||
if (!storage.save(get_TrxName()))
|
||||
{
|
||||
m_processMsg = "Storage not updated(1)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
log.fine(storage.toString());
|
||||
// Transaction
|
||||
trx = new MTransaction (getCtx(), line.getAD_Org_ID(),
|
||||
MTransaction.MOVEMENTTYPE_InventoryIn,
|
||||
line.getM_Locator_ID(), line.getM_Product_ID(), 0,
|
||||
qtyDiff, getMovementDate(), get_TrxName());
|
||||
trx.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
|
||||
if (!trx.save())
|
||||
{
|
||||
m_processMsg = "Transaction not inserted(1)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
}
|
||||
else // negative qty
|
||||
{
|
||||
MInventoryLineMA mas[] = MInventoryLineMA.get(getCtx(),
|
||||
line.getM_InventoryLine_ID(), get_TrxName());
|
||||
for (int j = 0; j < mas.length; j++)
|
||||
{
|
||||
MInventoryLineMA ma = mas[j];
|
||||
// Storage
|
||||
MStorage storage = MStorage.get(getCtx(), line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName());
|
||||
if (storage == null)
|
||||
storage = MStorage.getCreate(getCtx(), line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName());
|
||||
//
|
||||
BigDecimal maxDiff = qtyDiff;
|
||||
if (maxDiff.signum() < 0
|
||||
&& ma.getMovementQty().compareTo(maxDiff.negate()) < 0)
|
||||
maxDiff = ma.getMovementQty().negate();
|
||||
BigDecimal qtyNew = ma.getMovementQty().add(maxDiff); // Storage+Diff
|
||||
log.fine("MA Qty=" + ma.getMovementQty()
|
||||
+ ",Diff=" + qtyDiff + "|" + maxDiff
|
||||
+ " - OnHand=" + storage.getQtyOnHand() + "->" + qtyNew
|
||||
+ " {" + ma.getM_AttributeSetInstance_ID() + "}");
|
||||
//
|
||||
storage.setQtyOnHand(qtyNew);
|
||||
storage.setDateLastInventory(getMovementDate());
|
||||
if (!storage.save(get_TrxName()))
|
||||
{
|
||||
m_processMsg = "Storage not updated (MA)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
log.fine(storage.toString());
|
||||
|
||||
// Transaction
|
||||
trx = new MTransaction (getCtx(), line.getAD_Org_ID(),
|
||||
MTransaction.MOVEMENTTYPE_InventoryIn,
|
||||
line.getM_Locator_ID(), line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(),
|
||||
maxDiff, getMovementDate(), get_TrxName());
|
||||
trx.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
|
||||
if (!trx.save())
|
||||
{
|
||||
m_processMsg = "Transaction not inserted (MA)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
//
|
||||
qtyDiff = qtyDiff.subtract(maxDiff);
|
||||
if (qtyDiff.signum() == 0)
|
||||
break;
|
||||
}
|
||||
} // negative qty
|
||||
}
|
||||
// Fallback
|
||||
if (trx == null)
|
||||
{
|
||||
// Storage
|
||||
MStorage storage = MStorage.get(getCtx(), line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), get_TrxName());
|
||||
if (storage == null)
|
||||
storage = MStorage.getCreate(getCtx(), line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(), get_TrxName());
|
||||
//
|
||||
BigDecimal qtyDiff = line.getQtyInternalUse().negate();
|
||||
if (Env.ZERO.compareTo(qtyDiff) == 0)
|
||||
qtyDiff = line.getQtyCount().subtract(line.getQtyBook());
|
||||
BigDecimal qtyNew = storage.getQtyOnHand().add(qtyDiff);
|
||||
log.fine("Count=" + line.getQtyCount()
|
||||
+ ",Book=" + line.getQtyBook() + ", Difference=" + qtyDiff
|
||||
+ " - OnHand=" + storage.getQtyOnHand() + "->" + qtyNew);
|
||||
//
|
||||
storage.setQtyOnHand(qtyNew);
|
||||
storage.setDateLastInventory(getMovementDate());
|
||||
if (!storage.save(get_TrxName()))
|
||||
{
|
||||
m_processMsg = "Storage not updated(2)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
log.fine(storage.toString());
|
||||
|
||||
// Transaction
|
||||
trx = new MTransaction (getCtx(), line.getAD_Org_ID(),
|
||||
MTransaction.MOVEMENTTYPE_InventoryIn,
|
||||
line.getM_Locator_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(),
|
||||
qtyDiff, getMovementDate(), get_TrxName());
|
||||
trx.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
|
||||
if (!trx.save())
|
||||
{
|
||||
m_processMsg = "Transaction not inserted(2)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
} // Fallback
|
||||
|
||||
*/
|
||||
|
||||
|
||||
MInventoryLine[] lines = getLines(false);
|
||||
for (MInventoryLine line : lines)
|
||||
{
|
||||
|
@ -792,51 +601,6 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
MClient.MMPOLICY_FiFo.equals(MMPolicy), get_TrxName());
|
||||
BigDecimal qtyToDeliver = qtyDiff.negate();
|
||||
|
||||
/*for (int ii = 0; ii < storages.length; ii++)
|
||||
{
|
||||
MStorage storage = storages[ii];
|
||||
if (ii == 0)
|
||||
{
|
||||
if (storage.getQtyOnHand().compareTo(qtyToDeliver) >= 0)
|
||||
{
|
||||
line.setM_AttributeSetInstance_ID(storage.getM_AttributeSetInstance_ID());
|
||||
needSave = true;
|
||||
log.config("Direct - " + line);
|
||||
qtyToDeliver = Env.ZERO;
|
||||
}
|
||||
else
|
||||
{
|
||||
log.config("Split - " + line);
|
||||
MInventoryLineMA ma = new MInventoryLineMA (line,
|
||||
storage.getM_AttributeSetInstance_ID(),
|
||||
storage.getQtyOnHand().negate());
|
||||
if (!ma.save())
|
||||
;
|
||||
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
|
||||
log.fine("#" + ii + ": " + ma + ", QtyToDeliver=" + qtyToDeliver);
|
||||
}
|
||||
}
|
||||
else // create addl material allocation
|
||||
{
|
||||
MInventoryLineMA ma = new MInventoryLineMA (line,
|
||||
storage.getM_AttributeSetInstance_ID(),
|
||||
qtyToDeliver.negate());
|
||||
if (storage.getQtyOnHand().compareTo(qtyToDeliver) >= 0)
|
||||
qtyToDeliver = Env.ZERO;
|
||||
else
|
||||
{
|
||||
ma.setMovementQty(storage.getQtyOnHand().negate());
|
||||
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
|
||||
}
|
||||
if (!ma.save())
|
||||
;
|
||||
log.fine("#" + ii + ": " + ma + ", QtyToDeliver=" + qtyToDeliver);
|
||||
}
|
||||
if (qtyToDeliver.signum() == 0)
|
||||
break;
|
||||
} // for all storages
|
||||
*/
|
||||
|
||||
for (MStorage storage: storages)
|
||||
{
|
||||
//cosume ASI Zero
|
||||
|
@ -1069,7 +833,7 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
setDocAction(DOCACTION_None);
|
||||
|
||||
return true;
|
||||
} // reverseCorrectionIt
|
||||
} // reverseCorrectIt
|
||||
|
||||
/**
|
||||
* Reverse Accrual
|
||||
|
|
|
@ -16,12 +16,16 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.*;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
||||
/**
|
||||
* Physical Inventory Line Model
|
||||
|
|
|
@ -16,11 +16,15 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import org.compiere.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,10 +16,15 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import org.compiere.util.*;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CCache;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
|
||||
/**
|
||||
* Warehouse Locator Object
|
||||
|
|
|
@ -16,15 +16,23 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import org.compiere.process.*;
|
||||
import org.compiere.util.*;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.eevolution.model.*;
|
||||
import org.compiere.process.DocAction;
|
||||
import org.compiere.process.DocumentEngine;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.eevolution.model.MDDOrder;
|
||||
import org.eevolution.model.MDDOrderLine;
|
||||
/**
|
||||
* Inventory Movement Model
|
||||
*
|
||||
|
@ -439,7 +447,7 @@ public class MMovement extends X_M_Movement implements DocAction
|
|||
line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName());
|
||||
//*/
|
||||
|
||||
MLocator locatorTo = new MLocator (getCtx(), line.getM_LocatorTo_ID(), get_TrxName());
|
||||
// MLocator locatorTo = new MLocator (getCtx(), line.getM_LocatorTo_ID(), get_TrxName());
|
||||
//Update Storage
|
||||
if (!MStorage.add(getCtx(),locator.getM_Warehouse_ID(),
|
||||
line.getM_LocatorTo_ID(),
|
||||
|
@ -530,7 +538,7 @@ public class MMovement extends X_M_Movement implements DocAction
|
|||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
|
||||
MLocator locatorTo = new MLocator (getCtx(), line.getM_LocatorTo_ID(), get_TrxName());
|
||||
// MLocator locatorTo = new MLocator (getCtx(), line.getM_LocatorTo_ID(), get_TrxName());
|
||||
//Update Storage
|
||||
if (!MStorage.add(getCtx(),locator.getM_Warehouse_ID(),
|
||||
line.getM_LocatorTo_ID(),
|
||||
|
|
|
@ -16,11 +16,19 @@
|
|||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.math.*;
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
import java.util.logging.*;
|
||||
import org.compiere.util.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.compiere.util.CLogMgt;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* Inventory Storage Model
|
||||
|
|
Loading…
Reference in New Issue