IDEMPIERE-5782 Generated Shipments/MR and Invoices with Invalid SalesRep (#2127)
* IDEMPIERE-5782 Generated Shipments/MR and Invoices with Invalid Sales Rep - Fix same issue with RMA * - add the callout validations also on beforeSave
This commit is contained in:
parent
948b494cb0
commit
d6121597b0
|
@ -0,0 +1,10 @@
|
|||
-- IDEMPIERE-5782 Generated Shipments/MR and Invoices with Invalid Sales Rep
|
||||
SELECT register_migration_script('202312041243_IDEMPIERE-5782.sql') FROM dual;
|
||||
|
||||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- Dec 4, 2023, 12:43:33 PM CET
|
||||
UPDATE AD_Column SET Callout='org.adempiere.model.CalloutRMA.inout',Updated=TO_TIMESTAMP('2023-12-04 12:43:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=10842
|
||||
;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
-- IDEMPIERE-5782 Generated Shipments/MR and Invoices with Invalid Sales Rep
|
||||
SELECT register_migration_script('202312041243_IDEMPIERE-5782.sql') FROM dual;
|
||||
|
||||
-- Dec 4, 2023, 12:43:33 PM CET
|
||||
UPDATE AD_Column SET Callout='org.adempiere.model.CalloutRMA.inout',Updated=TO_TIMESTAMP('2023-12-04 12:43:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=10842
|
||||
;
|
||||
|
|
@ -28,6 +28,7 @@ import org.compiere.model.GridField;
|
|||
import org.compiere.model.GridTab;
|
||||
import org.compiere.model.I_C_InvoiceLine;
|
||||
import org.compiere.model.MCharge;
|
||||
import org.compiere.model.MInOut;
|
||||
import org.compiere.model.MInOutLine;
|
||||
import org.compiere.model.MInvoice;
|
||||
import org.compiere.model.MInvoiceLine;
|
||||
|
@ -255,4 +256,33 @@ public class CalloutRMA extends CalloutEngine {
|
|||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* inOut - set sales rep based on shipment/receipt
|
||||
*
|
||||
* @param ctx
|
||||
* @param WindowNo
|
||||
* @param mTab
|
||||
* @param mField
|
||||
* @param value
|
||||
* @return error message or ""
|
||||
*/
|
||||
public String inout(Properties ctx, int WindowNo, GridTab mTab, GridField mField, Object value)
|
||||
{
|
||||
Integer M_InOut_ID = (Integer) value;
|
||||
if (M_InOut_ID == null || M_InOut_ID.intValue() == 0)
|
||||
return "";
|
||||
|
||||
MInOut inout = new MInOut(ctx, M_InOut_ID, null);
|
||||
if (inout.get_ID() != 0)
|
||||
{
|
||||
if (inout.getSalesRep_ID() > 0)
|
||||
mTab.setValue("SalesRep_ID", Integer.valueOf(inout.getSalesRep_ID()));
|
||||
else
|
||||
mTab.setValue("SalesRep_ID", null);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -153,6 +153,7 @@ public class CalloutInOut extends CalloutEngine
|
|||
mTab.setValue("FreightAmt", originalReceipt.getFreightAmt());
|
||||
|
||||
mTab.setValue("C_BPartner_ID", Integer.valueOf(originalReceipt.getC_BPartner_ID()));
|
||||
mTab.setValue("SalesRep_ID", Integer.valueOf(originalReceipt.getSalesRep_ID()));
|
||||
|
||||
//[ 1867464 ]
|
||||
mTab.setValue("C_BPartner_Location_ID", Integer.valueOf(originalReceipt.getC_BPartner_Location_ID()));
|
||||
|
|
|
@ -1337,6 +1337,17 @@ public class MInOut extends X_M_InOut implements DocAction, IDocsPostProcess
|
|||
}
|
||||
}
|
||||
|
||||
if (getSalesRep_ID() == 0) {
|
||||
if (getC_Order_ID() > 0) {
|
||||
MOrder order = new MOrder(getCtx(), getC_Order_ID(), get_TrxName());
|
||||
setSalesRep_ID(order.getSalesRep_ID());
|
||||
} else if (getM_RMA_ID() > 0) {
|
||||
MRMA rma = new MRMA(getCtx(), getM_RMA_ID(), get_TrxName());
|
||||
MInOut originalReceipt = rma.getShipment();
|
||||
setSalesRep_ID(originalReceipt.getSalesRep_ID());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} // beforeSave
|
||||
|
||||
|
|
|
@ -294,6 +294,10 @@ public class MRMA extends X_M_RMA implements DocAction
|
|||
return false;
|
||||
}
|
||||
|
||||
if (getSalesRep_ID() == 0 && m_inout != null && m_inout.getSalesRep_ID() > 0) {
|
||||
setSalesRep_ID(m_inout.getSalesRep_ID());
|
||||
}
|
||||
|
||||
return true;
|
||||
} // beforeSave
|
||||
|
||||
|
|
Loading…
Reference in New Issue