details: https://code.openbravo.com/erp/devel/pi/rev/8d73ffc2b531 changeset: 35327:8d73ffc2b531 user: Atul Gaware <atul.gaware <at> openbravo.com> date: Thu Jan 17 14:57:34 2019 +0530 summary: Related To Issue 39616:Added junit tests for the Landed Cost with multiple currency records in Cost Tab
diffstat: src-test/src/org/openbravo/test/costing/TestCosting.java | 6 +- src-test/src/org/openbravo/test/costing/TestIssue39616.java | 121 ++++++++++++ 2 files changed, 125 insertions(+), 2 deletions(-) diffs (148 lines): diff -r 123e2c24a1b1 -r 8d73ffc2b531 src-test/src/org/openbravo/test/costing/TestCosting.java --- a/src-test/src/org/openbravo/test/costing/TestCosting.java Fri Jan 18 09:56:54 2019 +0100 +++ b/src-test/src/org/openbravo/test/costing/TestCosting.java Thu Jan 17 14:57:34 2019 +0530 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2018 Openbravo SLU + * All portions are Copyright (C) 2018-2019 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************ @@ -33,7 +33,9 @@ TestCostingNoSourceAdjustments.class, // TestCostingLandedCost.class, // TestIssue37033.class, // - TestIssue37279.class // + TestIssue37279.class, // + TestIssue39616.class // + }) public class TestCosting { // No content is required, this is just the definition of a test suite. diff -r 123e2c24a1b1 -r 8d73ffc2b531 src-test/src/org/openbravo/test/costing/TestIssue39616.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src-test/src/org/openbravo/test/costing/TestIssue39616.java Thu Jan 17 14:57:34 2019 +0530 @@ -0,0 +1,121 @@ +/* + ************************************************************************* + * The contents of this file are subject to the Openbravo Public License + * Version 1.1 (the "License"), being the Mozilla Public License + * Version 1.1 with a permitted attribution clause; you may not use this + * file except in compliance with the License. You may obtain a copy of + * the License at http://www.openbravo.com/legal/license.html + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + * License for the specific language governing rights and limitations + * under the License. + * The Original Code is Openbravo ERP. + * The Initial Developer of the Original Code is Openbravo SLU + * All portions are Copyright (C) 2019 Openbravo SLU + * All Rights Reserved. + * Contributor(s): ______________________________________. + ************************************************************************ + */ +package org.openbravo.test.costing; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; +import org.openbravo.base.exception.OBException; +import org.openbravo.dal.core.OBContext; +import org.openbravo.dal.service.OBDal; +import org.openbravo.model.common.plm.Product; +import org.openbravo.model.materialmgmt.cost.CostAdjustment; +import org.openbravo.model.materialmgmt.transaction.MaterialTransaction; +import org.openbravo.model.materialmgmt.transaction.ShipmentInOut; +import org.openbravo.model.materialmgmt.transaction.ShipmentInOutLine; +import org.openbravo.test.costing.assertclass.CostAdjustmentAssert; +import org.openbravo.test.costing.utils.TestCostingConstants; +import org.openbravo.test.costing.utils.TestCostingUtils; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class TestIssue39616 extends TestCostingBase { + + /** + * Test for issue 39616. + * + * <ul> + * <li>Create Landed Cost Type</li> + * <li>Create Landed Cost</li> + * <li>Create records in Cost Tab with USD Currency</li> + * <li>Create records in Cost Tab with EUR Currency</li> + * <li>Create records in Receipt Tab</li> + * <li>Process Landed Cost</li> + * <li>Assert Cost Adjustment for USD Currency</li> + * <li>Assert Cost Adjustment for EUR Currency</li> + */ + @Test + public void testIssue39616() throws Exception { + final int day0 = 0; + final int day1 = 5; + final BigDecimal price = new BigDecimal("10.00"); + final BigDecimal amount1 = new BigDecimal("10.00"); + final BigDecimal amount2 = new BigDecimal("20.00"); + final BigDecimal amount3 = new BigDecimal("30.00"); + final BigDecimal amount4 = new BigDecimal("40.00"); + final BigDecimal quantity = new BigDecimal("5"); + + try { + OBContext.setOBContext(TestCostingConstants.OPENBRAVO_USER_ID, + TestCostingConstants.QATESTING_ROLE_ID, TestCostingConstants.QATESTING_CLIENT_ID, + TestCostingConstants.SPAIN_ORGANIZATION_ID); + OBContext.setAdminMode(true); + + // Create a new product for the test + Product product = TestCostingUtils.createProduct("testCostingLC39616", price); + + // Create goods receipt, run costing background, post it and assert it + ShipmentInOut goodsReceipt = TestCostingUtils.createGoodsReceipt(product, price, quantity, + day0); + + // Create Landed Cost + List<String> landedCostTypeIdList = new ArrayList<String>(); + landedCostTypeIdList.add(TestCostingConstants.LANDEDCOSTTYPE_FEES_ID); + landedCostTypeIdList.add(TestCostingConstants.LANDEDCOSTTYPE_USD_COST_ID); + landedCostTypeIdList.add(TestCostingConstants.LANDEDCOSTTYPE_FEES_ID); + landedCostTypeIdList.add(TestCostingConstants.LANDEDCOSTTYPE_USD_COST_ID); + List<BigDecimal> amountList = new ArrayList<BigDecimal>(); + amountList.add(amount1); + amountList.add(amount2); + amountList.add(amount3); + amountList.add(amount4); + List<ShipmentInOut> receiptList = new ArrayList<ShipmentInOut>(); + List<ShipmentInOutLine> receiptLineList = new ArrayList<ShipmentInOutLine>(); + receiptList.add(goodsReceipt); + receiptLineList.add(goodsReceipt.getMaterialMgmtShipmentInOutLineList().get(0)); + TestCostingUtils.createLandedCost(landedCostTypeIdList, amountList, receiptList, + receiptLineList, day1); + + List<MaterialTransaction> transactionList = TestCostingUtils.getProductTransactions(product + .getId()); + + List<CostAdjustment> costAdjustmentList = TestCostingUtils.getCostAdjustment(product.getId()); + + List<List<CostAdjustmentAssert>> costAdjustmentAssertList = new ArrayList<List<CostAdjustmentAssert>>(); + List<CostAdjustmentAssert> costAdjustmentAssertLineList1 = new ArrayList<CostAdjustmentAssert>(); + costAdjustmentAssertLineList1.add(new CostAdjustmentAssert(transactionList.get(0), + TestCostingConstants.EURO_ID, "LC", amount1.add(amount3), day1, true, false)); + costAdjustmentAssertLineList1.add(new CostAdjustmentAssert(transactionList.get(0), + TestCostingConstants.DOLLAR_ID, "LC", amount2.add(amount4), day1, true, false)); + costAdjustmentAssertList.add(costAdjustmentAssertLineList1); + TestCostingUtils.assertCostAdjustment(costAdjustmentList, costAdjustmentAssertList); + + OBDal.getInstance().commitAndClose(); + + } catch (Exception e) { + System.out.println(e.getMessage()); + throw new OBException(e); + } finally { + OBContext.restorePreviousMode(); + } + } +} _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits