BF [ 1885414 ] ASI should be always mandatory if CostingLevel is Batch/Lot
This commit is contained in:
parent
71b71e4618
commit
cab309511f
|
@ -1096,21 +1096,11 @@ public class MInOut extends X_M_InOut implements DocAction
|
||||||
//
|
//
|
||||||
if (line.getM_AttributeSetInstance_ID() != 0)
|
if (line.getM_AttributeSetInstance_ID() != 0)
|
||||||
continue;
|
continue;
|
||||||
if (product != null)
|
if (product != null && product.isASIMandatory(isSOTrx()))
|
||||||
{
|
{
|
||||||
int M_AttributeSet_ID = product.getM_AttributeSet_ID();
|
m_processMsg = "@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #" + lines[i].getLine() +
|
||||||
if (M_AttributeSet_ID != 0)
|
", @M_Product_ID@=" + product.getValue() + ")";
|
||||||
{
|
return DocAction.STATUS_Invalid;
|
||||||
MAttributeSet mas = MAttributeSet.get(getCtx(), M_AttributeSet_ID);
|
|
||||||
if (mas != null
|
|
||||||
&& ((isSOTrx() && mas.isMandatory())
|
|
||||||
|| (!isSOTrx() && mas.isMandatoryAlways())) )
|
|
||||||
{
|
|
||||||
m_processMsg = "@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #" + lines[i].getLine() +
|
|
||||||
", @M_Product_ID@=" + product.getValue() + ")";
|
|
||||||
return DocAction.STATUS_Invalid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setVolume(Volume);
|
setVolume(Volume);
|
||||||
|
|
|
@ -3,263 +3,263 @@
|
||||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* 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 *
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
* by the Free Software Foundation. This program is distributed in the hope *
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
* See the GNU General Public License for more details. *
|
* See the GNU General Public License for more details. *
|
||||||
* You should have received a copy of the GNU General Public License along *
|
* You should have received a copy of the GNU General Public License along *
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.model;
|
package org.compiere.model;
|
||||||
|
|
||||||
import java.math.*;
|
import java.math.*;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Physical Inventory Line Model
|
* Physical Inventory Line Model
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: MInventoryLine.java,v 1.3 2006/07/30 00:51:02 jjanke Exp $
|
* @version $Id: MInventoryLine.java,v 1.3 2006/07/30 00:51:02 jjanke Exp $
|
||||||
*
|
*
|
||||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
* <li>BF [ 1817757 ] Error on saving MInventoryLine in a custom environment
|
* <li>BF [ 1817757 ] Error on saving MInventoryLine in a custom environment
|
||||||
*/
|
*/
|
||||||
public class MInventoryLine extends X_M_InventoryLine
|
public class MInventoryLine extends X_M_InventoryLine
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get Inventory Line with parameters
|
* Get Inventory Line with parameters
|
||||||
* @param inventory inventory
|
* @param inventory inventory
|
||||||
* @param M_Locator_ID locator
|
* @param M_Locator_ID locator
|
||||||
* @param M_Product_ID product
|
* @param M_Product_ID product
|
||||||
* @param M_AttributeSetInstance_ID asi
|
* @param M_AttributeSetInstance_ID asi
|
||||||
* @return line or null
|
* @return line or null
|
||||||
*/
|
*/
|
||||||
public static MInventoryLine get (MInventory inventory,
|
public static MInventoryLine get (MInventory inventory,
|
||||||
int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID)
|
int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID)
|
||||||
{
|
{
|
||||||
MInventoryLine retValue = null;
|
MInventoryLine retValue = null;
|
||||||
String sql = "SELECT * FROM M_InventoryLine "
|
String sql = "SELECT * FROM M_InventoryLine "
|
||||||
+ "WHERE M_Inventory_ID=? AND M_Locator_ID=?"
|
+ "WHERE M_Inventory_ID=? AND M_Locator_ID=?"
|
||||||
+ " AND M_Product_ID=? AND M_AttributeSetInstance_ID=?";
|
+ " AND M_Product_ID=? AND M_AttributeSetInstance_ID=?";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pstmt = DB.prepareStatement (sql, inventory.get_TrxName());
|
pstmt = DB.prepareStatement (sql, inventory.get_TrxName());
|
||||||
pstmt.setInt (1, inventory.getM_Inventory_ID());
|
pstmt.setInt (1, inventory.getM_Inventory_ID());
|
||||||
pstmt.setInt(2, M_Locator_ID);
|
pstmt.setInt(2, M_Locator_ID);
|
||||||
pstmt.setInt(3, M_Product_ID);
|
pstmt.setInt(3, M_Product_ID);
|
||||||
pstmt.setInt(4, M_AttributeSetInstance_ID);
|
pstmt.setInt(4, M_AttributeSetInstance_ID);
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
ResultSet rs = pstmt.executeQuery ();
|
||||||
if (rs.next ())
|
if (rs.next ())
|
||||||
retValue = new MInventoryLine (inventory.getCtx(), rs, inventory.get_TrxName());
|
retValue = new MInventoryLine (inventory.getCtx(), rs, inventory.get_TrxName());
|
||||||
rs.close ();
|
rs.close ();
|
||||||
pstmt.close ();
|
pstmt.close ();
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
s_log.log (Level.SEVERE, sql, e);
|
s_log.log (Level.SEVERE, sql, e);
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (pstmt != null)
|
if (pstmt != null)
|
||||||
pstmt.close ();
|
pstmt.close ();
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return retValue;
|
return retValue;
|
||||||
} // get
|
} // get
|
||||||
|
|
||||||
|
|
||||||
/** Logger */
|
/** Logger */
|
||||||
private static CLogger s_log = CLogger.getCLogger (MInventoryLine.class);
|
private static CLogger s_log = CLogger.getCLogger (MInventoryLine.class);
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Default Constructor
|
* Default Constructor
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
* @param M_InventoryLine_ID line
|
* @param M_InventoryLine_ID line
|
||||||
* @param trxName transaction
|
* @param trxName transaction
|
||||||
*/
|
*/
|
||||||
public MInventoryLine (Properties ctx, int M_InventoryLine_ID, String trxName)
|
public MInventoryLine (Properties ctx, int M_InventoryLine_ID, String trxName)
|
||||||
{
|
{
|
||||||
super (ctx, M_InventoryLine_ID, trxName);
|
super (ctx, M_InventoryLine_ID, trxName);
|
||||||
if (M_InventoryLine_ID == 0)
|
if (M_InventoryLine_ID == 0)
|
||||||
{
|
{
|
||||||
// setM_Inventory_ID (0); // Parent
|
// setM_Inventory_ID (0); // Parent
|
||||||
// setM_InventoryLine_ID (0); // PK
|
// setM_InventoryLine_ID (0); // PK
|
||||||
// setM_Locator_ID (0); // FK
|
// setM_Locator_ID (0); // FK
|
||||||
setLine(0);
|
setLine(0);
|
||||||
// setM_Product_ID (0); // FK
|
// setM_Product_ID (0); // FK
|
||||||
setM_AttributeSetInstance_ID(0); // FK
|
setM_AttributeSetInstance_ID(0); // FK
|
||||||
setInventoryType (INVENTORYTYPE_InventoryDifference);
|
setInventoryType (INVENTORYTYPE_InventoryDifference);
|
||||||
setQtyBook (Env.ZERO);
|
setQtyBook (Env.ZERO);
|
||||||
setQtyCount (Env.ZERO);
|
setQtyCount (Env.ZERO);
|
||||||
setProcessed(false);
|
setProcessed(false);
|
||||||
}
|
}
|
||||||
} // MInventoryLine
|
} // MInventoryLine
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Constructor
|
* Load Constructor
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
* @param rs result set
|
* @param rs result set
|
||||||
* @param trxName transaction
|
* @param trxName transaction
|
||||||
*/
|
*/
|
||||||
public MInventoryLine (Properties ctx, ResultSet rs, String trxName)
|
public MInventoryLine (Properties ctx, ResultSet rs, String trxName)
|
||||||
{
|
{
|
||||||
super(ctx, rs, trxName);
|
super(ctx, rs, trxName);
|
||||||
} // MInventoryLine
|
} // MInventoryLine
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detail Constructor.
|
* Detail Constructor.
|
||||||
* Locator/Product/AttributeSetInstance must be unique
|
* Locator/Product/AttributeSetInstance must be unique
|
||||||
* @param inventory parent
|
* @param inventory parent
|
||||||
* @param M_Locator_ID locator
|
* @param M_Locator_ID locator
|
||||||
* @param M_Product_ID product
|
* @param M_Product_ID product
|
||||||
* @param M_AttributeSetInstance_ID instance
|
* @param M_AttributeSetInstance_ID instance
|
||||||
* @param QtyBook book value
|
* @param QtyBook book value
|
||||||
* @param QtyCount count value
|
* @param QtyCount count value
|
||||||
*/
|
*/
|
||||||
public MInventoryLine (MInventory inventory,
|
public MInventoryLine (MInventory inventory,
|
||||||
int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID,
|
int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID,
|
||||||
BigDecimal QtyBook, BigDecimal QtyCount)
|
BigDecimal QtyBook, BigDecimal QtyCount)
|
||||||
{
|
{
|
||||||
this (inventory.getCtx(), 0, inventory.get_TrxName());
|
this (inventory.getCtx(), 0, inventory.get_TrxName());
|
||||||
if (inventory.get_ID() == 0)
|
if (inventory.get_ID() == 0)
|
||||||
throw new IllegalArgumentException("Header not saved");
|
throw new IllegalArgumentException("Header not saved");
|
||||||
m_parent = inventory;
|
m_parent = inventory;
|
||||||
setM_Inventory_ID (inventory.getM_Inventory_ID()); // Parent
|
setM_Inventory_ID (inventory.getM_Inventory_ID()); // Parent
|
||||||
setClientOrg (inventory.getAD_Client_ID(), inventory.getAD_Org_ID());
|
setClientOrg (inventory.getAD_Client_ID(), inventory.getAD_Org_ID());
|
||||||
setM_Locator_ID (M_Locator_ID); // FK
|
setM_Locator_ID (M_Locator_ID); // FK
|
||||||
setM_Product_ID (M_Product_ID); // FK
|
setM_Product_ID (M_Product_ID); // FK
|
||||||
setM_AttributeSetInstance_ID (M_AttributeSetInstance_ID);
|
setM_AttributeSetInstance_ID (M_AttributeSetInstance_ID);
|
||||||
//
|
//
|
||||||
if (QtyBook != null)
|
if (QtyBook != null)
|
||||||
setQtyBook (QtyBook);
|
setQtyBook (QtyBook);
|
||||||
if (QtyCount != null && QtyCount.signum() != 0)
|
if (QtyCount != null && QtyCount.signum() != 0)
|
||||||
setQtyCount (QtyCount);
|
setQtyCount (QtyCount);
|
||||||
m_isManualEntry = false;
|
m_isManualEntry = false;
|
||||||
} // MInventoryLine
|
} // MInventoryLine
|
||||||
|
|
||||||
/** Manually created */
|
/** Manually created */
|
||||||
private boolean m_isManualEntry = true;
|
private boolean m_isManualEntry = true;
|
||||||
/** Parent */
|
/** Parent */
|
||||||
private MInventory m_parent = null;
|
private MInventory m_parent = null;
|
||||||
/** Product */
|
/** Product */
|
||||||
private MProduct m_product = null;
|
private MProduct m_product = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Qty Book
|
* Get Qty Book
|
||||||
* @return Qty Book
|
* @return Qty Book
|
||||||
*/
|
*/
|
||||||
public BigDecimal getQtyBook ()
|
public BigDecimal getQtyBook ()
|
||||||
{
|
{
|
||||||
BigDecimal bd = super.getQtyBook ();
|
BigDecimal bd = super.getQtyBook ();
|
||||||
if (bd == null)
|
if (bd == null)
|
||||||
bd = Env.ZERO;
|
bd = Env.ZERO;
|
||||||
return bd;
|
return bd;
|
||||||
} // getQtyBook
|
} // getQtyBook
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Qty Count
|
* Get Qty Count
|
||||||
* @return Qty Count
|
* @return Qty Count
|
||||||
*/
|
*/
|
||||||
public BigDecimal getQtyCount ()
|
public BigDecimal getQtyCount ()
|
||||||
{
|
{
|
||||||
BigDecimal bd = super.getQtyCount();
|
BigDecimal bd = super.getQtyCount();
|
||||||
if (bd == null)
|
if (bd == null)
|
||||||
bd = Env.ZERO;
|
bd = Env.ZERO;
|
||||||
return bd;
|
return bd;
|
||||||
} // getQtyBook
|
} // getQtyBook
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Product
|
* Get Product
|
||||||
* @return product or null if not defined
|
* @return product or null if not defined
|
||||||
*/
|
*/
|
||||||
public MProduct getProduct()
|
public MProduct getProduct()
|
||||||
{
|
{
|
||||||
int M_Product_ID = getM_Product_ID();
|
int M_Product_ID = getM_Product_ID();
|
||||||
if (M_Product_ID == 0)
|
if (M_Product_ID == 0)
|
||||||
return null;
|
return null;
|
||||||
if (m_product != null && m_product.getM_Product_ID() != M_Product_ID)
|
if (m_product != null && m_product.getM_Product_ID() != M_Product_ID)
|
||||||
m_product = null; // reset
|
m_product = null; // reset
|
||||||
if (m_product == null)
|
if (m_product == null)
|
||||||
m_product = MProduct.get(getCtx(), M_Product_ID);
|
m_product = MProduct.get(getCtx(), M_Product_ID);
|
||||||
return m_product;
|
return m_product;
|
||||||
} // getProduct
|
} // getProduct
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Count Qty - enforce UOM
|
* Set Count Qty - enforce UOM
|
||||||
* @param QtyCount qty
|
* @param QtyCount qty
|
||||||
*/
|
*/
|
||||||
public void setQtyCount (BigDecimal QtyCount)
|
public void setQtyCount (BigDecimal QtyCount)
|
||||||
{
|
{
|
||||||
if (QtyCount != null)
|
if (QtyCount != null)
|
||||||
{
|
{
|
||||||
MProduct product = getProduct();
|
MProduct product = getProduct();
|
||||||
if (product != null)
|
if (product != null)
|
||||||
{
|
{
|
||||||
int precision = product.getUOMPrecision();
|
int precision = product.getUOMPrecision();
|
||||||
QtyCount = QtyCount.setScale(precision, BigDecimal.ROUND_HALF_UP);
|
QtyCount = QtyCount.setScale(precision, BigDecimal.ROUND_HALF_UP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.setQtyCount(QtyCount);
|
super.setQtyCount(QtyCount);
|
||||||
} // setQtyCount
|
} // setQtyCount
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Internal Use Qty - enforce UOM
|
* Set Internal Use Qty - enforce UOM
|
||||||
* @param QtyInternalUse qty
|
* @param QtyInternalUse qty
|
||||||
*/
|
*/
|
||||||
public void setQtyInternalUse (BigDecimal QtyInternalUse)
|
public void setQtyInternalUse (BigDecimal QtyInternalUse)
|
||||||
{
|
{
|
||||||
if (QtyInternalUse != null)
|
if (QtyInternalUse != null)
|
||||||
{
|
{
|
||||||
MProduct product = getProduct();
|
MProduct product = getProduct();
|
||||||
if (product != null)
|
if (product != null)
|
||||||
{
|
{
|
||||||
int precision = product.getUOMPrecision();
|
int precision = product.getUOMPrecision();
|
||||||
QtyInternalUse = QtyInternalUse.setScale(precision, BigDecimal.ROUND_HALF_UP);
|
QtyInternalUse = QtyInternalUse.setScale(precision, BigDecimal.ROUND_HALF_UP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.setQtyInternalUse(QtyInternalUse);
|
super.setQtyInternalUse(QtyInternalUse);
|
||||||
} // setQtyInternalUse
|
} // setQtyInternalUse
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add to Description
|
* Add to Description
|
||||||
* @param description text
|
* @param description text
|
||||||
*/
|
*/
|
||||||
public void addDescription (String description)
|
public void addDescription (String description)
|
||||||
{
|
{
|
||||||
String desc = getDescription();
|
String desc = getDescription();
|
||||||
if (desc == null)
|
if (desc == null)
|
||||||
setDescription(description);
|
setDescription(description);
|
||||||
else
|
else
|
||||||
setDescription(desc + " | " + description);
|
setDescription(desc + " | " + description);
|
||||||
} // addDescription
|
} // addDescription
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Parent
|
* Get Parent
|
||||||
* @param parent parent
|
* @param parent parent
|
||||||
*/
|
*/
|
||||||
protected void setParent(MInventory parent)
|
protected void setParent(MInventory parent)
|
||||||
{
|
{
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
} // setParent
|
} // setParent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Parent
|
* Get Parent
|
||||||
* @return parent
|
* @return parent
|
||||||
*/
|
*/
|
||||||
|
@ -267,155 +267,184 @@ public class MInventoryLine extends X_M_InventoryLine
|
||||||
{
|
{
|
||||||
if (m_parent == null)
|
if (m_parent == null)
|
||||||
m_parent = new MInventory (getCtx(), getM_Inventory_ID(), get_TrxName());
|
m_parent = new MInventory (getCtx(), getM_Inventory_ID(), get_TrxName());
|
||||||
return m_parent;
|
return m_parent;
|
||||||
} // getParent
|
} // getParent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String Representation
|
* String Representation
|
||||||
* @return info
|
* @return info
|
||||||
*/
|
*/
|
||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
StringBuffer sb = new StringBuffer ("MInventoryLine[");
|
StringBuffer sb = new StringBuffer ("MInventoryLine[");
|
||||||
sb.append (get_ID())
|
sb.append (get_ID())
|
||||||
.append("-M_Product_ID=").append (getM_Product_ID())
|
.append("-M_Product_ID=").append (getM_Product_ID())
|
||||||
.append(",QtyCount=").append(getQtyCount())
|
.append(",QtyCount=").append(getQtyCount())
|
||||||
.append(",QtyInternalUse=").append(getQtyInternalUse())
|
.append(",QtyInternalUse=").append(getQtyInternalUse())
|
||||||
.append(",QtyBook=").append(getQtyBook())
|
.append(",QtyBook=").append(getQtyBook())
|
||||||
.append(",M_AttributeSetInstance_ID=").append(getM_AttributeSetInstance_ID())
|
.append(",M_AttributeSetInstance_ID=").append(getM_AttributeSetInstance_ID())
|
||||||
.append("]");
|
.append("]");
|
||||||
return sb.toString ();
|
return sb.toString ();
|
||||||
} // toString
|
} // toString
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Before Save
|
* Before Save
|
||||||
* @param newRecord new
|
* @param newRecord new
|
||||||
* @return true if can be saved
|
* @return true if can be saved
|
||||||
*/
|
*/
|
||||||
protected boolean beforeSave (boolean newRecord)
|
protected boolean beforeSave (boolean newRecord)
|
||||||
{
|
{
|
||||||
if (newRecord && m_isManualEntry)
|
if (newRecord && m_isManualEntry)
|
||||||
{
|
{
|
||||||
// Product requires ASI
|
// Product requires ASI
|
||||||
if (getM_AttributeSetInstance_ID() == 0)
|
if (getM_AttributeSetInstance_ID() == 0)
|
||||||
{
|
{
|
||||||
MProduct product = MProduct.get(getCtx(), getM_Product_ID());
|
MProduct product = MProduct.get(getCtx(), getM_Product_ID());
|
||||||
if (product.getM_AttributeSet_ID() != 0)
|
if (product != null && product.isASIMandatory(isSOTrx()))
|
||||||
{
|
{
|
||||||
MAttributeSet mas = MAttributeSet.get(getCtx(), product.getM_AttributeSet_ID());
|
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID));
|
||||||
if (mas.isInstanceAttribute()
|
return false;
|
||||||
&& (mas.isMandatory() || mas.isMandatoryAlways()))
|
}
|
||||||
{
|
} // No ASI
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "M_AttributeSetInstance_ID"));
|
} // new or manual
|
||||||
return false;
|
|
||||||
}
|
// Set Line No
|
||||||
}
|
if (getLine() == 0)
|
||||||
} // No ASI
|
{
|
||||||
} // new or manual
|
String sql = "SELECT COALESCE(MAX(Line),0)+10 AS DefaultValue FROM M_InventoryLine WHERE M_Inventory_ID=?";
|
||||||
|
int ii = DB.getSQLValue (get_TrxName(), sql, getM_Inventory_ID());
|
||||||
// Set Line No
|
setLine (ii);
|
||||||
if (getLine() == 0)
|
}
|
||||||
{
|
|
||||||
String sql = "SELECT COALESCE(MAX(Line),0)+10 AS DefaultValue FROM M_InventoryLine WHERE M_Inventory_ID=?";
|
// Enforce Qty UOM
|
||||||
int ii = DB.getSQLValue (get_TrxName(), sql, getM_Inventory_ID());
|
if (newRecord || is_ValueChanged("QtyCount"))
|
||||||
setLine (ii);
|
setQtyCount(getQtyCount());
|
||||||
}
|
if (newRecord || is_ValueChanged("QtyInternalUse"))
|
||||||
|
setQtyInternalUse(getQtyInternalUse());
|
||||||
// Enforce Qty UOM
|
|
||||||
if (newRecord || is_ValueChanged("QtyCount"))
|
// InternalUse Inventory
|
||||||
setQtyCount(getQtyCount());
|
if (getQtyInternalUse().signum() != 0)
|
||||||
if (newRecord || is_ValueChanged("QtyInternalUse"))
|
{
|
||||||
setQtyInternalUse(getQtyInternalUse());
|
if (!INVENTORYTYPE_ChargeAccount.equals(getInventoryType()))
|
||||||
|
setInventoryType(INVENTORYTYPE_ChargeAccount);
|
||||||
// InternalUse Inventory
|
//
|
||||||
if (getQtyInternalUse().signum() != 0)
|
if (getC_Charge_ID() == 0)
|
||||||
{
|
{
|
||||||
if (!INVENTORYTYPE_ChargeAccount.equals(getInventoryType()))
|
log.saveError("InternalUseNeedsCharge", "");
|
||||||
setInventoryType(INVENTORYTYPE_ChargeAccount);
|
return false;
|
||||||
//
|
}
|
||||||
if (getC_Charge_ID() == 0)
|
}
|
||||||
{
|
else if (INVENTORYTYPE_ChargeAccount.equals(getInventoryType()))
|
||||||
log.saveError("InternalUseNeedsCharge", "");
|
{
|
||||||
return false;
|
if (getC_Charge_ID() == 0)
|
||||||
}
|
{
|
||||||
}
|
log.saveError("FillMandatory", Msg.getElement(getCtx(), "C_Charge_ID"));
|
||||||
else if (INVENTORYTYPE_ChargeAccount.equals(getInventoryType()))
|
return false;
|
||||||
{
|
}
|
||||||
if (getC_Charge_ID() == 0)
|
}
|
||||||
{
|
else if (getC_Charge_ID() != 0)
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "C_Charge_ID"));
|
setC_Charge_ID(0);
|
||||||
return false;
|
|
||||||
}
|
// Set AD_Org to parent if not charge
|
||||||
}
|
if (getC_Charge_ID() == 0)
|
||||||
else if (getC_Charge_ID() != 0)
|
setAD_Org_ID(getParent().getAD_Org_ID());
|
||||||
setC_Charge_ID(0);
|
|
||||||
|
return true;
|
||||||
// Set AD_Org to parent if not charge
|
} // beforeSave
|
||||||
if (getC_Charge_ID() == 0)
|
|
||||||
setAD_Org_ID(getParent().getAD_Org_ID());
|
/**
|
||||||
|
* After Save
|
||||||
return true;
|
* @param newRecord new
|
||||||
} // beforeSave
|
* @param success success
|
||||||
|
* @return true
|
||||||
/**
|
*/
|
||||||
* After Save
|
protected boolean afterSave (boolean newRecord, boolean success)
|
||||||
* @param newRecord new
|
{
|
||||||
* @param success success
|
|
||||||
* @return true
|
|
||||||
*/
|
|
||||||
protected boolean afterSave (boolean newRecord, boolean success)
|
|
||||||
{
|
|
||||||
if (!success)
|
if (!success)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Create MA
|
// Create MA
|
||||||
if (newRecord && success
|
if (newRecord && success
|
||||||
&& m_isManualEntry && getM_AttributeSetInstance_ID() == 0)
|
&& m_isManualEntry && getM_AttributeSetInstance_ID() == 0)
|
||||||
createMA();
|
createMA();
|
||||||
return true;
|
return true;
|
||||||
} // afterSave
|
} // afterSave
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Material Allocations for new Instances
|
* Create Material Allocations for new Instances
|
||||||
*/
|
*/
|
||||||
private void createMA()
|
private void createMA()
|
||||||
{
|
{
|
||||||
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());
|
||||||
boolean allZeroASI = true;
|
boolean allZeroASI = true;
|
||||||
for (int i = 0; i < storages.length; i++)
|
for (int i = 0; i < storages.length; i++)
|
||||||
{
|
{
|
||||||
if (storages[i].getM_AttributeSetInstance_ID() != 0)
|
if (storages[i].getM_AttributeSetInstance_ID() != 0)
|
||||||
{
|
{
|
||||||
allZeroASI = false;
|
allZeroASI = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (allZeroASI)
|
if (allZeroASI)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MInventoryLineMA ma = null;
|
MInventoryLineMA ma = null;
|
||||||
BigDecimal sum = Env.ZERO;
|
BigDecimal sum = Env.ZERO;
|
||||||
for (int i = 0; i < storages.length; i++)
|
for (int i = 0; i < storages.length; i++)
|
||||||
{
|
{
|
||||||
MStorage storage = storages[i];
|
MStorage storage = storages[i];
|
||||||
if (storage.getQtyOnHand().signum() == 0)
|
if (storage.getQtyOnHand().signum() == 0)
|
||||||
continue;
|
continue;
|
||||||
if (ma != null
|
if (ma != null
|
||||||
&& ma.getM_AttributeSetInstance_ID() == storage.getM_AttributeSetInstance_ID())
|
&& ma.getM_AttributeSetInstance_ID() == storage.getM_AttributeSetInstance_ID())
|
||||||
ma.setMovementQty(ma.getMovementQty().add(storage.getQtyOnHand()));
|
ma.setMovementQty(ma.getMovementQty().add(storage.getQtyOnHand()));
|
||||||
else
|
else
|
||||||
ma = new MInventoryLineMA (this,
|
ma = new MInventoryLineMA (this,
|
||||||
storage.getM_AttributeSetInstance_ID(), storage.getQtyOnHand());
|
storage.getM_AttributeSetInstance_ID(), storage.getQtyOnHand());
|
||||||
if (!ma.save())
|
if (!ma.save())
|
||||||
;
|
;
|
||||||
sum = sum.add(storage.getQtyOnHand());
|
sum = sum.add(storage.getQtyOnHand());
|
||||||
}
|
}
|
||||||
if (sum.compareTo(getQtyBook()) != 0)
|
if (sum.compareTo(getQtyBook()) != 0)
|
||||||
{
|
{
|
||||||
log.warning("QtyBook=" + getQtyBook() + " corrected to Sum of MA=" + sum);
|
log.warning("QtyBook=" + getQtyBook() + " corrected to Sum of MA=" + sum);
|
||||||
setQtyBook(sum);
|
setQtyBook(sum);
|
||||||
}
|
}
|
||||||
} // createMA
|
} // createMA
|
||||||
|
|
||||||
} // MInventoryLine
|
/**
|
||||||
|
* Is Internal Use Inventory
|
||||||
|
* @return true if is internal use inventory
|
||||||
|
*/
|
||||||
|
public boolean isInternalUseInventory() {
|
||||||
|
/* TODO: need to add M_Inventory.IsInternalUseInventory flag
|
||||||
|
see FR [ 1879029 ] Added IsInternalUseInventory flag to M_Inventory table
|
||||||
|
MInventory parent = getParent();
|
||||||
|
return parent != null && parent.isInternalUseInventory();
|
||||||
|
*/
|
||||||
|
return getQtyInternalUse().signum() != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Movement Qty (absolute value)
|
||||||
|
* <li>negative value means outgoing trx
|
||||||
|
* <li>positive value means incoming trx
|
||||||
|
* @return movement qty
|
||||||
|
*/
|
||||||
|
public BigDecimal getMovementQty() {
|
||||||
|
if(isInternalUseInventory()) {
|
||||||
|
return getQtyInternalUse().negate();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return getQtyCount().subtract(getQtyBook());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if is an outgoing transaction
|
||||||
|
*/
|
||||||
|
public boolean isSOTrx() {
|
||||||
|
return getMovementQty().signum() < 0;
|
||||||
|
}
|
||||||
|
} // MInventoryLine
|
||||||
|
|
|
@ -3,23 +3,23 @@
|
||||||
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
* Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* 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 *
|
* under the terms version 2 of the GNU General Public License as published *
|
||||||
* by the Free Software Foundation. This program is distributed in the hope *
|
* by the Free Software Foundation. This program is distributed in the hope *
|
||||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||||
* See the GNU General Public License for more details. *
|
* See the GNU General Public License for more details. *
|
||||||
* You should have received a copy of the GNU General Public License along *
|
* You should have received a copy of the GNU General Public License along *
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||||
* For the text or an alternative of this public license, you may reach us *
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.compiere.model;
|
package org.compiere.model;
|
||||||
|
|
||||||
import java.math.*;
|
import java.math.*;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.compiere.util.*;
|
import org.compiere.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inventory Move Line Model
|
* Inventory Move Line Model
|
||||||
|
@ -27,18 +27,18 @@ import org.compiere.util.*;
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: MMovementLine.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
|
* @version $Id: MMovementLine.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
public class MMovementLine extends X_M_MovementLine
|
public class MMovementLine extends X_M_MovementLine
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Standard Cosntructor
|
* Standard Cosntructor
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
* @param M_MovementLine_ID id
|
* @param M_MovementLine_ID id
|
||||||
* @param trxName transaction
|
* @param trxName transaction
|
||||||
*/
|
*/
|
||||||
public MMovementLine (Properties ctx, int M_MovementLine_ID, String trxName)
|
public MMovementLine (Properties ctx, int M_MovementLine_ID, String trxName)
|
||||||
{
|
{
|
||||||
super (ctx, M_MovementLine_ID, trxName);
|
super (ctx, M_MovementLine_ID, trxName);
|
||||||
if (M_MovementLine_ID == 0)
|
if (M_MovementLine_ID == 0)
|
||||||
{
|
{
|
||||||
// setM_LocatorTo_ID (0); // @M_LocatorTo_ID@
|
// setM_LocatorTo_ID (0); // @M_LocatorTo_ID@
|
||||||
// setM_Locator_ID (0); // @M_Locator_ID@
|
// setM_Locator_ID (0); // @M_Locator_ID@
|
||||||
|
@ -47,7 +47,7 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
// setM_Product_ID (0);
|
// setM_Product_ID (0);
|
||||||
setM_AttributeSetInstance_ID(0); // ID
|
setM_AttributeSetInstance_ID(0); // ID
|
||||||
setMovementQty (Env.ZERO); // 1
|
setMovementQty (Env.ZERO); // 1
|
||||||
setTargetQty (Env.ZERO); // 0
|
setTargetQty (Env.ZERO); // 0
|
||||||
setScrappedQty(Env.ZERO);
|
setScrappedQty(Env.ZERO);
|
||||||
setConfirmedQty(Env.ZERO);
|
setConfirmedQty(Env.ZERO);
|
||||||
setProcessed (false);
|
setProcessed (false);
|
||||||
|
@ -55,23 +55,23 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
} // MMovementLine
|
} // MMovementLine
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Constructor
|
* Load Constructor
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
* @param rs result set
|
* @param rs result set
|
||||||
* @param trxName transaction
|
* @param trxName transaction
|
||||||
*/
|
*/
|
||||||
public MMovementLine (Properties ctx, ResultSet rs, String trxName)
|
public MMovementLine (Properties ctx, ResultSet rs, String trxName)
|
||||||
{
|
{
|
||||||
super(ctx, rs, trxName);
|
super(ctx, rs, trxName);
|
||||||
} // MMovementLine
|
} // MMovementLine
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent constructor
|
* Parent constructor
|
||||||
* @param parent parent
|
* @param parent parent
|
||||||
*/
|
*/
|
||||||
public MMovementLine (MMovement parent)
|
public MMovementLine (MMovement parent)
|
||||||
{
|
{
|
||||||
this (parent.getCtx(), 0, parent.get_TrxName());
|
this (parent.getCtx(), 0, parent.get_TrxName());
|
||||||
setClientOrg(parent);
|
setClientOrg(parent);
|
||||||
setM_Movement_ID(parent.getM_Movement_ID());
|
setM_Movement_ID(parent.getM_Movement_ID());
|
||||||
} // MMovementLine
|
} // MMovementLine
|
||||||
|
@ -79,11 +79,11 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
/**
|
/**
|
||||||
* Get AttributeSetInstance To
|
* Get AttributeSetInstance To
|
||||||
* @return ASI
|
* @return ASI
|
||||||
*/
|
*/
|
||||||
public int getM_AttributeSetInstanceTo_ID ()
|
public int getM_AttributeSetInstanceTo_ID ()
|
||||||
{
|
{
|
||||||
int M_AttributeSetInstanceTo_ID = super.getM_AttributeSetInstanceTo_ID();
|
int M_AttributeSetInstanceTo_ID = super.getM_AttributeSetInstanceTo_ID();
|
||||||
if (M_AttributeSetInstanceTo_ID == 0)
|
if (M_AttributeSetInstanceTo_ID == 0)
|
||||||
M_AttributeSetInstanceTo_ID = super.getM_AttributeSetInstance_ID();
|
M_AttributeSetInstanceTo_ID = super.getM_AttributeSetInstance_ID();
|
||||||
return M_AttributeSetInstanceTo_ID;
|
return M_AttributeSetInstanceTo_ID;
|
||||||
} // getM_AttributeSetInstanceTo_ID
|
} // getM_AttributeSetInstanceTo_ID
|
||||||
|
@ -91,23 +91,23 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
/**
|
/**
|
||||||
* Add to Description
|
* Add to Description
|
||||||
* @param description text
|
* @param description text
|
||||||
*/
|
*/
|
||||||
public void addDescription (String description)
|
public void addDescription (String description)
|
||||||
{
|
{
|
||||||
String desc = getDescription();
|
String desc = getDescription();
|
||||||
if (desc == null)
|
if (desc == null)
|
||||||
setDescription(description);
|
setDescription(description);
|
||||||
else
|
else
|
||||||
setDescription(desc + " | " + description);
|
setDescription(desc + " | " + description);
|
||||||
} // addDescription
|
} // addDescription
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Product
|
* Get Product
|
||||||
* @return product or null if not defined
|
* @return product or null if not defined
|
||||||
*/
|
*/
|
||||||
public MProduct getProduct()
|
public MProduct getProduct()
|
||||||
{
|
{
|
||||||
if (getM_Product_ID() != 0)
|
if (getM_Product_ID() != 0)
|
||||||
return MProduct.get(getCtx(), getM_Product_ID());
|
return MProduct.get(getCtx(), getM_Product_ID());
|
||||||
return null;
|
return null;
|
||||||
} // getProduct
|
} // getProduct
|
||||||
|
@ -117,9 +117,9 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
* @param MovementQty qty
|
* @param MovementQty qty
|
||||||
*/
|
*/
|
||||||
public void setMovementQty (BigDecimal MovementQty)
|
public void setMovementQty (BigDecimal MovementQty)
|
||||||
{
|
{
|
||||||
if (MovementQty != null)
|
if (MovementQty != null)
|
||||||
{
|
{
|
||||||
MProduct product = getProduct();
|
MProduct product = getProduct();
|
||||||
if (product != null)
|
if (product != null)
|
||||||
{
|
{
|
||||||
|
@ -148,10 +148,10 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
/**
|
/**
|
||||||
* Before Save
|
* Before Save
|
||||||
* @param newRecord new
|
* @param newRecord new
|
||||||
* @return true
|
* @return true
|
||||||
*/
|
*/
|
||||||
protected boolean beforeSave (boolean newRecord)
|
protected boolean beforeSave (boolean newRecord)
|
||||||
{
|
{
|
||||||
// Set Line No
|
// Set Line No
|
||||||
if (getLine() == 0)
|
if (getLine() == 0)
|
||||||
{
|
{
|
||||||
|
@ -163,41 +163,41 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
if (getM_Locator_ID() == getM_LocatorTo_ID())
|
if (getM_Locator_ID() == getM_LocatorTo_ID())
|
||||||
{
|
{
|
||||||
log.saveError("Error", Msg.parseTranslation(getCtx(), "@M_Locator_ID@ == @M_LocatorTo_ID@"));
|
log.saveError("Error", Msg.parseTranslation(getCtx(), "@M_Locator_ID@ == @M_LocatorTo_ID@"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getMovementQty().signum() == 0)
|
if (getMovementQty().signum() == 0)
|
||||||
{
|
{
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "MovementQty"));
|
log.saveError("FillMandatory", Msg.getElement(getCtx(), "MovementQty"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Qty Precision
|
// Qty Precision
|
||||||
if (newRecord || is_ValueChanged(COLUMNNAME_MovementQty))
|
if (newRecord || is_ValueChanged(COLUMNNAME_MovementQty))
|
||||||
setMovementQty(getMovementQty());
|
setMovementQty(getMovementQty());
|
||||||
|
|
||||||
// Mandatory Instance
|
// Mandatory Instance
|
||||||
|
MProduct product = getProduct();
|
||||||
|
if (getM_AttributeSetInstance_ID() == 0) {
|
||||||
|
if (product != null && product.isASIMandatory(false)) {
|
||||||
|
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (getM_AttributeSetInstanceTo_ID() == 0)
|
if (getM_AttributeSetInstanceTo_ID() == 0)
|
||||||
{
|
{
|
||||||
if (getM_AttributeSetInstance_ID() != 0) // set to from
|
if (getM_AttributeSetInstance_ID() != 0) // set to from
|
||||||
setM_AttributeSetInstanceTo_ID(getM_AttributeSetInstance_ID());
|
setM_AttributeSetInstanceTo_ID(getM_AttributeSetInstance_ID());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MProduct product = getProduct();
|
if (product != null && product.isASIMandatory(true))
|
||||||
if (product != null
|
|
||||||
&& product.getM_AttributeSet_ID() != 0)
|
|
||||||
{
|
{
|
||||||
MAttributeSet mas = MAttributeSet.get(getCtx(), product.getM_AttributeSet_ID());
|
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstanceTo_ID));
|
||||||
if (mas.isInstanceAttribute()
|
return false;
|
||||||
&& (mas.isMandatory() || mas.isMandatoryAlways()))
|
|
||||||
{
|
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "M_AttributeSetInstanceTo_ID"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // ASI
|
} // ASI
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // beforeSave
|
} // beforeSave
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.compiere.util.*;
|
||||||
*
|
*
|
||||||
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
* <li>FR [ 1885153 ] Refactor: getMMPolicy code
|
* <li>FR [ 1885153 ] Refactor: getMMPolicy code
|
||||||
|
* <li>BF [ 1885414 ] ASI should be always mandatory if CostingLevel is Batch/Lot
|
||||||
*/
|
*/
|
||||||
public class MProduct extends X_M_Product
|
public class MProduct extends X_M_Product
|
||||||
{
|
{
|
||||||
|
@ -748,4 +749,41 @@ public class MProduct extends X_M_Product
|
||||||
return MMPolicy;
|
return MMPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if ASI is mandatory
|
||||||
|
* @param isSOTrx is outgoing trx?
|
||||||
|
* @return true if ASI is mandatory, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean isASIMandatory(boolean isSOTrx) {
|
||||||
|
//
|
||||||
|
// If CostingLevel is BatchLot ASI is always mandatory - check all client acct schemas
|
||||||
|
MAcctSchema[] mass = MAcctSchema.getClientAcctSchema(getCtx(), getAD_Client_ID(), get_TrxName());
|
||||||
|
for (MAcctSchema as : mass) {
|
||||||
|
MProductCategoryAcct pca = MProductCategoryAcct.get(getCtx(), getM_Product_Category_ID(), as.getC_AcctSchema_ID(), get_TrxName());
|
||||||
|
String cl = pca.getCostingLevel();
|
||||||
|
if (cl == null)
|
||||||
|
cl = as.getCostingLevel();
|
||||||
|
if (MAcctSchema.COSTINGLEVEL_BatchLot.equals(cl)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Check Attribute Set settings
|
||||||
|
int M_AttributeSet_ID = getM_AttributeSet_ID();
|
||||||
|
if (M_AttributeSet_ID != 0)
|
||||||
|
{
|
||||||
|
MAttributeSet mas = MAttributeSet.get(getCtx(), M_AttributeSet_ID);
|
||||||
|
if (mas == null || !mas.isInstanceAttribute())
|
||||||
|
return false;
|
||||||
|
// Outgoing transaction
|
||||||
|
else if (isSOTrx)
|
||||||
|
return mas.isMandatory();
|
||||||
|
// Incoming transaction
|
||||||
|
else // isSOTrx == false
|
||||||
|
return mas.isMandatoryAlways();
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Default not mandatory
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} // MProduct
|
} // MProduct
|
||||||
|
|
Loading…
Reference in New Issue