set shipment doctype base on order doctype setting.

(transplanted from 392957b9195a360103d2c04b45365f46e9122c4c)
This commit is contained in:
Heng Sin Low 2011-05-22 10:29:07 +08:00
parent cdea8a2d31
commit 27e3a3fc88
2 changed files with 72 additions and 4 deletions

View File

@ -86,6 +86,20 @@ public class CalloutInOut extends CalloutEngine
else
mTab.setValue("AD_User_ID", null);
}
/**
* Modification: set corresponding document type
*/
int docTypeId = order.getC_DocType_ID();
int relatedDocTypeId = 0;
if (docTypeId == 0)
{
docTypeId = order.getC_DocTypeTarget_ID();
}
relatedDocTypeId = MDocType.getShipmentReceiptDocType(docTypeId);
mTab.setValue("C_DocType_ID", relatedDocTypeId);
return "";
} // order
@ -179,6 +193,8 @@ public class CalloutInOut extends CalloutEngine
String DocBaseType = rs.getString("DocBaseType");
// BF [2708789] Read IsSOTrx from C_DocType
String trxFlag = rs.getString(7);
if (!(trxFlag.equals(mTab.getValue("IsSOTrx"))))
mTab.setValue("IsSOTrx", trxFlag);
if (DocBaseType.equals("MMS")) // Material Shipments
/**solve 1648131 bug vpj-cd e-evolution */
{
@ -198,9 +214,7 @@ public class CalloutInOut extends CalloutEngine
mTab.setValue("MovementType", "C+"); // Customer Return
else
mTab.setValue("MovementType", "V+"); // Vendor Receipts
}
if (!(trxFlag.equals(mTab.getValue("IsSOTrx"))))
mTab.setValue("IsSOTrx", trxFlag);
}
/**END vpj-cd e-evolution */
// DocumentNo

View File

@ -302,5 +302,59 @@ public class MDocType extends X_C_DocType
}
return success;
} // afterDelete
/**
* Returns Document type for the shipment/receipt based
* on Document type provided for order/rma
* @param docTypeId
* @return shipment/receipt doctype id
*/
public static int getShipmentReceiptDocType(int docTypeId)
{
int relatedDocTypeId = 0;
if (docTypeId != 0)
{
MDocType docType = MDocType.get(Env.getCtx(), docTypeId);
// FIXME: Should refactor code and remove the hard coded name
// Should change document type to allow query the value
if ("Return Material".equals(docType.getName()) ||
"Vendor Return".equals(docType.getName())|| !docType.isSOTrx())
{
String relatedDocTypeName = null;
if (("Purchase Order").equals(docType.getName()))
{
relatedDocTypeName = "MM Receipt";
}
else if ("Return Material".equals(docType.getName()))
{
relatedDocTypeName = "MM Returns";
}
else if ("Vendor Return".equals(docType.getName()))
{
relatedDocTypeName = "MM Vendor Returns";
}
if (relatedDocTypeName != null)
{
StringBuffer whereClause = new StringBuffer(30);
whereClause.append("Name='").append(relatedDocTypeName).append("' ");
whereClause.append("and AD_Client_ID=").append(Env.getAD_Client_ID(Env.getCtx()));
whereClause.append(" AND IsActive='Y'");
int relDocTypeIds[] = MDocType.getAllIDs(MDocType.Table_Name, whereClause.toString(), null);
if (relDocTypeIds.length > 0)
{
relatedDocTypeId = relDocTypeIds[0];
}
}
}
else
{
relatedDocTypeId = docType.getC_DocTypeShipment_ID();
}
}
return relatedDocTypeId;
}
} // MDocType