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:
Carlos Ruiz 2020-08-03 14:45:08 +02:00 committed by GitHub
parent a3a86739c2
commit 59758e8a7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 111 additions and 46 deletions

View File

@ -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
@ -1283,23 +1283,11 @@ public class MInOut extends X_M_InOut implements DocAction
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
// Outstanding (not processed) Incoming Confirmations ?
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;
//
m_processMsg = "Open @M_InOutConfirm_ID@: " +
confirm.getConfirmTypeName() + " - " + confirm.getDocumentNo();
return DocAction.STATUS_InProgress;
}
if (pendingCustomerConfirmations()) {
m_processMsg = "@Open@: @M_InOutConfirm_ID@";
return DocAction.STATUS_InProgress;
}
// Implicit Approval
if (!isApproved())
approveIt();
@ -1720,6 +1708,39 @@ public class MInOut extends X_M_InOut implements DocAction
return DocAction.STATUS_Completed;
} // 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 */
ArrayList<PO> docsPostProcess = new ArrayList<PO>();

View File

@ -88,7 +88,7 @@ public class MInOutConfirm extends X_M_InOutConfirm implements DocAction
}
if (s_log.isLoggable(Level.INFO)) s_log.info("New: " + confirm);
return confirm;
} // MInOutConfirm
} // create
/** Static Logger */
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());
}
return null;
} // getPDF
} // createPDF
/**
* Create PDF file

View File

@ -514,6 +514,13 @@ public class MInOutLine extends X_M_InOutLine
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_InOutLine"));
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 ]
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"));
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
List<MInvoiceLine> ils = new Query(getCtx(), MInvoiceLine.Table_Name, "M_InOutLine_ID=?", get_TrxName())
.setParameters(getM_InOutLine_ID())

View File

@ -144,7 +144,7 @@ public class MInOutLineConfirm extends X_M_InOutLineConfirm
{
line.setTargetQty(getTargetQty());
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());
line.setMovementQty(qty); // Entered NOT changed
//

View File

@ -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
@ -400,19 +400,11 @@ public class MMovement extends X_M_Movement implements DocAction
if (m_processMsg != null)
return DocAction.STATUS_Invalid;
// Outstanding (not processed) Incoming Confirmations ?
MMovementConfirm[] confirmations = getConfirmations(true);
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;
}
if (pendingConfirmations()) {
m_processMsg = "@Open@: @M_MovementConfirm_ID@";
return DocAction.STATUS_InProgress;
}
// Implicit Approval
if (!isApproved())
approveIt();
@ -625,7 +617,21 @@ public class MMovement extends X_M_Movement implements DocAction
setDocAction(DOCACTION_Close);
return DocAction.STATUS_Completed;
} // 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
*/

View File

@ -82,7 +82,7 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
cLine.saveEx(move.get_TrxName());
}
return confirm;
} // MInOutConfirm
} // create
/**************************************************************************
@ -124,7 +124,7 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
this (move.getCtx(), 0, move.get_TrxName());
setClientOrg(move);
setM_Movement_ID(move.getM_Movement_ID());
} // MInOutConfirm
} // MMovementConfirm
/** Confirm Lines */
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());
}
return null;
} // getPDF
} // createPDF
/**
* Create PDF file
@ -409,7 +409,7 @@ public class MMovementConfirm extends X_M_MovementConfirm implements DocAction
+ " - Difference=" + confirm.getDifferenceQty());
if (m_processMsg == null)
m_processMsg = "Differnce Doc not created";
m_processMsg = "Difference Doc not created";
return DocAction.STATUS_Invalid;
}
}

View File

@ -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
@ -171,6 +171,13 @@ public class MMovementLine extends X_M_MovementLine
log.saveError("ParentComplete", Msg.translate(getCtx(), "M_MovementLine"));
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
if (getLine() == 0)
{
@ -188,17 +195,24 @@ public class MMovementLine extends X_M_MovementLine
if (getMovementQty().signum() == 0)
{
if ( MMovement.DOCACTION_Void.equals(getParent().getDocAction())
&& ( MMovement.DOCSTATUS_Drafted.equals(getParent().getDocStatus())
|| MMovement.DOCSTATUS_Invalid.equals(getParent().getDocStatus())
|| MMovement.DOCSTATUS_InProgress.equals(getParent().getDocStatus())
|| MMovement.DOCSTATUS_Approved.equals(getParent().getDocStatus())
|| MMovement.DOCSTATUS_NotApproved.equals(getParent().getDocStatus())
String docAction = getParent().getDocAction();
String docStatus = getParent().getDocStatus();
if ( MMovement.DOCACTION_Void.equals(docAction)
&& ( MMovement.DOCSTATUS_Drafted.equals(docStatus)
|| MMovement.DOCSTATUS_Invalid.equals(docStatus)
|| MMovement.DOCSTATUS_InProgress.equals(docStatus)
|| MMovement.DOCSTATUS_Approved.equals(docStatus)
|| MMovement.DOCSTATUS_NotApproved.equals(docStatus)
)
)
)
{
// [ 2092198 ] Error voiding an Inventory Move - globalqss
// 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 {
log.saveError("FillMandatory", Msg.getElement(getCtx(), "MovementQty"));
return false;
@ -222,7 +236,20 @@ public class MMovementLine extends X_M_MovementLine
return true;
} // 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.
* Does not set Quantity!