void createBusinessCaseTest(String trxName){
  createDataMaster();
  generateHistoryCost();
  Timestamp dateAcct;
  dateAcct=today;
  MOrder purchase1=createPurchaseOrder(dateAcct,new BigDecimal(100),new BigDecimal(36));
  MInOut receipt1=null;
  for (  MOrderLine line : purchase1.getLines()) {
    receipt1=createMaterialReceipt(dateAcct,new BigDecimal(10),line.getC_OrderLine_ID());
  }
  for (  MInOutLine line : receipt1.getLines()) {
    CostResult costResult=new CostResult(product.getM_Product_ID(),new BigDecimal("47.7292"),new BigDecimal("30"),new BigDecimal("1431.8748"),new BigDecimal("477.2920"),new BigDecimal("0"),new BigDecimal("10"),new BigDecimal("53.5937"),new BigDecimal("20"),new BigDecimal("1071.8748"),dateAcct);
    assertCostReceipt(costResult,line.getM_InOutLine_ID(),as,trxName);
  }
  dateAcct=TimeUtil.addDays(today,15);
  MOrder sales1=createSalesOrder(dateAcct,new BigDecimal(5),new BigDecimal(45));
  for (  MOrderLine line : sales1.getLines()) {
    CostResult costResult=new CostResult(product.getM_Product_ID(),new BigDecimal("47.7292"),new BigDecimal("25"),new BigDecimal("1193.2288"),new BigDecimal("238.6460"),new BigDecimal("0"),new BigDecimal("-5"),new BigDecimal("47.7292"),new BigDecimal("30"),new BigDecimal("1431.8748"),dateAcct);
    assertCostShipment(costResult,line.getC_OrderLine_ID(),as,trxName);
  }
  dateAcct=TimeUtil.addDays(today,31);
  MOrder purchase2=createPurchaseOrder(dateAcct,new BigDecimal(100),new BigDecimal(34));
  MInOut receipt2=null;
  for (  MOrderLine line : purchase2.getLines()) {
    receipt2=createMaterialReceipt(dateAcct,new BigDecimal(10),line.getC_OrderLine_ID());
  }
  for (  MInOutLine line : receipt2.getLines()) {
    CostResult costResult=new CostResult(product.getM_Product_ID(),new BigDecimal("43.8065"),new BigDecimal("35"),new BigDecimal("1533.2288"),new BigDecimal("438.0650"),new BigDecimal("0"),new BigDecimal("10"),new BigDecimal("47.7292"),new BigDecimal("25"),new BigDecimal("1193.2288"),dateAcct);
    assertCostReceipt(costResult,line.getM_InOutLine_ID(),as,trxName);
  }
  dateAcct=TimeUtil.addDays(today,60);
  MOrder sales2=createSalesOrder(dateAcct,new BigDecimal(10),new BigDecimal(45));
  for (  MOrderLine line : sales2.getLines()) {
    CostResult costResult=new CostResult(product.getM_Product_ID(),new BigDecimal("43.8065"),new BigDecimal("25"),new BigDecimal("1095.1638"),new BigDecimal("438.0650"),new BigDecimal("0"),new BigDecimal("-10"),new BigDecimal("43.8065"),new BigDecimal("35"),new BigDecimal("1533.2288"),dateAcct);
    assertCostShipment(costResult,line.getC_OrderLine_ID(),as,trxName);
  }
  dateAcct=receipt1.getDateAcct();
  int M_InOutLine_ID=0;
  for (  MInOutLine line : receipt1.getLines()) {
    M_InOutLine_ID=line.getM_InOutLine_ID();
    MInvoice invoice=createInvoiceVendor(dateAcct,new BigDecimal(10),new BigDecimal(38),line.getM_InOutLine_ID());
  }
  CostResult costResult=new CostResult(product.getM_Product_ID(),new BigDecimal("44.2827"),new BigDecimal("25"),new BigDecimal("1107.0688"),new BigDecimal("380.0000"),new BigDecimal("20.0000"),new BigDecimal("10"),new BigDecimal("53.5937"),new BigDecimal("20"),new BigDecimal("1071.8748"),dateAcct);
  assertCostInvoice(costResult,M_InOutLine_ID,as,trxName);
  dateAcct=Timestamp.valueOf("2010-01-16 00:00:00.0");
  for (  MOrderLine line : sales1.getLines()) {
    costResult=new CostResult(line.getM_Product_ID(),new BigDecimal("44.2827"),new BigDecimal("25"),new BigDecimal("1107.0688"),new BigDecimal("241.9790"),new BigDecimal("0"),new BigDecimal("-5"),new BigDecimal("48.3958"),new BigDecimal("30"),new BigDecimal("1451.8748"),dateAcct);
    assertCostShipmentAdjust(costResult,line.getC_OrderLine_ID(),as,trxName);
  }
  dateAcct=today;
  receipt1.processIt(DocAction.ACTION_Reverse_Correct);
  receipt1.saveEx();
  for (  MInOutLine line : receipt1.getLines(true)) {
    costResult=new CostResult(product.getM_Product_ID(),new BigDecimal("44.2827"),new BigDecimal("25"),new BigDecimal("1107.0688"),new BigDecimal("380.0000"),new BigDecimal("20.0000"),new BigDecimal("10"),new BigDecimal("53.5937"),new BigDecimal("20"),new BigDecimal("1071.8748"),dateAcct);
    assertCostReceiptReversal(costResult,line.getM_InOutLine_ID(),as,trxName);
  }
  MInOut reversal=new MInOut(getCtx(),receipt1.getReversal_ID(),trxName);
  for (  MInOutLine line : reversal.getLines(true)) {
    costResult=new CostResult(product.getM_Product_ID(),new BigDecimal("46.8373"),new BigDecimal("19"),new BigDecimal("889.9081"),new BigDecimal("380"),new BigDecimal("20"),new BigDecimal("-10"),new BigDecimal("49.0073"),new BigDecimal("34"),new BigDecimal("1666.2496"),dateAcct);
    assertCostReceiptReversal(costResult,line.getM_InOutLine_ID(),as,trxName);
  }
  dateAcct=TimeUtil.addDays(today,7);
  MOrder purchase3=createPurchaseOrder(dateAcct,new BigDecimal(100),new BigDecimal(37));
  MInOut receipt3=null;
  for (  MOrderLine line : purchase3.getLines()) {
    receipt3=createMaterialReceipt(dateAcct,new BigDecimal(20),line.getC_OrderLine_ID());
  }
  for (  MInOutLine line : receipt3.getLines()) {
    costResult=new CostResult(product.getM_Product_ID(),new BigDecimal("42.0489"),new BigDecimal("45"),new BigDecimal("1892.1983"),new BigDecimal("876.7500"),new BigDecimal("0"),new BigDecimal("20"),new BigDecimal("48.3958"),new BigDecimal("30"),new BigDecimal("1451.8748"),dateAcct);
    assertCostReceipt(costResult,line.getM_InOutLine_ID(),as,trxName);
  }
  dateAcct=TimeUtil.addDays(today,65);
  MMovement move=createMovement(dateAcct,new BigDecimal("5"));
  for (  MMovementLine line : move.getLines(true)) {
    costResult=new CostResult(product.getM_Product_ID(),new BigDecimal("53.5938"),new BigDecimal("9"),new BigDecimal("482.3442"),new BigDecimal("267.9690"),new BigDecimal("0"),new BigDecimal("5"),new BigDecimal("53.5938"),new BigDecimal("4"),new BigDecimal("214.3752"),dateAcct);
    assertCostMovement(costResult,line.getM_MovementLine_ID(),as,trxName);
  }
  dateAcct=TimeUtil.addDays(today,70);
  MInventory inventory=createPhisicalInventory(dateAcct,new BigDecimal("20"),costResult.cumulateQty);
  for (  MInventoryLine line : inventory.getLines(true)) {
    costResult=new CostResult(product.getM_Product_ID(),new BigDecimal("42.0488"),new BigDecimal("51"),new BigDecimal("2144.4906"),new BigDecimal("462.5368"),new BigDecimal("0"),new BigDecimal("11"),new BigDecimal("42.0488"),new BigDecimal("40"),new BigDecimal("1681.9538"),dateAcct);
    assertCostPhisicalInventory(costResult,line.getM_InventoryLine_ID(),as,trxName);
    break;
  }
  dateAcct=TimeUtil.addDays(today,80);
  inventory=createInvetoryInternalUse(dateAcct,new BigDecimal("-5"));
  for (  MInventoryLine line : inventory.getLines(true)) {
    costResult=new CostResult(product.getM_Product_ID(),new BigDecimal("42.0488"),new BigDecimal("56"),new BigDecimal("2354.7346"),new BigDecimal("210.2440"),new BigDecimal("0"),new BigDecimal("5"),new BigDecimal("42.0488"),new BigDecimal("51"),new BigDecimal("2144.4906"),dateAcct);
    assertCostPhisicalInventory(costResult,line.getM_InventoryLine_ID(),as,trxName);
    ;
  }
  createTrxAndInventoryValuationReport();
}

void createBusinessCaseTest ( String trxName ) { createDataMaster ( ) ; generateHistoryCost ( ) ; Timestamp dateAcct ; dateAcct = today ; MOrder purchase1 = createPurchaseOrder ( dateAcct , new BigDecimal ( 100 ) , new BigDecimal ( 36 ) ) ; MInOut receipt1 = null ; for ( MOrderLine line : purchase1 . getLines ( ) ) { receipt1 = createMaterialReceipt ( dateAcct , new BigDecimal ( 10 ) , line . getC_OrderLine_ID ( ) ) ; } for ( MInOutLine line : receipt1 . getLines ( ) ) { CostResult costResult = new CostResult ( product . getM_Product_ID ( ) , new BigDecimal ( "47.7292" ) , new BigDecimal ( "30" ) , new BigDecimal ( "1431.8748" ) , new BigDecimal ( "477.2920" ) , new BigDecimal ( "0" ) , new BigDecimal ( "10" ) , new BigDecimal ( "53.5937" ) , new BigDecimal ( "20" ) , new BigDecimal ( "1071.8748" ) , dateAcct ) ; assertCostReceipt ( costResult , line . getM_InOutLine_ID ( ) , as , trxName ) ; } dateAcct = TimeUtil . addDays ( today , 15 ) ; MOrder sales1 = createSalesOrder ( dateAcct , new BigDecimal ( 5 ) , new BigDecimal ( 45 ) ) ; for ( MOrderLine line : sales1 . getLines ( ) ) { CostResult costResult = new CostResult ( product . getM_Product_ID ( ) , new BigDecimal ( "47.7292" ) , new BigDecimal ( "25" ) , new BigDecimal ( "1193.2288" ) , new BigDecimal ( "238.6460" ) , new BigDecimal ( "0" ) , new BigDecimal ( "-5" ) , new BigDecimal ( "47.7292" ) , new BigDecimal ( "30" ) , new BigDecimal ( "1431.8748" ) , dateAcct ) ; assertCostShipment ( costResult , line . getC_OrderLine_ID ( ) , as , trxName ) ; } dateAcct = TimeUtil . addDays ( today , 31 ) ; MOrder purchase2 = createPurchaseOrder ( dateAcct , new BigDecimal ( 100 ) , new BigDecimal ( 34 ) ) ; MInOut receipt2 = null ; for ( MOrderLine line : purchase2 . getLines ( ) ) { receipt2 = createMaterialReceipt ( dateAcct , new BigDecimal ( 10 ) , line . getC_OrderLine_ID ( ) ) ; } for ( MInOutLine line : receipt2 . getLines ( ) ) { CostResult costResult = new CostResult ( product . getM_Product_ID ( ) , new BigDecimal ( "43.8065" ) , new BigDecimal ( "35" ) , new BigDecimal ( "1533.2288" ) , new BigDecimal ( "438.0650" ) , new BigDecimal ( "0" ) , new BigDecimal ( "10" ) , new BigDecimal ( "47.7292" ) , new BigDecimal ( "25" ) , new BigDecimal ( "1193.2288" ) , dateAcct ) ; assertCostReceipt ( costResult , line . getM_InOutLine_ID ( ) , as , trxName ) ; } dateAcct = TimeUtil . addDays ( today , 60 ) ; MOrder sales2 = createSalesOrder ( dateAcct , new BigDecimal ( 10 ) , new BigDecimal ( 45 ) ) ; for ( MOrderLine line : sales2 . getLines ( ) ) { CostResult costResult = new CostResult ( product . getM_Product_ID ( ) , new BigDecimal ( "43.8065" ) , new BigDecimal ( "25" ) , new BigDecimal ( "1095.1638" ) , new BigDecimal ( "438.0650" ) , new BigDecimal ( "0" ) , new BigDecimal ( "-10" ) , new BigDecimal ( "43.8065" ) , new BigDecimal ( "35" ) , new BigDecimal ( "1533.2288" ) , dateAcct ) ; assertCostShipment ( costResult , line . getC_OrderLine_ID ( ) , as , trxName ) ; } dateAcct = receipt1 . getDateAcct ( ) ; int M_InOutLine_ID = 0 ; for ( MInOutLine line : receipt1 . getLines ( ) ) { M_InOutLine_ID = line . getM_InOutLine_ID ( ) ; MInvoice invoice = createInvoiceVendor ( dateAcct , new BigDecimal ( 10 ) , new BigDecimal ( 38 ) , line . getM_InOutLine_ID ( ) ) ; } CostResult costResult = new CostResult ( product . getM_Product_ID ( ) , new BigDecimal ( "44.2827" ) , new BigDecimal ( "25" ) , new BigDecimal ( "1107.0688" ) , new BigDecimal ( "380.0000" ) , new BigDecimal ( "20.0000" ) , new BigDecimal ( "10" ) , new BigDecimal ( "53.5937" ) , new BigDecimal ( "20" ) , new BigDecimal ( "1071.8748" ) , dateAcct ) ; assertCostInvoice ( costResult , M_InOutLine_ID , as , trxName ) ; dateAcct = Timestamp . valueOf ( "2010-01-16 00:00:00.0" ) ; for ( MOrderLine line : sales1 . getLines ( ) ) { costResult = new CostResult ( line . getM_Product_ID ( ) , new BigDecimal ( "44.2827" ) , new BigDecimal ( "25" ) , new BigDecimal ( "1107.0688" ) , new BigDecimal ( "241.9790" ) , new BigDecimal ( "0" ) , new BigDecimal ( "-5" ) , new BigDecimal ( "48.3958" ) , new BigDecimal ( "30" ) , new BigDecimal ( "1451.8748" ) , dateAcct ) ; assertCostShipmentAdjust ( costResult , line . getC_OrderLine_ID ( ) , as , trxName ) ; } dateAcct = today ; receipt1 . processIt ( DocAction . ACTION_Reverse_Correct ) ; receipt1 . saveEx ( ) ; for ( MInOutLine line : receipt1 . getLines ( true ) ) { costResult = new CostResult ( product . getM_Product_ID ( ) , new BigDecimal ( "44.2827" ) , new BigDecimal ( "25" ) , new BigDecimal ( "1107.0688" ) , new BigDecimal ( "380.0000" ) , new BigDecimal ( "20.0000" ) , new BigDecimal ( "10" ) , new BigDecimal ( "53.5937" ) , new BigDecimal ( "20" ) , new BigDecimal ( "1071.8748" ) , dateAcct ) ; assertCostReceiptReversal ( costResult , line . getM_InOutLine_ID ( ) , as , trxName ) ; } MInOut reversal = new MInOut ( getCtx ( ) , receipt1 . getReversal_ID ( ) , trxName ) ; for ( MInOutLine line : reversal . getLines ( true ) ) { costResult = new CostResult ( product . getM_Product_ID ( ) , new BigDecimal ( "46.8373" ) , new BigDecimal ( "19" ) , new BigDecimal ( "889.9081" ) , new BigDecimal ( "380" ) , new BigDecimal ( "20" ) , new BigDecimal ( "-10" ) , new BigDecimal ( "49.0073" ) , new BigDecimal ( "34" ) , new BigDecimal ( "1666.2496" ) , dateAcct ) ; assertCostReceiptReversal ( costResult , line . getM_InOutLine_ID ( ) , as , trxName ) ; } dateAcct = TimeUtil . addDays ( today , 7 ) ; MOrder purchase3 = createPurchaseOrder ( dateAcct , new BigDecimal ( 100 ) , new BigDecimal ( 37 ) ) ; MInOut receipt3 = null ; for ( MOrderLine line : purchase3 . getLines ( ) ) { receipt3 = createMaterialReceipt ( dateAcct , new BigDecimal ( 20 ) , line . getC_OrderLine_ID ( ) ) ; } for ( MInOutLine line : receipt3 . getLines ( ) ) { costResult = new CostResult ( product . getM_Product_ID ( ) , new BigDecimal ( "42.0489" ) , new BigDecimal ( "45" ) , new BigDecimal ( "1892.1983" ) , new BigDecimal ( "876.7500" ) , new BigDecimal ( "0" ) , new BigDecimal ( "20" ) , new BigDecimal ( "48.3958" ) , new BigDecimal ( "30" ) , new BigDecimal ( "1451.8748" ) , dateAcct ) ; assertCostReceipt ( costResult , line . getM_InOutLine_ID ( ) , as , trxName ) ; } dateAcct = TimeUtil . addDays ( today , 65 ) ; MMovement move = createMovement ( dateAcct , new BigDecimal ( "5" ) ) ; for ( MMovementLine line : move . getLines ( true ) ) { costResult = new CostResult ( product . getM_Product_ID ( ) , new BigDecimal ( "53.5938" ) , new BigDecimal ( "9" ) , new BigDecimal ( "482.3442" ) , new BigDecimal ( "267.9690" ) , new BigDecimal ( "0" ) , new BigDecimal ( "5" ) , new BigDecimal ( "53.5938" ) , new BigDecimal ( "4" ) , new BigDecimal ( "214.3752" ) , dateAcct ) ; assertCostMovement ( costResult , line . getM_MovementLine_ID ( ) , as , trxName ) ; } dateAcct = TimeUtil . addDays ( today , 70 ) ; MInventory inventory = createPhisicalInventory ( dateAcct , new BigDecimal ( "20" ) , costResult . cumulateQty ) ; for ( MInventoryLine line : inventory . getLines ( true ) ) { costResult = new CostResult ( product . getM_Product_ID ( ) , new BigDecimal ( "42.0488" ) , new BigDecimal ( "51" ) , new BigDecimal ( "2144.4906" ) , new BigDecimal ( "462.5368" ) , new BigDecimal ( "0" ) , new BigDecimal ( "11" ) , new BigDecimal ( "42.0488" ) , new BigDecimal ( "40" ) , new BigDecimal ( "1681.9538" ) , dateAcct ) ; assertCostPhisicalInventory ( costResult , line . getM_InventoryLine_ID ( ) , as , trxName ) ; break ; } dateAcct = TimeUtil . addDays ( today , 80 ) ; inventory = createInvetoryInternalUse ( dateAcct , new BigDecimal ( "-5" ) ) ; for ( MInventoryLine line : inventory . getLines ( true ) ) { costResult = new CostResult ( product . getM_Product_ID ( ) , new BigDecimal ( "42.0488" ) , new BigDecimal ( "56" ) , new BigDecimal ( "2354.7346" ) , new BigDecimal ( "210.2440" ) , new BigDecimal ( "0" ) , new BigDecimal ( "5" ) , new BigDecimal ( "42.0488" ) , new BigDecimal ( "51" ) , new BigDecimal ( "2144.4906" ) , dateAcct ) ; assertCostPhisicalInventory ( costResult , line . getM_InventoryLine_ID ( ) , as , trxName ) ; ; } createTrxAndInventoryValuationReport ( ) ; }
create business test case
