IDEMPIERE-1770 Allowing manual entry from Attributes tab on shipment/MR line -> move validation for mandatory serial from beforeSave to prepareIt on MInventory and MMovement
This commit is contained in:
parent
87432dd660
commit
b248f46cde
|
@ -334,6 +334,38 @@ public class MInventory extends X_M_Inventory implements DocAction
|
||||||
return DocAction.STATUS_Invalid;
|
return DocAction.STATUS_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate mandatory ASI on lines - IDEMPIERE-1770 - ASI validation must be moved to MInventory.prepareIt
|
||||||
|
for (MInventoryLine line : lines) {
|
||||||
|
// Product requires ASI
|
||||||
|
if (line.getM_AttributeSetInstance_ID() == 0)
|
||||||
|
{
|
||||||
|
MProduct product = MProduct.get(getCtx(), line.getM_Product_ID());
|
||||||
|
if (product != null && product.isASIMandatory(line.isSOTrx()))
|
||||||
|
{
|
||||||
|
if (! product.getAttributeSet().excludeTableEntry(MInventoryLine.Table_ID, line.isSOTrx())) {
|
||||||
|
MDocType dt = MDocType.get(getCtx(), getC_DocType_ID());
|
||||||
|
String docSubTypeInv = dt.getDocSubTypeInv();
|
||||||
|
BigDecimal qtyDiff = line.getQtyInternalUse();
|
||||||
|
if (MDocType.DOCSUBTYPEINV_PhysicalInventory.equals(docSubTypeInv))
|
||||||
|
qtyDiff = line.getQtyBook().subtract(line.getQtyCount());
|
||||||
|
// verify if the ASIs are captured on lineMA
|
||||||
|
MInventoryLineMA mas[] = MInventoryLineMA.get(getCtx(),
|
||||||
|
line.getM_InventoryLine_ID(), get_TrxName());
|
||||||
|
BigDecimal qtyma = Env.ZERO;
|
||||||
|
for (MInventoryLineMA ma : mas) {
|
||||||
|
if (! ma.isAutoGenerated()) {
|
||||||
|
qtyma = qtyma.add(ma.getMovementQty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (qtyma.subtract(qtyDiff).signum() != 0) {
|
||||||
|
m_processMsg = "@Line@ " + line.getLine() + ": @FillMandatory@ @M_AttributeSetInstance_ID@";
|
||||||
|
return DocAction.STATUS_Invalid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // No ASI
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Add up Amounts
|
// TODO: Add up Amounts
|
||||||
// setApprovalAmt();
|
// setApprovalAmt();
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class MInventoryLine extends X_M_InventoryLine
|
||||||
setQtyCount (QtyCount);
|
setQtyCount (QtyCount);
|
||||||
if (QtyInternalUse != null && QtyInternalUse.signum() != 0)
|
if (QtyInternalUse != null && QtyInternalUse.signum() != 0)
|
||||||
setQtyInternalUse (QtyInternalUse);
|
setQtyInternalUse (QtyInternalUse);
|
||||||
m_isManualEntry = false;
|
// m_isManualEntry = false;
|
||||||
} // MInventoryLine
|
} // MInventoryLine
|
||||||
|
|
||||||
public MInventoryLine (MInventory inventory,
|
public MInventoryLine (MInventory inventory,
|
||||||
|
@ -136,7 +136,7 @@ public class MInventoryLine extends X_M_InventoryLine
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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 */
|
||||||
|
@ -260,6 +260,7 @@ public class MInventoryLine extends X_M_InventoryLine
|
||||||
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InventoryLine"));
|
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InventoryLine"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/* IDEMPIERE-1770 - ASI validation must be moved to MInventory.prepareIt, saving a line without ASI is ok on draft
|
||||||
if (m_isManualEntry)
|
if (m_isManualEntry)
|
||||||
{
|
{
|
||||||
// Product requires ASI
|
// Product requires ASI
|
||||||
|
@ -279,7 +280,8 @@ public class MInventoryLine extends X_M_InventoryLine
|
||||||
}
|
}
|
||||||
} // No ASI
|
} // No ASI
|
||||||
} // manual
|
} // manual
|
||||||
|
*/
|
||||||
|
|
||||||
// Set Line No
|
// Set Line No
|
||||||
if (getLine() == 0)
|
if (getLine() == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -290,7 +290,43 @@ public class MMovement extends X_M_Movement implements DocAction
|
||||||
m_processMsg = "@NoLines@";
|
m_processMsg = "@NoLines@";
|
||||||
return DocAction.STATUS_Invalid;
|
return DocAction.STATUS_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate mandatory ASI on lines - IDEMPIERE-1770 - ASI validation must be moved to MMovement.prepareIt
|
||||||
|
for (MMovementLine line : lines) {
|
||||||
|
// Mandatory Instance
|
||||||
|
MProduct product = line.getProduct();
|
||||||
|
if (line.getM_AttributeSetInstance_ID() == 0) {
|
||||||
|
if (product != null && product.isASIMandatory(true)) {
|
||||||
|
if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, true)) { // outgoing
|
||||||
|
BigDecimal qtyDiff = line.getMovementQty();
|
||||||
|
// verify if the ASIs are captured on lineMA
|
||||||
|
MMovementLineMA mas[] = MMovementLineMA.get(getCtx(),
|
||||||
|
line.getM_MovementLine_ID(), get_TrxName());
|
||||||
|
BigDecimal qtyma = Env.ZERO;
|
||||||
|
for (MMovementLineMA ma : mas) {
|
||||||
|
if (! ma.isAutoGenerated()) {
|
||||||
|
qtyma = qtyma.add(ma.getMovementQty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (qtyma.subtract(qtyDiff).signum() != 0) {
|
||||||
|
m_processMsg = "@Line@ " + line.getLine() + ": @FillMandatory@ @M_AttributeSetInstance_ID@";
|
||||||
|
return DocAction.STATUS_Invalid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (line.getM_AttributeSetInstanceTo_ID() == 0)
|
||||||
|
{
|
||||||
|
if (product != null && product.isASIMandatory(false) && line.getM_AttributeSetInstanceTo_ID() == 0)
|
||||||
|
{
|
||||||
|
if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, false)) { // incoming
|
||||||
|
m_processMsg = "@Line@ " + line.getLine() + ": @FillMandatory@ @M_AttributeSetInstanceTo_ID@";
|
||||||
|
return DocAction.STATUS_Invalid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // ASI
|
||||||
|
}
|
||||||
|
|
||||||
// Confirmation
|
// Confirmation
|
||||||
if (dt.isInTransit())
|
if (dt.isInTransit())
|
||||||
createConfirmation();
|
createConfirmation();
|
||||||
|
|
|
@ -207,8 +207,9 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
// Qty Precision
|
// Qty Precision
|
||||||
if (newRecord || is_ValueChanged(COLUMNNAME_MovementQty))
|
if (newRecord || is_ValueChanged(COLUMNNAME_MovementQty))
|
||||||
setMovementQty(getMovementQty());
|
setMovementQty(getMovementQty());
|
||||||
|
|
||||||
// Mandatory Instance
|
// Mandatory Instance
|
||||||
|
/* IDEMPIERE-1770 - ASI validation must be moved to MMovement.prepareIt, saving a line without ASI is ok on draft
|
||||||
MProduct product = getProduct();
|
MProduct product = getProduct();
|
||||||
if (getM_AttributeSetInstance_ID() == 0) {
|
if (getM_AttributeSetInstance_ID() == 0) {
|
||||||
if (product != null && product.isASIMandatory(true)) {
|
if (product != null && product.isASIMandatory(true)) {
|
||||||
|
@ -216,12 +217,13 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
log.saveError("NoAttributeSet", product.getValue());
|
log.saveError("NoAttributeSet", product.getValue());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, true /*outgoing*/)) {
|
if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, true)) { // outgoing
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID));
|
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstance_ID));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
if (getM_AttributeSetInstanceTo_ID() == 0)
|
if (getM_AttributeSetInstanceTo_ID() == 0)
|
||||||
{
|
{
|
||||||
//instance id default to same for movement between locator
|
//instance id default to same for movement between locator
|
||||||
|
@ -230,18 +232,20 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* IDEMPIERE-1770 - ASI validation must be moved to MMovement.prepareIt, saving a line without ASI is ok on draft
|
||||||
if (product != null && product.isASIMandatory(false) && getM_AttributeSetInstanceTo_ID() == 0)
|
if (product != null && product.isASIMandatory(false) && getM_AttributeSetInstanceTo_ID() == 0)
|
||||||
{
|
{
|
||||||
if (product.getAttributeSet()==null) {
|
if (product.getAttributeSet()==null) {
|
||||||
log.saveError("NoAttributeSet", product.getValue());
|
log.saveError("NoAttributeSet", product.getValue());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, false /*incoming*/)) {
|
if (! product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, false)) { // incoming
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstanceTo_ID));
|
log.saveError("FillMandatory", Msg.getElement(getCtx(), COLUMNNAME_M_AttributeSetInstanceTo_ID));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
} // ASI
|
} // ASI
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue