IDEMPIERE-5069 Completion of Shipment for Close Order produce inconsistent order line data (#1030)

This commit is contained in:
hengsin 2021-12-07 20:12:52 +08:00 committed by GitHub
parent 40462f674b
commit 055c614336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 89 additions and 0 deletions

View File

@ -0,0 +1,23 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-5069 Completion of Shipment for Close Order produce inconsistent order line data
-- Dec 6, 2021, 1:06:27 PM MYT
INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','Shipment/Material Receipt is in progress','Please process all shipment/material receipt documents for an order before closing it',0,0,'Y',TO_DATE('2021-12-06 13:06:26','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-12-06 13:06:26','YYYY-MM-DD HH24:MI:SS'),100,200722,'MInOutInProgress','D','c4e61fb0-1ac6-4a51-bb83-1435ce66bf4f')
;
-- Dec 6, 2021, 1:14:37 PM MYT
INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','Order has been closed','You can not ship or receive on a closed order',0,0,'Y',TO_DATE('2021-12-06 13:14:36','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2021-12-06 13:14:36','YYYY-MM-DD HH24:MI:SS'),100,200723,'OrderClosed','D','13f415ff-8347-4751-8480-f7165ace0a63')
;
-- Dec 6, 2021, 4:14:25 PM MYT
UPDATE AD_Message SET MsgText='Order has been closed.', MsgTip=NULL,Updated=TO_DATE('2021-12-06 16:14:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200723
;
-- Dec 6, 2021, 4:14:32 PM MYT
UPDATE AD_Message SET MsgText='Shipment/Material Receipt is in progress.', MsgTip=NULL,Updated=TO_DATE('2021-12-06 16:14:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200722
;
SELECT register_migration_script('202112060845_IDEMPIERE-5069.sql') FROM dual
;

View File

@ -0,0 +1,20 @@
-- IDEMPIERE-5069 Completion of Shipment for Close Order produce inconsistent order line data
-- Dec 6, 2021, 1:06:27 PM MYT
INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','Shipment/Material Receipt is in progress','Please process all shipment/material receipt documents for an order before closing it',0,0,'Y',TO_TIMESTAMP('2021-12-06 13:06:26','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-12-06 13:06:26','YYYY-MM-DD HH24:MI:SS'),100,200722,'MInOutInProgress','D','c4e61fb0-1ac6-4a51-bb83-1435ce66bf4f')
;
-- Dec 6, 2021, 1:14:37 PM MYT
INSERT INTO AD_Message (MsgType,MsgText,MsgTip,AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,AD_Message_ID,Value,EntityType,AD_Message_UU) VALUES ('E','Order has been closed','You can not ship or receive on a closed order',0,0,'Y',TO_TIMESTAMP('2021-12-06 13:14:36','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2021-12-06 13:14:36','YYYY-MM-DD HH24:MI:SS'),100,200723,'OrderClosed','D','13f415ff-8347-4751-8480-f7165ace0a63')
;
-- Dec 6, 2021, 4:14:25 PM MYT
UPDATE AD_Message SET MsgText='Order has been closed.', MsgTip=NULL,Updated=TO_TIMESTAMP('2021-12-06 16:14:25','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200723
;
-- Dec 6, 2021, 4:14:32 PM MYT
UPDATE AD_Message SET MsgText='Shipment/Material Receipt is in progress.', MsgTip=NULL,Updated=TO_TIMESTAMP('2021-12-06 16:14:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Message_ID=200722
;
SELECT register_migration_script('202112060845_IDEMPIERE-5069.sql') FROM dual
;

View File

@ -1132,6 +1132,31 @@ public class MInOut extends X_M_InOut implements DocAction, IDocsPostProcess
return DocAction.STATUS_Invalid;
}
// Validate Close Order
if (!isReversal())
{
StringBuilder sql = new StringBuilder("SELECT DISTINCT o.DocumentNo FROM M_InOut io ")
.append("JOIN M_InOutLine iol ON (io.M_InOut_ID=iol.M_InOut_ID) ")
.append("JOIN C_OrderLine ol ON (iol.C_OrderLine_ID=ol.C_OrderLine_ID) ")
.append("JOIN C_Order o ON (ol.C_Order_ID=o.C_Order_ID) ")
.append("WHERE o.DocStatus='CL' AND (ol.M_Product_ID > 0 OR ol.C_Charge_ID > 0) AND iol.MovementQty != 0 ")
.append("AND ol.IsActive='Y' AND iol.IsActive='Y' ")
.append("AND io.M_InOut_ID=? ");
List<List<Object>> closeOrders = DB.getSQLArrayObjectsEx(get_TrxName(), sql.toString(), getM_InOut_ID());
if (closeOrders != null && closeOrders.size() > 0)
{
m_processMsg = Msg.getMsg(p_ctx,"OrderClosed")+" (";
for(int i = 0; i< closeOrders.size(); i++)
{
if (i > 0)
m_processMsg += ", ";
m_processMsg += closeOrders.get(i).get(0).toString();
}
m_processMsg += ")";
return DocAction.STATUS_Invalid;
}
}
// Credit Check
if (isSOTrx() && !isReversal() && !isCustomerReturn())
{

View File

@ -2594,6 +2594,27 @@ public class MOrder extends X_C_Order implements DocAction
if (m_processMsg != null)
return false;
// Validate In Progress MInOUt
StringBuilder sql = new StringBuilder("SELECT DISTINCT io.DocumentNo FROM M_InOut io ")
.append("JOIN M_InOutLine iol ON (io.M_InOut_ID=iol.M_InOut_ID) ")
.append("JOIN C_OrderLine ol ON (iol.C_OrderLine_ID=ol.C_OrderLine_ID) ")
.append("WHERE io.DocStatus='IP' AND ol.QtyOrdered != 0 AND (ol.M_Product_ID > 0 OR ol.C_Charge_ID > 0) ")
.append("AND ol.IsActive='Y' AND iol.IsActive='Y' ")
.append("AND ol.C_Order_ID=? ");
List<List<Object>> openShipments = DB.getSQLArrayObjectsEx(get_TrxName(), sql.toString(), getC_Order_ID());
if (openShipments != null && openShipments.size() > 0)
{
m_processMsg = Msg.getMsg(p_ctx,"MInOutInProgress")+" (";
for(int i = 0; i< openShipments.size(); i++)
{
if (i > 0)
m_processMsg += ", ";
m_processMsg += openShipments.get(i).get(0).toString();
}
m_processMsg += ")";
return false;
}
// Close Not delivered Qty - SO/PO
MOrderLine[] lines = getLines(true, MOrderLine.COLUMNNAME_M_Product_ID);
for (int i = 0; i < lines.length; i++)