IDEMPIERE-4854 Bugfixes in InOutGenerate (#979)

add unit test
This commit is contained in:
hengsin 2021-11-14 15:10:56 +08:00 committed by GitHub
parent e405daf52e
commit 5c8b7ae6a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 46 additions and 3 deletions

View File

@ -663,6 +663,7 @@ public class SalesOrderTest extends AbstractTestCase {
@Test
/**
* https://idempiere.atlassian.net/browse/IDEMPIERE-4768
* https://idempiere.atlassian.net/browse/IDEMPIERE-4854
*/
public void testMultiASIShipment() {
Properties ctx = Env.getCtx();
@ -707,7 +708,7 @@ public class SalesOrderTest extends AbstractTestCase {
MOrder order = new MOrder(ctx, 0, trxName);
order.setAD_Org_ID(ORG_FERTILIZER);
order.setBPartner(MBPartner.get(ctx, BP_JOE_BLOCK));
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_POS);
order.setC_DocTypeTarget_ID(MOrder.DocSubTypeSO_Standard);
order.setDeliveryRule(MOrder.DELIVERYRULE_CompleteOrder);
order.setM_Warehouse_ID(WAREHOUSE_FERTILIZER);
order.setDocStatus(DocAction.STATUS_Drafted);
@ -729,10 +730,41 @@ public class SalesOrderTest extends AbstractTestCase {
assertFalse(info.isError(), info.getSummary());
order.load(trxName);
assertEquals(DocAction.STATUS_Completed, order.getDocStatus());
//generate shipment
int AD_Process_ID = PROCESS_M_INOUT_GENERATE_MANUAL;
MPInstance instance = new MPInstance(Env.getCtx(), AD_Process_ID, 0);
instance.saveEx();
String insert = "INSERT INTO T_SELECTION(AD_PINSTANCE_ID, T_SELECTION_ID) Values (?, ?)";
DB.executeUpdateEx(insert, new Object[] {instance.getAD_PInstance_ID(), order.getC_Order_ID()}, null);
//call process
ProcessInfo pi = new ProcessInfo ("InOutGen", AD_Process_ID);
pi.setAD_PInstance_ID (instance.getAD_PInstance_ID());
// Add Parameter - Selection=Y
MPInstancePara ip = new MPInstancePara(instance, 10);
ip.setParameter("Selection","Y");
ip.saveEx();
//Add Document action parameter
ip = new MPInstancePara(instance, 20);
ip.setParameter("DocAction", "CO");
ip.saveEx();
// Add Parameter - M_Warehouse_ID=x
ip = new MPInstancePara(instance, 30);
ip.setParameter("M_Warehouse_ID", WAREHOUSE_FERTILIZER);
ip.saveEx();
ServerProcessCtl processCtl = new ServerProcessCtl(pi, getTrx());
processCtl.setManagedTrxForJavaProcess(false);
processCtl.run();
assertFalse(pi.isError(), pi.getSummary());
line1.load(trxName);
assertEquals(0, line1.getQtyReserved().intValue());
assertEquals(2, line1.getQtyDelivered().intValue());
assertEquals(2, line1.getQtyInvoiced().intValue());
// Expected to have cleared both storage entries on shipment
storages = MStorageOnHand.getWarehouse(ctx, WAREHOUSE_FERTILIZER,
@ -740,6 +772,17 @@ public class SalesOrderTest extends AbstractTestCase {
MClient.MMPOLICY_FiFo.equals(fert50.getMMPolicy()), false,
0, trxName);
assertEquals(0, storages.length);
Query query = new Query(Env.getCtx(), MInOut.Table_Name, "C_Order_ID=?", getTrxName());
MInOut inout = query.setParameters(order.get_ID()).first();
assertNotNull(inout, "Can't find shipment for order");
MInOutLine[] ilines = inout.getLines();
assertTrue(ilines.length==1, "Shipment doesn't has 1 line as expected: " + ilines.length);
assertEquals(line1.get_ID(), ilines[0].getC_OrderLine_ID(), "Shipment line doesn't has the expected order line ID");
assertEquals(line1.getQtyOrdered(), ilines[0].getMovementQty(), "Shipment line doesn't has the expected movement quantity");
assertEquals(line1.getM_Product_ID(), ilines[0].getM_Product_ID(), "Shipment line doesn't has the expected product ID");
assertEquals(line1.getM_AttributeSetInstance_ID(), ilines[0].getM_AttributeSetInstance_ID(), "Shipment line doesn't has the expected ASI ID");
assertEquals(LOCATOR_FERTILIZER, ilines[0].getM_Locator_ID(), "Shipment line doesn't has the expected Locator ID");
}
@Test