Related to issue 28933. Verifies issue 28130: Added several tests
authorRafa Alonso <rafael.alonso@openbravo.com>
Fri, 27 Feb 2015 10:00:33 +0100
changeset 4065 0324c60bb932
parent 4064 03027eead0fc
child 4066 7c7f24150f18
Related to issue 28933. Verifies issue 28130: Added several tests
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashup/MultiterminalSaleAndCashupVerifyingDatabase.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashup/SaleAndCashupVerifyingDatabaseI.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashup/SaleAndCashupVerifyingDatabaseII.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashup/SalesCashupReturnCashupVerifyingDatabase.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/LayawayNotListedWhenFinished.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/LayawayRetrieval.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/LayawayRetrievalWithinOrganization.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/LayawayVerifyPaymentsInformation.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Fin1.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Fin2.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Par1Fin2.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Par2Fin1.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Par2Fin2.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Par2Fin3.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Par2Void3.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Void2.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/sales/CreateSaleVerifyingDatabaseFields.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/sales/SaleAndReturnInvoicedVerifyingDatabase.java
src-test/org/openbravo/test/mobile/retail/pack/selenium/todo/MultiterminalMulticurrencyLayaways.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashup/MultiterminalSaleAndCashupVerifyingDatabase.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,547 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.cashup;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.fail;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+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.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.Format;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+@RunWith(Parameterized.class)
+public class MultiterminalSaleAndCashupVerifyingDatabase extends WebPOSTerminalHelper {
+
+  private static final String VBS1001 = "VBS1001";
+  private static final String VBS1002 = "VBS1002";
+  private static final float NET1 = 6.45F;
+  private static final float GROSS1 = 7.80F;
+  private static final float NET2 = 11.16F;
+  private static final float GROSS2 = 13.50F;
+  private static String documentNo1;
+  private static String documentNo2;
+
+  @Parameters(name = "({index}) terminal: {0}")
+  public static Collection<String[]> getTestParameters() {
+    final ArrayList<String[]> parameters = new ArrayList<String[]>();
+    parameters.add(new String[] { VBS1001 });
+    parameters.add(new String[] { VBS1002 });
+    return parameters;
+  }
+
+  public MultiterminalSaleAndCashupVerifyingDatabase(final String terminal) {
+    super(terminal, "vallblanca", "openbravo");
+  }
+
+  @Test
+  public void test() {
+    if (!getTerminal().equals(VBS1001) && !getTerminal().equals(VBS1002)) {
+      fail(String.format("This terminal ('%s') is missing its test", getTerminal()));
+    }
+
+    WebPOSSnippet.cleanCashup(this);
+    final String organizationId = BackboneHelper.getTerminalValue("organization");
+    final String clientId = BackboneHelper.getTerminalValue("client");
+    final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+    final String businessPartnerId = BackboneHelper.getTerminalValue("businessPartner");
+
+    if (getTerminal().equals(VBS1001)) {
+
+      createTicket1();
+      WebPOSDatabaseHelper.verifyOrder(documentNo1, cashupId, GROSS1);
+      WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo1, 0,
+          GROSS1, "RDNC", cashupId, null);
+      cashupVBS1001();
+      final String reconciliationId = WebPOSDatabaseHelper.retrieveReconcialiationId(cashupId);
+      WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo1, 0,
+          GROSS1, "RPPC", cashupId, reconciliationId);
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, GROSS1, 0F, NET1,
+          0, GROSS1);
+      WebPOSDatabaseHelper.verifyCashupTaxes(cashupId, new OBNumber("1.35"), 0);
+      verifyFinFinaccTransactionVBS1001(organizationId, clientId, cashupId, reconciliationId,
+          WebPOSDatabaseConstants.VBS1001_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID, GROSS1,
+          businessPartnerId, 7F);
+      verifyReconciliation(reconciliationId, 3);
+
+    } else if (getTerminal().equals(VBS1002)) {
+
+      createTicket2();
+      WebPOSDatabaseHelper.verifyOrder(documentNo2, cashupId, GROSS2);
+      WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo2, 0,
+          GROSS2, "RDNC", cashupId, null);
+      cashupVBS1002();
+      final String reconciliationId = WebPOSDatabaseHelper.retrieveReconcialiationId(cashupId);
+      WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo2, 0,
+          GROSS2, "RPPC", cashupId, reconciliationId);
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, GROSS2, 0F, NET2,
+          0, GROSS2);
+      WebPOSDatabaseHelper.verifyCashupTaxes(cashupId, new OBNumber("2.34"), 0);
+      verifyFinFinaccTransactionVBS1001(organizationId, clientId, cashupId, reconciliationId,
+          WebPOSDatabaseConstants.VBS1002_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID, GROSS2,
+          businessPartnerId, 13.70F);
+      verifyReconciliation(reconciliationId, 3);
+
+    } else {
+      fail(String.format("This terminal ('%s') is missing its test", getTerminal()));
+    }
+  }
+
+
+  private void createTicket1() {
+    // sale
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_MOUNTAINEERING);
+    tap(TestId.BUTTON_PRODUCT_MOUNTAINEERING_DESCENDERCLASSIC);
+    documentNo1 = BackboneHelper.getDocumentNo();
+    verify(TestId.LABEL_TOTALTOPAY, Format.floatToWebPOSFloat(GROSS1));
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void createTicket2() {
+    // sale
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_LIGHTINGANDELECTRONICS);
+    tap(TestId.BUTTON_PRODUCT_LIGHTINGANDELECTRONICS_TORCHMINI);
+    documentNo2 = BackboneHelper.getDocumentNo();
+    verify(TestId.LABEL_TOTALTOPAY, Format.floatToWebPOSFloat(GROSS2));
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1002() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, Format.floatToWebPOSFloat(GROSS2));
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, Format.floatToWebPOSFloat(-GROSS2));
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_10);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_2);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_1);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_050);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_020);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "0.20");
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, "0.20");
+    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_AMOUNT, Format.floatToWebPOSFloat(NET2));
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "2.34");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, Format.floatToWebPOSFloat(GROSS2));
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, Format.floatToWebPOSFloat(GROSS2));
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, Format.floatToWebPOSFloat(GROSS2));
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, Format.floatToWebPOSFloat(GROSS2));
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, Format.floatToWebPOSFloat(GROSS2));
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, Format.floatToWebPOSFloat(GROSS2));
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, "13.70");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, "13.70");
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, "0.20");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, "0.20");
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, "13.70");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, "13.70");
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1001() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, Format.floatToWebPOSFloat(GROSS1));
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "-7.80");
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_5);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_2);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "-0.80");
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, "-0.80");
+    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_AMOUNT, Format.floatToWebPOSFloat(NET1));
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "1.35");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, Format.floatToWebPOSFloat(GROSS1));
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, Format.floatToWebPOSFloat(GROSS1));
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, Format.floatToWebPOSFloat(GROSS1));
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, Format.floatToWebPOSFloat(GROSS1));
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, Format.floatToWebPOSFloat(GROSS1));
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, Format.floatToWebPOSFloat(GROSS1));
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, "7.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, "7.00");
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, "-0.80");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, "-0.80");
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, "7.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, "7.00");
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void verifyFinFinaccTransactionVBS1001(final String organizationId,
+      final String clientId, final String cashupId, final String reconciliationId,
+      final String cashbookStore, final float gross, final String businessPartnerId,
+      final float deposit) {
+    final String sql = String
+        .format(
+            "SELECT"
+                + " fin_finacc_transaction.ad_client_id,"
+                + " fin_finacc_transaction.ad_org_id,"
+                + " fin_finacc_transaction.fin_reconciliation_id,"
+                + " fin_finacc_transaction.status,"
+                + " fin_finacc_transaction.processing,"
+                + " fin_finacc_transaction.processed,"
+
+                + " fin_finacc_transaction.fin_financial_account_id,"
+                + " fin_finacc_transaction.fin_payment_id,"
+                + " fin_finacc_transaction.c_glitem_id,"
+                + " fin_finacc_transaction.paymentamt,"
+                + " fin_finacc_transaction.depositamt,"
+                + " fin_finacc_transaction.trxtype,"
+                + " fin_finacc_transaction.c_bpartner_id,"
+                + " fin_finacc_transaction.em_aprm_processed"
+                + " FROM fin_finacc_transaction"
+                + " INNER JOIN obpos_app_cashup ON fin_finacc_transaction.em_obpos_app_cashup_id = obpos_app_cashup.obpos_app_cashup_id"
+                + " WHERE obpos_app_cashup.obpos_app_cashup_id='%s'" //
+                + " ORDER BY status, trxtype, c_glitem_id", cashupId);
+
+    class FinFinaccTransactionRow {
+      protected String fin_financial_account_id;
+      protected String fin_reconciliation_id;
+      protected String fin_payment_id;
+      protected String c_glitem_id;
+      protected String status;
+      protected float paymentamt;
+      protected float depositamt;
+      protected String trxtype;
+      protected String c_bpartner_id;
+      protected String em_aprm_processed;
+    }
+
+    final ArrayList<FinFinaccTransactionRow> cashupRows = new ArrayList<FinFinaccTransactionRow>();
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        // common fields
+        assertThat(rs.getString("ad_org_id"), equalTo(organizationId));
+        assertThat(rs.getString("ad_client_id"), equalTo(clientId));
+        assertThat(rs.getString("processing"), equalTo("N"));
+        assertThat(rs.getString("processed"), equalTo("Y"));
+
+        final FinFinaccTransactionRow cur = new FinFinaccTransactionRow();
+        cur.fin_reconciliation_id = rs.getString("fin_reconciliation_id");
+        cur.fin_financial_account_id = rs.getString("fin_financial_account_id");
+        cur.fin_payment_id = rs.getString("fin_payment_id");
+        cur.c_glitem_id = rs.getString("c_glitem_id");
+        cur.status = rs.getString("status");
+        cur.paymentamt = rs.getFloat("paymentamt");
+        cur.depositamt = rs.getFloat("depositamt");
+        cur.trxtype = rs.getString("trxtype");
+        cur.c_bpartner_id = rs.getString("c_bpartner_id");
+        cur.em_aprm_processed = rs.getString("em_aprm_processed");
+        cashupRows.add(cur);
+      }
+    }.execute(sql, 4);
+
+    for (int i = 0; i < cashupRows.size(); i++) {
+      final FinFinaccTransactionRow tran = cashupRows.get(i);
+      switch (i) {
+      case 0:
+        assertThat(tran.fin_financial_account_id,
+            equalTo(WebPOSDatabaseConstants.VBS_CASHBOOK_BACKOFFICE_FIN_ACCOUNT_ID));
+        assertThat(tran.fin_reconciliation_id, is(nullValue()));
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo("2C62436C613E4C398E7B34A4DED1B726"));
+        assertThat(tran.status, equalTo("RDNC"));
+        assertThat(tran.paymentamt, equalTo(0F));
+        assertThat(tran.depositamt, equalTo(deposit));
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      case 1:
+        assertThat(tran.fin_financial_account_id, equalTo(cashbookStore));
+        assertThat(tran.fin_reconciliation_id, equalTo(reconciliationId));
+        assertThat(tran.fin_payment_id, not(nullValue()));
+        assertThat(tran.c_glitem_id, is(nullValue()));
+        assertThat(tran.status, equalTo("RPPC"));
+        assertThat(tran.paymentamt, equalTo(0F));
+        assertThat(tran.depositamt, equalTo(gross));
+        assertThat(tran.trxtype, equalTo("BPD"));
+        assertThat(tran.c_bpartner_id, equalTo(businessPartnerId));
+        assertThat(tran.em_aprm_processed, equalTo("R"));
+        break;
+      case 2:
+        assertThat(tran.fin_financial_account_id, equalTo(cashbookStore));
+        assertThat(tran.fin_reconciliation_id, equalTo(reconciliationId));
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo("1EC5D1EA070F45BEB4C8023631DC4BBE"));
+        assertThat(tran.status, equalTo("RPPC"));
+        final float difference = (deposit * 100 - gross * 100) / 100;
+        if (difference < 0) {
+          assertThat(tran.paymentamt, equalTo(Math.abs(difference)));
+          assertThat(tran.depositamt, equalTo(0F));
+        } else {
+          assertThat(tran.paymentamt, equalTo(0F));
+          assertThat(tran.depositamt, equalTo(difference));
+        }
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      case 3:
+        assertThat(tran.fin_financial_account_id, equalTo(cashbookStore));
+        assertThat(tran.fin_reconciliation_id, equalTo(reconciliationId));
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo("2C62436C613E4C398E7B34A4DED1B726"));
+        assertThat(tran.status, equalTo("RPPC"));
+        assertThat(tran.paymentamt, equalTo(deposit));
+        assertThat(tran.depositamt, equalTo(0F));
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      default:
+        fail("Not implemented");
+      }
+    }
+  }
+
+  private void verifyReconciliation(final String reconciliationId, final int transactionCount) {
+    final String sql = String
+        .format(
+            "SELECT" //
+                + " COUNT(*) AS counted" //
+                + " FROM fin_reconciliation"
+                + " INNER JOIN fin_finacc_transaction ON fin_reconciliation.fin_reconciliation_id = fin_finacc_transaction.fin_reconciliation_id"
+                + " WHERE fin_reconciliation.fin_reconciliation_id='%s'", reconciliationId);
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(transactionCount));
+      }
+    }.execute(sql, 1);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashup/SaleAndCashupVerifyingDatabaseI.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,260 @@
+/*
+ *************************************************************************
+ * 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):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.cashup;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.fail;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+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.database.WebPOSDatabaseHelper.InvoiceLinesOfDocumentno;
+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.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.Format;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+public class SaleAndCashupVerifyingDatabaseI extends WebPOSTerminalHelper {
+
+  private static final float GROSS = 109.90F;
+
+  @Test
+  public void test() {
+    // starting cashup
+    WebPOSSnippet.cleanCashup(this);
+
+    final String organizationId = BackboneHelper.getTerminalValue("organization");
+    final String clientId = BackboneHelper.getTerminalValue("client");
+    final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+    final String businessPartnerId = BackboneHelper.getTerminalValue("businessPartner");
+
+    // sale
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_BACKPACKSANDTRAVEL);
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_ALPINESKIING);
+    verify(TestId.LABEL_TOTALTOPAY, Format.floatToWebPOSFloat(GROSS));
+    final String documentNo1 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+
+    WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo1, 0,
+        GROSS, "RDNC", cashupId, null);
+
+    // final cashup
+    finalCashup();
+
+    // database verifications
+    verifyInvoice(documentNo1, GROSS);
+    final String reconciliationId = WebPOSDatabaseHelper.retrieveReconcialiationId(cashupId);
+    WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo1, 0,
+        GROSS, "RPPC", cashupId, reconciliationId);
+    WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, GROSS,
+        0F, 90.83F, 0, 109.90F);
+    WebPOSDatabaseHelper.verifyCashupTaxes(cashupId, new OBNumber("19.07"), 0);
+    verifyFinFinaccTransaction(organizationId, clientId, cashupId, reconciliationId, GROSS,
+        businessPartnerId);
+    verifyReconciliation(reconciliationId, 1);
+    verifyInvoice(documentNo1);
+  }
+
+  private void verifyReconciliation(final String reconciliationId, final int receiptCount) {
+    final String sql = String
+        .format(
+            "SELECT" //
+                + " COUNT(*) AS counted" //
+                + " FROM fin_reconciliation"
+                + " INNER JOIN fin_finacc_transaction ON fin_reconciliation.fin_reconciliation_id = fin_finacc_transaction.fin_reconciliation_id"
+                + " WHERE fin_reconciliation.fin_reconciliation_id='%s'", reconciliationId);
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(receiptCount * 2));
+      }
+    }.execute(sql, 1);
+  }
+
+  private void verifyInvoice(final String documentNo) {
+    // verify that there is no payment plan created and the invoice values are right
+    final WebPOSDatabaseHelper dbh = new WebPOSDatabaseHelper();
+    final ArrayList<InvoiceLinesOfDocumentno> ils = dbh.getInvoiceLinesOf(documentNo, 1);
+
+    final InvoiceLinesOfDocumentno row1 = ils.get(0);
+    assertThat(row1.c_order_documentno, equalTo(documentNo));
+    assertThat(row1.c_invoice_paymentcomplete, equalTo(true));
+    assertThat(row1.fin_payment_schedule_expectedamount, equalTo(GROSS));
+    assertThat(row1.fin_payment_schedule_receivedamount, equalTo(GROSS));
+    assertThat(row1.c_invoice_grandtotal, equalTo(GROSS));
+    assertThat(row1.c_invoice_totalpaid, equalTo(GROSS));
+    assertThat(row1.c_invoice_outstandingamt, equalTo(0.0F));
+    assertThat(row1.c_invoice_finalsettlement, not(nullValue()));
+    assertThat(row1.fin_payment_schedule_id, not(nullValue()));
+  }
+
+  private void verifyFinFinaccTransaction(final String organizationId, final String clientId,
+      final String cashupId, final String reconciliationId, final float gross,
+      final String businessPartnerId) {
+    final String sql = String
+        .format(
+            "SELECT"
+                + " fin_finacc_transaction.ad_client_id,"
+                + " fin_finacc_transaction.ad_org_id,"
+                + " fin_finacc_transaction.fin_reconciliation_id,"
+                + " fin_finacc_transaction.fin_financial_account_id,"
+                + " fin_finacc_transaction.status,"
+                + " fin_finacc_transaction.processing,"
+                + " fin_finacc_transaction.processed,"
+
+                + " fin_finacc_transaction.fin_payment_id,"
+                + " fin_finacc_transaction.c_glitem_id,"
+                + " fin_finacc_transaction.paymentamt,"
+                + " fin_finacc_transaction.depositamt,"
+                + " fin_finacc_transaction.trxtype,"
+                + " fin_finacc_transaction.c_bpartner_id,"
+                + " fin_finacc_transaction.em_aprm_processed"
+                + " FROM fin_finacc_transaction"
+                + " INNER JOIN obpos_app_cashup ON fin_finacc_transaction.em_obpos_app_cashup_id = obpos_app_cashup.obpos_app_cashup_id"
+                + " WHERE obpos_app_cashup.obpos_app_cashup_id='%s'" //
+                + " ORDER BY fin_finacc_transaction.depositamt DESC", cashupId);
+
+    class FinFinaccTransactionRow {
+      protected String fin_payment_id;
+      protected String c_glitem_id;
+      protected float paymentamt;
+      protected float depositamt;
+      protected String trxtype;
+      protected String c_bpartner_id;
+      protected String em_aprm_processed;
+    }
+
+    final ArrayList<FinFinaccTransactionRow> cashupRows = new ArrayList<FinFinaccTransactionRow>();
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        // common fields
+        assertThat(rs.getString("ad_org_id"), equalTo(organizationId));
+        assertThat(rs.getString("ad_client_id"), equalTo(clientId));
+        assertThat(rs.getString("fin_reconciliation_id"), equalTo(reconciliationId));
+        assertThat(rs.getString("fin_financial_account_id"),
+            equalTo(WebPOSDatabaseConstants.VBS1001_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID));
+        assertThat(rs.getString("status"), equalTo("RPPC"));
+        assertThat(rs.getString("processing"), equalTo("N"));
+        assertThat(rs.getString("processed"), equalTo("Y"));
+
+        final FinFinaccTransactionRow cur = new FinFinaccTransactionRow();
+        cur.fin_payment_id = rs.getString("fin_payment_id");
+        cur.c_glitem_id = rs.getString("c_glitem_id");
+        cur.paymentamt = rs.getFloat("paymentamt");
+        cur.depositamt = rs.getFloat("depositamt");
+        cur.trxtype = rs.getString("trxtype");
+        cur.c_bpartner_id = rs.getString("c_bpartner_id");
+        cur.em_aprm_processed = rs.getString("em_aprm_processed");
+        cashupRows.add(cur);
+      }
+    }.execute(sql, 2);
+
+    for (int i = 0; i < cashupRows.size(); i++) {
+      final FinFinaccTransactionRow tran = cashupRows.get(i);
+      switch (i) {
+      case 0:
+        assertThat(tran.fin_payment_id, not(nullValue()));
+        assertThat(tran.c_glitem_id, is(nullValue()));
+        assertThat(tran.paymentamt, equalTo(0F));
+        assertThat(tran.depositamt, equalTo(gross));
+        assertThat(tran.trxtype, equalTo("BPD"));
+        assertThat(tran.c_bpartner_id, equalTo(businessPartnerId));
+        assertThat(tran.em_aprm_processed, equalTo("R"));
+        break;
+      case 1:
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo(WebPOSDatabaseConstants.VBS_GL_CASH_DIFFERENCES_ID));
+        assertThat(tran.paymentamt, equalTo(gross));
+        assertThat(tran.depositamt, equalTo(0F));
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      default:
+        fail("Not implemented");
+      }
+    }
+  }
+
+  private void verifyInvoice(final String documentNo, final float gross) {
+    // verify that the invoice values are right and the invoice have a payment plan
+    final WebPOSDatabaseHelper dbh = new WebPOSDatabaseHelper();
+    final ArrayList<InvoiceLinesOfDocumentno> ils = dbh.getInvoiceLinesOf(documentNo, 1);
+
+    final InvoiceLinesOfDocumentno row1 = ils.get(0);
+    assertThat(row1.c_order_documentno, equalTo(documentNo));
+    assertThat(row1.c_invoice_paymentcomplete, equalTo(true));
+    assertThat(row1.fin_payment_schedule_expectedamount, equalTo(gross));
+    assertThat(row1.fin_payment_schedule_receivedamount, equalTo(gross));
+    assertThat(row1.c_invoice_grandtotal, equalTo(gross));
+    assertThat(row1.c_invoice_totalpaid, equalTo(gross));
+    assertThat(row1.c_invoice_outstandingamt, equalTo(0.0F));
+    assertThat(row1.c_invoice_finalsettlement, not(nullValue()));
+    assertThat(row1.fin_payment_schedule_id, not(nullValue()));
+  }
+
+  private void finalCashup() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_CASHUP);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // step 2 of 5
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // step 3 of 5
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASH_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // step 4 of 5
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashup/SaleAndCashupVerifyingDatabaseII.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,357 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.cashup;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.fail;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+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.database.WebPOSDatabaseHelper.InvoiceLinesOfDocumentno;
+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.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.Format;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+public class SaleAndCashupVerifyingDatabaseII extends WebPOSTerminalHelper {
+
+  private static final float NET = 6.45F;
+  private static final float GROSS = 7.80F;
+  private static String documentNo1;
+
+  @Test
+  public void test() {
+    // 1. Create a layaway in one terminal making a partial payment and the cashup
+    WebPOSSnippet.cleanCashup(this);
+    final String organizationId = BackboneHelper.getTerminalValue("organization");
+    final String clientId = BackboneHelper.getTerminalValue("client");
+    final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+    final String businessPartnerId = BackboneHelper.getTerminalValue("businessPartner");
+    createTicket1();
+    WebPOSDatabaseHelper.verifyOrder(documentNo1, cashupId, GROSS);
+
+    cashupVBS1001();
+
+    // database verifications
+    final String reconciliationId = WebPOSDatabaseHelper.retrieveReconcialiationId(cashupId);
+    WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo1, 0,
+        GROSS, "RPPC", cashupId, reconciliationId);
+    WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, GROSS, 0F, NET, 0,
+        GROSS);
+    WebPOSDatabaseHelper.verifyCashupTaxes(cashupId, new OBNumber("1.35"), 0);
+    verifyFinFinaccTransaction(organizationId, clientId, cashupId, reconciliationId, GROSS,
+        businessPartnerId);
+    verifyInvoice(documentNo1);
+  }
+
+  private void verifyInvoice(final String documentNo) {
+    // verify that there is no payment plan created and the invoice values are right
+    final WebPOSDatabaseHelper dbh = new WebPOSDatabaseHelper();
+    final ArrayList<InvoiceLinesOfDocumentno> ils = dbh.getInvoiceLinesOf(documentNo, 1);
+
+    final InvoiceLinesOfDocumentno row1 = ils.get(0);
+    assertThat(row1.c_order_documentno, equalTo(documentNo));
+    assertThat(row1.c_invoice_paymentcomplete, equalTo(true));
+    assertThat(row1.fin_payment_schedule_expectedamount, equalTo(GROSS));
+    assertThat(row1.fin_payment_schedule_receivedamount, equalTo(GROSS));
+    assertThat(row1.c_invoice_grandtotal, equalTo(GROSS));
+    assertThat(row1.c_invoice_totalpaid, equalTo(GROSS));
+    assertThat(row1.c_invoice_outstandingamt, equalTo(0.0F));
+    assertThat(row1.c_invoice_finalsettlement, not(nullValue()));
+    assertThat(row1.fin_payment_schedule_id, not(nullValue()));
+  }
+
+  private void createTicket1() {
+    // sale
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_MOUNTAINEERING);
+    tap(TestId.BUTTON_PRODUCT_MOUNTAINEERING_DESCENDERCLASSIC);
+    documentNo1 = BackboneHelper.getDocumentNo();
+    verify(TestId.LABEL_TOTALTOPAY, Format.floatToWebPOSFloat(GROSS));
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1001() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, Format.floatToWebPOSFloat(GROSS));
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "-7.80");
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_5);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_2);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "-0.80");
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, "-0.80");
+    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_AMOUNT, Format.floatToWebPOSFloat(NET));
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "1.35");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, Format.floatToWebPOSFloat(GROSS));
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, Format.floatToWebPOSFloat(GROSS));
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, Format.floatToWebPOSFloat(GROSS));
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, Format.floatToWebPOSFloat(GROSS));
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, Format.floatToWebPOSFloat(GROSS));
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, Format.floatToWebPOSFloat(GROSS));
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, "7.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, "7.00");
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, "-0.80");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, "-0.80");
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, "7.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, "7.00");
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void verifyFinFinaccTransaction(final String organizationId, final String clientId,
+      final String cashupId, final String reconciliationId, final float gross,
+      final String businessPartnerId) {
+    final String sql = String
+        .format(
+            "SELECT"
+                + " fin_finacc_transaction.ad_client_id,"
+                + " fin_finacc_transaction.ad_org_id,"
+                + " fin_finacc_transaction.fin_reconciliation_id,"
+                + " fin_finacc_transaction.status,"
+                + " fin_finacc_transaction.processing,"
+                + " fin_finacc_transaction.processed,"
+
+                + " fin_finacc_transaction.fin_financial_account_id,"
+                + " fin_finacc_transaction.fin_payment_id,"
+                + " fin_finacc_transaction.c_glitem_id,"
+                + " fin_finacc_transaction.paymentamt,"
+                + " fin_finacc_transaction.depositamt,"
+                + " fin_finacc_transaction.trxtype,"
+                + " fin_finacc_transaction.c_bpartner_id,"
+                + " fin_finacc_transaction.em_aprm_processed"
+                + " FROM fin_finacc_transaction"
+                + " INNER JOIN obpos_app_cashup ON fin_finacc_transaction.em_obpos_app_cashup_id = obpos_app_cashup.obpos_app_cashup_id"
+                + " WHERE obpos_app_cashup.obpos_app_cashup_id='%s'" //
+                + " ORDER BY fin_finacc_transaction.paymentamt + fin_finacc_transaction.depositamt DESC, fin_finacc_transaction.paymentamt",
+            cashupId);
+
+    class FinFinaccTransactionRow {
+      protected String fin_financial_account_id;
+      protected String fin_reconciliation_id;
+      protected String fin_payment_id;
+      protected String c_glitem_id;
+      protected String status;
+      protected float paymentamt;
+      protected float depositamt;
+      protected String trxtype;
+      protected String c_bpartner_id;
+      protected String em_aprm_processed;
+    }
+
+    final ArrayList<FinFinaccTransactionRow> cashupRows = new ArrayList<FinFinaccTransactionRow>();
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        // common fields
+        assertThat(rs.getString("ad_org_id"), equalTo(organizationId));
+        assertThat(rs.getString("ad_client_id"), equalTo(clientId));
+        assertThat(rs.getString("processing"), equalTo("N"));
+        assertThat(rs.getString("processed"), equalTo("Y"));
+
+        final FinFinaccTransactionRow cur = new FinFinaccTransactionRow();
+        cur.fin_reconciliation_id = rs.getString("fin_reconciliation_id");
+        cur.fin_financial_account_id = rs.getString("fin_financial_account_id");
+        cur.fin_payment_id = rs.getString("fin_payment_id");
+        cur.c_glitem_id = rs.getString("c_glitem_id");
+        cur.status = rs.getString("status");
+        cur.paymentamt = rs.getFloat("paymentamt");
+        cur.depositamt = rs.getFloat("depositamt");
+        cur.trxtype = rs.getString("trxtype");
+        cur.c_bpartner_id = rs.getString("c_bpartner_id");
+        cur.em_aprm_processed = rs.getString("em_aprm_processed");
+        cashupRows.add(cur);
+      }
+    }.execute(sql, 4);
+
+    for (int i = 0; i < cashupRows.size(); i++) {
+      final FinFinaccTransactionRow tran = cashupRows.get(i);
+      switch (i) {
+      case 0:
+        assertThat(tran.fin_financial_account_id,
+            equalTo(WebPOSDatabaseConstants.VBS1001_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID));
+        assertThat(tran.fin_reconciliation_id, equalTo(reconciliationId));
+        assertThat(tran.fin_payment_id, not(nullValue()));
+        assertThat(tran.c_glitem_id, is(nullValue()));
+        assertThat(tran.status, equalTo("RPPC"));
+        assertThat(tran.paymentamt, equalTo(0F));
+        assertThat(tran.depositamt, equalTo(gross));
+        assertThat(tran.trxtype, equalTo("BPD"));
+        assertThat(tran.c_bpartner_id, equalTo(businessPartnerId));
+        assertThat(tran.em_aprm_processed, equalTo("R"));
+        break;
+      case 1:
+        assertThat(tran.fin_financial_account_id,
+            equalTo(WebPOSDatabaseConstants.VBS_CASHBOOK_BACKOFFICE_FIN_ACCOUNT_ID));
+        assertThat(tran.fin_reconciliation_id, is(nullValue()));
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo("2C62436C613E4C398E7B34A4DED1B726"));
+        assertThat(tran.status, equalTo("RDNC"));
+        assertThat(tran.paymentamt, equalTo(0F));
+        assertThat(tran.depositamt, equalTo(7F));
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      case 2:
+        assertThat(tran.fin_financial_account_id,
+            equalTo(WebPOSDatabaseConstants.VBS1001_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID));
+        assertThat(tran.fin_reconciliation_id, equalTo(reconciliationId));
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo("2C62436C613E4C398E7B34A4DED1B726"));
+        assertThat(tran.status, equalTo("RPPC"));
+        assertThat(tran.paymentamt, equalTo(7F));
+        assertThat(tran.depositamt, equalTo(0F));
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      case 3:
+        assertThat(tran.fin_financial_account_id,
+            equalTo(WebPOSDatabaseConstants.VBS1001_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID));
+        assertThat(tran.fin_reconciliation_id, equalTo(reconciliationId));
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo("1EC5D1EA070F45BEB4C8023631DC4BBE"));
+        assertThat(tran.status, equalTo("RPPC"));
+        assertThat(tran.paymentamt, equalTo(0.8F));
+        assertThat(tran.depositamt, equalTo(0F));
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      default:
+        fail("Not implemented");
+      }
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashup/SalesCashupReturnCashupVerifyingDatabase.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,367 @@
+/*
+ *************************************************************************
+ * 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):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.cashup;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.fail;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.TestAnnotations;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+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.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.Format;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+public class SalesCashupReturnCashupVerifyingDatabase extends WebPOSTerminalHelper {
+
+  private static final float GROSS1 = 28.60F;
+  private static final float GROSS2 = 261.81F;
+  private static final float TOTALNET = 240.01F;
+  private static final float TOTALNETRETURNS = 216.37F;
+  private static final float TOTALTAXES = 50.40F;
+  private static final float TOTALTAXESRETURNS = 45.44F;
+
+  @Test
+  @TestAnnotations(waitFixOf = 28983)
+  public void test() {
+    // starting cashup
+    WebPOSSnippet.cleanCashup(this);
+
+    final String organizationId = BackboneHelper.getTerminalValue("organization");
+    final String clientId = BackboneHelper.getTerminalValue("client");
+    final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+    final String businessPartnerId = BackboneHelper.getTerminalValue("businessPartner");
+
+    // sale
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_BACKPACKSANDTRAVEL);
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_ADHESIVEBODYWARNMERS);
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_SUNCREAMLIPSTICK);
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_SUNCREAMLIPSTICK);
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_SUNCREAMLIPSTICK);
+    verify(TestId.LABEL_TOTALTOPAY, Format.floatToWebPOSFloat(GROSS1));
+    final String documentNo1 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+
+    // sale
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_LIGHTINGANDELECTRONICS);
+    tap(TestId.BUTTON_PRODUCT_LIGHTINGANDELECTRONICS_GPSHANDHELD);
+    verify(TestId.LABEL_TOTALTOPAY, Format.floatToWebPOSFloat(GROSS2));
+    final String documentNo2 = BackboneHelper.getDocumentNo();
+    final String customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+
+    // return the sale
+    tap(TestId.BUTTON_MENU);
+    verify(TestId.LABEL_MENU_VERIFIEDRETURN, "Verified Returns");
+    tap(TestId.BUTTON_MENU_VERIFIEDRETURN);
+    verify(TestId.LABEL_VERIFIEDRETURNS_TITLE, "Receipts");
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo2);
+    tap(TestId.BUTTON_VERIFIEDRETURNS_SEARCH);
+    verify(TestId.LABEL_VERIFIEDRETURNS_ROW1_TITLE, String.format("%s - %s", documentNo2, customer));
+    tap(TestId.BUTTON_VERIFIEDRETURNS_ROW1);
+    verify(TestId.LABEL_POPUP_DOCUMENTNO, documentNo2);
+    tap(TestId.BUTTON_POPUP_CHECKALL);
+    verify(TestId.BUTTON_POPUP_APPLY, "Apply");
+    tap(TestId.BUTTON_POPUP_APPLY);
+    verify(TestId.LABEL_TOTALTOPAY, Format.floatToWebPOSFloat(-GROSS2));
+    final String documentNo3 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+
+    // TODO: from here, it fails because there seems to be an issue with invoiced returns
+    WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo1, 0,
+        GROSS1, "RDNC", cashupId, null);
+    WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo2, 0,
+        GROSS2, "RDNC", cashupId, null);
+    WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo3, GROSS2,
+        0, "RDNC", cashupId, null);
+
+    // final cashup
+    finalCashup();
+
+    final String reconciliationId = retrieveReconcialiationId(cashupId);
+    verifyReconciliation(reconciliationId, 4);
+    WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo1, 0,
+        GROSS1, "RPPC", cashupId, reconciliationId);
+    WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo2, 0,
+        GROSS2, "RPPC", cashupId, reconciliationId);
+    WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo3, GROSS2,
+        0, "RPPC", cashupId, reconciliationId);
+
+    WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, GROSS1, 0F, 90.83F,
+        0, 109.90F);
+    WebPOSDatabaseHelper.verifyCashupTaxes(cashupId, new OBNumber(TOTALTAXES), 0);
+    WebPOSDatabaseHelper.verifyCashupTaxes(cashupId, new OBNumber(TOTALTAXESRETURNS), 1);
+    verifyFinFinaccTransaction(organizationId, clientId, cashupId, reconciliationId, GROSS1,
+        businessPartnerId);
+    verifyInvoice(documentNo1, 0F, 0F);
+    verifyInvoiceLines(reconciliationId);
+  }
+
+  private void verifyReconciliation(final String reconciliationId, final int totalTransactions) {
+    final String sql = String
+        .format(
+            "SELECT" //
+                + " COUNT(*) AS counted" //
+                + " FROM fin_reconciliation"
+                + " INNER JOIN fin_finacc_transaction ON fin_reconciliation.fin_reconciliation_id = fin_finacc_transaction.fin_reconciliation_id"
+                + " WHERE fin_reconciliation.fin_reconciliation_id='%s'", reconciliationId);
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(totalTransactions));
+      }
+    }.execute(sql, 1);
+  }
+
+  /**
+   * @return the invoiceNo
+   */
+  private String verifyInvoice(final String documentNo, final float net, final float gross) {
+    final String sql = String.format(" SELECT" //
+        + " c_invoice.documentno,"//
+        + " c_invoice.totallines," //
+        + " c_invoice.grandtotal," //
+        + " c_invoice.totalpaid," //
+        + " c_invoice.outstandingamt" //
+        + " FROM c_invoice" //
+        + " INNER JOIN c_order ON c_invoice.c_order_id = c_order.c_order_id" // s
+        + " WHERE c_order.documentno = '%s'", documentNo);
+    final ArrayList<String> retrieveValue = new ArrayList<String>();
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        retrieveValue.add(rs.getString("documentno"));
+        assertThat(rs.getFloat("totallines"), equalTo(net));
+        assertThat(rs.getFloat("grandtotal"), equalTo(gross));
+        assertThat(rs.getFloat("totalpaid"), equalTo(gross));
+        assertThat(rs.getFloat("outstandingamt"), equalTo(0F));
+      }
+    }.execute(sql, 1);
+
+    return retrieveValue.get(0);
+  }
+
+  private void verifyInvoiceLines(final String invoiceNo) {
+    final String sql = String.format(" SELECT" //
+        + " m_product.name," //
+        + " c_invoiceline.linenetamt," //
+        + " c_invoiceline.taxamt," //
+        + " c_invoiceline.line_gross_amount," //
+        + " c_invoiceline.qtyinvoiced," //
+        + " c_invoiceline.priceactual," //
+        + " c_invoiceline.gross_unit_price" //
+        + " FROM c_invoiceline" //
+        + " INNER JOIN c_invoice ON c_invoiceline.c_invoice_id = c_invoice.c_invoice_id" //
+        + " INNER JOIN c_orderline ON c_invoiceline.c_orderline_id = c_orderline.c_orderline_id" //
+        + " INNER JOIN c_order ON c_orderline.c_order_id = c_order.c_order_id" //
+        + " INNER JOIN m_product ON c_orderline.m_product_id = m_product.m_product_id" //
+        + " WHERE c_invoice.documentno = '%s'" //
+        + " ORDER BY c_invoiceline.created DESC", invoiceNo);
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+
+      }
+    }.execute(sql, 0);
+  }
+
+  private void verifyFinFinaccTransaction(final String organizationId, final String clientId,
+      final String cashupId, final String reconciliationId, final float gross,
+      final String businessPartnerId) {
+    final String sql = String
+        .format(
+            "SELECT"
+                + " fin_finacc_transaction.ad_client_id,"
+                + " fin_finacc_transaction.ad_org_id,"
+                + " fin_finacc_transaction.fin_reconciliation_id,"
+                + " fin_finacc_transaction.fin_financial_account_id,"
+                + " fin_finacc_transaction.status,"
+                + " fin_finacc_transaction.processing,"
+                + " fin_finacc_transaction.processed,"
+
+                + " fin_finacc_transaction.fin_payment_id,"
+                + " fin_finacc_transaction.c_glitem_id,"
+                + " fin_finacc_transaction.paymentamt,"
+                + " fin_finacc_transaction.depositamt,"
+                + " fin_finacc_transaction.trxtype,"
+                + " fin_finacc_transaction.c_bpartner_id,"
+                + " fin_finacc_transaction.em_aprm_processed"
+                + " FROM fin_finacc_transaction"
+                + " INNER JOIN obpos_app_cashup ON fin_finacc_transaction.em_obpos_app_cashup_id = obpos_app_cashup.obpos_app_cashup_id"
+                + " WHERE obpos_app_cashup.obpos_app_cashup_id='%s'"
+                + " ORDER BY obpos_app_cashup.updated DESC", cashupId);
+
+    class FinFinaccTransactionRow {
+      protected String fin_payment_id;
+      protected String c_glitem_id;
+      protected float paymentamt;
+      protected float depositamt;
+      protected String trxtype;
+      protected String c_bpartner_id;
+      protected String em_aprm_processed;
+    }
+
+    final ArrayList<FinFinaccTransactionRow> cashupRows = new ArrayList<FinFinaccTransactionRow>();
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        // common fields
+        assertThat(rs.getString("ad_org_id"), equalTo(organizationId));
+        assertThat(rs.getString("ad_client_id"), equalTo(clientId));
+        assertThat(rs.getString("fin_reconciliation_id"), equalTo(reconciliationId));
+        assertThat(rs.getString("fin_financial_account_id"),
+            equalTo("F37A1534BB6C4BB9AC8564B7850792D4"));
+        assertThat(rs.getString("status"), equalTo("RPPC"));
+        assertThat(rs.getString("processing"), equalTo("N"));
+        assertThat(rs.getString("processed"), equalTo("Y"));
+
+        final FinFinaccTransactionRow cur = new FinFinaccTransactionRow();
+        cur.fin_payment_id = rs.getString("fin_payment_id");
+        cur.c_glitem_id = rs.getString("c_glitem_id");
+        cur.paymentamt = rs.getFloat("paymentamt");
+        cur.depositamt = rs.getFloat("depositamt");
+        cur.trxtype = rs.getString("trxtype");
+        cur.c_bpartner_id = rs.getString("c_bpartner_id");
+        cur.em_aprm_processed = rs.getString("em_aprm_processed");
+        cashupRows.add(cur);
+      }
+    }.execute(sql, 2);
+
+    for (int i = 0; i < cashupRows.size(); i++) {
+      final FinFinaccTransactionRow tran = cashupRows.get(i);
+      switch (i) {
+      case 0:
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo("1EC5D1EA070F45BEB4C8023631DC4BBE"));
+        assertThat(tran.paymentamt, equalTo(gross));
+        assertThat(tran.depositamt, equalTo(0F));
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      case 1:
+        // assertThat(tran.fin_payment_id, unknown value
+        assertThat(tran.c_glitem_id, is(nullValue()));
+        assertThat(tran.paymentamt, equalTo(0F));
+        assertThat(tran.depositamt, equalTo(gross));
+        assertThat(tran.trxtype, equalTo("BPD"));
+        assertThat(tran.c_bpartner_id, equalTo(businessPartnerId));
+        assertThat(tran.em_aprm_processed, equalTo("R"));
+        break;
+      default:
+        fail("Not implemented");
+      }
+    }
+  }
+
+  private String retrieveReconcialiationId(final String cashupId) {
+    final String sql = String
+        .format(
+            "SELECT"
+                + " fin_finacc_transaction.fin_reconciliation_id"
+                + " FROM fin_finacc_transaction"
+                + " INNER JOIN obpos_app_cashup ON fin_finacc_transaction.em_obpos_app_cashup_id = obpos_app_cashup.obpos_app_cashup_id"
+                + " WHERE obpos_app_cashup.obpos_app_cashup_id='%s'"
+                + " GROUP BY fin_finacc_transaction.fin_reconciliation_id", cashupId);
+
+    final ArrayList<String> extractedValues = new ArrayList<String>();
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        extractedValues.add(rs.getString("fin_reconciliation_id"));
+      }
+    }.execute(sql, 1);
+    final String reconciliationId = extractedValues.get(0);
+    return reconciliationId;
+  }
+
+  private void finalCashup() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_CASHUP);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // step 2 of 5
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // step 3 of 5
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASH_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // step 4 of 5
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    verify(TestId.LABEL_CASHUP_NETSALES_AMOUNT, Format.floatToWebPOSFloat(TOTALNET));
+    // verify(TestId.LABEL_CASHUP_NETSALES_TAX21, Format.floatToWebPOSFloat(TOTALTAXES));
+    verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, Format.floatToWebPOSFloat(TOTALTAXES));
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, Format.floatToWebPOSFloat(GROSS1 + GROSS2));
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, Format.floatToWebPOSFloat(TOTALNETRETURNS));
+    verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, Format.floatToWebPOSFloat(TOTALTAXESRETURNS));
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, Format.floatToWebPOSFloat(GROSS2));
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, Format.floatToWebPOSFloat(GROSS1));
+
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, Format.floatToWebPOSFloat(GROSS2));
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, Format.floatToWebPOSFloat(GROSS1 + GROSS2));
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, Format.floatToWebPOSFloat(GROSS1));
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, Format.floatToWebPOSFloat(GROSS1));
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, Format.floatToWebPOSFloat(GROSS1));
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/LayawayNotListedWhenFinished.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,90 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+import org.junit.Test;
+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.utils.Constants;
+import org.openbravo.test.mobile.common.selenium.utils.Utils;
+
+public class LayawayNotListedWhenFinished extends WebPOSTerminalHelper {
+
+  private static String documentNo1;
+  private static String customer;
+
+  @Test
+  public void test() {
+    createLayaway();
+    retrieveLayawayAndPay();
+
+    // verify that is no longer listed
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    Utils.pause(Constants.WAIT_FORDATABASESYNCHRONIZATION);
+    final boolean isListed = (Boolean) TestId.TABLE_RECEIPTSEARCH.enyoNode()
+        .executeExtensionWithReturn(
+            String.format(".getLineByValue('topLine', '%s - %s') !== undefined", documentNo1,
+                customer));
+    assertThat(isListed, equalTo(false));
+    tap(TestId.BUTTON_LAYAWAYS_CANCEL);
+  }
+
+  private void createLayaway() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+    verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_MOUNTAINEERING);
+    tap(TestId.BUTTON_PRODUCT_MOUNTAINEERING_DESCENDERCLASSIC);
+    documentNo1 = BackboneHelper.getDocumentNo();
+    customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    verify(TestId.LABEL_TOTALTOPAY, "7.80");
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void retrieveLayawayAndPay() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    // SeleniumHelper.executeScriptWithReturn(TestRegistry.registry().enyoObject.getLineByValue('topLine',
+    // String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    isDisabled(TestId.BUTTON_PAY, false);
+    verify(TestId.LABEL_TOTALTOPAY, "7.80");
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/LayawayRetrieval.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,70 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import org.junit.Test;
+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;
+
+public class LayawayRetrieval extends WebPOSTerminalHelper {
+
+  @Test
+  public void test() {
+    // create the layaway
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+    verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_BACKPACKSANDTRAVEL);
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_ALPINESKIING);
+    final String receiptNo = BackboneHelper.getDocumentNo();
+    final String customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    verify(TestId.LABEL_TOTALTOPAY, "109.90");
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+
+    // partial pay
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, receiptNo);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", receiptNo, customer));
+    // verifications
+    verify(TestId.LABEL_RECEIPT_TYPE, "Layaway");
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    verify(TestId.LABEL_TOTALTOPAY, "109.90");
+    tap(TestId.BUTTON_CARD);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, "109.90€");
+    tap(TestId.BUTTON_CASH);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, "109.90€");
+    tap(TestId.BUTTON_CASHUSA);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, "$144.45");
+    tap(TestId.BUTTON_VOUCHER);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, "109.90€");
+    isDisabled(TestId.BUTTON_LAYAWAY, false);
+    tap(TestId.BUTTON_LAYAWAY);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/LayawayRetrievalWithinOrganization.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,96 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+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;
+
+@RunWith(Parameterized.class)
+public class LayawayRetrievalWithinOrganization extends WebPOSTerminalHelper {
+
+  private static final String VBS1001 = "VBS1001";
+  private static final String VBS1002 = "VBS1002";
+  private static String receiptNo;
+  private static String customer;
+
+  @Parameters(name = "({index}) terminal: {0}")
+  public static Collection<String[]> getTestParameters() {
+    final ArrayList<String[]> parameters = new ArrayList<String[]>();
+    parameters.add(new String[] { VBS1001 });
+    parameters.add(new String[] { VBS1002 });
+    return parameters;
+  }
+
+  public LayawayRetrievalWithinOrganization(final String terminal) {
+    super(terminal, "vallblanca", "openbravo");
+  }
+
+  @Test
+  public void test() {
+    if (getTerminal().equals(VBS1001)) {
+
+      // create the layaway
+      tap(TestId.BUTTON_MENU);
+      tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+      verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
+      tap(TestId.BUTTON_BROWSE);
+      tap(TestId.BUTTON_CATEGORY_BACKPACKSANDTRAVEL);
+      tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_ALPINESKIING);
+      receiptNo = BackboneHelper.getDocumentNo();
+      customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+      verify(TestId.LABEL_TOTALTOPAY, "109.90");
+      tap(TestId.BUTTON_PAY);
+      tap(TestId.BUTTON_LAYAWAY);
+      verify(TestId.LABEL_TOTALTOPAY, "0.00");
+
+    } else if (getTerminal().equals(VBS1002)) {
+
+      // retrieve the VBS1001 layaway in this terminal
+      tap(TestId.BUTTON_MENU);
+      tap(TestId.BUTTON_MENU_LAYAWAYS);
+      write(TestId.FIELD_SEARCH_RECEIPT, receiptNo);
+      tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+      tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", receiptNo, customer));
+      verify(TestId.LABEL_TOTALTOPAY, "109.90");
+
+      verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+      isDisabled(TestId.BUTTON_PAY, false);
+
+      tap(TestId.BUTTON_DELETERECEIPT);
+
+    } else {
+      fail("The terminal is missing its test");
+    }
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/LayawayVerifyPaymentsInformation.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,92 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import org.junit.Test;
+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;
+
+public class LayawayVerifyPaymentsInformation extends WebPOSTerminalHelper {
+
+  @Test
+  public void test() {
+    // create the layaway with a initial partial pay
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+    verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_BACKPACKSANDTRAVEL);
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_ALPINESKIING);
+    final String receiptNo = BackboneHelper.getDocumentNo();
+    final String customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    verify(TestId.LABEL_TOTALTOPAY, "109.90");
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_KEYPAD_1);
+    tap(TestId.BUTTON_KEYPAD_2);
+    tap(TestId.BUTTON_CARD);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, "97.90€");
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+
+    // retrieve the layaway and do other payments
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, receiptNo);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", receiptNo, customer));
+    // verifications
+    verify(TestId.LABEL_RECEIPT_TYPE, "Layaway");
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    verify(TestId.LABEL_TOTALTOPAY, "109.90");
+    tap(TestId.BUTTON_PAY);
+
+    tap(TestId.BUTTON_KEYPAD_1);
+    tap(TestId.BUTTON_KEYPAD_3);
+    tap(TestId.BUTTON_CASH);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, "84.90€");
+
+    tap(TestId.BUTTON_KEYPAD_1);
+    tap(TestId.BUTTON_KEYPAD_4);
+    tap(TestId.BUTTON_CASHUSA);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, "74.25€");
+
+    tap(TestId.BUTTON_KEYPAD_1);
+    tap(TestId.BUTTON_KEYPAD_5);
+    tap(TestId.BUTTON_VOUCHER);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, "59.25€");
+
+    verify(TestId.LABEL_RECEIPT_PAYMENT_ROW1_NAME, "Card");
+    verify(TestId.LABEL_RECEIPT_PAYMENT_ROW2_NAME, "Cash");
+    verify(TestId.LABEL_RECEIPT_PAYMENT_ROW3_NAME, "USA Cash");
+    verify(TestId.LABEL_RECEIPT_PAYMENT_ROW4_NAME, "Voucher");
+    verify(TestId.LABEL_RECEIPT_PAYMENT_ROW1_AMOUNT, "12.00");
+    verify(TestId.LABEL_RECEIPT_PAYMENT_ROW2_AMOUNT, "13.00");
+    verify(TestId.LABEL_RECEIPT_PAYMENT_ROW3_AMOUNT, "10.65");
+    verify(TestId.LABEL_RECEIPT_PAYMENT_ROW4_AMOUNT, "15.00");
+
+    isDisabled(TestId.BUTTON_LAYAWAY, false);
+    tap(TestId.BUTTON_LAYAWAY);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Fin1.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,398 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.common.selenium.database.FinFinaccTransactionRow;
+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.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+/**
+ * Create a layaway, retrieve and finish it in terminal 1001
+ */
+public class Layaway_Cre1Fin1 extends WebPOSTerminalHelper {
+
+  private static final OBNumber NET = new OBNumber("6.45");
+  private static final OBNumber GROSS = new OBNumber("7.80");
+  private static String documentNo1;
+  private static String documentNo2;
+  private static String customer;
+
+
+  @Test
+  public void test() {
+    WebPOSSnippet.cleanCashup(this);
+
+    // 1. Create a layaway in one terminal and cashup
+    createLayaway();
+    final String organizationId = BackboneHelper.getTerminalValue("organization");
+    final String clientId = BackboneHelper.getTerminalValue("client");
+    final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+    WebPOSDatabaseHelper.verifyOrder(documentNo1, cashupId, GROSS);
+    verifyThereIsNoTransaction(organizationId, clientId, cashupId, documentNo1);
+
+    verifyCashup();
+
+    // 2. Retrieve the layaway and finish it
+    retrieveLayawayAndPay();
+    final String businessPartnerId = BackboneHelper.getTerminalValue("businessPartner");
+    WebPOSDatabaseHelper.verifyOrder(documentNo2, cashupId, GROSS);
+    WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo2,
+        OBNumber.ZERO, GROSS, "RDNC", cashupId, null);
+
+    cashup();
+
+    final String reconciliationId = WebPOSDatabaseHelper.retrieveReconcialiationId(cashupId);
+    WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo2,
+        OBNumber.ZERO, GROSS, "RPPC", cashupId, reconciliationId);
+    WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, GROSS,
+        OBNumber.ZERO, NET, OBNumber.ZERO, GROSS);
+
+    final ArrayList<FinFinaccTransactionRow> cashupTransactions = WebPOSDatabaseHelper
+        .getCashupTransactions(cashupId,
+            WebPOSDatabaseConstants.VBS1001_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID, businessPartnerId,
+            GROSS, new OBNumber(7), 4);
+    assertThat(cashupTransactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+    assertThat(cashupTransactions.get(0).depositamt, equalTo(GROSS));
+
+    verifyReconciliation(reconciliationId, 3);
+
+  }
+
+  private void verifyThereIsNoTransaction(final String organizationId, final String clientId,
+      final String cashupId, final String documentNo) {
+    final String c_order = String
+        .format(
+            "SELECT"
+                + " COUNT(*) AS counted"
+                + " FROM c_order"
+                + " INNER JOIN fin_payment_schedule ON c_order.c_order_id = fin_payment_schedule.c_order_id"
+                + " INNER JOIN fin_payment_scheduledetail ON fin_payment_schedule.fin_payment_schedule_id = fin_payment_scheduledetail.fin_payment_schedule_order"
+                + " INNER JOIN fin_payment_detail ON fin_payment_scheduledetail.fin_payment_detail_id = fin_payment_detail.fin_payment_detail_id"
+                + " INNER JOIN fin_payment ON fin_payment_detail.fin_payment_id = fin_payment.fin_payment_id"
+                + " INNER JOIN fin_finacc_transaction ON fin_payment.fin_payment_id = fin_finacc_transaction.fin_payment_id"
+                + " WHERE c_order.documentno='%s'", documentNo);
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(0));
+      }
+    }.execute(c_order, 1);
+  }
+
+
+  private void createLayaway() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+    verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_MOUNTAINEERING);
+    tap(TestId.BUTTON_PRODUCT_MOUNTAINEERING_DESCENDERCLASSIC);
+    documentNo1 = BackboneHelper.getDocumentNo();
+    customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    verify(TestId.LABEL_TOTALTOPAY, "7.80");
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void retrieveLayawayAndPay() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    isDisabled(TestId.BUTTON_PAY, false);
+    verify(TestId.LABEL_TOTALTOPAY, "7.80");
+    documentNo2 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void verifyCashup() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "0.00");
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, "0.00");
+    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_AMOUNT, "6.45");
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "1.35");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, "7.80");
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, "7.80");
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, "0.00");
+
+    tap(TestId.BUTTON_CASHUP_CANCEL);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void 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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, "7.80");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "-7.80");
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_5);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_2);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "-0.80");
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, "-0.80");
+    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_AMOUNT, NET);
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "1.35");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, GROSS);
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, GROSS);
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, GROSS);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, GROSS);
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, GROSS);
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, GROSS);
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, "7.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, "7.00");
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, "-0.80");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, "-0.80");
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, "7.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, "7.00");
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void verifyReconciliation(final String reconciliationId, final int transactionCount) {
+    final String sql = String
+        .format(
+            "SELECT" //
+                + " COUNT(*) AS counted" //
+                + " FROM fin_reconciliation"
+                + " INNER JOIN fin_finacc_transaction ON fin_reconciliation.fin_reconciliation_id = fin_finacc_transaction.fin_reconciliation_id"
+                + " WHERE fin_reconciliation.fin_reconciliation_id='%s'", reconciliationId);
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(transactionCount));
+      }
+    }.execute(sql, 1);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Fin2.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,435 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.fail;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.common.selenium.database.FinFinaccTransactionRow;
+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.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+/**
+ * Create a layaway in terminal 1001 with no initial amount and complete the payment in the terminal
+ * 1002
+ */
+@RunWith(Parameterized.class)
+public class Layaway_Cre1Fin2 extends WebPOSTerminalHelper {
+
+  private static final String VBS1001 = "VBS1001";
+  private static final String VBS1002 = "VBS1002";
+  private static final OBNumber NET = new OBNumber("6.45");
+  private static final OBNumber GROSS = new OBNumber("7.80");
+  private static String documentNo1;
+  private static String documentNo2;
+  private static String customer;
+
+  @Parameters(name = "({index}) terminal: {0}")
+  public static Collection<String[]> getTestParameters() {
+    final ArrayList<String[]> parameters = new ArrayList<String[]>();
+    parameters.add(new String[] { VBS1001 });
+    parameters.add(new String[] { VBS1002 });
+    return parameters;
+  }
+
+  public Layaway_Cre1Fin2(final String terminal) {
+    super(terminal, "vallblanca", "openbravo");
+  }
+
+  @Test
+  public void test() {
+    WebPOSSnippet.cleanCashup(this);
+
+    if (getTerminal().equals(VBS1001)) {
+
+      // 1. Create a layaway in one terminal and cashup
+      createLayaway();
+      final String organizationId = BackboneHelper.getTerminalValue("organization");
+      final String clientId = BackboneHelper.getTerminalValue("client");
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+      WebPOSDatabaseHelper.verifyOrder(documentNo1, cashupId, GROSS);
+      verifyThereIsNoTransaction(organizationId, clientId, cashupId, documentNo1);
+
+      cashupVBS1001();
+
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, GROSS,
+          OBNumber.ZERO, NET, OBNumber.ZERO, GROSS);
+      WebPOSDatabaseHelper.verifyCashupTaxes(cashupId, new OBNumber("1.35"), 0);
+
+    } else if (getTerminal().equals(VBS1002)) {
+
+      // 2. Retrieve the layaway in another terminal finishing the layaway and cashup
+      retrieveLayawayAndPay();
+      final String organizationId = BackboneHelper.getTerminalValue("organization");
+      final String clientId = BackboneHelper.getTerminalValue("client");
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+      final String businessPartnerId = BackboneHelper.getTerminalValue("businessPartner");
+      WebPOSDatabaseHelper.verifyOrder(documentNo2, cashupId, GROSS);
+      WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo2,
+          OBNumber.ZERO, GROSS, "RDNC", cashupId, null);
+
+      cashupVBS1002();
+
+      final String reconciliationId = WebPOSDatabaseHelper.retrieveReconcialiationId(cashupId);
+      WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo2,
+          OBNumber.ZERO, GROSS, "RPPC", cashupId, reconciliationId);
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, OBNumber.ZERO,
+          OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO);
+
+      final ArrayList<FinFinaccTransactionRow> cashupTransactions = WebPOSDatabaseHelper
+          .getCashupTransactions(cashupId,
+              WebPOSDatabaseConstants.VBS1002_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID,
+              businessPartnerId, GROSS, new OBNumber(7), 4);
+      assertThat(cashupTransactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(cashupTransactions.get(0).depositamt, equalTo(GROSS));
+
+      verifyReconciliation(reconciliationId, 3);
+
+    } else {
+      fail(String.format("This terminal ('%s') is missing its test", getTerminal()));
+    }
+  }
+
+  private void verifyThereIsNoTransaction(final String organizationId, final String clientId,
+      final String cashupId, final String documentNo) {
+    final String c_order = String
+        .format(
+            "SELECT"
+                + " COUNT(*) AS counted"
+                + " FROM c_order"
+                + " INNER JOIN fin_payment_schedule ON c_order.c_order_id = fin_payment_schedule.c_order_id"
+                + " INNER JOIN fin_payment_scheduledetail ON fin_payment_schedule.fin_payment_schedule_id = fin_payment_scheduledetail.fin_payment_schedule_order"
+                + " INNER JOIN fin_payment_detail ON fin_payment_scheduledetail.fin_payment_detail_id = fin_payment_detail.fin_payment_detail_id"
+                + " INNER JOIN fin_payment ON fin_payment_detail.fin_payment_id = fin_payment.fin_payment_id"
+                + " INNER JOIN fin_finacc_transaction ON fin_payment.fin_payment_id = fin_finacc_transaction.fin_payment_id"
+                + " WHERE c_order.documentno='%s'", documentNo);
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(0));
+      }
+    }.execute(c_order, 1);
+  }
+
+  private void createLayaway() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+    verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_MOUNTAINEERING);
+    tap(TestId.BUTTON_PRODUCT_MOUNTAINEERING_DESCENDERCLASSIC);
+    documentNo1 = BackboneHelper.getDocumentNo();
+    customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    verify(TestId.LABEL_TOTALTOPAY, "7.80");
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void retrieveLayawayAndPay() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    isDisabled(TestId.BUTTON_PAY, false);
+    verify(TestId.LABEL_TOTALTOPAY, "7.80");
+    documentNo2 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1001() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "0.00");
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, "0.00");
+    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_AMOUNT, "6.45");
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "1.35");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, "7.80");
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, "7.80");
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, "0.00");
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1002() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, "7.80");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "-7.80");
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_5);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_2);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "-0.80");
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, "-0.80");
+    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_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, "0.00");
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, "7.80");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, "7.80");
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, "7.80");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, "7.80");
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, "7.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, "7.00");
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, "-0.80");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, "-0.80");
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, "7.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, "7.00");
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void verifyReconciliation(final String reconciliationId, final int transactionCount) {
+    final String sql = String
+        .format(
+            "SELECT" //
+                + " COUNT(*) AS counted" //
+                + " FROM fin_reconciliation"
+                + " INNER JOIN fin_finacc_transaction ON fin_reconciliation.fin_reconciliation_id = fin_finacc_transaction.fin_reconciliation_id"
+                + " WHERE fin_reconciliation.fin_reconciliation_id='%s'", reconciliationId);
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(transactionCount));
+      }
+    }.execute(sql, 1);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Par1Fin2.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,667 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.fail;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.common.selenium.database.FinFinaccTransactionRow;
+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.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+/**
+ * Create a layaway in terminal 1001 with initial payment, complete the payment in terminal 1002
+ */
+@RunWith(Parameterized.class)
+public class Layaway_Cre1Par1Fin2 extends WebPOSTerminalHelper {
+
+  private static final String VBS1001 = "VBS1001";
+  private static final String VBS1002 = "VBS1002";
+  private static final OBNumber NETTOTAL = new OBNumber("32.98");
+  private static final OBNumber GROSSTOTAL = new OBNumber("39.90");
+
+  private static final OBNumber PARTIALPAYMENT1 = new OBNumber("12.00");
+  private static final OBNumber DEPOSIT1 = new OBNumber("11.50");
+  private static final OBNumber GROSS1 = new OBNumber("27.90");
+  private static final OBNumber TAX1 = new OBNumber("6.92");
+  private static final OBNumber CASHDIFF1 = new OBNumber("-0.50");
+
+  private static final OBNumber PARTIALPAYMENT2 = GROSS1;
+  private static final OBNumber DEPOSIT2 = new OBNumber("30.00");
+  private static final OBNumber GROSS2 = GROSS1;
+  // private static final OBNumber TAX2 = ;
+  private static final OBNumber CASHDIFF2 = new OBNumber("2.10");
+
+  private static String documentNo1;
+  private static String documentNo2;
+  private static String customer;
+
+  @Parameters(name = "({index}) terminal: {0}")
+  public static Collection<String[]> getTestParameters() {
+    final ArrayList<String[]> parameters = new ArrayList<String[]>();
+    parameters.add(new String[] { VBS1001 });
+    // parameters.add(new String[] { VBS1002 });
+    return parameters;
+  }
+
+  public Layaway_Cre1Par1Fin2(final String terminal) {
+    super(terminal, "vallblanca", "openbravo");
+  }
+
+  @Test
+  public void test() {
+    WebPOSSnippet.cleanCashup(this);
+
+    if (getTerminal().equals(VBS1001)) {
+
+      // 1. Create a layaway in one terminal making a partial payment and cashup
+      createLayawayWithInitialPayment();
+      final String organizationId = BackboneHelper.getTerminalValue("organization");
+      final String clientId = BackboneHelper.getTerminalValue("client");
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+      final String businessPartnerId = BackboneHelper.getTerminalValue("businessPartner");
+      WebPOSDatabaseHelper.verifyOrder(documentNo1, cashupId, GROSSTOTAL);
+      WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo1,
+          OBNumber.ZERO,
+          PARTIALPAYMENT1, "RDNC", cashupId, null);
+
+      cashupVBS1001();
+
+      final String reconciliationId = WebPOSDatabaseHelper.retrieveReconcialiationId(cashupId);
+      WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo1,
+          OBNumber.ZERO,
+          PARTIALPAYMENT1, "RPPC", cashupId, reconciliationId);
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, GROSSTOTAL,
+          OBNumber.ZERO, NETTOTAL, OBNumber.ZERO, GROSSTOTAL);
+      WebPOSDatabaseHelper.verifyCashupTaxes(cashupId, new OBNumber(TAX1), 0);
+      verifyPaymentMethods1001(cashupId);
+      verifyFinFinaccTransaction1001(organizationId, clientId, cashupId, reconciliationId,
+          WebPOSDatabaseConstants.VBS1001_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID, PARTIALPAYMENT1,
+          businessPartnerId, DEPOSIT1);
+      verifyReconciliation(reconciliationId, 3);
+
+    } else if (getTerminal().equals(VBS1002)) {
+
+      // 2. Retrieve the layaway in another terminal finishing the layaway and cashup
+      retrieveLayawayAndPay();
+      final String organizationId = BackboneHelper.getTerminalValue("organization");
+      final String clientId = BackboneHelper.getTerminalValue("client");
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+      final String businessPartnerId = BackboneHelper.getTerminalValue("businessPartner");
+      WebPOSDatabaseHelper.verifyOrder(documentNo2, cashupId, GROSSTOTAL);
+      WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo2,
+          OBNumber.ZERO,
+          PARTIALPAYMENT2, "RDNC", cashupId, null);
+
+      cashupVBS1002();
+
+      final String reconciliationId = WebPOSDatabaseHelper.retrieveReconcialiationId(cashupId);
+      WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo2,
+          OBNumber.ZERO,
+          PARTIALPAYMENT2, "RPPC", cashupId, reconciliationId);
+      WebPOSDatabaseHelper
+.verifyCashupTable(organizationId, clientId, cashupId, OBNumber.ZERO,
+          OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO);
+      verifyPaymentMethods1002(cashupId);
+      verifyFinFinaccTransaction1002(organizationId, clientId, cashupId, reconciliationId,
+          WebPOSDatabaseConstants.VBS1002_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID, PARTIALPAYMENT2,
+          businessPartnerId, DEPOSIT2);
+      verifyReconciliation(reconciliationId, 3);
+      // WebPOSDatabaseHelper.verifyCashupTaxes(cashupId, TAX2, 0); // There are no taxes involved
+
+    } else {
+      fail(String.format("This terminal ('%s') is missing its test", getTerminal()));
+    }
+  }
+
+  private void createLayawayWithInitialPayment() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+    verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_MOUNTAINEERING);
+    tap(TestId.BUTTON_PRODUCT_MOUNTAINEERING_CRAMPONS10POINT);
+    documentNo1 = BackboneHelper.getDocumentNo();
+    customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    verify(TestId.LABEL_TOTALTOPAY, GROSSTOTAL);
+    tap(TestId.BUTTON_PAY);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, GROSSTOTAL + "€");
+    WebPOSSnippet.tapKeypad(this,  PARTIALPAYMENT1.intValue());
+    tap(TestId.BUTTON_CASH);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, GROSS1 + "€");
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void retrieveLayawayAndPay() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    isDisabled(TestId.BUTTON_PAY, false);
+    verify(TestId.LABEL_TOTALTOPAY, GROSSTOTAL);
+    documentNo2 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, GROSS1 + "€");
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1001() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, PARTIALPAYMENT1);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, PARTIALPAYMENT1.negativeSign());
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_5);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_5);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_1);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_050);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, CASHDIFF1);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, CASHDIFF1);
+    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_AMOUNT, "32.98");
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, TAX1);
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, GROSSTOTAL);
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, GROSSTOTAL);
+
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, PARTIALPAYMENT1);
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, PARTIALPAYMENT1);
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, DEPOSIT1);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, CASHDIFF1);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, DEPOSIT1);
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1002() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, PARTIALPAYMENT2);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, PARTIALPAYMENT2.negativeSign());
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_10);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_10);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_10);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, CASHDIFF2);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, CASHDIFF2);
+    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_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, "0.00");
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, GROSS2);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, GROSS2);
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, GROSS2);
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, GROSS2);
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, DEPOSIT2);
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, DEPOSIT2);
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, CASHDIFF2);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, CASHDIFF2);
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, DEPOSIT2);
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, DEPOSIT2);
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void verifyFinFinaccTransaction1001(final String organizationId, final String clientId,
+      final String cashupId, final String reconciliationId, final String cashbookStore,
+      final OBNumber gross, final String businessPartnerId, final OBNumber deposit) {
+    final String sql = String
+        .format(
+            "SELECT"
+                + " fin_finacc_transaction.ad_client_id,"
+                + " fin_finacc_transaction.ad_org_id,"
+                + " fin_finacc_transaction.fin_reconciliation_id,"
+                + " fin_finacc_transaction.status,"
+                + " fin_finacc_transaction.processing,"
+                + " fin_finacc_transaction.processed,"
+
+                + " fin_finacc_transaction.fin_financial_account_id,"
+                + " fin_finacc_transaction.fin_payment_id,"
+                + " fin_finacc_transaction.c_glitem_id,"
+                + " fin_finacc_transaction.paymentamt,"
+                + " fin_finacc_transaction.depositamt,"
+                + " fin_finacc_transaction.trxtype,"
+                + " fin_finacc_transaction.c_bpartner_id,"
+                + " fin_finacc_transaction.em_aprm_processed"
+                + " FROM fin_finacc_transaction"
+                + " INNER JOIN obpos_app_cashup ON fin_finacc_transaction.em_obpos_app_cashup_id = obpos_app_cashup.obpos_app_cashup_id"
+                + " WHERE obpos_app_cashup.obpos_app_cashup_id='%s'" //
+                + " ORDER BY status, trxtype, c_glitem_id", cashupId);
+
+    final ArrayList<FinFinaccTransactionRow> cashupRows = new ArrayList<FinFinaccTransactionRow>();
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        // common fields
+        assertThat(rs.getString("ad_org_id"), equalTo(organizationId));
+        assertThat(rs.getString("ad_client_id"), equalTo(clientId));
+        assertThat(rs.getString("processing"), equalTo("N"));
+        assertThat(rs.getString("processed"), equalTo("Y"));
+
+        final FinFinaccTransactionRow cur = new FinFinaccTransactionRow();
+        cur.fin_reconciliation_id = rs.getString("fin_reconciliation_id");
+        cur.fin_financial_account_id = rs.getString("fin_financial_account_id");
+        cur.fin_payment_id = rs.getString("fin_payment_id");
+        cur.c_glitem_id = rs.getString("c_glitem_id");
+        cur.status = rs.getString("status");
+        cur.paymentamt = new OBNumber(rs.getFloat("paymentamt"));
+        cur.depositamt = new OBNumber(rs.getFloat("depositamt"));
+        cur.trxtype = rs.getString("trxtype");
+        cur.c_bpartner_id = rs.getString("c_bpartner_id");
+        cur.em_aprm_processed = rs.getString("em_aprm_processed");
+        cashupRows.add(cur);
+      }
+    }.execute(sql, 4);
+
+    for (int i = 0; i < cashupRows.size(); i++) {
+      final FinFinaccTransactionRow tran = cashupRows.get(i);
+      switch (i) {
+      case 0:
+        assertThat(tran.fin_financial_account_id,
+            equalTo(WebPOSDatabaseConstants.VBS_CASHBOOK_BACKOFFICE_FIN_ACCOUNT_ID));
+        assertThat(tran.fin_reconciliation_id, is(nullValue()));
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo("2C62436C613E4C398E7B34A4DED1B726"));
+        assertThat(tran.status, equalTo("RDNC"));
+        assertThat(tran.paymentamt, equalTo(OBNumber.ZERO));
+        assertThat(tran.depositamt, equalTo(deposit));
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      case 1:
+        assertThat(tran.fin_financial_account_id, equalTo(cashbookStore));
+        assertThat(tran.fin_reconciliation_id, equalTo(reconciliationId));
+        assertThat(tran.fin_payment_id, not(nullValue()));
+        assertThat(tran.c_glitem_id, is(nullValue()));
+        assertThat(tran.status, equalTo("RPPC"));
+        assertThat(tran.paymentamt, equalTo(OBNumber.ZERO));
+        assertThat(tran.depositamt, equalTo(gross));
+        assertThat(tran.trxtype, equalTo("BPD"));
+        assertThat(tran.c_bpartner_id, equalTo(businessPartnerId));
+        assertThat(tran.em_aprm_processed, equalTo("R"));
+        break;
+      case 2:
+        assertThat(tran.fin_financial_account_id, equalTo(cashbookStore));
+        assertThat(tran.fin_reconciliation_id, equalTo(reconciliationId));
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo("1EC5D1EA070F45BEB4C8023631DC4BBE"));
+        assertThat(tran.status, equalTo("RPPC"));
+        final OBNumber difference = deposit.subtract(gross);
+        if (difference.compareTo(OBNumber.ZERO) == -1) {
+          assertThat(tran.paymentamt, equalTo(difference.abs()));
+          assertThat(tran.depositamt, equalTo(OBNumber.ZERO));
+        } else {
+          assertThat(tran.paymentamt, equalTo(OBNumber.ZERO));
+          assertThat(tran.depositamt, equalTo(difference));
+        }
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      case 3:
+        assertThat(tran.fin_financial_account_id, equalTo(cashbookStore));
+        assertThat(tran.fin_reconciliation_id, equalTo(reconciliationId));
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo("2C62436C613E4C398E7B34A4DED1B726"));
+        assertThat(tran.status, equalTo("RPPC"));
+        assertThat(tran.paymentamt, equalTo(deposit));
+        assertThat(tran.depositamt, equalTo(OBNumber.ZERO));
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      default:
+        fail("Not implemented");
+      }
+    }
+  }
+
+  private void verifyFinFinaccTransaction1002(final String organizationId, final String clientId,
+      final String cashupId, final String reconciliationId, final String cashbookStore,
+      final OBNumber gross, final String businessPartnerId, final OBNumber deposit) {
+    final String sql = String
+        .format(
+            "SELECT"
+                + " fin_finacc_transaction.ad_client_id,"
+                + " fin_finacc_transaction.ad_org_id,"
+                + " fin_finacc_transaction.fin_reconciliation_id,"
+                + " fin_finacc_transaction.status,"
+                + " fin_finacc_transaction.processing,"
+                + " fin_finacc_transaction.processed,"
+
+                + " fin_finacc_transaction.fin_financial_account_id,"
+                + " fin_finacc_transaction.fin_payment_id,"
+                + " fin_finacc_transaction.c_glitem_id,"
+                + " fin_finacc_transaction.paymentamt,"
+                + " fin_finacc_transaction.depositamt,"
+                + " fin_finacc_transaction.trxtype,"
+                + " fin_finacc_transaction.c_bpartner_id,"
+                + " fin_finacc_transaction.em_aprm_processed"
+                + " FROM fin_finacc_transaction"
+                + " INNER JOIN obpos_app_cashup ON fin_finacc_transaction.em_obpos_app_cashup_id = obpos_app_cashup.obpos_app_cashup_id"
+                + " WHERE obpos_app_cashup.obpos_app_cashup_id='%s'" //
+                + " ORDER BY status, trxtype, c_glitem_id", cashupId);
+
+    final ArrayList<FinFinaccTransactionRow> cashupRows = new ArrayList<FinFinaccTransactionRow>();
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        // common fields
+        assertThat(rs.getString("ad_org_id"), equalTo(organizationId));
+        assertThat(rs.getString("ad_client_id"), equalTo(clientId));
+        assertThat(rs.getString("processing"), equalTo("N"));
+        assertThat(rs.getString("processed"), equalTo("Y"));
+
+        final FinFinaccTransactionRow cur = new FinFinaccTransactionRow();
+        cur.fin_reconciliation_id = rs.getString("fin_reconciliation_id");
+        cur.fin_financial_account_id = rs.getString("fin_financial_account_id");
+        cur.fin_payment_id = rs.getString("fin_payment_id");
+        cur.c_glitem_id = rs.getString("c_glitem_id");
+        cur.status = rs.getString("status");
+        cur.paymentamt = new OBNumber(rs.getFloat("paymentamt"));
+        cur.depositamt = new OBNumber(rs.getFloat("depositamt"));
+        cur.trxtype = rs.getString("trxtype");
+        cur.c_bpartner_id = rs.getString("c_bpartner_id");
+        cur.em_aprm_processed = rs.getString("em_aprm_processed");
+        cashupRows.add(cur);
+      }
+    }.execute(sql, 4);
+
+    for (int i = 0; i < cashupRows.size(); i++) {
+      final FinFinaccTransactionRow tran = cashupRows.get(i);
+      switch (i) {
+      case 0:
+        assertThat(tran.fin_financial_account_id,
+            equalTo(WebPOSDatabaseConstants.VBS_CASHBOOK_BACKOFFICE_FIN_ACCOUNT_ID));
+        assertThat(tran.fin_reconciliation_id, is(nullValue()));
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo(WebPOSDatabaseConstants.VBS_GL_CASHUP_MANDARORY_ID));
+        assertThat(tran.status, equalTo("RDNC"));
+        assertThat(tran.paymentamt, equalTo(OBNumber.ZERO));
+        assertThat(tran.depositamt, equalTo(deposit));
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      case 1:
+        assertThat(tran.fin_financial_account_id, equalTo(cashbookStore));
+        assertThat(tran.fin_reconciliation_id, equalTo(reconciliationId));
+        assertThat(tran.fin_payment_id, not(nullValue()));
+        assertThat(tran.c_glitem_id, is(nullValue()));
+        assertThat(tran.status, equalTo("RPPC"));
+        assertThat(tran.paymentamt, equalTo(OBNumber.ZERO));
+        assertThat(tran.depositamt, equalTo(gross));
+        assertThat(tran.trxtype, equalTo("BPD"));
+        assertThat(tran.c_bpartner_id, equalTo(businessPartnerId));
+        assertThat(tran.em_aprm_processed, equalTo("R"));
+        break;
+      case 2:
+        assertThat(tran.fin_financial_account_id, equalTo(cashbookStore));
+        assertThat(tran.fin_reconciliation_id, equalTo(reconciliationId));
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo(WebPOSDatabaseConstants.VBS_GL_CASH_DIFFERENCES_ID));
+        assertThat(tran.status, equalTo("RPPC"));
+        final OBNumber difference = deposit.subtract(gross);
+        if (difference.compareTo(OBNumber.ZERO) == -1) {
+          assertThat(tran.paymentamt, equalTo(difference.abs()));
+          assertThat(tran.depositamt, equalTo(OBNumber.ZERO));
+        } else {
+          assertThat(tran.paymentamt, equalTo(OBNumber.ZERO));
+          assertThat(tran.depositamt, equalTo(difference));
+        }
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      case 3:
+        assertThat(tran.fin_financial_account_id, equalTo(cashbookStore));
+        assertThat(tran.fin_reconciliation_id, equalTo(reconciliationId));
+        assertThat(tran.fin_payment_id, is(nullValue()));
+        assertThat(tran.c_glitem_id, equalTo(WebPOSDatabaseConstants.VBS_GL_CASHUP_MANDARORY_ID));
+        assertThat(tran.status, equalTo("RPPC"));
+        assertThat(tran.paymentamt, equalTo(deposit));
+        assertThat(tran.depositamt, equalTo(OBNumber.ZERO));
+        assertThat(tran.trxtype, equalTo("BPW"));
+        assertThat(tran.c_bpartner_id, is(nullValue()));
+        assertThat(tran.em_aprm_processed, equalTo("P"));
+        break;
+      default:
+        fail("Not implemented");
+      }
+    }
+  }
+
+  private void verifyReconciliation(final String reconciliationId, final int transactionCount) {
+    final String sql = String
+        .format(
+            "SELECT" //
+                + " COUNT(*) AS counted" //
+                + " FROM fin_reconciliation"
+                + " INNER JOIN fin_finacc_transaction ON fin_reconciliation.fin_reconciliation_id = fin_finacc_transaction.fin_reconciliation_id"
+                + " WHERE fin_reconciliation.fin_reconciliation_id='%s'", reconciliationId);
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(transactionCount));
+      }
+    }.execute(sql, 1);
+  }
+
+  private void verifyPaymentMethods1001(final String cashupId) {
+    WebPOSDatabaseHelper.verifyPaymentMethod(cashupId,
+        WebPOSDatabaseConstants.VBS_PAYMENTMETHOD.CARD, OBNumber.ZERO, OBNumber.ZERO,
+        OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO);
+    WebPOSDatabaseHelper.verifyPaymentMethod(cashupId,
+        WebPOSDatabaseConstants.VBS_PAYMENTMETHOD.CASH, OBNumber.ZERO, PARTIALPAYMENT1,
+        OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO);
+    WebPOSDatabaseHelper.verifyPaymentMethod(cashupId,
+        WebPOSDatabaseConstants.VBS_PAYMENTMETHOD.USACASH, OBNumber.ZERO, OBNumber.ZERO,
+        OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO);
+    WebPOSDatabaseHelper.verifyPaymentMethod(cashupId,
+        WebPOSDatabaseConstants.VBS_PAYMENTMETHOD.VOUCHER, OBNumber.ZERO, OBNumber.ZERO,
+        OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO);
+  }
+
+  private void verifyPaymentMethods1002(final String cashupId) {
+    WebPOSDatabaseHelper.verifyPaymentMethod(cashupId,
+        WebPOSDatabaseConstants.VBS_PAYMENTMETHOD.CARD, OBNumber.ZERO, OBNumber.ZERO,
+        OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO);
+    WebPOSDatabaseHelper.verifyPaymentMethod(cashupId,
+        WebPOSDatabaseConstants.VBS_PAYMENTMETHOD.CASH, OBNumber.ZERO, PARTIALPAYMENT2,
+        OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO);
+    WebPOSDatabaseHelper.verifyPaymentMethod(cashupId,
+        WebPOSDatabaseConstants.VBS_PAYMENTMETHOD.USACASH, OBNumber.ZERO, OBNumber.ZERO,
+        OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO);
+    WebPOSDatabaseHelper.verifyPaymentMethod(cashupId,
+        WebPOSDatabaseConstants.VBS_PAYMENTMETHOD.VOUCHER, OBNumber.ZERO, OBNumber.ZERO,
+        OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Par2Fin1.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,362 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.fail;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.common.selenium.database.FinFinaccTransactionRow;
+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.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+/**
+ * Create a layaway in terminal 1001 with no initial amount and complete the payment in the terminal
+ * 1002
+ */
+@RunWith(Parameterized.class)
+public class Layaway_Cre1Par2Fin1 extends WebPOSTerminalHelper {
+
+  private static int testCount = 0;
+
+  // terminals
+  private static final String VBS1001 = "VBS1001";
+  private static final String VBS1002 = "VBS1002";
+  // sale related constants
+  private static final OBNumber NET = new OBNumber("6.45");
+  private static final OBNumber TAXES = new OBNumber("1.35");
+  private static final OBNumber GROSS = NET.add(TAXES);
+  private static final OBNumber PARTIALPAYMENT1 = new OBNumber("5.00");
+  private static final OBNumber PARTIALPAYMENT2 = new OBNumber("2.80");
+  private static final OBNumber DIFFERENCE3 = new OBNumber("0.10");
+  private static String documentNo1;
+  private static String documentNo2;
+  private static String documentNo3;
+  private static String customer;
+
+  @Parameters(name = "({index}) terminal: {0}")
+  public static Collection<String[]> getTestParameters() {
+    final ArrayList<String[]> parameters = new ArrayList<String[]>();
+    parameters.add(new String[] { VBS1001 });
+    parameters.add(new String[] { VBS1002 });
+    parameters.add(new String[] { VBS1001 });
+    return parameters;
+  }
+
+  public Layaway_Cre1Par2Fin1(final String terminal) {
+    super(terminal, "vallblanca", "openbravo");
+    testCount++;
+  }
+
+  @Test
+  public void test() {
+
+    switch (testCount) {
+    case 1:
+      WebPOSSnippet.cleanCashup(this);
+      // 1. Create a layaway in one terminal and cashup
+      createLayaway();
+      final String organizationId = BackboneHelper.getTerminalValue("organization");
+      final String clientId = BackboneHelper.getTerminalValue("client");
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+      WebPOSDatabaseHelper.verifyOrder(documentNo1, cashupId, GROSS);
+      verifyThereIsNoTransaction(organizationId, clientId, cashupId, documentNo1);
+      break;
+    case 2:
+      // 2. Retrieve the layaway and pay partially
+      retrieveLayawayAndPay5();
+      assertThat(documentNo2, equalTo(documentNo1));
+      final String cashupId2 = BackboneHelper.getTerminalValue("cashUpId");
+      WebPOSDatabaseHelper.verifyOrder(documentNo2, cashupId2, GROSS);
+
+      final ArrayList<FinFinaccTransactionRow> receipt2Transactions = WebPOSDatabaseHelper
+          .getSaleTransactions(documentNo2, cashupId2, null, 1);
+      assertThat(receipt2Transactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(receipt2Transactions.get(0).depositamt, equalTo(PARTIALPAYMENT1));
+      break;
+    case 3:
+      // 3. Retrieve again the layaway, finishing the layaway and cashup
+      retrieveLayawayAndFinish();
+      final String organizationId3 = BackboneHelper.getTerminalValue("organization");
+      final String clientId3 = BackboneHelper.getTerminalValue("client");
+      final String cashupId3 = BackboneHelper.getTerminalValue("cashUpId");
+      final String businessPartnerId = BackboneHelper.getTerminalValue("businessPartner");
+      assertThat(documentNo3, equalTo(documentNo1));
+
+      WebPOSDatabaseHelper.verifyOrder(documentNo1, cashupId3, GROSS);
+
+      final ArrayList<FinFinaccTransactionRow> receipt3PreCashupTransactions = WebPOSDatabaseHelper
+          .getSaleTransactions(documentNo1, cashupId3, null, 1);
+      assertThat(receipt3PreCashupTransactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(receipt3PreCashupTransactions.get(0).depositamt, equalTo(PARTIALPAYMENT2));
+
+      cashupVBS1001();
+
+      final String reconciliationId = WebPOSDatabaseHelper.retrieveReconcialiationId(cashupId3);
+
+      final ArrayList<FinFinaccTransactionRow> receipt3PostCashupTransactions = WebPOSDatabaseHelper
+          .getSaleTransactions(documentNo1, cashupId3, reconciliationId, 1);
+      assertThat(receipt3PostCashupTransactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(receipt3PostCashupTransactions.get(0).depositamt, equalTo(PARTIALPAYMENT2));
+
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId3, clientId3, cashupId3, GROSS,
+          OBNumber.ZERO, NET, OBNumber.ZERO, GROSS);
+
+      final ArrayList<FinFinaccTransactionRow> cashupTransactions = WebPOSDatabaseHelper
+          .getCashupTransactions(cashupId3,
+              WebPOSDatabaseConstants.VBS1001_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID,
+              businessPartnerId, PARTIALPAYMENT2,
+              new OBNumber(PARTIALPAYMENT2.subtract(DIFFERENCE3)), 4);
+      assertThat(cashupTransactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(cashupTransactions.get(0).depositamt, equalTo(PARTIALPAYMENT2));
+
+      verifyReconciliation(reconciliationId, 3);
+      break;
+    default:
+      fail(String.format("This terminal ('%s') is missing its test", getTerminal()));
+    }
+  }
+
+  private void verifyReconciliation(final String reconciliationId, final int transactionCount) {
+    final String sql = String
+        .format(
+            "SELECT" //
+                + " COUNT(*) AS counted" //
+                + " FROM fin_reconciliation"
+                + " INNER JOIN fin_finacc_transaction ON fin_reconciliation.fin_reconciliation_id = fin_finacc_transaction.fin_reconciliation_id"
+                + " WHERE fin_reconciliation.fin_reconciliation_id='%s'", reconciliationId);
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(transactionCount));
+      }
+    }.execute(sql, 1);
+  }
+
+  private void createLayaway() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+    verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_MOUNTAINEERING);
+    tap(TestId.BUTTON_PRODUCT_MOUNTAINEERING_DESCENDERCLASSIC);
+    documentNo1 = BackboneHelper.getDocumentNo();
+    customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    verify(TestId.LABEL_TOTALTOPAY, "7.80");
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+  }
+
+  private void retrieveLayawayAndPay5() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    verify(TestId.LABEL_TOTALTOPAY, GROSS);
+    documentNo2 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, GROSS.toString() + "€");
+    WebPOSSnippet.tapKeypad(this, PARTIALPAYMENT1.intValue());
+    tap(TestId.BUTTON_CASH);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, PARTIALPAYMENT2.toString() + "€");
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+  }
+
+  private void retrieveLayawayAndFinish() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    verify(TestId.LABEL_TOTALTOPAY, GROSS.toString());
+    tap(TestId.BUTTON_PAY);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, PARTIALPAYMENT2.toString() + "€");
+    documentNo3 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+  }
+
+  private void cashupVBS1001() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, PARTIALPAYMENT2);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, OBNumber.ZERO);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_2);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_050);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_020);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, DIFFERENCE3.negativeSign());
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, DIFFERENCE3.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_AMOUNT, NET);
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, TAXES);
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, GROSS);
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, OBNumber.ZERO);
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, GROSS);
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, PARTIALPAYMENT2);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, PARTIALPAYMENT2);
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, PARTIALPAYMENT2);
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, PARTIALPAYMENT2);
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, PARTIALPAYMENT2.subtract(DIFFERENCE3));
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, PARTIALPAYMENT2.subtract(DIFFERENCE3));
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, DIFFERENCE3.negativeSign());
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, DIFFERENCE3.negativeSign());
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, PARTIALPAYMENT2.subtract(DIFFERENCE3));
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, PARTIALPAYMENT2.subtract(DIFFERENCE3));
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+  }
+
+  private void verifyThereIsNoTransaction(final String organizationId, final String clientId,
+      final String cashupId, final String documentNo) {
+    final String c_order = String
+        .format(
+            "SELECT"
+                + " COUNT(*) AS counted"
+                + " FROM c_order"
+                + " INNER JOIN fin_payment_schedule ON c_order.c_order_id = fin_payment_schedule.c_order_id"
+                + " INNER JOIN fin_payment_scheduledetail ON fin_payment_schedule.fin_payment_schedule_id = fin_payment_scheduledetail.fin_payment_schedule_order"
+                + " INNER JOIN fin_payment_detail ON fin_payment_scheduledetail.fin_payment_detail_id = fin_payment_detail.fin_payment_detail_id"
+                + " INNER JOIN fin_payment ON fin_payment_detail.fin_payment_id = fin_payment.fin_payment_id"
+                + " INNER JOIN fin_finacc_transaction ON fin_payment.fin_payment_id = fin_finacc_transaction.fin_payment_id"
+                + " WHERE c_order.documentno='%s'", documentNo);
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(0));
+      }
+    }.execute(c_order, 1);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Par2Fin2.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,483 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.fail;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.common.selenium.database.FinFinaccTransactionRow;
+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.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+/**
+ * Create a layaway in terminal 1001 with no initial amount and complete the payment in the terminal
+ * 1002
+ */
+@RunWith(Parameterized.class)
+public class Layaway_Cre1Par2Fin2 extends WebPOSTerminalHelper {
+
+  // terminals
+  private static final String VBS1001 = "VBS1001";
+  private static final String VBS1002 = "VBS1002";
+  // sale related constants
+  private static final OBNumber NET = new OBNumber("6.45");
+  private static final OBNumber GROSS = new OBNumber("7.80");
+  private static final OBNumber PARTIALPAYMENT1 = new OBNumber("5.00");
+  private static final OBNumber PARTIALPAYMENT2 = new OBNumber("2.80");
+  private static String documentNo1;
+  private static String documentNo2;
+  private static String documentNo3;
+  private static String customer;
+
+  @Parameters(name = "({index}) terminal: {0}")
+  public static Collection<String[]> getTestParameters() {
+    final ArrayList<String[]> parameters = new ArrayList<String[]>();
+    parameters.add(new String[] { VBS1001 });
+    parameters.add(new String[] { VBS1002 });
+    return parameters;
+  }
+
+  public Layaway_Cre1Par2Fin2(final String terminal) {
+    super(terminal, "vallblanca", "openbravo");
+  }
+
+  @Test
+  public void test() {
+    WebPOSSnippet.cleanCashup(this);
+
+    if (getTerminal().equals(VBS1001)) {
+
+      // 1. Create a layaway in one terminal and cashup
+      createLayaway();
+      final String organizationId = BackboneHelper.getTerminalValue("organization");
+      final String clientId = BackboneHelper.getTerminalValue("client");
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+      WebPOSDatabaseHelper.verifyOrder(documentNo1, cashupId, GROSS);
+      verifyThereIsNoTransaction(organizationId, clientId, cashupId, documentNo1);
+
+      cashupVBS1001();
+
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, GROSS,
+          OBNumber.ZERO, NET, OBNumber.ZERO, GROSS);
+      WebPOSDatabaseHelper.verifyCashupTaxes(cashupId, new OBNumber("1.35"), 0);
+
+    } else if (getTerminal().equals(VBS1002)) {
+
+      // 2. Retrieve the layaway and pay partially
+      retrieveLayaway1AndPay5();
+      final String organizationId = BackboneHelper.getTerminalValue("organization");
+      final String clientId = BackboneHelper.getTerminalValue("client");
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+      final String businessPartnerId = BackboneHelper.getTerminalValue("businessPartner");
+      WebPOSDatabaseHelper.verifyOrder(documentNo2, cashupId, GROSS);
+
+      final ArrayList<FinFinaccTransactionRow> receipt2Transactions = WebPOSDatabaseHelper
+          .getSaleTransactions(documentNo2, cashupId, null, 1);
+      assertThat(receipt2Transactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(receipt2Transactions.get(0).depositamt, equalTo(PARTIALPAYMENT1));
+
+      // 3. Retrieve again the layaway, finishing the layaway and cashup
+      retrieveLayaway2AndFinish();
+      assertThat(documentNo2, equalTo(documentNo3));
+
+      WebPOSDatabaseHelper.verifyOrder(documentNo3, cashupId, GROSS);
+
+      final ArrayList<FinFinaccTransactionRow> receipt3PreCashupTransactions = WebPOSDatabaseHelper
+          .getSaleTransactions(documentNo3, cashupId, null, 2);
+      assertThat(receipt3PreCashupTransactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(receipt3PreCashupTransactions.get(0).depositamt, equalTo(PARTIALPAYMENT2));
+      assertThat(receipt3PreCashupTransactions.get(1).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(receipt3PreCashupTransactions.get(1).depositamt, equalTo(PARTIALPAYMENT1));
+
+      cashupVBS1002();
+
+      final String reconciliationId = WebPOSDatabaseHelper.retrieveReconcialiationId(cashupId);
+
+      final ArrayList<FinFinaccTransactionRow> receipt3PostCashupTransactions = WebPOSDatabaseHelper
+          .getSaleTransactions(documentNo3, cashupId, reconciliationId, 2);
+      assertThat(receipt3PostCashupTransactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(receipt3PostCashupTransactions.get(0).depositamt, equalTo(PARTIALPAYMENT2));
+      assertThat(receipt3PostCashupTransactions.get(1).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(receipt3PostCashupTransactions.get(1).depositamt, equalTo(PARTIALPAYMENT1));
+
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, OBNumber.ZERO,
+          OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO);
+
+      final ArrayList<FinFinaccTransactionRow> cashupTransactions = WebPOSDatabaseHelper
+          .getCashupTransactions(cashupId,
+              WebPOSDatabaseConstants.VBS1002_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID,
+              businessPartnerId, GROSS, new OBNumber("7.00"), 5);
+      assertThat(cashupTransactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(cashupTransactions.get(0).depositamt, equalTo(PARTIALPAYMENT2));
+      assertThat(cashupTransactions.get(1).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(cashupTransactions.get(1).depositamt, equalTo(PARTIALPAYMENT1));
+
+      verifyReconciliation(reconciliationId, 4);
+
+    } else {
+      fail(String.format("This terminal ('%s') is missing its test", getTerminal()));
+    }
+  }
+
+  private void verifyReconciliation(final String reconciliationId, final int transactionCount) {
+    final String sql = String
+        .format(
+            "SELECT" //
+                + " COUNT(*) AS counted" //
+                + " FROM fin_reconciliation"
+                + " INNER JOIN fin_finacc_transaction ON fin_reconciliation.fin_reconciliation_id = fin_finacc_transaction.fin_reconciliation_id"
+                + " WHERE fin_reconciliation.fin_reconciliation_id='%s'", reconciliationId);
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(transactionCount));
+      }
+    }.execute(sql, 1);
+  }
+
+  private void createLayaway() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+    verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_MOUNTAINEERING);
+    tap(TestId.BUTTON_PRODUCT_MOUNTAINEERING_DESCENDERCLASSIC);
+    documentNo1 = BackboneHelper.getDocumentNo();
+    customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    verify(TestId.LABEL_TOTALTOPAY, "7.80");
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void retrieveLayaway1AndPay5() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    verify(TestId.LABEL_TOTALTOPAY, GROSS);
+    documentNo2 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, GROSS.toString() + "€");
+    WebPOSSnippet.tapKeypad(this, PARTIALPAYMENT1.intValue());
+    tap(TestId.BUTTON_CASH);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, PARTIALPAYMENT2.toString() + "€");
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+
+  private void retrieveLayaway2AndFinish() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    verify(TestId.LABEL_TOTALTOPAY, GROSS.toString());
+    tap(TestId.BUTTON_PAY);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, PARTIALPAYMENT2.toString() + "€");
+    documentNo3 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1001() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "0.00");
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, "0.00");
+    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_AMOUNT, "6.45");
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "1.35");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, "7.80");
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, "7.80");
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, "0.00");
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1002() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, "7.80");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "-7.80");
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_5);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_2);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "-0.80");
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, "-0.80");
+    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_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, "0.00");
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, "7.80");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, "7.80");
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, "7.80");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, "7.80");
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, "7.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, "7.00");
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, "-0.80");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, "-0.80");
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, "7.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, "7.00");
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void verifyThereIsNoTransaction(final String organizationId, final String clientId,
+      final String cashupId, final String documentNo) {
+    final String c_order = String
+        .format(
+            "SELECT"
+                + " COUNT(*) AS counted"
+                + " FROM c_order"
+                + " INNER JOIN fin_payment_schedule ON c_order.c_order_id = fin_payment_schedule.c_order_id"
+                + " INNER JOIN fin_payment_scheduledetail ON fin_payment_schedule.fin_payment_schedule_id = fin_payment_scheduledetail.fin_payment_schedule_order"
+                + " INNER JOIN fin_payment_detail ON fin_payment_scheduledetail.fin_payment_detail_id = fin_payment_detail.fin_payment_detail_id"
+                + " INNER JOIN fin_payment ON fin_payment_detail.fin_payment_id = fin_payment.fin_payment_id"
+                + " INNER JOIN fin_finacc_transaction ON fin_payment.fin_payment_id = fin_finacc_transaction.fin_payment_id"
+                + " WHERE c_order.documentno='%s'", documentNo);
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(0));
+      }
+    }.execute(c_order, 1);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Par2Fin3.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,483 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.fail;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.common.selenium.database.FinFinaccTransactionRow;
+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.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+/**
+ * Create a layaway in terminal 1001 with no initial amount and complete the payment in the terminal
+ * 1002
+ */
+@RunWith(Parameterized.class)
+public class Layaway_Cre1Par2Fin3 extends WebPOSTerminalHelper {
+
+  // terminals
+  private static final String VBS1001 = "VBS1001";
+  private static final String VBS1002 = "VBS1002";
+  private static final String VBS1003 = "VBS1003";
+  // sale related constants
+  private static final OBNumber NET = new OBNumber("6.45");
+  private static final OBNumber GROSS = new OBNumber("7.80");
+  private static final OBNumber PARTIALPAYMENT1 = new OBNumber("5.00");
+  private static final OBNumber PARTIALPAYMENT2 = new OBNumber("2.80");
+  private static final OBNumber DIFFERENCE3 = new OBNumber("0.10");
+  private static String documentNo1;
+  private static String documentNo2;
+  private static String documentNo3;
+  private static String customer;
+
+  @Parameters(name = "({index}) terminal: {0}")
+  public static Collection<String[]> getTestParameters() {
+    final ArrayList<String[]> parameters = new ArrayList<String[]>();
+    parameters.add(new String[] { VBS1001 });
+    parameters.add(new String[] { VBS1002 });
+    parameters.add(new String[] { VBS1003 });
+    return parameters;
+  }
+
+  public Layaway_Cre1Par2Fin3(final String terminal) {
+    super(terminal, "vallblanca", "openbravo");
+  }
+
+  @Test
+  public void test() {
+    WebPOSSnippet.cleanCashup(this);
+
+    if (getTerminal().equals(VBS1001)) {
+
+      // 1. Create a layaway in one terminal and cashup
+      createLayaway();
+      final String organizationId = BackboneHelper.getTerminalValue("organization");
+      final String clientId = BackboneHelper.getTerminalValue("client");
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+      WebPOSDatabaseHelper.verifyOrder(documentNo1, cashupId, GROSS);
+      verifyThereIsNoTransaction(organizationId, clientId, cashupId, documentNo1);
+
+      cashupVBS1001();
+
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, GROSS,
+          OBNumber.ZERO, NET, OBNumber.ZERO, GROSS);
+      WebPOSDatabaseHelper.verifyCashupTaxes(cashupId, new OBNumber("1.35"), 0);
+
+    } else if (getTerminal().equals(VBS1002)) {
+
+      // 2. Retrieve the layaway and pay partially
+      retrieveLayaway1AndPay5();
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+
+      final ArrayList<FinFinaccTransactionRow> receipt2Transactions = WebPOSDatabaseHelper
+          .getSaleTransactions(documentNo2, cashupId, null, 1);
+      assertThat(receipt2Transactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(receipt2Transactions.get(0).depositamt, equalTo(PARTIALPAYMENT1));
+
+      WebPOSDatabaseHelper.verifyOrder(documentNo2, cashupId, GROSS);
+
+    } else if (getTerminal().equals(VBS1003)) {
+      // 3. Retrieve again the layaway, finishing the layaway and cashup
+      retrieveLayaway2AndFinish();
+      final String organizationId = BackboneHelper.getTerminalValue("organization");
+      final String clientId = BackboneHelper.getTerminalValue("client");
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+      final String businessPartnerId = BackboneHelper.getTerminalValue("businessPartner");
+      assertThat(documentNo2, equalTo(documentNo3));
+
+      final ArrayList<FinFinaccTransactionRow> receipt3PreCashupTransactions = WebPOSDatabaseHelper
+          .getSaleTransactions(documentNo3, cashupId, null, 1);
+      assertThat(receipt3PreCashupTransactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(receipt3PreCashupTransactions.get(0).depositamt, equalTo(PARTIALPAYMENT2));
+
+      WebPOSDatabaseHelper.verifyOrder(documentNo3, cashupId, GROSS);
+
+      cashupVBS1003();
+
+      final String reconciliationId = WebPOSDatabaseHelper.retrieveReconcialiationId(cashupId);
+
+      final ArrayList<FinFinaccTransactionRow> receipt3PostCashupTransactions = WebPOSDatabaseHelper
+          .getSaleTransactions(documentNo3, cashupId, reconciliationId, 1);
+      assertThat(receipt3PostCashupTransactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(receipt3PostCashupTransactions.get(0).depositamt, equalTo(PARTIALPAYMENT2));
+
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, OBNumber.ZERO,
+          OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO, OBNumber.ZERO);
+
+      final ArrayList<FinFinaccTransactionRow> cashupTransactions = WebPOSDatabaseHelper
+          .getCashupTransactions(cashupId,
+              WebPOSDatabaseConstants.VBS1003_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID,
+              businessPartnerId, PARTIALPAYMENT2,
+              new OBNumber(PARTIALPAYMENT2.subtract(DIFFERENCE3)), 4);
+      assertThat(cashupTransactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(cashupTransactions.get(0).depositamt, equalTo(PARTIALPAYMENT2));
+
+      verifyReconciliation(reconciliationId, 3);
+
+    } else {
+      fail(String.format("This terminal ('%s') is missing its test", getTerminal()));
+    }
+  }
+
+  private void verifyReconciliation(final String reconciliationId, final int transactionCount) {
+    final String sql = String
+        .format(
+            "SELECT" //
+                + " COUNT(*) AS counted" //
+                + " FROM fin_reconciliation"
+                + " INNER JOIN fin_finacc_transaction ON fin_reconciliation.fin_reconciliation_id = fin_finacc_transaction.fin_reconciliation_id"
+                + " WHERE fin_reconciliation.fin_reconciliation_id='%s'", reconciliationId);
+
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(transactionCount));
+      }
+    }.execute(sql, 1);
+  }
+
+  private void createLayaway() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+    verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_MOUNTAINEERING);
+    tap(TestId.BUTTON_PRODUCT_MOUNTAINEERING_DESCENDERCLASSIC);
+    documentNo1 = BackboneHelper.getDocumentNo();
+    customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    verify(TestId.LABEL_TOTALTOPAY, "7.80");
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void retrieveLayaway1AndPay5() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    verify(TestId.LABEL_TOTALTOPAY, GROSS);
+    documentNo2 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, GROSS.toString() + "€");
+    WebPOSSnippet.tapKeypad(this, PARTIALPAYMENT1.intValue());
+    tap(TestId.BUTTON_CASH);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, PARTIALPAYMENT2.toString() + "€");
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void retrieveLayaway2AndFinish() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    verify(TestId.LABEL_TOTALTOPAY, GROSS.toString());
+    tap(TestId.BUTTON_PAY);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, PARTIALPAYMENT2.toString() + "€");
+    documentNo3 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1001() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "0.00");
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, "0.00");
+    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_AMOUNT, "6.45");
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "1.35");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, "7.80");
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, "7.80");
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, "0.00");
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1003() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, PARTIALPAYMENT2);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_2);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_050);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_020);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, DIFFERENCE3.negativeSign());
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, DIFFERENCE3.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_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, "0.00");
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, PARTIALPAYMENT2);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, PARTIALPAYMENT2);
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, PARTIALPAYMENT2);
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, PARTIALPAYMENT2);
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, PARTIALPAYMENT2.subtract(DIFFERENCE3));
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, PARTIALPAYMENT2.subtract(DIFFERENCE3));
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, DIFFERENCE3.negativeSign());
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, DIFFERENCE3.negativeSign());
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, PARTIALPAYMENT2.subtract(DIFFERENCE3));
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, PARTIALPAYMENT2.subtract(DIFFERENCE3));
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void verifyThereIsNoTransaction(final String organizationId, final String clientId,
+      final String cashupId, final String documentNo) {
+    final String c_order = String
+        .format(
+            "SELECT"
+                + " COUNT(*) AS counted"
+                + " FROM c_order"
+                + " INNER JOIN fin_payment_schedule ON c_order.c_order_id = fin_payment_schedule.c_order_id"
+                + " INNER JOIN fin_payment_scheduledetail ON fin_payment_schedule.fin_payment_schedule_id = fin_payment_scheduledetail.fin_payment_schedule_order"
+                + " INNER JOIN fin_payment_detail ON fin_payment_scheduledetail.fin_payment_detail_id = fin_payment_detail.fin_payment_detail_id"
+                + " INNER JOIN fin_payment ON fin_payment_detail.fin_payment_id = fin_payment.fin_payment_id"
+                + " INNER JOIN fin_finacc_transaction ON fin_payment.fin_payment_id = fin_finacc_transaction.fin_payment_id"
+                + " WHERE c_order.documentno='%s'", documentNo);
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(0));
+      }
+    }.execute(c_order, 1);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Par2Void3.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,505 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.fail;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.common.selenium.database.FinFinaccTransactionRow;
+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.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+/**
+ * Create a layaway in terminal 1001 with no initial amount and complete the payment in the terminal
+ * 1002
+ */
+@RunWith(Parameterized.class)
+public class Layaway_Cre1Par2Void3 extends WebPOSTerminalHelper {
+
+  // terminals
+  private static final String VBS1001 = "VBS1001";
+  private static final String VBS1002 = "VBS1002";
+  private static final String VBS1003 = "VBS1003";
+  // sale related constants
+  private static final OBNumber NET = new OBNumber("6.45");
+  private static final OBNumber TAXES = new OBNumber("1.35");
+  private static final OBNumber GROSS = NET.add(TAXES);
+  private static final OBNumber PARTIALPAYMENT1 = new OBNumber("5.00");
+  private static final OBNumber PARTIALPAYMENT2 = new OBNumber("2.80");
+  private static final OBNumber CASHDEPOSIT = new OBNumber("100.00");
+  private static String documentNo1;
+  private static String documentNo2;
+  private static String customer;
+
+  @Parameters(name = "({index}) terminal: {0}")
+  public static Collection<String[]> getTestParameters() {
+    final ArrayList<String[]> parameters = new ArrayList<String[]>();
+    parameters.add(new String[] { VBS1001 });
+    parameters.add(new String[] { VBS1002 });
+    parameters.add(new String[] { VBS1003 });
+    return parameters;
+  }
+
+  public Layaway_Cre1Par2Void3(final String terminal) {
+    super(terminal, "vallblanca", "openbravo");
+  }
+
+  @Test
+  public void test() {
+    WebPOSSnippet.cleanCashup(this);
+
+    if (getTerminal().equals(VBS1001)) {
+
+      // 1. Create a layaway in one terminal and cashup
+      createLayaway();
+      final String organizationId = BackboneHelper.getTerminalValue("organization");
+      final String clientId = BackboneHelper.getTerminalValue("client");
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+      WebPOSDatabaseHelper.verifyOrder(documentNo1, cashupId, GROSS);
+      verifyThereIsNoTransaction(organizationId, clientId, cashupId, documentNo1);
+
+      cashupVBS1001();
+
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, GROSS,
+          OBNumber.ZERO, NET, OBNumber.ZERO, GROSS);
+      WebPOSDatabaseHelper.verifyCashupTaxes(cashupId, new OBNumber("1.35"), 0);
+
+    } else if (getTerminal().equals(VBS1002)) {
+
+      // 2. Retrieve the layaway and pay partially
+      retrieveLayaway1AndPay5();
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+      WebPOSDatabaseHelper.verifyOrder(documentNo2, cashupId, GROSS);
+
+      final ArrayList<FinFinaccTransactionRow> receipt2Transactions = WebPOSDatabaseHelper
+          .getSaleTransactions(documentNo2, cashupId, null, 1);
+      assertThat(receipt2Transactions.get(0).paymentamt, equalTo(OBNumber.ZERO));
+      assertThat(receipt2Transactions.get(0).depositamt, equalTo(PARTIALPAYMENT1));
+
+      cashupVBS1002();
+
+    } else if (getTerminal().equals(VBS1003)) {
+
+      addCash();
+      // 2. Retrieve the layaway and void it
+      retrieveLayawayAndVoid();
+      final String organizationId = BackboneHelper.getTerminalValue("organization");
+      final String clientId = BackboneHelper.getTerminalValue("client");
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+
+      cashupVBS1003();
+
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId,
+          GROSS.negativeSign(), OBNumber.ZERO, NET.negativeSign(), OBNumber.ZERO,
+          GROSS.negativeSign());
+    } else {
+      fail(String.format("This terminal ('%s') is missing its test", getTerminal()));
+    }
+  }
+
+  private void addCash() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_CASHMANAGEMENT);
+    verify(TestId.LABEL_CASHMANAGEMENT_TITLE, "Cash Management");
+    WebPOSSnippet.tapKeypad(this, CASHDEPOSIT.intValue());
+    tap(TestId.BUTTON_CASHMANAGEMENT_CASHDEPOSIT);
+    verify(TestId.LABEL_SELECTDEPOSIT_BACOFFICEVBS, "Backoffice transfer to VBS");
+    tap(TestId.BUTTON_SELECTDEPOSIT_BACOFFICEVBS);
+    verify(TestId.LABEL_CASHMANAGEMENT_ROW1_AMOUNT, CASHDEPOSIT);
+    verify(TestId.LABEL_CASHMANAGEMENT_ROW1_DESCRIPTION,
+        "Deposit: Cash - Backoffice transfer to VBS");
+    tap(TestId.BUTTON_CASHMANAGEMENT_DONE);
+    verify(TestId.LABEL_POPUP_TITLE, "Done");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1002() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_CASHUP);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // step 2 of 5
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // step 3 of 5
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASH_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // step 4 of 5
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    verify(TestId.LABEL_CASHUP_NETSALES_AMOUNT, OBNumber.ZERO);
+    // verify(TestId.LABEL_CASHUP_NETSALES_TAX21, OBNumber.ZERO);
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, Format.floatToWebPOSFloat(TOTALTAXES));
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, OBNumber.ZERO);
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, Format.floatToWebPOSFloat(TOTALTAXESRETURNS));
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, PARTIALPAYMENT1);
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, PARTIALPAYMENT1);
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, PARTIALPAYMENT1);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, PARTIALPAYMENT1);
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+  }
+
+  private void retrieveLayawayAndVoid() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    isDisabled(TestId.BUTTON_PAY, false);
+    verify(TestId.LABEL_TOTALTOPAY, "7.80");
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_VOIDLAYAWAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+  }
+
+  private void createLayaway() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+    verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_MOUNTAINEERING);
+    tap(TestId.BUTTON_PRODUCT_MOUNTAINEERING_DESCENDERCLASSIC);
+    documentNo1 = BackboneHelper.getDocumentNo();
+    customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    verify(TestId.LABEL_TOTALTOPAY, "7.80");
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+  }
+
+  private void retrieveLayaway1AndPay5() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    verify(TestId.LABEL_TOTALTOPAY, GROSS);
+    documentNo2 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, GROSS.toString() + "€");
+    WebPOSSnippet.tapKeypad(this, PARTIALPAYMENT1.intValue());
+    tap(TestId.BUTTON_CASH);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, PARTIALPAYMENT2.toString() + "€");
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+  }
+
+  private void cashupVBS1001() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, OBNumber.ZERO);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, OBNumber.ZERO);
+    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_AMOUNT, "6.45");
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "1.35");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, "7.80");
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, OBNumber.ZERO);
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, "7.80");
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, OBNumber.ZERO);
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+  }
+
+  private void cashupVBS1003() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, CASHDEPOSIT.subtract(PARTIALPAYMENT1));
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, CASHDEPOSIT.subtract(PARTIALPAYMENT1)
+        .negativeSign());
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_50);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_20);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_20);
+    tap(TestId.BUTTON_CASHUP_COUNTCASH_5);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, OBNumber.ZERO);
+    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_AMOUNT, NET.negativeSign());
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, TAXES.negativeSign());
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, GROSS.negativeSign());
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, OBNumber.ZERO);
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, GROSS.negativeSign());
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, PARTIALPAYMENT1);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, PARTIALPAYMENT1);
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, CASHDEPOSIT);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, CASHDEPOSIT);
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, CASHDEPOSIT.subtract(PARTIALPAYMENT1));
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, CASHDEPOSIT.subtract(PARTIALPAYMENT1));
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH,CASHDEPOSIT.subtract(PARTIALPAYMENT1));
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, CASHDEPOSIT.subtract(PARTIALPAYMENT1));
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, OBNumber.ZERO);
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, CASHDEPOSIT.subtract(PARTIALPAYMENT1));
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL,CASHDEPOSIT.subtract(PARTIALPAYMENT1));
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, OBNumber.ZERO);
+  }
+
+  private void verifyThereIsNoTransaction(final String organizationId, final String clientId,
+      final String cashupId, final String documentNo) {
+    final String c_order = String
+        .format(
+            "SELECT"
+                + " COUNT(*) AS counted"
+                + " FROM c_order"
+                + " INNER JOIN fin_payment_schedule ON c_order.c_order_id = fin_payment_schedule.c_order_id"
+                + " INNER JOIN fin_payment_scheduledetail ON fin_payment_schedule.fin_payment_schedule_id = fin_payment_scheduledetail.fin_payment_schedule_order"
+                + " INNER JOIN fin_payment_detail ON fin_payment_scheduledetail.fin_payment_detail_id = fin_payment_detail.fin_payment_detail_id"
+                + " INNER JOIN fin_payment ON fin_payment_detail.fin_payment_id = fin_payment.fin_payment_id"
+                + " INNER JOIN fin_finacc_transaction ON fin_payment.fin_payment_id = fin_finacc_transaction.fin_payment_id"
+                + " WHERE c_order.documentno='%s'", documentNo);
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(0));
+      }
+    }.execute(c_order, 1);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/layaway/Layaway_Cre1Void2.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,347 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.layaway;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.fail;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+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.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.OBNumber;
+
+/**
+ * Create a layaway in terminal 1001, void in 1002
+ */
+@RunWith(Parameterized.class)
+public class Layaway_Cre1Void2 extends WebPOSTerminalHelper {
+
+  private static final String VBS1001 = "VBS1001";
+  private static final String VBS1002 = "VBS1002";
+  private static final OBNumber NET = new OBNumber("6.45");
+  private static final OBNumber TAXES = new OBNumber("1.35");
+  private static final OBNumber GROSS = NET.add(TAXES);
+  private static final OBNumber CASHDEPOSIT = new OBNumber("100.00");
+  private static String documentNo1;
+  private static String customer;
+
+  @Parameters(name = "({index}) terminal: {0}")
+  public static Collection<String[]> getTestParameters() {
+    final ArrayList<String[]> parameters = new ArrayList<String[]>();
+    parameters.add(new String[] { VBS1001 });
+    parameters.add(new String[] { VBS1002 });
+    return parameters;
+  }
+
+  public Layaway_Cre1Void2(final String terminal) {
+    super(terminal, "vallblanca", "openbravo");
+  }
+
+  @Test
+  public void test() {
+    WebPOSSnippet.cleanCashup(this);
+
+    if (getTerminal().equals(VBS1001)) {
+
+      // 1. Create a layaway in one terminal and cashup
+      createLayaway();
+      final String organizationId = BackboneHelper.getTerminalValue("organization");
+      final String clientId = BackboneHelper.getTerminalValue("client");
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+      WebPOSDatabaseHelper.verifyOrder(documentNo1, cashupId, GROSS);
+      verifyThereIsNoTransaction(organizationId, clientId, cashupId, documentNo1);
+
+      cashupVBS1001();
+
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId, GROSS,
+          OBNumber.ZERO, NET, OBNumber.ZERO, GROSS);
+      WebPOSDatabaseHelper.verifyCashupTaxes(cashupId, TAXES, 0);
+
+    } else if (getTerminal().equals(VBS1002)) {
+
+      addCash();
+      // 2. Retrieve the layaway and void it
+      retrieveLayawayAndVoid();
+      final String organizationId = BackboneHelper.getTerminalValue("organization");
+      final String clientId = BackboneHelper.getTerminalValue("client");
+      final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+
+      cashupVBS1002();
+
+      WebPOSDatabaseHelper.verifyCashupTable(organizationId, clientId, cashupId,
+          GROSS.negativeSign(), OBNumber.ZERO, NET.negativeSign(), OBNumber.ZERO,
+          GROSS.negativeSign());
+
+    } else {
+      fail(String.format("This terminal ('%s') is missing its test", getTerminal()));
+    }
+  }
+
+  private void addCash() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_CASHMANAGEMENT);
+    verify(TestId.LABEL_CASHMANAGEMENT_TITLE, "Cash Management");
+    WebPOSSnippet.tapKeypad(this, CASHDEPOSIT.intValue());
+    tap(TestId.BUTTON_CASHMANAGEMENT_CASHDEPOSIT);
+    verify(TestId.LABEL_SELECTDEPOSIT_BACOFFICEVBS, "Backoffice transfer to VBS");
+    tap(TestId.BUTTON_SELECTDEPOSIT_BACOFFICEVBS);
+    verify(TestId.LABEL_CASHMANAGEMENT_ROW1_AMOUNT, CASHDEPOSIT);
+    verify(TestId.LABEL_CASHMANAGEMENT_ROW1_DESCRIPTION,
+        "Deposit: Cash - Backoffice transfer to VBS");
+    tap(TestId.BUTTON_CASHMANAGEMENT_DONE);
+    verify(TestId.LABEL_POPUP_TITLE, "Done");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void verifyThereIsNoTransaction(final String organizationId, final String clientId,
+      final String cashupId, final String documentNo) {
+    final String c_order = String
+        .format(
+            "SELECT"
+                + " COUNT(*) AS counted"
+                + " FROM c_order"
+                + " INNER JOIN fin_payment_schedule ON c_order.c_order_id = fin_payment_schedule.c_order_id"
+                + " INNER JOIN fin_payment_scheduledetail ON fin_payment_schedule.fin_payment_schedule_id = fin_payment_scheduledetail.fin_payment_schedule_order"
+                + " INNER JOIN fin_payment_detail ON fin_payment_scheduledetail.fin_payment_detail_id = fin_payment_detail.fin_payment_detail_id"
+                + " INNER JOIN fin_payment ON fin_payment_detail.fin_payment_id = fin_payment.fin_payment_id"
+                + " INNER JOIN fin_finacc_transaction ON fin_payment.fin_payment_id = fin_finacc_transaction.fin_payment_id"
+                + " WHERE c_order.documentno='%s'", documentNo);
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getInt("counted"), equalTo(0));
+      }
+    }.execute(c_order, 1);
+  }
+
+  private void createLayaway() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYTHISRECEIPT);
+    verify(TestId.LABEL_RECEIPT_TYPE, "To be laid away");
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_MOUNTAINEERING);
+    tap(TestId.BUTTON_PRODUCT_MOUNTAINEERING_DESCENDERCLASSIC);
+    documentNo1 = BackboneHelper.getDocumentNo();
+    customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    verify(TestId.LABEL_TOTALTOPAY, "7.80");
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_LAYAWAY);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void retrieveLayawayAndVoid() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_LAYAWAYS);
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo1);
+    tap(TestId.BUTTON_LAYAWAYS_SEARCH);
+    tap(TestId.TABLE_RECEIPTSEARCH, String.format("%s - %s", documentNo1, customer));
+    verify(TestId.LABEL_RECEIPT_COUNTER, "1");
+    isDisabled(TestId.BUTTON_PAY, false);
+    verify(TestId.LABEL_TOTALTOPAY, "7.80");
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_VOIDLAYAWAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1001() {
+    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");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, "0.00");
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    // step 3 of 5
+    verify(TestId.LABEL_CASHUP_STEP3_TITLE, "Step 3 of 5: Count Cash");
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    verify(TestId.LABEL_CASHUP_TOTALCOUNTED, "0.00");
+    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_AMOUNT, "6.45");
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, "1.35");
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, "7.80");
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, "0.00");
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, "1.35");
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, "7.80");
+
+    verify(TestId.LABEL_CASHUP_STARTING_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_STARTING_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_EXPECTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_EXPECTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_COUNTED_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_COUNTED_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, "0.00");
+
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CARD, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASH, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSAFOREIGN, "");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_CASHUSA, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_VOUCHER, "0.00");
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, "0.00");
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+
+    // done
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+  private void cashupVBS1002() {
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_CASHUP);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // step 2 of 5
+    verify(TestId.LABEL_CASHUP_STEP2_TITLE, "Step 2 of 5: Count Cash");
+    verify(TestId.LABEL_CASHUP_COUNTCASH_TOTAL, CASHDEPOSIT);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_COUNTED, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_COUNTCASH_REMAINING, CASHDEPOSIT.negativeSign());
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // step 3 of 5
+    tap(TestId.BUTTON_CASHUP_CARD_OK);
+    tap(TestId.BUTTON_CASHUP_CASH_OK);
+    tap(TestId.BUTTON_CASHUP_CASHUSA_OK);
+    tap(TestId.BUTTON_CASHUP_VOUCHER_OK);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    // step 4 of 5
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+    tap(TestId.BUTTON_CASHUP_KEEPNOTHING);
+    tap(TestId.BUTTON_CASHUP_NEXT);
+
+    verify(TestId.LABEL_CASHUP_NETSALES_AMOUNT, NET.negativeSign());
+    verify(TestId.LABEL_CASHUP_NETSALES_TAX21, TAXES.negativeSign());
+    // verify(TestId.LABEL_CASHUP_NETSALES_2_TAX21, Format.floatToWebPOSFloat(TOTALTAXES));
+    verify(TestId.LABEL_CASHUP_GROSSSALES_AMOUNT, GROSS.negativeSign());
+    verify(TestId.LABEL_CASHUP_NETRETURNS_AMOUNT, OBNumber.ZERO);
+    // verify(TestId.LABEL_CASHUP_NETRETURMS_TAX21, Format.floatToWebPOSFloat(TOTALTAXESRETURNS));
+    verify(TestId.LABEL_CASHUP_GROSSRETURNS_AMOUNT, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTRASACTIONS, GROSS.negativeSign());
+
+    verify(TestId.LABEL_CASHUP_STARTING_TOTAL, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_WITHDRAWAL_TOTAL, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_DEPOSIT_TOTAL, CASHDEPOSIT);
+    verify(TestId.LABEL_CASHUP_EXPECTED_TOTAL, CASHDEPOSIT);
+    verify(TestId.LABEL_CASHUP_COUNTED_TOTAL, CASHDEPOSIT);
+    verify(TestId.LABEL_CASHUP_DIFFERENCE_TOTAL, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTOKEEP_TOTAL, OBNumber.ZERO);
+    verify(TestId.LABEL_CASHUP_TOTALTODEPOSIT_TOTAL, CASHDEPOSIT);
+
+    tap(TestId.BUTTON_CASHUP_POSTPRINTANDCLOSE);
+    verify(TestId.LABEL_POPUP_TITLE, "Good job!");
+    tap(TestId.BUTTON_POPUP_OK);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/sales/CreateSaleVerifyingDatabaseFields.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,69 @@
+/*
+ *************************************************************************
+ * 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) 2014 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.sales;
+
+import org.junit.Test;
+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;
+
+public class CreateSaleVerifyingDatabaseFields extends WebPOSTerminalHelper {
+
+  @Test
+  public void test() {
+    // create sale
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_BACKPACKSANDTRAVEL);
+    verify(TestId.LABEL_PRODUCT_BACKPACKSANDTRAVEL_BASECAMPDUFFEL_PRICE, "89.50");
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_BASECAMPDUFFEL);
+    // verify receipt
+    verify(TestId.LABEL_TOTALTOPAY, "89.50");
+
+    final String organizationId = BackboneHelper.getTerminalValue("organization");
+    final String clientId = BackboneHelper.getTerminalValue("client");
+    final String cashupId = BackboneHelper.getTerminalValue("cashUpId");
+
+    verify(TestId.LABEL_RECEIPT_ROW1_TITLE, "Base camp duffel 70 L");
+    verify(TestId.LABEL_RECEIPT_ROW1_QTY, "1");
+    verify(TestId.LABEL_RECEIPT_ROW1_AMOUNT, "89.50");
+    verify(TestId.LABEL_RECEIPT_TOTAL_GROSS, "89.50");
+
+    // verify taxes
+    verify(TestId.LABEL_RECEIPT_TAX_ROW1_TITLE, "Entregas IVA 21%");
+    verify(TestId.LABEL_RECEIPT_TAX_ROW1_NET, "73.97");
+    verify(TestId.LABEL_RECEIPT_TAX_ROW1_TOTALTAX, "15.53");
+
+    final String documentNo = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_PAY);
+    verify(TestId.LABEL_RECEIPT_PAY_REMAINING, "89.50€");
+    tap(TestId.BUTTON_CARD);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+
+    WebPOSDatabaseHelper.verifyCOrder(documentNo, organizationId, clientId, 73.97F, 89.50F,
+        cashupId);
+
+    WebPOSDatabaseHelper.verifyFinFinaccTransaction(organizationId, clientId, documentNo, 0,
+        89.50F, "RDNC", cashupId, null);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/sales/SaleAndReturnInvoicedVerifyingDatabase.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,224 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.sales;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.fail;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.TestAnnotations;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+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.utils.Format;
+
+public class SaleAndReturnInvoicedVerifyingDatabase extends WebPOSTerminalHelper {
+
+  private static final float NET1 = 23.64F;
+  private static final float GROSS1 = 28.60F;
+  private static final float NET2 = 216.37F;
+  private static final float GROSS2 = 261.81F;
+
+  private static final String invoiceLinesSql = "SELECT" //
+      + " m_product.name," //
+      + " c_invoiceline.linenetamt," //
+      + " c_invoiceline.taxamt," //
+      + " c_invoiceline.line_gross_amount," //
+      + " c_invoiceline.qtyinvoiced," //
+      + " c_invoiceline.priceactual," //
+      + " c_invoiceline.gross_unit_price" //
+      + " FROM c_invoiceline" //
+      + " INNER JOIN c_invoice ON c_invoiceline.c_invoice_id = c_invoice.c_invoice_id" //
+      + " INNER JOIN c_orderline ON c_invoiceline.c_orderline_id = c_orderline.c_orderline_id" //
+      + " INNER JOIN c_order ON c_orderline.c_order_id = c_order.c_order_id" //
+      + " INNER JOIN m_product ON c_orderline.m_product_id = m_product.m_product_id" //
+      + " WHERE c_invoice.documentno = '%s'" //
+      + " ORDER BY c_invoiceline.created DESC";
+
+  @Test
+  @TestAnnotations(waitFixOf = 28983)
+  public void test() {
+
+    final String organizationId = BackboneHelper.getTerminalValue("organization");
+    final String clientId = BackboneHelper.getTerminalValue("client");
+
+    // sale
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_BACKPACKSANDTRAVEL);
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_ADHESIVEBODYWARNMERS);
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_SUNCREAMLIPSTICK);
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_SUNCREAMLIPSTICK);
+    tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_SUNCREAMLIPSTICK);
+    verify(TestId.LABEL_TOTALTOPAY, Format.floatToWebPOSFloat(GROSS1));
+    final String documentNo1 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_INVOICETHISRECEIPT);
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+
+    // sale
+    tap(TestId.BUTTON_BROWSE);
+    tap(TestId.BUTTON_CATEGORY_LIGHTINGANDELECTRONICS);
+    tap(TestId.BUTTON_PRODUCT_LIGHTINGANDELECTRONICS_GPSHANDHELD);
+    verify(TestId.LABEL_TOTALTOPAY, Format.floatToWebPOSFloat(GROSS2));
+    final String documentNo2 = BackboneHelper.getDocumentNo();
+    final String customer = get(TestId.BUTTON_RECEIPT_CUSTOMER);
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_INVOICETHISRECEIPT);
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+
+    // return the sale
+    tap(TestId.BUTTON_MENU);
+    verify(TestId.LABEL_MENU_VERIFIEDRETURN, "Verified Returns");
+    tap(TestId.BUTTON_MENU_VERIFIEDRETURN);
+    verify(TestId.LABEL_VERIFIEDRETURNS_TITLE, "Receipts");
+    write(TestId.FIELD_SEARCH_RECEIPT, documentNo2);
+    tap(TestId.BUTTON_VERIFIEDRETURNS_SEARCH);
+    verify(TestId.LABEL_VERIFIEDRETURNS_ROW1_TITLE, String.format("%s - %s", documentNo2, customer));
+    tap(TestId.BUTTON_VERIFIEDRETURNS_ROW1);
+    verify(TestId.LABEL_POPUP_DOCUMENTNO, documentNo2);
+    tap(TestId.BUTTON_POPUP_CHECKALL);
+    verify(TestId.BUTTON_POPUP_APPLY, "Apply");
+    tap(TestId.BUTTON_POPUP_APPLY);
+    verify(TestId.LABEL_TOTALTOPAY, Format.floatToWebPOSFloat(-GROSS2));
+    final String documentNo3 = BackboneHelper.getDocumentNo();
+    tap(TestId.BUTTON_MENU);
+    tap(TestId.BUTTON_MENU_INVOICETHISRECEIPT);
+    tap(TestId.BUTTON_PAY);
+    tap(TestId.BUTTON_PAY_EXACT);
+    tap(TestId.BUTTON_PAY_DONE);
+    verify(TestId.LABEL_TOTALTOPAY, "0.00");
+
+    final String invoiceNo1 = verifyInvoice(documentNo1, organizationId, clientId, NET1, GROSS1);
+    verifyInvoiceLines1(invoiceNo1);
+
+    final String invoiceNo2 = verifyInvoice(documentNo2, organizationId, clientId, NET2, GROSS2);
+    verifyInvoiceLines2(invoiceNo2);
+
+    final String invoiceNo3 = verifyInvoice(documentNo3, organizationId, clientId, -NET2, -GROSS2);
+    verifyInvoiceLines3(invoiceNo3);
+  }
+
+  /**
+   * @return the invoiceNo
+   */
+  private String verifyInvoice(final String documentNo, final String organizationId,
+      final String clientId, final float net, final float gross) {
+    final String sql = String.format("SELECT" //
+        + " c_invoice.ad_org_id,"//
+        + " c_invoice.ad_client_id,"//
+        + " c_invoice.documentno,"//
+        + " c_invoice.totallines," //
+        + " c_invoice.grandtotal," //
+        + " c_invoice.totalpaid," //
+        + " c_invoice.outstandingamt" //
+        + " FROM c_invoice" //
+        + " INNER JOIN c_order ON c_invoice.c_order_id = c_order.c_order_id" //s
+        + " WHERE c_order.documentno = '%s'", documentNo);
+    final ArrayList<String> retrieveValue = new ArrayList<String>();
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        retrieveValue.add(rs.getString("documentno"));
+        assertThat(rs.getString("ad_org_id"), equalTo(organizationId));
+        assertThat(rs.getString("ad_client_id"), equalTo(clientId));
+        assertThat(rs.getFloat("totallines"), equalTo(net));
+        assertThat(rs.getFloat("grandtotal"), equalTo(gross));
+        assertThat(rs.getFloat("totalpaid"), equalTo(gross));
+        assertThat(rs.getFloat("outstandingamt"), equalTo(0F));
+      }
+    }.execute(sql, 1);
+
+    return retrieveValue.get(0);
+  }
+
+  private void verifyInvoiceLines1(final String invoiceNo) {
+    new DatabaseHelperSelect() {
+      int count = 0;
+
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        switch (count) {
+        case 0:
+          assertThat(rs.getString("name"), equalTo("Adhesive body warmers"));
+          assertThat(rs.getFloat("linenetamt"), equalTo(2.98F));
+          assertThat(rs.getFloat("taxamt"), equalTo(0.62F));
+          assertThat(rs.getFloat("line_gross_amount"), equalTo(3.6F));
+          assertThat(rs.getFloat("qtyinvoiced"), equalTo(1F));
+          assertThat(rs.getFloat("priceactual"), equalTo(2.98F));
+          assertThat(rs.getFloat("gross_unit_price"), equalTo(3.6F));
+          break;
+        case 1:
+          assertThat(rs.getString("name"), equalTo("Sun cream + lip stick"));
+          assertThat(rs.getFloat("linenetamt"), equalTo(20.66F));
+          assertThat(rs.getFloat("taxamt"), equalTo(6.51F));
+          assertThat(rs.getFloat("line_gross_amount"), equalTo(25F));
+          assertThat(rs.getFloat("qtyinvoiced"), equalTo(3F));
+          assertThat(rs.getFloat("priceactual"), equalTo(6.89F));
+          assertThat(rs.getFloat("gross_unit_price"), equalTo(8.33F));
+          break;
+        default:
+          throw new IllegalArgumentException();
+        }
+        count++;
+      }
+    }.execute(String.format(invoiceLinesSql, invoiceNo), 2);
+  }
+
+  private void verifyInvoiceLines2(final String invoiceNo) {
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getString("name"), equalTo("GPS handheld"));
+        assertThat(rs.getFloat("linenetamt"), equalTo(NET2));
+        assertThat(rs.getFloat("taxamt"), equalTo(50.49F));
+        assertThat(rs.getFloat("line_gross_amount"), equalTo(GROSS2));
+        assertThat(rs.getFloat("qtyinvoiced"), equalTo(1F));
+        assertThat(rs.getFloat("priceactual"), equalTo(NET2));
+        assertThat(rs.getFloat("gross_unit_price"), equalTo(GROSS2));
+      }
+    }.execute(String.format(invoiceLinesSql, invoiceNo), 1);
+  }
+
+  private void verifyInvoiceLines3(final String invoiceNo) {
+    new DatabaseHelperSelect() {
+      @Override
+      protected void yieldResultSet(final ResultSet rs) throws SQLException {
+        assertThat(rs.getString("name"), equalTo("GPS handheld"));
+        fail("Not yet implemented");
+      }
+    }.execute(String.format(invoiceLinesSql, invoiceNo), 1);
+  }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/todo/MultiterminalMulticurrencyLayaways.java	Fri Feb 27 10:00:33 2015 +0100
@@ -0,0 +1,37 @@
+/*
+ *************************************************************************
+ * 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-2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAL
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.todo;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.selenium.terminals.WebPOSTerminalHelper;
+
+public class MultiterminalMulticurrencyLayaways extends WebPOSTerminalHelper {
+  
+  @Test
+  public void test() {
+    fail("Not yet implemented");
+  }
+  
+}