# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1488259964 -19800
#      Tue Feb 28 11:02:44 2017 +0530
# Node ID 879e640b6327e6bf5b53e0734147bca95c6dfcca
# Parent  09e5a58c23bb9075015e39b6d1044fccb627e3b7
Verifies issue 35355 : Added automated test 'I35355_VerifyLayawayAmountInPayOpen'

diff -r 09e5a58c23bb -r 879e640b6327 src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/I35355_VerifyLayawayAmountInPayOpen.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/I35355_VerifyLayawayAmountInPayOpen.java	Tue Feb 28 11:02:44 2017 +0530
@@ -0,0 +1,83 @@
+/*
+ *************************************************************************
+ * 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) 2017 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAN
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.retail.mobilecore.annotations.TestClassAnnotations;
+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;
+
+@TestClassAnnotations(isHighVolumeCompatible = true)
+public class I35355_VerifyLayawayAmountInPayOpen extends WebPOSTerminalHelper {
+
+  @Test
+  public void test() {
+    final String customer = get(TestIdPack.BUTTON_RECEIPT_CUSTOMER);
+    final String documentNo = BackboneHelper.getDocumentNo();
+    tap(TestIdPack.BUTTON_MENU);
+    tap(TestIdPack.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+    verify(TestIdPack.LABEL_RECEIPT_TYPE, "To be laid away");
+    tap(TestIdPack.BUTTON_SEARCH);
+    write(TestIdPack.FIELD_SEARCH_TEXT,
+        TestIdPack.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVER.getRowName());
+    tap(TestIdPack.BUTTON_SEARCH_EXECUTE);
+    tap(TestIdPack.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVER);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "150.50");
+    tap(TestIdPack.BUTTON_PAY);
+    tap(TestIdPack.BUTTON_LAYAWAY);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+
+    // Open the layaway using pay open tickets
+    tap(TestIdPack.BUTTON_MENU);
+    tap(TestIdPack.BUTTON_MENU_PAYOPENTICKETS);
+    write(TestIdPack.FIELD_SEARCH_MULTIORDERS_TEXT, documentNo);
+    tap(TestIdPack.BUTTON_POPUP_OPENTICKETS_SEARCH);
+    verify(TestIdPack.LABEL_MULTIORDERS_SEARCHRESULTS_ROW1_TOPLINE,
+        String.format("%s - %s", documentNo, customer));
+    tap(TestIdPack.BUTTON_POPUP_OPENTICKETS_ROW1);
+    tap(TestIdPack.BUTTON_POPUP_OPENTICKETS_DONE);
+
+    // Verify the information
+    verify(TestIdPack.LABEL_TOTALTOPAY, "150.50");
+    verify(TestIdPack.LABEL_RECEIPT_MULTIORDER_TOTALQTY, "1");
+
+    // Add amount for layaway
+    tap(TestIdPack.BUTTON_RECEIPT_MULTIORDER_ROW1_LINE);
+    write(TestIdPack.INPUT_POPUP_MULTIORDER_AMNTLAYAWAY, "100.00");
+    tap(TestIdPack.BUTTON_POPUP_MULTIORDER_APPLYAMNT);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "100.00");
+    verify(TestIdPack.LABEL_RECEIPT_MULTIORDER_ROW1_TOTAL, "100.00");
+
+    // Add empty in amount to layaway
+    tap(TestIdPack.BUTTON_RECEIPT_MULTIORDER_ROW1_LINE);
+    write(TestIdPack.INPUT_POPUP_MULTIORDER_AMNTLAYAWAY, "");
+    tap(TestIdPack.BUTTON_POPUP_MULTIORDER_APPLYAMNT);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "150.50");
+    verify(TestIdPack.LABEL_RECEIPT_MULTIORDER_ROW1_TOTAL, "150.50");
+
+    tap(TestIdPack.BUTTON_PAY_EXACT);
+    tap(TestIdPack.BUTTON_PAY_DONE);
+    verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+  }
+}
\ No newline at end of file
