[DMI] merge from main repo
authorGuillermo Alvarez de Eulate <guillermo.alvarez@openbravo.com>
Thu, 16 May 2019 17:02:35 +0200
changeset 8540 e50c96d4dd40
parent 8539 e10badc6fd2b (current diff)
parent 8512 67b7a4855e3b (diff)
child 8541 e1ba59106b45
[DMI] merge from main repo
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/awo/tests/Scan/AWO_VerifyBinScanWhileBoxUnboxProcess.java	Thu May 16 17:02:35 2019 +0200
@@ -0,0 +1,172 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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 S.L.U.
+ * All portions are Copyright (C) 2019 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author alekosmp86
+ *
+ */
+
+package org.openbravo.test.mobile.awo.tests.Scan;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.apache.commons.codec.binary.StringUtils;
+import org.junit.Test;
+import org.openbravo.test.mobile.awo.utilities.AWOTerminalHelper;
+import org.openbravo.test.mobile.awo.utilities.TestIdAwo;
+import org.openbravo.test.mobile.core.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.core.utils.OBUtils;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect.RecordsCount;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.TestRegistryHelper;
+import org.openbravo.test.mobile.retail.mobilecore.selenium.TestIdConstructor;
+import org.openbravo.test.mobile.retail.mobilecore.utils.ApplicationWindow;
+import org.openqa.selenium.Keys;
+
+public class AWO_VerifyBinScanWhileBoxUnboxProcess extends AWOTerminalHelper {
+  final private String SHP301_LOCATOR_ID = "11DFB1B220B44B5DBA51B8C6096FDD5F";
+  final private String SHP301_BARCODE = "112233";
+  final private String FOOD001_LOCATOR_ID = "7F3D8960E85440DABCB013F827C5528F";
+  final private String FOOD001_BARCODE = "445566";
+  final private String PRODUCT_NAME = "Havana Club Rum";
+
+  final private String UNBOX_CONTAINER = "CNT1000000";
+
+  @Test
+  public void test() {
+    tap(TestIdAwo.BUTTON_MENU);
+    tap(TestIdAwo.BUTTON_MENU_BOX);
+    verify(TestIdAwo.REFINV_SELECT_REFERENCE_HEADER, "Select Reference");
+    // create a new reference
+    tap(TestIdAwo.REFINV_CREATENEW_REF);
+    tap(TestIdAwo.REFINV_REFTYPE_SELECTOR);
+    write(TestIdAwo.REFINV_REFTYPE_SELECTORLIST_INPUT, "Sequenced Container");
+    tap(TestIdAwo.REFINV_REFTYPE_SELECTORLIST_SEARCH);
+    tap(TestIdAwo.REFINV_REFTYPE_SELECTORLIST_ROW1);
+    tap(TestIdAwo.REFINV_GENERATE_REF_BUTTON);
+    tap(TestIdAwo.REFINV_CREATEANDBOXUNBOX_BUTTON);
+
+    // verify the reference was created without a defined locator
+    assertThat("Header should contain the string 'Unknown locator'",
+        get(TestIdAwo.REFINV_REFLOCATOR_HEADER).contains("(Unknown Locator)"));
+
+    // add product
+    tap(TestIdAwo.REFINV_ADDPRODUCT_BUTTON);
+    write(TestIdAwo.REFINV_PRODUCT_INPUT_FILTER, PRODUCT_NAME);
+    TestIdAwo.REFINV_PRODUCT_INPUT_FILTER.enyoNode().executeExtension(".pressKey()");
+    tap(TestIdAwo.REFINV_PRODUCT_SEARCH);
+    waitForRecordsToRenderInList(TestIdAwo.REFINV_PRODUCT_LIST, 0,
+        RecordsCount.GREATER_THAN_EXPECTED);
+    isVisible(TestIdAwo.PRODUCTLIST_ROW1, true);
+    tap(TestIdAwo.PRODUCTLIST_ROW1);
+
+    // save the current (undefined) locator
+    String initialLocator = get(TestIdAwo.REFINV_TARGETBIN_SELECTOR_CONFIRMEDVALUE);
+    // scan barcode and compare locators
+    OBUtils.pause(1000);
+    scanBarcode(SHP301_BARCODE);
+    OBUtils.pause(1000);
+    SeleniumHelper.pressKey(Keys.ENTER);
+    SeleniumHelper.takeScreenshot("justAfterScan_BarCode");
+    TestRegistryHelper.forceRefresh();
+    String finalLocatorIdTest = getElementFullIdtest("_confirmedValue");
+    TestIdConstructor bin = new TestIdConstructor(finalLocatorIdTest);
+    String finalLocator = get(bin);
+    OBUtils.pause(1000);
+    assertThat("From Bin locator should have changed",
+        !StringUtils.equals(initialLocator, finalLocator));
+    verify(TestIdAwo.REFINV_TARGETBIN_SELECTOR_CONFIRMEDVALUE, "SHP301");
+
+    tap(TestIdAwo.REFINV_BACK_BUTTON);
+    tap(TestIdAwo.POPUP_CONFIRM_OKBUTTON_UP);
+    waitUntilCertainWindowIsReached(ApplicationWindow.AWO_TASKS);
+  }
+
+  @Test
+  public void test2() {
+    tap(TestIdAwo.BUTTON_MENU);
+    tap(TestIdAwo.BUTTON_MENU_UNBOX);
+
+    // find a reference with stock
+    write(TestIdAwo.REFINV_REFERENCE_INPUT, UNBOX_CONTAINER);
+    tap(TestIdAwo.REFINV_SELECTREFERENCE_BUTTON);
+
+    // verify that button "Unbox" appears
+    isVisible(TestIdAwo.REFINV_BOXUNBOX_BUTTON, true);
+    isDisabled(TestIdAwo.REFINV_BOXUNBOX_BUTTON, false);
+
+    // start unbox process
+    tap(TestIdAwo.REFINV_BOXUNBOX_BUTTON);
+    tap(TestIdAwo.REFINV_ADDPRODUCT_BUTTON);
+    write(TestIdAwo.REFINV_PRODUCT_INPUT_FILTER, PRODUCT_NAME);
+    TestIdAwo.REFINV_PRODUCT_INPUT_FILTER.enyoNode().executeExtension(".pressKey()");
+    tap(TestIdAwo.REFINV_PRODUCT_SEARCH);
+    waitForRecordsToRenderInList(TestIdAwo.REFINV_PRODUCT_LIST, 1, RecordsCount.SAME_AS_EXPECTED);
+    tap(TestIdAwo.REFINV_PRODUCTLIST_ROW1);
+
+    // save the current (undefined) locator
+    String initialLocator = get(TestIdAwo.REFINV_TARGETBIN_SELECTOR_CONFIRMEDVALUE);
+    // scan barcode and compare locators
+    OBUtils.pause(1000);
+    scanBarcode(FOOD001_BARCODE);
+    OBUtils.pause(1000);
+    SeleniumHelper.pressKey(Keys.ENTER);
+    SeleniumHelper.takeScreenshot("justAfterScan_BarCode");
+    TestRegistryHelper.forceRefresh();
+    String finalLocatorIdTest = getElementFullIdtest("_confirmedValue");
+    TestIdConstructor bin = new TestIdConstructor(finalLocatorIdTest);
+    String finalLocator = get(bin);
+    OBUtils.pause(1000);
+    assertThat("From Bin locator should have changed",
+        !StringUtils.equals(initialLocator, finalLocator));
+    verify(TestIdAwo.REFINV_TARGETBIN_SELECTOR_CONFIRMEDVALUE, "Food001");
+
+    tap(TestIdAwo.REFINV_BACK_BUTTON);
+    tap(TestIdAwo.POPUP_CONFIRM_OKBUTTON_UP);
+    waitUntilCertainWindowIsReached(ApplicationWindow.AWO_TASKS);
+  }
+
+  @Override
+  public void beforeWithReload() {
+    setBinBarcode(SHP301_LOCATOR_ID, SHP301_BARCODE);
+    setBinBarcode(FOOD001_LOCATOR_ID, FOOD001_BARCODE);
+  }
+
+  @Override
+  public void afterWithReload() {
+    setBinBarcode(SHP301_LOCATOR_ID, null);
+    setBinBarcode(FOOD001_LOCATOR_ID, null);
+  }
+
+  private void setBinBarcode(String locatorId, String barcode) {
+    String sql = "";
+    if (!StringUtils.equals(barcode, null)) {
+      sql = String.format("update m_locator set barcode = '%s' where m_locator_id = '%s'", barcode,
+          locatorId);
+    } else {
+      sql = String.format("update m_locator set barcode = NULL where m_locator_id = '%s'",
+          locatorId);
+    }
+
+    new DatabaseHelperInsertUpdateOrDelete() {
+    }.execute(sql, 1);
+  }
+  
+  private void scanBarcode(String barcode) {
+    SeleniumHelper.pressKeyAction(barcode);
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/awo/tests/Scan/AWO_VerifyFromBinCanNotBeScannedInMoveProcess.java	Thu May 16 17:02:35 2019 +0200
@@ -0,0 +1,110 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo  Public  License
+ * Version  1.0  (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 S.L.U.
+ * All portions are Copyright (C) 2019 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author alekosmp86
+ *
+ */
+
+package org.openbravo.test.mobile.awo.tests.Scan;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.apache.commons.codec.binary.StringUtils;
+import org.junit.Test;
+import org.openbravo.test.mobile.awo.utilities.AWOTerminalHelper;
+import org.openbravo.test.mobile.awo.utilities.TestIdAwo;
+import org.openbravo.test.mobile.core.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.core.utils.OBUtils;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect.RecordsCount;
+import org.openbravo.test.mobile.retail.mobilecore.selenium.TestIdConstructor;
+import org.openqa.selenium.Keys;
+
+public class AWO_VerifyFromBinCanNotBeScannedInMoveProcess extends AWOTerminalHelper {
+  final private String PRODUCT = "Mango";
+  final private String BARCODE = "112233";
+  final private String FOOD001_LOCATOR_ID = "7F3D8960E85440DABCB013F827C5528F";
+  final private String WARNING_MESSAGE = "Scanned code 112233 was ignored since locator is a read only field.";
+
+  @Test
+  public void test() {
+    startListeningBubbleWarnings();
+
+    tap(TestIdAwo.BUTTON_MENU);
+    tap(TestIdAwo.MENU_ASSIGN_BUTTON);
+    isVisible(TestIdAwo.UNASSIGNEDTASK_FILTER_INPUT, true);
+    write(TestIdAwo.UNASSIGNEDTASK_FILTER_INPUT, PRODUCT);
+    TestIdAwo.UNASSIGNEDTASK_FILTER_INPUT.enyoNode().executeExtension(".waterfall('onchange')");
+    tap(TestIdAwo.UNASSIGNEDTASK_SEARCH_BUTTON);
+    waitForRecordsToRenderInList(TestIdAwo.ASSIGNDIALOG_LISTOFTASKS, 1,
+        RecordsCount.GREATER_OR_EQUAL_THAN_EXPECTED);
+    tap(TestIdAwo.UNASSIGNEDTASK_ROW1);
+    tap(TestIdAwo.UNASSIGNEDTASK_CONFIRM_BUTTON);
+    waitForTasksRender(1);
+
+    String confirmedLocator = get(TestIdAwo.LOCATORFROM_CONFIRMED_VALUE);
+    // put focus on from bin and scan by barcode
+    tap(TestIdAwo.LOCATORFROM_CONFIRMED_CONTAINER);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKeyAction(BARCODE);
+    OBUtils.pause(500);
+    SeleniumHelper.pressKey(Keys.ENTER);
+
+    String warn = getLastBubbleWarning();
+    assertThat(String.format("Wrong warning message, expected '%s' but got '%s'", WARNING_MESSAGE, warn), StringUtils.equals(warn, WARNING_MESSAGE));
+
+    String finalLocator = get(TestIdAwo.LOCATORFROM_CONFIRMED_VALUE);
+    assertThat("From Bin locator should have not changed",
+        StringUtils.equals(confirmedLocator, finalLocator));
+
+    // unassign the task
+    String idtest = getElementIdtestByOffset(TestIdAwo.INDIVIDUAL_TASKS_LIST, 0);
+    TestIdConstructor task = new TestIdConstructor(idtest);
+    tap(task);
+    tap(TestIdAwo.BUTTON_MENU);
+    tap(TestIdAwo.MENU_UNASSIGN_BUTTON);
+
+    // verify there are no tasks pending
+    isVisible(TestIdAwo.TASKS_EMPTY_MSG, true);
+    stopListeningBubbleWarnings();
+  }
+
+  @Override
+  public void beforeWithReload() {
+    setBinBarcode(FOOD001_LOCATOR_ID, BARCODE);
+  }
+
+  @Override
+  public void afterWithReload() {
+    setBinBarcode(FOOD001_LOCATOR_ID, null);
+  }
+
+  private void setBinBarcode(String locatorId, String barcode) {
+    String sql = "";
+    if (!StringUtils.equals(barcode, null)) {
+      sql = String.format("update m_locator set barcode = '%s' where m_locator_id = '%s'", barcode,
+          locatorId);
+    } else {
+      sql = String.format("update m_locator set barcode = NULL where m_locator_id = '%s'",
+          locatorId);
+    }
+
+    new DatabaseHelperInsertUpdateOrDelete() {
+    }.execute(sql, 1);
+  }
+}
--- a/src-test/org/openbravo/test/mobile/awo/utilities/TestIdAwo.java	Thu May 16 17:01:51 2019 +0200
+++ b/src-test/org/openbravo/test/mobile/awo/utilities/TestIdAwo.java	Thu May 16 17:02:35 2019 +0200
@@ -111,6 +111,8 @@
       "menuScroller_menuUnassignTask"); //
   public static TestIdConstructor TASK_CONFIRMED_LOCATOR_FROM = new TestIdConstructor(
       "value_confirmedLocatorFrom"); //
+  public static TestIdConstructor LOCATORFROM_CONFIRMED_CONTAINER = new TestIdConstructor(
+      "taskFieldsContainerLines_confirmedLocatorFrom"); //
   public static TestIdConstructor TASK_CONFIRMED_LOCATOR_TO = new TestIdConstructor(
       "value_confirmedLocatorTo"); //
   public static TestIdConstructor PRODUCTLIST_ROW1 = new TestIdConstructor(
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/discounts_combo/I40831_VerifyDiscountWhenTwoCombosAreApplied.java	Thu May 16 17:02:35 2019 +0200
@@ -0,0 +1,115 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.0 (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 S.L.U.
+ * All portions are Copyright (C) 2019 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author alekosmp86@gmail.com
+ *
+ */
+
+package org.openbravo.test.mobile.retail.extmodules.selenium.tests.discounts_combo;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.math.BigDecimal;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.retail.extmodules.selenium.terminals.WebPOSExtModulesTerminalHelper;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.BackboneHelper;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.SynchronizationMonitor;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+
+public class I40831_VerifyDiscountWhenTwoCombosAreApplied extends WebPOSExtModulesTerminalHelper {
+  final private String PRODUCT_A_NAME = "Headlamp ultralight";
+  final private String PRODUCT_B_NAME = "Headlamp 2 leds";
+  final private String DISCOUNT_ID = "3F7156BB261A4CADA7CB104DD0FF8633";
+  Long line = 10L;
+
+  @Test
+  public void test() {
+    String docNo = BackboneHelper.getDocumentNo();
+
+    addProduct(PRODUCT_A_NAME);
+    addProduct(PRODUCT_B_NAME);
+    verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTNAME, "-- Lamps Combo");
+    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTNAME, "-- Lamps Combo");
+    addProduct(PRODUCT_A_NAME);
+    addProduct(PRODUCT_B_NAME);
+    verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTNAME, "-- (2x) Lamps Combo");
+    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTNAME, "-- (2x) Lamps Combo");
+    verify(TestIdPack.BUTTON_PAY_AMOUNT, "20.00");
+    verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTAMOUNT, "-29.29");
+    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTAMOUNT, "-39.51");
+    tap(TestIdPack.BUTTON_PAY);
+    tap(TestIdPack.BUTTON_PAY_EXACT);
+    tap(TestIdPack.BUTTON_PAY_DONE);
+    SynchronizationMonitor.waitUntilDataIsInTheServer();
+
+    verifyDataInBackend(docNo);
+  }
+
+  @Override
+  public void beforeWithReload() {
+    setActiveDiscount(DISCOUNT_ID, true);
+  }
+
+  @Override
+  public void afterWithReload() {
+    setActiveDiscount(DISCOUNT_ID, false);
+  }
+
+  private void setActiveDiscount(String discountId, boolean active) {
+    String sql = String.format("update m_offer set isactive = '%s' where m_offer_id = '%s'",
+        active ? "Y" : "N", discountId);
+
+    new DatabaseHelperInsertUpdateOrDelete() {
+    }.execute(sql, 1);
+  }
+
+  private void addProduct(String productName) {
+    // add a product
+    tap(TestIdPack.BUTTON_SEARCH);
+    write(TestIdPack.FIELD_SEARCH_TEXT, productName);
+    TestIdPack.FIELD_SEARCH_TEXT.enyoNode().executeExtension(".waterfall('onchange')");
+    tap(TestIdPack.BUTTON_SEARCH_EXECUTE);
+    tap(TestIdPack.BUTTON_SEARCHPRODUCT_FIRSTROW);
+  }
+
+  private void verifyDataInBackend(String documentNo) {
+    String sql = String.format(
+        "select ol.line_gross_amount from c_orderline ol left join c_order o on o.c_order_id = ol.c_order_id where o.documentno = '%s' "
+            + "order by ol.line_gross_amount asc",
+        documentNo);
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(ResultSet rs) throws SQLException {
+        if (line == 10L) {
+          assertThat("Wrong line gross amount",
+              rs.getBigDecimal(1).compareTo(new BigDecimal("8.51")) == 0);
+        } else {
+          assertThat("Wrong line gross amount",
+              rs.getBigDecimal(1).compareTo(new BigDecimal("11.49")) == 0);
+        }
+        line += 10L;
+      }
+    }.execute(sql, 2);
+  }
+}
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/multidiscounts/Multidiscounts_FixedAmount.java	Thu May 16 17:01:51 2019 +0200
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/multidiscounts/Multidiscounts_FixedAmount.java	Thu May 16 17:02:35 2019 +0200
@@ -87,9 +87,9 @@
     verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTAMOUNT2, "-5.00");
     verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTNAME3, "-- disc_5_ var_perc - 16 %");
     verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTAMOUNT3, "-22.48");
-    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTNAME, "-- disc_5_ var_perc - 5 %");
-    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTAMOUNT, "-5.50");
-    verify(TestIdPack.LABEL_TOTALTOPAY, "222.42");
+    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTNAME, "-- disc_5_ var_perc - 16 %");
+    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTAMOUNT, "-17.58");
+    verify(TestIdPack.LABEL_TOTALTOPAY, "210.34");
     // Pay the ticket
     tap(TestIdPack.BUTTON_PAY);
     tap(TestIdPack.BUTTON_PAY_EXACT);
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/multidiscounts/Multidiscounts_FixedPercentage.java	Thu May 16 17:01:51 2019 +0200
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/multidiscounts/Multidiscounts_FixedPercentage.java	Thu May 16 17:02:35 2019 +0200
@@ -88,8 +88,8 @@
     verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTNAME3, "-- disc_5_var_euro");
     verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTAMOUNT3, "-16.00");
     verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTNAME, "-- disc_5_var_euro");
-    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTAMOUNT, "-5.00");
-    verify(TestIdPack.LABEL_TOTALTOPAY, "224.72");
+    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTAMOUNT, "-16.00");
+    verify(TestIdPack.LABEL_TOTALTOPAY, "213.72");
     // Pay the ticket
     tap(TestIdPack.BUTTON_PAY);
     tap(TestIdPack.BUTTON_PAY_EXACT);
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/multidiscounts/Multidiscounts_VariableAmount.java	Thu May 16 17:01:51 2019 +0200
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/multidiscounts/Multidiscounts_VariableAmount.java	Thu May 16 17:02:35 2019 +0200
@@ -87,9 +87,9 @@
     verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTAMOUNT2, "-13.50");
     verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTNAME3, "-- disc_5_ var_perc - 16 %");
     verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTAMOUNT3, "-21.12");
-    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTNAME, "-- disc_5_ var_perc - 5 %");
-    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTAMOUNT, "-5.50");
-    verify(TestIdPack.LABEL_TOTALTOPAY, "215.28");
+    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTNAME, "-- disc_5_ var_perc - 16 %");
+    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTAMOUNT, "-17.58");
+    verify(TestIdPack.LABEL_TOTALTOPAY, "203.20");
     // Pay the ticket
     tap(TestIdPack.BUTTON_PAY);
     tap(TestIdPack.BUTTON_PAY_EXACT);
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/multidiscounts/Multidiscounts_VariablePercentage.java	Thu May 16 17:01:51 2019 +0200
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/multidiscounts/Multidiscounts_VariablePercentage.java	Thu May 16 17:02:35 2019 +0200
@@ -88,8 +88,8 @@
     verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTNAME3, "-- disc_5_var_euro");
     verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTAMOUNT3, "-16.00");
     verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTNAME, "-- disc_5_var_euro");
-    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTAMOUNT, "-5.00");
-    verify(TestIdPack.LABEL_TOTALTOPAY, "212.57");
+    verify(TestIdPack.LABEL_RECEIPT_ROW2_DISCOUNTAMOUNT, "-16.00");
+    verify(TestIdPack.LABEL_TOTALTOPAY, "201.57");
     // Pay the ticket
     tap(TestIdPack.BUTTON_PAY);
     tap(TestIdPack.BUTTON_PAY_EXACT);
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/reversepayments/ReversePaymentPaidOnCreditWithCredit.java	Thu May 16 17:01:51 2019 +0200
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/reversepayments/ReversePaymentPaidOnCreditWithCredit.java	Thu May 16 17:02:35 2019 +0200
@@ -102,7 +102,8 @@
 
     // Check that the CREDIT button is disabled
     verify(TestIdPack.LABEL_RECEIPT_PAY_REMAINING, "150.50€");
-    isDisabled(TestIdPack.BUTTON_PAY_USECREDIT, true);
+    isVisible(TestIdPack.BUTTON_PAY_USECREDIT, true);
+    isDisabled(TestIdPack.BUTTON_PAY_USECREDIT, false);
     tap(TestIdPack.BUTTON_PAYMENT_CARD);
     tap(TestIdPack.BUTTON_PAY_EXACT);
     tap(TestIdPack.BUTTON_PAY_DONE);
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/reversepayments/ReversePaymentWithCredit.java	Thu May 16 17:01:51 2019 +0200
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/reversepayments/ReversePaymentWithCredit.java	Thu May 16 17:02:35 2019 +0200
@@ -102,7 +102,8 @@
 
       // Pay the rest in credit
       verify(TestIdPack.LABEL_RECEIPT_PAY_REMAINING, "150.50€");
-      isDisabled(TestIdPack.BUTTON_PAY_USECREDIT, true);
+      isVisible(TestIdPack.BUTTON_PAY_USECREDIT, true);
+      isDisabled(TestIdPack.BUTTON_PAY_USECREDIT, false);
       tap(TestIdPack.BUTTON_CARD);
       tap(TestIdPack.BUTTON_PAY_EXACT);
       isVisible(TestIdPack.LABEL_RECEIPT_PAY_EXACT, true);
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I32878_CheckDeleteKeyOnReceipt.java	Thu May 16 17:01:51 2019 +0200
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I32878_CheckDeleteKeyOnReceipt.java	Thu May 16 17:02:35 2019 +0200
@@ -56,6 +56,10 @@
 
       // Delete on Empty Receipt
       SeleniumHelper.pressKey(Keys.DELETE);
+      
+      tap(TestIdPack.BUTTON_DELETERECEIPT);
+      tap(TestIdPack.BUTTON_DELETERECEIPT_CONFIRM);
+      verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
 
       changeUseExternalInput(false);
       isFinishedCorrectly = true;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I40810_VerifyCreditButtonOnReversePayment.java	Thu May 16 17:02:35 2019 +0200
@@ -0,0 +1,122 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.0 (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 S.L.U.
+ * All portions are Copyright (C) 2019 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAN
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.system;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.BackboneHelper;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSTerminalHelper;
+
+public class I40810_VerifyCreditButtonOnReversePayment extends WebPOSTerminalHelper {
+
+  final String vbsPOSTerminalType = "BD39916225594B32A88983899CF05F72";
+  final String strCarlStudson = "Carl Studson";
+
+  @Test
+  public void test() {
+    changeCustomer();
+    addProduct();
+    String receiptNo1 = BackboneHelper.getDocumentNo();
+    tap(TestIdPack.BUTTON_PAY);
+    tap(TestIdPack.BUTTON_PAY_EXACT);
+    tap(TestIdPack.BUTTON_PAY_DONE);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+    tap(TestIdPack.BUTTON_MENU);
+    tap(TestIdPack.BUTTON_MENU_OPENRECEIPT);
+    write(TestIdPack.FIELD_OPEN_RECEIPT_FILTER_TXT, receiptNo1);
+    tap(TestIdPack.BUTTON_OPEN_RECEIPT_SEARCH);
+    tap(TestIdPack.TABLE_OPEN_RECEIPT, receiptNo1);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "3.60");
+    tap(TestIdPack.BUTTON_PAY);
+    tap(TestIdPack.BUTTON_REVERSEPAYMENT_ROW1);
+    verify(TestIdPack.LABEL_POPUP_TITLE, "Reverse Payment");
+    tap(TestIdPack.BUTTON_POPUP_CONFIRMATION_OK);
+    isVisible(TestIdPack.BUTTON_PAY_USECREDIT, true);
+    isDisabled(TestIdPack.BUTTON_PAY_USECREDIT, false);
+    tap(TestIdPack.BUTTON_PAY_USECREDIT);
+    isVisible(TestIdPack.LABEL_PAY_USECREDIT_POPUP, true);
+    tap(TestIdPack.BUTTON_PAY_USECREDIT_OK);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+    
+    changeCustomer();
+    addProduct();
+    String receiptNo2 = BackboneHelper.getDocumentNo();
+    tap(TestIdPack.BUTTON_PAY);
+    isVisible(TestIdPack.BUTTON_PAY_USECREDIT, true);
+    tap(TestIdPack.BUTTON_PAY_USECREDIT);
+    isVisible(TestIdPack.LABEL_PAY_USECREDIT_POPUP, true);
+    tap(TestIdPack.BUTTON_PAY_USECREDIT_OK);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+    
+    tap(TestIdPack.BUTTON_MENU);
+    tap(TestIdPack.BUTTON_MENU_VERIFIEDRETURN);
+    write(TestIdPack.FIELD_VERIFIED_RETURNS_FILTER_TXT, receiptNo2);
+    tap(TestIdPack.BUTTON_VERIFIEDRETURNS_SEARCH);
+    tap(TestIdPack.BUTTON_VERIFIEDRETURNS_ROW1);
+    tap(TestIdPack.BUTTON_VERIFIEDRETURNS_LINES_CHECKROW1);
+    tap(TestIdPack.BUTTON_POPUP_APPLY);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "-3.60");
+    tap(TestIdPack.BUTTON_PAY);
+    isVisible(TestIdPack.BUTTON_PAY_USECREDIT, true);
+    isDisabled(TestIdPack.BUTTON_PAY_USECREDIT, false);
+    tap(TestIdPack.BUTTON_PAY_USECREDIT);
+    isVisible(TestIdPack.LABEL_PAY_USECREDIT_POPUP, true);
+    tap(TestIdPack.BUTTON_PAY_USECREDIT_OK);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void changeCustomer() {
+    tap(TestIdPack.BUTTON_RECEIPT_CUSTOMER);
+    write(TestIdPack.FIELD_CUSTOMER_MODAL, strCarlStudson);
+    tap(TestIdPack.BUTTON_CUSTOMER_MODAL_SEARCH);
+    verify(TestIdPack.LABEL_CUSTOMER_SEARCH_IDENTIFIER, strCarlStudson);
+    tap(TestIdPack.BUTTON_CUSTOMER_SEARCH_ROW1);
+  }
+
+  private void addProduct() {
+    tap(TestIdPack.BUTTON_SEARCH);
+    write(TestIdPack.FIELD_SEARCH_TEXT,
+        TestIdPack.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_ADHESIVEBODYWARNMERS.getRowName());
+    tap(TestIdPack.BUTTON_SEARCH_EXECUTE);
+    tap(TestIdPack.BUTTON_SEARCHPRODUCT_FIRSTROW);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "3.60");
+  }
+
+  @Override
+  public void beforeWithReload() {
+    updateChanges(true);
+  }
+
+  @Override
+  public void afterWithReload() {
+    updateChanges(false);
+  }
+
+  private void updateChanges(boolean isForTest) {
+    final String sql = String.format("update obpos_terminaltype set allowpayoncredit = '%s' "
+        + "where obpos_terminaltype_id = '%s'", isForTest ? "Y" : "N", vbsPOSTerminalType);
+    new DatabaseHelperInsertUpdateOrDelete().execute(sql, 1);
+  }
+}