IDEMPIERE-2624 Cant confirm 0 qty on Movement Confirmation (#198)
* IDEMPIERE-2624 Cant confirm 0 qty on Movement Confirmation * IDEMPIERE-2624 Cant confirm 0 qty on Movement Confirmation Add validations to avoid editing lines if there are pending confirmations, in movement and shipment/receipt
This commit is contained in:
parent
a3a86739c2
commit
59758e8a7e
|
@ -69,7 +69,7 @@ public class MInOut extends X_M_InOut implements DocAction
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1226522383231204912L;
|
private static final long serialVersionUID = 5791054523079936837L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create Shipment From Order
|
* Create Shipment From Order
|
||||||
|
@ -1283,22 +1283,10 @@ public class MInOut extends X_M_InOut implements DocAction
|
||||||
if (m_processMsg != null)
|
if (m_processMsg != null)
|
||||||
return DocAction.STATUS_Invalid;
|
return DocAction.STATUS_Invalid;
|
||||||
|
|
||||||
// Outstanding (not processed) Incoming Confirmations ?
|
if (pendingCustomerConfirmations()) {
|
||||||
MInOutConfirm[] confirmations = getConfirmations(true);
|
m_processMsg = "@Open@: @M_InOutConfirm_ID@";
|
||||||
for (int i = 0; i < confirmations.length; i++)
|
|
||||||
{
|
|
||||||
MInOutConfirm confirm = confirmations[i];
|
|
||||||
if (!confirm.isProcessed())
|
|
||||||
{
|
|
||||||
if (MInOutConfirm.CONFIRMTYPE_CustomerConfirmation.equals(confirm.getConfirmType()))
|
|
||||||
continue;
|
|
||||||
//
|
|
||||||
m_processMsg = "Open @M_InOutConfirm_ID@: " +
|
|
||||||
confirm.getConfirmTypeName() + " - " + confirm.getDocumentNo();
|
|
||||||
return DocAction.STATUS_InProgress;
|
return DocAction.STATUS_InProgress;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Implicit Approval
|
// Implicit Approval
|
||||||
if (!isApproved())
|
if (!isApproved())
|
||||||
|
@ -1720,6 +1708,39 @@ public class MInOut extends X_M_InOut implements DocAction
|
||||||
return DocAction.STATUS_Completed;
|
return DocAction.STATUS_Completed;
|
||||||
} // completeIt
|
} // completeIt
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outstanding (not processed) Customer Confirmations ?
|
||||||
|
* @return true if there are pending Customer Confirmations
|
||||||
|
*/
|
||||||
|
public boolean pendingCustomerConfirmations() {
|
||||||
|
MInOutConfirm[] confirmations = getConfirmations(true);
|
||||||
|
for (int i = 0; i < confirmations.length; i++) {
|
||||||
|
MInOutConfirm confirm = confirmations[i];
|
||||||
|
if (!confirm.isProcessed()) {
|
||||||
|
if (MInOutConfirm.CONFIRMTYPE_CustomerConfirmation.equals(confirm.getConfirmType())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outstanding (not processed) Confirmations ?
|
||||||
|
* @return true if there are pending Confirmations
|
||||||
|
*/
|
||||||
|
public boolean pendingConfirmations() {
|
||||||
|
MInOutConfirm[] confirmations = getConfirmations(true);
|
||||||
|
for (int i = 0; i < confirmations.length; i++) {
|
||||||
|
MInOutConfirm confirm = confirmations[i];
|
||||||
|
if (!confirm.isProcessed()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Save array of documents to process AFTER completing this one */
|
/* Save array of documents to process AFTER completing this one */
|
||||||
ArrayList<PO> docsPostProcess = new ArrayList<PO>();
|
ArrayList<PO> docsPostProcess = new ArrayList<PO>();
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction
|
||||||
}
|
}
|
||||||
if (s_log.isLoggable(Level.INFO)) s_log.info("New: " + confirm);
|
if (s_log.isLoggable(Level.INFO)) s_log.info("New: " + confirm);
|
||||||
return confirm;
|
return confirm;
|
||||||
} // MInOutConfirm
|
} // create
|
||||||
|
|
||||||
/** Static Logger */
|
/** Static Logger */
|
||||||
private static CLogger s_log = CLogger.getCLogger (MInOutConfirm.class);
|
private static CLogger s_log = CLogger.getCLogger (MInOutConfirm.class);
|
||||||
|
@ -228,7 +228,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction
|
||||||
log.severe("Could not create PDF - " + e.getMessage());
|
log.severe("Could not create PDF - " + e.getMessage());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} // getPDF
|
} // createPDF
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create PDF file
|
* Create PDF file
|
||||||
|
|
|
@ -514,6 +514,13 @@ public class MInOutLine extends X_M_InOutLine
|
||||||
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InOutLine"));
|
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InOutLine"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (getParent().pendingConfirmations()) {
|
||||||
|
if ( newRecord ||
|
||||||
|
(is_ValueChanged(COLUMNNAME_MovementQty) && !is_ValueChanged(COLUMNNAME_TargetQty))) {
|
||||||
|
log.saveError("SaveError", Msg.parseTranslation(getCtx(), "@Open@: @M_InOutConfirm_ID@"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Locator is mandatory if no charge is defined - teo_sarca BF [ 2757978 ]
|
// Locator is mandatory if no charge is defined - teo_sarca BF [ 2757978 ]
|
||||||
if(getProduct() != null && MProduct.PRODUCTTYPE_Item.equals(getProduct().getProductType()))
|
if(getProduct() != null && MProduct.PRODUCTTYPE_Item.equals(getProduct().getProductType()))
|
||||||
{
|
{
|
||||||
|
@ -646,6 +653,10 @@ public class MInOutLine extends X_M_InOutLine
|
||||||
log.saveError("Error", Msg.getMsg(getCtx(), "CannotDelete"));
|
log.saveError("Error", Msg.getMsg(getCtx(), "CannotDelete"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (getParent().pendingConfirmations()) {
|
||||||
|
log.saveError("DeleteError", Msg.parseTranslation(getCtx(), "@Open@: @M_InOutConfirm_ID@"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// IDEMPIERE-3391 Not possible to delete a line in the Material Receipt window
|
// IDEMPIERE-3391 Not possible to delete a line in the Material Receipt window
|
||||||
List<MInvoiceLine> ils = new Query(getCtx(), MInvoiceLine.Table_Name, "M_InOutLine_ID=?", get_TrxName())
|
List<MInvoiceLine> ils = new Query(getCtx(), MInvoiceLine.Table_Name, "M_InOutLine_ID=?", get_TrxName())
|
||||||
.setParameters(getM_InOutLine_ID())
|
.setParameters(getM_InOutLine_ID())
|
||||||
|
|
|
@ -144,7 +144,7 @@ public class MInOutLineConfirm extends X_M_InOutLineConfirm
|
||||||
{
|
{
|
||||||
line.setTargetQty(getTargetQty());
|
line.setTargetQty(getTargetQty());
|
||||||
BigDecimal qty = getConfirmedQty();
|
BigDecimal qty = getConfirmedQty();
|
||||||
if (!isSOTrx) // In PO, we have the responsibility for scapped
|
if (!isSOTrx) // In PO, we have the responsibility for scrapped
|
||||||
qty = qty.add(getScrappedQty());
|
qty = qty.add(getScrappedQty());
|
||||||
line.setMovementQty(qty); // Entered NOT changed
|
line.setMovementQty(qty); // Entered NOT changed
|
||||||
//
|
//
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class MMovement extends X_M_Movement implements DocAction
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 3201199540429467933L;
|
private static final long serialVersionUID = 5415969431202357692L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Constructor
|
* Standard Constructor
|
||||||
|
@ -400,18 +400,10 @@ public class MMovement extends X_M_Movement implements DocAction
|
||||||
if (m_processMsg != null)
|
if (m_processMsg != null)
|
||||||
return DocAction.STATUS_Invalid;
|
return DocAction.STATUS_Invalid;
|
||||||
|
|
||||||
// Outstanding (not processed) Incoming Confirmations ?
|
if (pendingConfirmations()) {
|
||||||
MMovementConfirm[] confirmations = getConfirmations(true);
|
m_processMsg = "@Open@: @M_MovementConfirm_ID@";
|
||||||
for (int i = 0; i < confirmations.length; i++)
|
|
||||||
{
|
|
||||||
MMovementConfirm confirm = confirmations[i];
|
|
||||||
if (!confirm.isProcessed())
|
|
||||||
{
|
|
||||||
m_processMsg = "Open: @M_MovementConfirm_ID@ - "
|
|
||||||
+ confirm.getDocumentNo();
|
|
||||||
return DocAction.STATUS_InProgress;
|
return DocAction.STATUS_InProgress;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Implicit Approval
|
// Implicit Approval
|
||||||
if (!isApproved())
|
if (!isApproved())
|
||||||
|
@ -626,6 +618,20 @@ public class MMovement extends X_M_Movement implements DocAction
|
||||||
return DocAction.STATUS_Completed;
|
return DocAction.STATUS_Completed;
|
||||||
} // completeIt
|
} // completeIt
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outstanding (not processed) Incoming Confirmations ?
|
||||||
|
* @return true if there are pending Confirmations
|
||||||
|
*/
|
||||||
|
public boolean pendingConfirmations() {
|
||||||
|
MMovementConfirm[] confirmations = getConfirmations(true);
|
||||||
|
for (int i = 0; i < confirmations.length; i++) {
|
||||||
|
MMovementConfirm confirm = confirmations[i];
|
||||||
|
if (!confirm.isProcessed())
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the definite document number after completed
|
* Set the definite document number after completed
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
|
||||||
cLine.saveEx(move.get_TrxName());
|
cLine.saveEx(move.get_TrxName());
|
||||||
}
|
}
|
||||||
return confirm;
|
return confirm;
|
||||||
} // MInOutConfirm
|
} // create
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
|
@ -124,7 +124,7 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
|
||||||
this (move.getCtx(), 0, move.get_TrxName());
|
this (move.getCtx(), 0, move.get_TrxName());
|
||||||
setClientOrg(move);
|
setClientOrg(move);
|
||||||
setM_Movement_ID(move.getM_Movement_ID());
|
setM_Movement_ID(move.getM_Movement_ID());
|
||||||
} // MInOutConfirm
|
} // MMovementConfirm
|
||||||
|
|
||||||
/** Confirm Lines */
|
/** Confirm Lines */
|
||||||
protected MMovementLineConfirm[] m_lines = null;
|
protected MMovementLineConfirm[] m_lines = null;
|
||||||
|
@ -235,7 +235,7 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
|
||||||
log.severe("Could not create PDF - " + e.getMessage());
|
log.severe("Could not create PDF - " + e.getMessage());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} // getPDF
|
} // createPDF
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create PDF file
|
* Create PDF file
|
||||||
|
@ -409,7 +409,7 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
|
||||||
+ " - Difference=" + confirm.getDifferenceQty());
|
+ " - Difference=" + confirm.getDifferenceQty());
|
||||||
|
|
||||||
if (m_processMsg == null)
|
if (m_processMsg == null)
|
||||||
m_processMsg = "Differnce Doc not created";
|
m_processMsg = "Difference Doc not created";
|
||||||
return DocAction.STATUS_Invalid;
|
return DocAction.STATUS_Invalid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = -5753062311388766921L;
|
private static final long serialVersionUID = -5614562023263896756L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard Cosntructor
|
* Standard Cosntructor
|
||||||
|
@ -171,6 +171,13 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_MovementLine"));
|
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_MovementLine"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (getParent().pendingConfirmations()) {
|
||||||
|
if ( newRecord ||
|
||||||
|
(is_ValueChanged(COLUMNNAME_MovementQty) && !is_ValueChanged(COLUMNNAME_TargetQty))) {
|
||||||
|
log.saveError("SaveError", Msg.parseTranslation(getCtx(), "@Open@: @M_MovementConfirm_ID@"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
// Set Line No
|
// Set Line No
|
||||||
if (getLine() == 0)
|
if (getLine() == 0)
|
||||||
{
|
{
|
||||||
|
@ -188,17 +195,24 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
|
|
||||||
if (getMovementQty().signum() == 0)
|
if (getMovementQty().signum() == 0)
|
||||||
{
|
{
|
||||||
if ( MMovement.DOCACTION_Void.equals(getParent().getDocAction())
|
String docAction = getParent().getDocAction();
|
||||||
&& ( MMovement.DOCSTATUS_Drafted.equals(getParent().getDocStatus())
|
String docStatus = getParent().getDocStatus();
|
||||||
|| MMovement.DOCSTATUS_Invalid.equals(getParent().getDocStatus())
|
if ( MMovement.DOCACTION_Void.equals(docAction)
|
||||||
|| MMovement.DOCSTATUS_InProgress.equals(getParent().getDocStatus())
|
&& ( MMovement.DOCSTATUS_Drafted.equals(docStatus)
|
||||||
|| MMovement.DOCSTATUS_Approved.equals(getParent().getDocStatus())
|
|| MMovement.DOCSTATUS_Invalid.equals(docStatus)
|
||||||
|| MMovement.DOCSTATUS_NotApproved.equals(getParent().getDocStatus())
|
|| MMovement.DOCSTATUS_InProgress.equals(docStatus)
|
||||||
|
|| MMovement.DOCSTATUS_Approved.equals(docStatus)
|
||||||
|
|| MMovement.DOCSTATUS_NotApproved.equals(docStatus)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// [ 2092198 ] Error voiding an Inventory Move - globalqss
|
// [ 2092198 ] Error voiding an Inventory Move - globalqss
|
||||||
// zero allowed in this case (action Void and status Draft)
|
// zero allowed in this case (action Void and status Draft)
|
||||||
|
} else if ( MMovement.DOCACTION_Complete.equals(docAction)
|
||||||
|
&& MMovement.DOCSTATUS_InProgress.equals(docStatus))
|
||||||
|
{
|
||||||
|
// IDEMPIERE-2624 Cant confirm 0 qty on Movement Confirmation
|
||||||
|
// zero allowed in this case (action Complete and status In Progress)
|
||||||
} else {
|
} else {
|
||||||
log.saveError("FillMandatory", Msg.getElement(getCtx(), "MovementQty"));
|
log.saveError("FillMandatory", Msg.getElement(getCtx(), "MovementQty"));
|
||||||
return false;
|
return false;
|
||||||
|
@ -223,6 +237,19 @@ public class MMovementLine extends X_M_MovementLine
|
||||||
return true;
|
return true;
|
||||||
} // beforeSave
|
} // beforeSave
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Before Delete
|
||||||
|
* @return true if it can be deleted
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected boolean beforeDelete() {
|
||||||
|
if (getParent().pendingConfirmations()) {
|
||||||
|
log.saveError("DeleteError", Msg.parseTranslation(getCtx(), "@Open@: @M_MovementConfirm_ID@"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return super.beforeDelete();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Distribution Order Line.
|
* Set Distribution Order Line.
|
||||||
* Does not set Quantity!
|
* Does not set Quantity!
|
||||||
|
|
Loading…
Reference in New Issue