Attached Files | issue 37600 posterminal.patch [^] (2,771 bytes) 2018-01-12 13:48 [Show Content] [Hide Content]# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1515761219 -19800
# Fri Jan 12 18:16:59 2018 +0530
# Node ID 791191d978f5814431b8d249cce2cbeb9c507dbe
# Parent 048104daf8b38e76547d65c673a9f812420d323e
Related to issue 37600 : Add locations attributes to bp model while creating new customer
diff -r 048104daf8b3 -r 791191d978f5 web/org.openbravo.retail.posterminal/js/data/datacustomersave.js
--- a/web/org.openbravo.retail.posterminal/js/data/datacustomersave.js Wed Jan 10 15:56:16 2018 +0100
+++ b/web/org.openbravo.retail.posterminal/js/data/datacustomersave.js Fri Jan 12 18:16:59 2018 +0530
@@ -97,6 +97,40 @@
bpToSave.set('c_bpartner_id', customer.get('id'));
} else {
isNew = true;
+ var shipping, billing, locations = [];
+ billing = new OB.Model.BPLocation();
+ billing.set('id', customer.get('locId'));
+ billing.set('bpartner', customer.get('id'));
+ billing.set('name', customer.get('locName'));
+ billing.set('postalCode', customer.get('postalCode'));
+ billing.set('cityName', customer.get('cityName'));
+ billing.set('_identifier', customer.get('locName'));
+ billing.set('countryName', customer.get('countryName'));
+ billing.set('countryId', customer.get('countryId'));
+ if (customer.get('useSameAddrForShipAndInv')) {
+ billing.set('isBillTo', true);
+ billing.set('isShipTo', true);
+ shipping = billing;
+ locations.push(billing);
+ } else {
+ billing.set('isBillTo', true);
+ billing.set('isShipTo', false);
+ shipping = new OB.Model.BPLocation();
+ shipping.set('id', customer.get('shipLocId'));
+ shipping.set('bpartner', customer.get('id'));
+ shipping.set('name', customer.get('shipLocName'));
+ shipping.set('postalCode', customer.get('shipPostalCode'));
+ shipping.set('cityName', customer.get('shipCityName'));
+ shipping.set('_identifier', customer.get('shipLocName'));
+ shipping.set('countryName', customer.get('shipCountryName'));
+ shipping.set('countryId', customer.get('shipCountryId'));
+ shipping.set('isBillTo', false);
+ shipping.set('isShipTo', true);
+ locations.push(billing);
+ locations.push(shipping);
+ }
+ customer.set('locations', locations);
+ customer.setBPLocations(shipping, billing, shipping);
}
// if the bp is already used in one of the orders then update locally also
updateLocally = !OB.MobileApp.model.hasPermission('OBPOS_remote.customer', true) || (!isNew && OB.MobileApp.model.orderList && _.filter(OB.MobileApp.model.orderList.models, function (order) {
issue 37600 test.patch [^] (7,921 bytes) 2018-01-17 11:37 [Show Content] [Hide Content]# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1516185182 -19800
# Wed Jan 17 16:03:02 2018 +0530
# Node ID 885786282edf69a8b84a7b38503dc3e9c5d4b0eb
# Parent b5147a78530d9cf02a672d58d0649270c679abd9
Verifies issue 37571 : Added automated test 'I37571_VerifyReceiptWithPaymentTermLine'
diff -r b5147a78530d -r 885786282edf src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/offline/I37600_VerifyNewCustomerReceipt.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/offline/I37600_VerifyNewCustomerReceipt.java Wed Jan 17 16:03:02 2018 +0530
@@ -0,0 +1,163 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.0 (the "License"), being the Mozilla Public License
+ * Version 1.1 with a permitted attribution clause; you may not use this
+ * file except in compliance with the License. You may obtain a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo S.L.U.
+ * All portions are Copyright (C) 2018 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAN
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.offline;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.core.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.core.utils.OBConstants;
+import org.openbravo.test.mobile.core.utils.OBUtils;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.retail.mobilecore.javascript.BackboneHelper;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+
+public class I37600_VerifyNewCustomerReceipt extends WebPOSOfflineCustomTerminalHelper {
+
+ private final String prefRemoteCustomer = "OBPOS_remote.customer";
+ private final String prefRemoteCustomerDisc = "OBPOS_remote.discount.bp";
+
+ @Test
+ public void test() {
+ enablePrefernece(prefRemoteCustomer, true);
+ enablePrefernece(prefRemoteCustomerDisc, true);
+
+ goOffline();
+ final String customerName = "Cus" + System.currentTimeMillis();
+ final String lastName = "Offline";
+ final String expectedBPName = customerName + " " + lastName;
+ final String addressName = "AddrOffline" + System.currentTimeMillis();
+ tap(TestIdPack.BUTTON_RECEIPT_CUSTOMER);
+ tap(TestIdPack.BUTTON_CUSTOMER_NEW);
+ write(TestIdPack.FIELD_CUSTOMER_NAME, customerName);
+ write(TestIdPack.FIELD_CUSTOMER_LASTNAME, lastName);
+ write(TestIdPack.FIELD_CUSTOMER_ADDRESS_INV_NAME, addressName);
+ tap(TestIdPack.BUTTON_CUSTOMER_SAVE);
+ OBUtils.pause(OBConstants.WAIT_FORDATABASESYNCHRONIZATION);
+ tap(TestIdPack.BUTTON_CUSTOMER_ASSIGNTOCUSTOMER);
+ verify(TestIdPack.BUTTON_RECEIPT_CUSTOMER, expectedBPName);
+
+ tap(TestIdPack.BUTTON_SEARCH);
+ write(TestIdPack.FIELD_SEARCH_TEXT,
+ TestIdPack.BUTTON_SEARCHPRODUCT_ADHESIVEBODYWARNMERS.getRowName());
+ tap(TestIdPack.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdPack.BUTTON_SEARCHPRODUCT_ADHESIVEBODYWARNMERS);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "3.60");
+ write(TestIdPack.FIELD_SEARCH_TEXT,
+ TestIdPack.BUTTON_SEARCHPRODUCT_BASECAMPLANTERN.getRowName());
+ tap(TestIdPack.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdPack.BUTTON_SEARCHPRODUCT_BASECAMPLANTERN);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "59.10");
+
+ final String receiptNo = BackboneHelper.getDocumentNo();
+ tap(TestIdPack.BUTTON_PAY);
+ tap(TestIdPack.BUTTON_PAY_EXACT);
+ tap(TestIdPack.BUTTON_PAY_DONE);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+ goOnline(false, false);
+ OBUtils.pause(3000);
+
+ enablePrefernece(prefRemoteCustomer, false);
+ enablePrefernece(prefRemoteCustomerDisc, false);
+
+ verifyInDatabase(receiptNo, customerName, expectedBPName, addressName);
+ }
+
+ private void enablePrefernece(String pref, boolean enable) {
+ System.out.println(String.format("OB.MobileApp.model.attributes.permissions['%s'] = %s;", pref,
+ enable));
+ SeleniumHelper.executeScript(String.format(
+ "OB.MobileApp.model.attributes.permissions['%s'] = %s;", pref, enable));
+ }
+
+ public void verifyInDatabase(final String receiptNo, final String customerName,
+ final String expectedBPName, final String addressName) {
+ // check bp
+ final String bpSql = "SELECT name FROM c_bpartner WHERE c_bpartner_id IN (SELECT c_bpartner_id FROM c_order WHERE documentno = '"
+ + receiptNo + "')";
+ new DatabaseHelperSelect() {
+
+ @Override
+ protected void yieldResultSet(final ResultSet rs) throws SQLException {
+ final String foundName = rs.getString("name");
+
+ logger.info(String.format("Verifying that the database record %s is the expected %s",
+ foundName, customerName));
+ assertThat("The bp name is not the expected", foundName, equalTo(expectedBPName));
+ }
+ }.execute(bpSql, 1);
+
+ // check address
+ final String bpLocationSql = "SELECT name FROM c_bpartner_location WHERE c_bpartner_location_id IN (SELECT c_bpartner_location_id FROM c_order WHERE documentno = '"
+ + receiptNo + "')";
+ new DatabaseHelperSelect() {
+
+ @Override
+ protected void yieldResultSet(final ResultSet rs) throws SQLException {
+ final String foundName = rs.getString("name");
+
+ logger.info(String.format("Verifying that the database record %s is the expected %s",
+ foundName, customerName));
+ assertThat("The address name is not the expected", foundName, equalTo(addressName));
+ }
+ }.execute(bpLocationSql, 1);
+
+ // check products
+ final String sql = "SELECT m_product_id, name FROM m_product WHERE m_product_id IN (SELECT m_product_id FROM c_orderline WHERE c_order_id IN (SELECT c_order_id FROM c_order WHERE documentno = '"
+ + receiptNo + "')) ORDER BY name";
+ new DatabaseHelperSelect() {
+ int count = 0;
+
+ @Override
+ protected void yieldResultSet(final ResultSet rs) throws SQLException {
+ count++;
+ final String productId = rs.getString("m_product_id");
+ final String productName = rs.getString("name");
+
+ logger.info(String.format(
+ "Verifying that the database record (%s) '%s' is one of the expected", productId,
+ productName));
+ switch (count) {
+ case 1:
+ assertThat("The product name is not one of the expected", productName,
+ equalTo(TestIdPack.BUTTON_SEARCHPRODUCT_ADHESIVEBODYWARNMERS.getRowName()));
+ assertThat("The 'productId' is not one of the expected", productId,
+ equalTo("AC79520FEB4743B3AAA379BF70B9B7DA"));
+ break;
+ case 2:
+ assertThat("The product name is not one of the expected", productName,
+ equalTo(TestIdPack.BUTTON_SEARCHPRODUCT_BASECAMPLANTERN.getRowName()));
+ assertThat("The 'productId' is not one of the expected", productId,
+ equalTo("772EE3421FE84D768A674840C2EB855B"));
+ break;
+ default:
+ throw new IllegalArgumentException("The returned resulset is missing the assertions");
+ }
+ }
+ }.execute(sql, 2);
+ }
+}
|