Verifies issue 37887 : Added automated test 'I37887_VerfiyInvoiceDate'
authorRanjith S R <ranjith@qualiantech.com>
Tue, 13 Feb 2018 12:08:32 +0530
changeset 7076 8bc96b7a124a
parent 7075 edcf61470df9
child 7077 13b6eaa302ec
Verifies issue 37887 : Added automated test 'I37887_VerfiyInvoiceDate'
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/receipts/I37887_VerfiyInvoiceDate.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/receipts/I37887_VerfiyInvoiceDate.java	Tue Feb 13 12:08:32 2018 +0530
@@ -0,0 +1,102 @@
+/*
+ *************************************************************************
+ * 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) 2018 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 java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.core.utils.OBNumber;
+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.API.WebPOSAPI;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSTerminalHelper;
+
+public class I37887_VerfiyInvoiceDate extends WebPOSTerminalHelper {
+
+  @Test
+  public void test() {
+    // Receipt 1
+    tap(TestIdPack.BUTTON_MENU);
+    tap(TestIdPack.BUTTON_MENU_INVOICETHISRECEIPT);
+    final String receiptNo1 = createReceipt();
+
+    // Receipt 2
+    final String receiptNo2 = createReceipt();
+
+    // Do Cashup
+    WebPOSAPI.cleanCashup(this);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+    final SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
+    final String strCurrentDate = dateFormatter.format(new Date());
+
+    final String sql = String.format("select o.documentno, i.dateinvoiced, i.dateacct, "
+        + "i.grandtotal from c_order o join c_orderline ol on ol.c_order_id = o.c_order_id "
+        + "join c_invoiceline il on il.c_orderline_id = ol.c_orderline_id "
+        + "join c_invoice i on i.c_invoice_id = il.c_invoice_id "
+        + "where o.documentno in ('%s', '%s') order by i.created asc", receiptNo1, receiptNo2);
+    new DatabaseHelperSelect() {
+      int count = 0;
+
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        count++;
+        switch (count) {
+        case 1:
+          assertThat("Time is present in Invoice Date", strCurrentDate,
+              equalTo(rs.getString("dateinvoiced")));
+          assertThat("Time is present in Invoice Date", strCurrentDate,
+              equalTo(rs.getString("dateacct")));
+          assertThat(new OBNumber("3.60"), equalTo(new OBNumber(rs.getBigDecimal("grandtotal"))));
+          break;
+        case 2:
+          assertThat("Time is present in Invoice Date", strCurrentDate,
+              equalTo(rs.getString("dateinvoiced")));
+          assertThat("Time is present in Invoice Date", strCurrentDate,
+              equalTo(rs.getString("dateacct")));
+          break;
+        }
+      }
+    }.execute(sql, 2);
+  }
+
+  private String createReceipt() {
+    tap(TestIdPack.BUTTON_BROWSE);
+    tap(TestIdPack.BUTTON_CATEGORY_BACKPACKSANDTRAVEL);
+    tap(TestIdPack.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_ADHESIVEBODYWARNMERS);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "3.60");
+    final String receiptNo = BackboneHelper.getDocumentNo();
+    tap(TestIdPack.BUTTON_PAY);
+    tap(TestIdPack.BUTTON_PAY_EXACT);
+    tap(TestIdPack.BUTTON_PAY_DONE);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+    return receiptNo;
+  }
+}
\ No newline at end of file