IDEMPIERE-3514 Production: Could not save MA for Production line

This commit is contained in:
Heng Sin Low 2017-10-26 10:16:49 +08:00
parent 267fab419a
commit 43300bdfc2
2 changed files with 55 additions and 7 deletions

View File

@ -114,17 +114,21 @@ public class MProductionLine extends X_M_ProductionLine {
}
Timestamp dateMPolicy = date;
if(getM_AttributeSetInstance_ID()>0){
Timestamp t = MStorageOnHand.getDateMaterialPolicy(getM_Product_ID(), getM_AttributeSetInstance_ID(), get_TrxName());
Timestamp t = MStorageOnHand.getDateMaterialPolicy(getM_Product_ID(), getM_AttributeSetInstance_ID(), getM_Locator_ID(), get_TrxName());
if (t != null)
dateMPolicy = t;
}
dateMPolicy = Util.removeTime(dateMPolicy);
MProductionLineMA lineMA = new MProductionLineMA( this,
asi.get_ID(), getMovementQty(),dateMPolicy);
if ( !lineMA.save(get_TrxName()) ) {
log.log(Level.SEVERE, "Could not save MA for " + toString());
errorString.append("Could not save MA for " + toString() + "\n" );
//for reversal, keep the ma copy from original trx
if (reversalId <= 0 )
{
MProductionLineMA lineMA = new MProductionLineMA( this,
asi.get_ID(), getMovementQty(),dateMPolicy);
if ( !lineMA.save(get_TrxName()) ) {
log.log(Level.SEVERE, "Could not save MA for " + toString());
errorString.append("Could not save MA for " + toString() + "\n" );
}
}
MTransaction matTrx = new MTransaction (getCtx(), getAD_Org_ID(),
"P+",

View File

@ -1035,7 +1035,8 @@ public class MStorageOnHand extends X_M_StorageOnHand
*
* @param M_Product_ID
* @param M_AttributeSetInstance_ID
* @return
* @param trxName
* @return datempolicy timestamp
*/
public static Timestamp getDateMaterialPolicy(int M_Product_ID, int M_AttributeSetInstance_ID,String trxName){
@ -1068,6 +1069,49 @@ public class MStorageOnHand extends X_M_StorageOnHand
}
return null;
} //getDateMaterialPolicy
/**
*
* @param M_Product_ID
* @param M_AttributeSetInstance_ID
* @param M_Locator_ID
* @param trxName
* @return datempolicy timestamp
*/
public static Timestamp getDateMaterialPolicy(int M_Product_ID, int M_AttributeSetInstance_ID, int M_Locator_ID, String trxName){
if (M_Product_ID <= 0 || M_AttributeSetInstance_ID <= 0)
return null;
String sql = "SELECT dateMaterialPolicy FROM M_StorageOnHand WHERE M_Product_ID=? and M_AttributeSetInstance_ID=? AND M_Locator_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, trxName);
pstmt.setInt(1, M_Product_ID);
pstmt.setInt(2, M_AttributeSetInstance_ID);
pstmt.setInt(3, M_Locator_ID);
rs = pstmt.executeQuery();
if (rs.next())
{
return rs.getTimestamp(1);
}
} catch (SQLException ex)
{
s_log.log(Level.SEVERE, sql, ex);
}finally
{
DB.close(rs, pstmt);
rs = null; pstmt = null;
}
return null;
} //getDateMaterialPolicy
} // MStorageOnHand