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;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
|
|
@ -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)
|
||||
{
|
||||
|
|
@ -603,11 +412,11 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
|
||||
//Ignore the Material Policy when is Reverse Correction
|
||||
if(!isReversal())
|
||||
checkMaterialPolicy(line, qtyDiff);
|
||||
checkMaterialPolicy(line, qtyDiff);
|
||||
|
||||
// Stock Movement - Counterpart MOrder.reserveStock
|
||||
if (product != null
|
||||
&& product.isStocked() )
|
||||
&& product.isStocked() )
|
||||
{
|
||||
log.fine("Material Transaction");
|
||||
MTransaction mtrx = null;
|
||||
|
|
@ -616,7 +425,7 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
if (line.getM_AttributeSetInstance_ID() == 0 || qtyDiff.compareTo(Env.ZERO) == 0)
|
||||
{
|
||||
MInventoryLineMA mas[] = MInventoryLineMA.get(getCtx(),
|
||||
line.getM_InventoryLine_ID(), get_TrxName());
|
||||
line.getM_InventoryLine_ID(), get_TrxName());
|
||||
|
||||
for (int j = 0; j < mas.length; j++)
|
||||
{
|
||||
|
|
@ -626,45 +435,45 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
log.fine("Diff=" + qtyDiff
|
||||
+ " - Instance OnHand=" + QtyMA + "->" + QtyNew);
|
||||
|
||||
if (!MStorage.add(getCtx(), getM_Warehouse_ID(),
|
||||
line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(),
|
||||
ma.getM_AttributeSetInstance_ID(), 0,
|
||||
QtyMA.negate(), Env.ZERO, Env.ZERO, get_TrxName()))
|
||||
{
|
||||
m_processMsg = "Cannot correct Inventory (MA)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
if (!MStorage.add(getCtx(), getM_Warehouse_ID(),
|
||||
line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(),
|
||||
ma.getM_AttributeSetInstance_ID(), 0,
|
||||
QtyMA.negate(), Env.ZERO, Env.ZERO, get_TrxName()))
|
||||
{
|
||||
m_processMsg = "Cannot correct Inventory (MA)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
|
||||
// Only Update Date Last Inventory if is a Physical Inventory
|
||||
if(line.getQtyInternalUse().compareTo(Env.ZERO) == 0)
|
||||
// Only Update Date Last Inventory if is a Physical Inventory
|
||||
if(line.getQtyInternalUse().compareTo(Env.ZERO) == 0)
|
||||
{
|
||||
MStorage storage = MStorage.get(getCtx(), line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName());
|
||||
storage.setDateLastInventory(getMovementDate());
|
||||
if (!storage.save(get_TrxName()))
|
||||
{
|
||||
MStorage storage = MStorage.get(getCtx(), line.getM_Locator_ID(),
|
||||
line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(), get_TrxName());
|
||||
storage.setDateLastInventory(getMovementDate());
|
||||
if (!storage.save(get_TrxName()))
|
||||
{
|
||||
m_processMsg = "Storage not updated(2)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
String m_MovementType =null;
|
||||
if(QtyMA.negate().compareTo(Env.ZERO) > 0 )
|
||||
m_MovementType = MTransaction.MOVEMENTTYPE_InventoryIn;
|
||||
else
|
||||
m_MovementType = MTransaction.MOVEMENTTYPE_InventoryOut;
|
||||
// Transaction
|
||||
mtrx = new MTransaction (getCtx(), line.getAD_Org_ID(), m_MovementType,
|
||||
line.getM_Locator_ID(), line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(),
|
||||
QtyMA.negate(), getMovementDate(), get_TrxName());
|
||||
mtrx.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
|
||||
if (!mtrx.save())
|
||||
{
|
||||
m_processMsg = "Transaction not inserted(2)";
|
||||
m_processMsg = "Storage not updated(2)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
qtyDiff = QtyNew;
|
||||
}
|
||||
|
||||
String m_MovementType =null;
|
||||
if(QtyMA.negate().compareTo(Env.ZERO) > 0 )
|
||||
m_MovementType = MTransaction.MOVEMENTTYPE_InventoryIn;
|
||||
else
|
||||
m_MovementType = MTransaction.MOVEMENTTYPE_InventoryOut;
|
||||
// Transaction
|
||||
mtrx = new MTransaction (getCtx(), line.getAD_Org_ID(), m_MovementType,
|
||||
line.getM_Locator_ID(), line.getM_Product_ID(), ma.getM_AttributeSetInstance_ID(),
|
||||
QtyMA.negate(), getMovementDate(), get_TrxName());
|
||||
mtrx.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
|
||||
if (!mtrx.save())
|
||||
{
|
||||
m_processMsg = "Transaction not inserted(2)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
qtyDiff = QtyNew;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -679,8 +488,8 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
line.getM_AttributeSetInstance_ID(), 0,
|
||||
qtyDiff, Env.ZERO, Env.ZERO, get_TrxName()))
|
||||
{
|
||||
m_processMsg = "Cannot correct Inventory (MA)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
m_processMsg = "Cannot correct Inventory (MA)";
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
|
||||
// Only Update Date Last Inventory if is a Physical Inventory
|
||||
|
|
@ -704,8 +513,8 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
m_MovementType = MTransaction.MOVEMENTTYPE_InventoryOut;
|
||||
// Transaction
|
||||
mtrx = new MTransaction (getCtx(), line.getAD_Org_ID(), m_MovementType,
|
||||
line.getM_Locator_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(),
|
||||
qtyDiff, getMovementDate(), get_TrxName());
|
||||
line.getM_Locator_ID(), line.getM_Product_ID(), line.getM_AttributeSetInstance_ID(),
|
||||
qtyDiff, getMovementDate(), get_TrxName());
|
||||
mtrx.setM_InventoryLine_ID(line.getM_InventoryLine_ID());
|
||||
if (!mtrx.save())
|
||||
{
|
||||
|
|
@ -713,7 +522,7 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
} // Fallback
|
||||
} // stock movement
|
||||
} // stock movement
|
||||
|
||||
|
||||
} // for all lines
|
||||
|
|
@ -762,128 +571,83 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
log.config("Delete old #" + no);
|
||||
|
||||
|
||||
// Check Line
|
||||
boolean needSave = false;
|
||||
BigDecimal qtyASI = Env.ZERO ;
|
||||
// Attribute Set Instance
|
||||
if (line.getM_AttributeSetInstance_ID() == 0)
|
||||
// Check Line
|
||||
boolean needSave = false;
|
||||
BigDecimal qtyASI = Env.ZERO ;
|
||||
// Attribute Set Instance
|
||||
if (line.getM_AttributeSetInstance_ID() == 0)
|
||||
{
|
||||
MProduct product = MProduct.get(getCtx(), line.getM_Product_ID());
|
||||
if (qtyDiff.signum() > 0) // Incoming Trx
|
||||
{
|
||||
MProduct product = MProduct.get(getCtx(), line.getM_Product_ID());
|
||||
if (qtyDiff.signum() > 0) // Incoming Trx
|
||||
MAttributeSetInstance asi = new MAttributeSetInstance(getCtx(), 0, get_TrxName());
|
||||
asi.setClientOrg(getAD_Client_ID(), 0);
|
||||
asi.setM_AttributeSet_ID(product.getM_AttributeSet_ID());
|
||||
if (!asi.save())
|
||||
{
|
||||
MAttributeSetInstance asi = new MAttributeSetInstance(getCtx(), 0, get_TrxName());
|
||||
asi.setClientOrg(getAD_Client_ID(), 0);
|
||||
asi.setM_AttributeSet_ID(product.getM_AttributeSet_ID());
|
||||
if (!asi.save())
|
||||
{
|
||||
throw new IllegalStateException("Error try create ASI Reservation");
|
||||
}
|
||||
if (asi.save())
|
||||
{
|
||||
line.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID());
|
||||
needSave = true;
|
||||
}
|
||||
throw new IllegalStateException("Error try create ASI Reservation");
|
||||
}
|
||||
else // Outgoing Trx
|
||||
if (asi.save())
|
||||
{
|
||||
String MMPolicy = product.getMMPolicy();
|
||||
MStorage[] storages = MStorage.getAllWithASI(getCtx(),
|
||||
line.setM_AttributeSetInstance_ID(asi.getM_AttributeSetInstance_ID());
|
||||
needSave = true;
|
||||
}
|
||||
}
|
||||
else // Outgoing Trx
|
||||
{
|
||||
String MMPolicy = product.getMMPolicy();
|
||||
MStorage[] storages = MStorage.getAllWithASI(getCtx(),
|
||||
line.getM_Product_ID(), line.getM_Locator_ID(),
|
||||
MClient.MMPOLICY_FiFo.equals(MMPolicy), get_TrxName());
|
||||
BigDecimal qtyToDeliver = qtyDiff.negate();
|
||||
BigDecimal qtyToDeliver = qtyDiff.negate();
|
||||
|
||||
/*for (int ii = 0; ii < storages.length; ii++)
|
||||
for (MStorage storage: storages)
|
||||
{
|
||||
//cosume ASI Zero
|
||||
if (storage.getM_AttributeSetInstance_ID() == 0)
|
||||
{
|
||||
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,
|
||||
qtyASI = qtyASI.add(storage.getQtyOnHand());
|
||||
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (storage.getQtyOnHand().compareTo(qtyToDeliver) >= 0)
|
||||
{
|
||||
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
|
||||
if (storage.getM_AttributeSetInstance_ID() == 0)
|
||||
{
|
||||
qtyASI = qtyASI.add(storage.getQtyOnHand());
|
||||
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (storage.getQtyOnHand().compareTo(qtyToDeliver) >= 0)
|
||||
{
|
||||
MInventoryLineMA ma = new MInventoryLineMA (line,
|
||||
storage.getM_AttributeSetInstance_ID(),
|
||||
qtyToDeliver);
|
||||
if (!ma.save())
|
||||
{
|
||||
throw new IllegalStateException("Error try create ASI Reservation");
|
||||
}
|
||||
qtyToDeliver = Env.ZERO;
|
||||
log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
|
||||
//return;
|
||||
}
|
||||
else
|
||||
{
|
||||
MInventoryLineMA ma = new MInventoryLineMA (line,
|
||||
storage.getM_AttributeSetInstance_ID(),
|
||||
storage.getQtyOnHand());
|
||||
if (!ma.save())
|
||||
{
|
||||
throw new IllegalStateException("Error try create ASI Reservation");
|
||||
}
|
||||
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
|
||||
log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
|
||||
}
|
||||
}
|
||||
|
||||
// No AttributeSetInstance found for remainder
|
||||
if (qtyToDeliver.signum() != 0 || qtyASI.signum() != 0)
|
||||
{
|
||||
MInventoryLineMA ma = new MInventoryLineMA (line, 0 , qtyToDeliver.add(qtyASI));
|
||||
|
||||
qtyToDeliver);
|
||||
if (!ma.save())
|
||||
;
|
||||
log.fine("##: " + ma);
|
||||
{
|
||||
throw new IllegalStateException("Error try create ASI Reservation");
|
||||
}
|
||||
qtyToDeliver = Env.ZERO;
|
||||
log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
|
||||
//return;
|
||||
}
|
||||
} // outgoing Trx
|
||||
else
|
||||
{
|
||||
MInventoryLineMA ma = new MInventoryLineMA (line,
|
||||
storage.getM_AttributeSetInstance_ID(),
|
||||
storage.getQtyOnHand());
|
||||
if (!ma.save())
|
||||
{
|
||||
throw new IllegalStateException("Error try create ASI Reservation");
|
||||
}
|
||||
qtyToDeliver = qtyToDeliver.subtract(storage.getQtyOnHand());
|
||||
log.fine( ma + ", QtyToDeliver=" + qtyToDeliver);
|
||||
}
|
||||
}
|
||||
|
||||
// No AttributeSetInstance found for remainder
|
||||
if (qtyToDeliver.signum() != 0 || qtyASI.signum() != 0)
|
||||
{
|
||||
MInventoryLineMA ma = new MInventoryLineMA (line, 0 , qtyToDeliver.add(qtyASI));
|
||||
|
||||
if (!ma.save())
|
||||
;
|
||||
log.fine("##: " + ma);
|
||||
}
|
||||
} // outgoing Trx
|
||||
|
||||
if (needSave && !line.save())
|
||||
log.severe("NOT saved " + line);
|
||||
|
|
@ -1033,12 +797,12 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
if (rLine.getM_AttributeSetInstance_ID() == 0)
|
||||
{
|
||||
MInventoryLineMA mas[] = MInventoryLineMA.get(getCtx(),
|
||||
oLines[i].getM_InventoryLine_ID(), get_TrxName());
|
||||
oLines[i].getM_InventoryLine_ID(), get_TrxName());
|
||||
for (int j = 0; j < mas.length; j++)
|
||||
{
|
||||
MInventoryLineMA ma = new MInventoryLineMA (rLine,
|
||||
mas[j].getM_AttributeSetInstance_ID(),
|
||||
mas[j].getMovementQty().negate());
|
||||
mas[j].getM_AttributeSetInstance_ID(),
|
||||
mas[j].getMovementQty().negate());
|
||||
if (!ma.save())
|
||||
;
|
||||
}
|
||||
|
|
@ -1069,7 +833,7 @@ public class MInventory extends X_M_Inventory implements DocAction
|
|||
setDocAction(DOCACTION_None);
|
||||
|
||||
return true;
|
||||
} // reverseCorrectionIt
|
||||
} // reverseCorrectIt
|
||||
|
||||
/**
|
||||
* Reverse Accrual
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
|
|
@ -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;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
|
|
|
|||
Loading…
Reference in New Issue