Related to issue 28933. Verifies issue 29153: Added 'I29153_CashupWithSaleAndReturnRetrieveFromServer' test
authorRafa Alonso <rafael.alonso@openbravo.com>
Sat, 07 Mar 2015 23:11:22 +0100
changeset 4063 f472a492da0d
parent 4062 6fd24a428a31
child 4064 03027eead0fc
Related to issue 28933. Verifies issue 29153: Added 'I29153_CashupWithSaleAndReturnRetrieveFromServer' test
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashup/I29153_CashupWithSaleAndReturnRetrieveFromServer.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashup/I29153_CashupWithSaleAndReturnRetrieveFromServer.java	Sat Mar 07 23:11:22 2015 +0100
@@ -0,0 +1,203 @@
+/*
+ *************************************************************************
+ * 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) 2008-2014 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.cashup;
+
+import org.junit.After;
+import org.junit.Test;
+import org.openbravo.test.mobile.common.selenium.database.WebPOSDatabaseConstants;
+import org.openbravo.test.mobile.common.selenium.database.WebPOSDatabaseHelper;
+import org.openbravo.test.mobile.common.selenium.javascript.BackboneHelper;
+import org.openbravo.test.mobile.common.selenium.javascript.TestId;
+import org.openbravo.test.mobile.common.selenium.terminals.WebPOSTerminalHelper;
+import org.openbravo.test.mobile.common.selenium.testhelpers.TestLogger;
+import org.openbravo.test.mobile.common.selenium.testhelpers.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+public class I29153_CashupWithSaleAndReturnRetrieveFromServer extends WebPOSTerminalHelper {
+
+  private static String cashupId;
+  private static OBNumber TOTALSALES = new OBNumber("243.9");
+  private static OBNumber TOTALRETURNS = new OBNumber("110.5");
+  private static OBNumber NETSALES = new OBNumber("201.58");
+  private static OBNumber NETRETURNS = new OBNumber("91.32");
+  private static OBNumber TOTALTRANSACTIONS = new OBNumber("133.40");
+
+  @Test
+  public void test1() {
+    WebPOSSnippet.cleanCashup(this);
+    cashupId = BackboneHelper.getTerminalValue("cashUpId");
+    sale();
+
+    // verify WebPOS
+    verifyCashup();
+    tap(TestId.BUTTON_CASHUP_CANCEL);
+
+    // verify database
+    verifyDatabase();
+  }
+
+  @Override
+  @After
+  public void after() {
+    if (TestLogger.getTestMethodName().equals("test1")) {
+      logoutAndCloseBrowser();
+      return;
+    }
+    super.after();
+  }
+
+  private void verifyDatabase() {
+    WebPOSDatabaseHelper.verifyCashupTable(cashupId, TOTALSALES, TOTALRETURNS, NETSALES,
+        NETRETURNS, TOTALTRANSACTIONS);
+
+    WebPOSDatabaseHelper.verifyPaymentMethod(cashupId,
+        WebPOSDatabaseConstants.VBS_PAYMENTMETHOD.CARD, OBNumber.ZERO, OBNumber.ZERO,
+        OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, null);
+    WebPOSDatabaseHelper.verifyPaymentMethod(cashupId,
+        WebPOSDatabaseConstants.VBS_PAYMENTMETHOD.CASH, OBNumber.ZERO, TOTALSALES, TOTALRETURNS,
+        OBNumber.ZERO, OBNumber.ZERO, null);
+    WebPOSDatabaseHelper.verifyPaymentMethod(cashupId,
+        WebPOSDatabaseConstants.VBS_PAYMENTMETHOD.USACASH, OBNumber.ZERO, OBNumber.ZERO,
+        OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, null);
+    WebPOSDatabaseHelper.verifyPaymentMethod(cashupId,
+        WebPOSDatabaseConstants.VBS_PAYMENTMETHOD.VOUCHER, OBNumber.ZERO, OBNumber.ZERO,
+        OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, null);
+  }
+
+  @Override
+  public void afterSuccessfulTest_VerifyTerminalIsLeftAsTestStarted() {
+    if (TestLogger.getTestMethodName().equals("test1")) {
+      return;
+    }
+    super.afterSuccessfulTest_VerifyTerminalIsLeftAsTestStarted();
+  }
+
+  @Test
+  public void test2() {
+    // verify WebPOS
+    verifyCashup();
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+
+    // verify database
+    verifyDatabase();
+  }
+
+  private void sale() {
+    // sale
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_BACKPACKSANDTRAVEL);
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_ADHESIVEBODYWARNMERS);
+    verify(TestId.LABEL_TOTALTOPAY, "3.60");
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_TEKTOWEL);
+    verify(TestId.LABEL_TOTALTOPAY, "23.50");
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_ALPINESKIING);
+    verify(TestId.LABEL_TOTALTOPAY, "133.40");
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_BABYCARRIER);
+    verify(TestId.LABEL_TOTALTOPAY, TOTALSALES);
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+
+    // with return
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_RETURNTHISRECEIPT);
+    verify(TestId.LABEL_RECEIPT_TYPE, "To be Returned");
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_BACKPACKSANDTRAVEL);
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_BABYCARRIER);
+    verify(TestId.LABEL_TOTALTOPAY, TOTALRETURNS.negativeSign());
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+
+  }
+
+  private void verifyCashup() {
+    // first cashup
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_CASHUP);
+
+    // step 1 of 5
+    verify(TestId.LABEL_CASHUP_STEP1_TITLE, "Step 1 of 5: Review pending receipts");
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 2 of 5
+    verify(TestId.LABEL_CASHUP_STEP2_TITLE, "Step 2 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    verify(TestId.LABEL_CASHUP_CARDEXPECTED, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_CASHEXPECTED, TOTALTRANSACTIONS);
+    verify(TestId.LABEL_CASHUP_CASHCOUNTED, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_CASHUSAFOREIGNEXPECTED, "(0.00 USD)");
+    verify(TestId.LABEL_CASHUP_CASHUSAEXPECTED, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_VOUCHEREXPECTED, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALEXPECTED, TOTALTRANSACTIONS);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, TOTALTRANSACTIONS.negativeSign());
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_CASHUSACOUNTED, "(0.00 USD)");
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, TOTALTRANSACTIONS.negativeSign());
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 4 of 5
+    // cash
+    verify(TestId.LABEL_CASHUP_STEP4_TITLE, "Step 4 of 5: Select Cash to keep");
+    verify(TestId.LABEL_CASHUP_KEEPNOTHING, "Nothing");
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // usa cash
+    verify(TestId.LABEL_CASHUP_STEP4_TITLE, "Step 4 of 5: Select USA Cash to keep");
+    verify(TestId.LABEL_CASHUP_KEEPNOTHING, "Nothing");
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // voucher
+    verify(TestId.LABEL_CASHUP_STEP4_TITLE, "Step 4 of 5: Select Voucher to keep");
+    verify(TestId.LABEL_CASHUP_KEEPNOTHING, "Nothing");
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 5 of 5
+    verify(TestId.LABEL_CASHUP_STEP5_TITLE, "Step 5 of 5: Post, print and close");
+    verify(TestId.LABEL_CASHUP_POSTPRINTANDCLOSE, "Post, Print & Close");
+
+    verify(TestId.LABEL_CASHUP_NETSALES_TITLE, "Net Sales");
+    verify(TestId.LABEL_CASHUP_NETSALES_AMOUNT, NETSALES);
+    verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, TOTALSALES.subtract(NETSALES));
+    verify(TestId.LABEL_CASHUP_GROSSSALES_TITLE, "Gross Sales");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, TOTALSALES);
+
+    verify(TestId.LABEL_CASHUP_NETRETURNS_TITLE, "Net Returns");
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, NETRETURNS);
+    verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, TOTALRETURNS.subtract(NETRETURNS));
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_TITLE, "Gross Returns");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, TOTALRETURNS);
+
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, TOTALTRANSACTIONS);
+  }
+
+}