Verifies issue 40082 : Added Automated Test 'I40082_VerifyDiscountAmtInOrderLine'
authorRanjith S R <ranjith@qualiantech.com>
Tue, 05 Feb 2019 19:21:36 +0530
changeset 8190 cbb360f811c9
parent 8189 fdee9e18b235
child 8191 efe2b09d51f3
Verifies issue 40082 : Added Automated Test 'I40082_VerifyDiscountAmtInOrderLine'
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/discountsandpromotions/Communit6783_BuyXPayYDifferentProductCheapestDistributed.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/discountsandpromotions/I22425_Communit6789_BuyXGetYGift.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/receipts/I40082_VerifyDiscountAmtInOrderLine.java
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/discountsandpromotions/Communit6783_BuyXPayYDifferentProductCheapestDistributed.java	Tue Feb 05 13:49:42 2019 +0100
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/discountsandpromotions/Communit6783_BuyXPayYDifferentProductCheapestDistributed.java	Tue Feb 05 19:21:36 2019 +0530
@@ -101,13 +101,13 @@
           case 2:
             assertEquals(10, line);
             assertEquals("6 x 5 Descenders", promotionName);
-            assertEquals(0.67, discountPerUnit, 0.1);
+            assertEquals(1, discountPerUnit, 0.1);
             assertEquals(2, totalDiscount, 0);
             break;
           case 3:
             assertEquals(20, line);
             assertEquals("6 x 5 Descenders", promotionName);
-            assertEquals(0.33, discountPerUnit, 0.1);
+            assertEquals(1, discountPerUnit, 0.1);
             assertEquals(1, totalDiscount, 0);
             break;
         }
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/discountsandpromotions/I22425_Communit6789_BuyXGetYGift.java	Tue Feb 05 13:49:42 2019 +0100
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/discountsandpromotions/I22425_Communit6789_BuyXGetYGift.java	Tue Feb 05 19:21:36 2019 +0530
@@ -103,7 +103,7 @@
           case 2:
             assertEquals(10, line);
             assertEquals("Unisex Skis ยป gift Glide Wax", promotionName);
-            assertEquals(0.89, discountPerUnit, 0.1);
+            assertEquals(1.78, discountPerUnit, 0.1);
             assertEquals(1.78, totalDiscount, 0.1);
             break;
           default:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/receipts/I40082_VerifyDiscountAmtInOrderLine.java	Tue Feb 05 19:21:36 2019 +0530
@@ -0,0 +1,126 @@
+/*
+ *************************************************************************
+ * 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.receipts;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect;
+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 I40082_VerifyDiscountAmtInOrderLine extends WebPOSTerminalHelper {
+
+  String receiptNo = null;
+
+  @Test
+  public void test() {
+    tap(TestIdPack.BUTTON_SEARCH);
+    write(TestIdPack.FIELD_SEARCH_TEXT, "Bottle 1 L");
+    tap(TestIdPack.BUTTON_SEARCH_EXECUTE);
+    tap(TestIdPack.BUTTON_SEARCHPRODUCT_FIRSTROW);
+    tap(TestIdPack.BUTTON_RECEIPT_ROW1);
+    tap(TestIdPack.BUTTON_KEYPAD_6);
+    tap(TestIdPack.BUTTON_KEYPAD_QUANTITY);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "38.00");
+    verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTNAME, "-- (2x) 3 x 2 Bottles");
+    verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTAMOUNT, "-19.00");
+    receiptNo = BackboneHelper.getDocumentNo();
+    tap(TestIdPack.BUTTON_PAY);
+    tap(TestIdPack.BUTTON_PAY_EXACT);
+    tap(TestIdPack.BUTTON_PAY_DONE);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+    final String sql = String.format("select old.em_obdisc_qtyoffer as qty, old.amtoffer as amt, "
+        + "old.totalamt from c_orderline_offer old "
+        + "join c_orderline ol on ol.c_orderline_id = old.c_orderline_id "
+        + "join c_order o on o.c_order_id = ol.c_order_id "
+        + "where o.documentno = '%s' order by old.line asc", receiptNo);
+    new DatabaseHelperSelect() {
+      private int count = 0;
+
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        count++;
+        switch (count) {
+          case 1:
+            assertThat((float) 4, equalTo(rs.getFloat("qty")));
+            assertThat((float) 0, equalTo(rs.getFloat("amt")));
+            assertThat((float) 0, equalTo(rs.getFloat("totalamt")));
+            break;
+          case 2:
+            assertThat((float) 2, equalTo(rs.getFloat("qty")));
+            assertThat((float) 9.5, equalTo(rs.getFloat("amt")));
+            assertThat((float) 19, equalTo(rs.getFloat("totalamt")));
+            break;
+        }
+      }
+    }.execute(sql, 2);
+
+    tap(TestIdPack.BUTTON_SEARCH);
+    write(TestIdPack.FIELD_SEARCH_TEXT, "Bottle 1 L");
+    tap(TestIdPack.BUTTON_SEARCH_EXECUTE);
+    tap(TestIdPack.BUTTON_SEARCHPRODUCT_FIRSTROW);
+    tap(TestIdPack.BUTTON_RECEIPT_ROW1);
+    tap(TestIdPack.BUTTON_KEYPAD_5);
+    tap(TestIdPack.BUTTON_KEYPAD_QUANTITY);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "38.00");
+    verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTNAME, "-- 3 x 2 Bottles");
+    verify(TestIdPack.LABEL_RECEIPT_ROW1_DISCOUNTAMOUNT, "-9.50");
+    receiptNo = BackboneHelper.getDocumentNo();
+    tap(TestIdPack.BUTTON_PAY);
+    tap(TestIdPack.BUTTON_PAY_EXACT);
+    tap(TestIdPack.BUTTON_PAY_DONE);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+    final String sql2 = String.format("select old.em_obdisc_qtyoffer as qty, old.amtoffer as amt, "
+        + "old.totalamt from c_orderline_offer old "
+        + "join c_orderline ol on ol.c_orderline_id = old.c_orderline_id "
+        + "join c_order o on o.c_order_id = ol.c_order_id "
+        + "where o.documentno = '%s' order by old.line asc", receiptNo);
+    new DatabaseHelperSelect() {
+      private int count = 0;
+
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        count++;
+        switch (count) {
+          case 1:
+            assertThat((float) 2, equalTo(rs.getFloat("qty")));
+            assertThat((float) 0, equalTo(rs.getFloat("amt")));
+            assertThat((float) 0, equalTo(rs.getFloat("totalamt")));
+            break;
+          case 2:
+            assertThat((float) 1, equalTo(rs.getFloat("qty")));
+            assertThat((float) 9.5, equalTo(rs.getFloat("amt")));
+            assertThat((float) 9.5, equalTo(rs.getFloat("totalamt")));
+            break;
+        }
+      }
+    }.execute(sql2, 2);
+  }
+}