IDEMPIERE-5078 - M_inout movementtype add to before save (#1038)

* IDEMPIERE-5078 - M_inout movementtype add to before save

* IDEMPIERE-5078 - shared logic between CalloutInOut.doctype and MInOut.getMovementType

* IDEMPIERE-5078 - javadoc added (#1038)

Co-authored-by: Igor Pojzl <igor.pojzl@cloudempiere.com>
This commit is contained in:
PeterTakacs300 2021-12-09 12:39:12 +01:00 committed by GitHub
parent 5f15207cba
commit 0dbbdcadab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 39 deletions

View File

@ -196,6 +196,7 @@ public class CalloutInOut extends CalloutEngine
String trxFlag = rs.getString("IsSOTrx"); String trxFlag = rs.getString("IsSOTrx");
Object isSOTrxValue = mTab.getValue("IsSOTrx"); Object isSOTrxValue = mTab.getValue("IsSOTrx");
String isSOTrxValueStr = null; String isSOTrxValueStr = null;
boolean IsSOTrx = "Y".equals(trxFlag);
if (isSOTrxValue != null) if (isSOTrxValue != null)
{ {
if (isSOTrxValue instanceof Boolean) if (isSOTrxValue instanceof Boolean)
@ -206,27 +207,8 @@ public class CalloutInOut extends CalloutEngine
if (!(trxFlag.equals(isSOTrxValueStr))) if (!(trxFlag.equals(isSOTrxValueStr)))
mTab.setValue("IsSOTrx", trxFlag); mTab.setValue("IsSOTrx", trxFlag);
if (DocBaseType.equals("MMS")) // Material Shipments
/**solve 1648131 bug vpj-cd e-evolution */
{
boolean IsSOTrx = "Y".equals(trxFlag);
if (IsSOTrx)
mTab.setValue("MovementType", "C-"); // Customer Shipments
else
mTab.setValue("MovementType", "V-"); // Vendor Return
} mTab.setValue("MovementType", MInOut.getMovementType(ctx, C_DocType_ID, IsSOTrx, null));
/**END vpj-cd e-evolution */
else if (DocBaseType.equals("MMR")) // Material Receipts
/**solve 1648131 bug vpj-cd e-evolution */
{
boolean IsSOTrx = "Y".equals(trxFlag);
if (IsSOTrx)
mTab.setValue("MovementType", "C+"); // Customer Return
else
mTab.setValue("MovementType", "V+"); // Vendor Receipts
}
/**END vpj-cd e-evolution */
// DocumentNo // DocumentNo
if (rs.getString("IsDocNoControlled").equals("Y")) if (rs.getString("IsDocNoControlled").equals("Y"))

View File

@ -202,15 +202,7 @@ public class MInOut extends X_M_InOut implements DocAction, IDocsPostProcess
to.setIsSOTrx(isSOTrx); to.setIsSOTrx(isSOTrx);
if (counter) if (counter)
{ {
MDocType docType = MDocType.get(from.getCtx(), C_DocType_ID); to.setMovementType();
if (MDocType.DOCBASETYPE_MaterialDelivery.equals(docType.getDocBaseType()))
{
to.setMovementType (isSOTrx ? MOVEMENTTYPE_CustomerShipment : MOVEMENTTYPE_VendorReturns);
}
else if (MDocType.DOCBASETYPE_MaterialReceipt.equals(docType.getDocBaseType()))
{
to.setMovementType (isSOTrx ? MOVEMENTTYPE_CustomerReturns : MOVEMENTTYPE_VendorReceipts);
}
} }
// //
@ -373,13 +365,7 @@ public class MInOut extends X_M_InOut implements DocAction, IDocsPostProcess
} }
setC_DocType_ID (C_DocTypeShipment_ID); setC_DocType_ID (C_DocTypeShipment_ID);
String movementTypeShipment = null; setMovementType();
MDocType dtShipment = new MDocType(order.getCtx(), C_DocTypeShipment_ID, order.get_TrxName());
if (dtShipment.getDocBaseType().equals(MDocType.DOCBASETYPE_MaterialDelivery))
movementTypeShipment = dtShipment.isSOTrx() ? MOVEMENTTYPE_CustomerShipment : MOVEMENTTYPE_VendorReturns;
else if (dtShipment.getDocBaseType().equals(MDocType.DOCBASETYPE_MaterialReceipt))
movementTypeShipment = dtShipment.isSOTrx() ? MOVEMENTTYPE_CustomerReturns : MOVEMENTTYPE_VendorReceipts;
setMovementType (movementTypeShipment);
// Default - Today // Default - Today
if (movementDate != null) if (movementDate != null)
@ -992,6 +978,41 @@ public class MInOut extends X_M_InOut implements DocAction, IDocsPostProcess
} }
} // setM_Warehouse_ID } // setM_Warehouse_ID
/**
* Gets Movement Type based on Document Type's DocBaseType and isSOTrx
* @param ctx
* @param C_DocType_ID Document Type ID
* @param issotrx is sales transaction
* @param trxName transaction name
* @return Movement Type
*/
public static String getMovementType(Properties ctx, int C_DocType_ID, boolean issotrx, String trxName) {
String movementType = null;
MDocType docType = MDocType.get(C_DocType_ID);
if (docType == null) return null;
if (docType.getDocBaseType().equals(MDocType.DOCBASETYPE_MaterialDelivery))
movementType = docType.isSOTrx() ? MOVEMENTTYPE_CustomerShipment : MOVEMENTTYPE_VendorReturns;
else if (docType.getDocBaseType().equals(MDocType.DOCBASETYPE_MaterialReceipt))
movementType = docType.isSOTrx() ? MOVEMENTTYPE_CustomerReturns : MOVEMENTTYPE_VendorReceipts;
return movementType;
}
/**
* Sets Movement Type based on Document Type's DocBaseType and isSOTrx
*/
public void setMovementType() {
if(getC_DocType_ID() <= 0) {
log.saveError("FillMandatory", Msg.translate(getCtx(), "C_DocType_ID"));
return;
}
String movementType = getMovementType(getCtx(), getC_DocType_ID(), isSOTrx(), get_TrxName());
setMovementType(movementType);
}
/** /**
* Before Save * Before Save
@ -1000,6 +1021,10 @@ public class MInOut extends X_M_InOut implements DocAction, IDocsPostProcess
*/ */
protected boolean beforeSave (boolean newRecord) protected boolean beforeSave (boolean newRecord)
{ {
if(newRecord || is_ValueChanged("C_DocType")) {
setMovementType();
}
MWarehouse wh = MWarehouse.get(getCtx(), getM_Warehouse_ID()); MWarehouse wh = MWarehouse.get(getCtx(), getM_Warehouse_ID());
// Warehouse Org // Warehouse Org
if (newRecord) if (newRecord)