Project:
View Issue Details[ Jump to Notes ] | [ Issue History ] [ Print ] | |||||||||||
ID | ||||||||||||
0031592 | ||||||||||||
Type | Category | Severity | Reproducibility | Date Submitted | Last Update | |||||||
defect | [Retail Modules] Web POS | minor | always | 2015-11-26 09:17 | 2016-05-16 10:23 | |||||||
Reporter | marvintm | View Status | public | |||||||||
Assigned To | simbu94 | |||||||||||
Priority | normal | Resolution | open | Fixed in Version | ||||||||
Status | scheduled | Fix in branch | Fixed in SCM revision | |||||||||
Projection | none | ETA | none | Target Version | ||||||||
OS | Any | Database | Any | Java version | ||||||||
OS Version | Database version | Ant version | ||||||||||
Product Version | SCM revision | |||||||||||
Review Assigned To | ||||||||||||
Regression level | ||||||||||||
Regression date | ||||||||||||
Regression introduced in release | ||||||||||||
Regression introduced by commit | ||||||||||||
Triggers an Emergency Pack | No | |||||||||||
Summary | 0031592: It should be possible to create payments in receipts which come from a different store | |||||||||||
Description | Currently, it is not possible to add a payment to a layaway which was created in another store. It's also not possible to return a receipt created in a different store. The idea is to add the ability to configure which is the "cross-store organization" of a store. In this way, also in a way which is configurable, terminals will be able to see receipts of stores which belong to the natural tree of this cross-store organization. Also in this way, if a terminal adds payments to a receipt (layaway) which comes from a different store, the payments will be created in this cross-store organization. | |||||||||||
Steps To Reproduce | . | |||||||||||
Tags | No tags attached. | |||||||||||
Attached Files | crossStore.patch [^] (11,199 bytes) 2015-12-08 10:54 [Show Content] [Hide Content]# HG changeset patch # User Silambarasan Sekar <silambarasan@qualiantech.com> # Date 1449568877 -19800 # Node ID b6e3a1173ed85f61d37cbc6fe43a7326d59493cd # Parent 91c5d64f5a26beb795e71f29da98221e494ca716 [Cross Store Payment] Implementation of cross store payment, Checkbox in Pay open tickets and Layaway selectors. diff --git a/src/org/openbravo/retail/posterminal/CashCloseProcessor.java b/src/org/openbravo/retail/posterminal/CashCloseProcessor.java --- a/src/org/openbravo/retail/posterminal/CashCloseProcessor.java +++ b/src/org/openbravo/retail/posterminal/CashCloseProcessor.java @@ -122,7 +122,8 @@ OBDal.getInstance().save(depositTransaction); } } - associateTransactions(paymentType, reconciliation, cashUpId, cashMgmtIds, slaveCashupIds); + associateTransactions(posTerminal, paymentType, reconciliation, cashUpId, cashMgmtIds, + slaveCashupIds); } for (FIN_Reconciliation reconciliation : arrayReconciliations) { @@ -175,7 +176,7 @@ return next; } - protected void associateTransactions(OBPOSAppPayment paymentType, + protected void associateTransactions(OBPOSApplications posTerminal, OBPOSAppPayment paymentType, FIN_Reconciliation reconciliation, String cashUpId, JSONArray cashMgmtIds, List<String> slaveCashupIds) { if (slaveCashupIds == null) { @@ -187,13 +188,14 @@ "where obposAppCashup.id in :slaveCashupIds and account.id=:account"); transactionsQuery.setNamedParameter("slaveCashupIds", slaveCashupIds); transactionsQuery.setNamedParameter("account", paymentType.getFinancialAccount().getId()); - associateTransactionsFromQuery(transactionsQuery, reconciliation); + associateTransactionsFromQuery(posTerminal, transactionsQuery, reconciliation); } - protected void associateTransactionsFromQuery(OBQuery<FIN_FinaccTransaction> transactionQuery, - FIN_Reconciliation reconciliation) { + protected void associateTransactionsFromQuery(OBPOSApplications posTerminal, + OBQuery<FIN_FinaccTransaction> transactionQuery, FIN_Reconciliation reconciliation) { ScrollableResults transactions = transactionQuery.scroll(ScrollMode.FORWARD_ONLY); try { + boolean crossStoreflag = false; while (transactions.next()) { FIN_FinaccTransaction transaction = (FIN_FinaccTransaction) transactions.get(0); transaction.setStatus("RPPC"); @@ -204,6 +206,17 @@ if (transaction.getFinPayment() != null) { transaction.getFinPayment().setStatus("RPPC"); } + if (crossStoreflag == false) { + if (transaction.getOrganization().getId() + .equals(posTerminal.getOrganization().getObposCrossStore().getId())) { + crossStoreflag = true; + } + } + } + + if (crossStoreflag == true) { + reconciliation.setOrganization(posTerminal.getOrganization().getObposCrossStore()); + OBDal.getInstance().save(reconciliation); } } finally { transactions.close(); diff --git a/src/org/openbravo/retail/posterminal/OrderLoader.java b/src/org/openbravo/retail/posterminal/OrderLoader.java --- a/src/org/openbravo/retail/posterminal/OrderLoader.java +++ b/src/org/openbravo/retail/posterminal/OrderLoader.java @@ -1789,12 +1789,25 @@ Date calculatedDate = (payment.has("date") && !payment.isNull("date")) ? OBMOBCUtils .calculateServerDate((String) payment.get("date"), jsonorder.getLong("timezoneOffset")) : OBMOBCUtils.stripTime(new Date()); - + // Cross store - Check if Order org is equal to terminal Org. + String posTerminalId = jsonorder.getString("posTerminal"); + OBPOSApplications posTerminal = OBDal.getInstance().get(OBPOSApplications.class, + posTerminalId); + Organization paymentOrg = null; + if (!order.getOrganization().getId().equals(posTerminal.getOrganization().getId())) { + if (posTerminal.getOrganization().getObposCrossStore() != null) { + paymentOrg = posTerminal.getOrganization().getObposCrossStore(); + } else { + return; + } + } else { + paymentOrg = order.getOrganization(); + } // insert the payment FIN_Payment finPayment = FIN_AddPayment.savePayment(null, true, paymentDocType, paymentDocNo, order.getBusinessPartner(), paymentType.getPaymentMethod().getPaymentMethod(), account, - amount.toString(), calculatedDate, order.getOrganization(), null, detail, paymentAmount, - false, false, order.getCurrency(), mulrate, origAmount); + amount.toString(), calculatedDate, paymentOrg, null, detail, paymentAmount, false, false, + order.getCurrency(), mulrate, origAmount); if (writeoffAmt.signum() == 1) { if (totalIsNegative) { diff --git a/src/org/openbravo/retail/posterminal/PaidReceiptsHeader.java b/src/org/openbravo/retail/posterminal/PaidReceiptsHeader.java --- a/src/org/openbravo/retail/posterminal/PaidReceiptsHeader.java +++ b/src/org/openbravo/retail/posterminal/PaidReceiptsHeader.java @@ -12,6 +12,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import javax.enterprise.inject.Any; import javax.enterprise.inject.Instance; @@ -22,6 +23,9 @@ import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; import org.openbravo.base.exception.OBException; +import org.openbravo.dal.core.OBContext; +import org.openbravo.dal.service.OBDal; +import org.openbravo.model.common.enterprise.Organization; public class PaidReceiptsHeader extends ProcessHQLQuery { public static final Logger log = Logger.getLogger(PaidReceiptsHeader.class); @@ -61,10 +65,24 @@ + strIsLayaway + "' as isLayaway from Order as ord " + "where ord.client='" - + json.getString("client") - + "' and ord.organization='" - + json.getString("organization") - + "' and ord.obposIsDeleted = false "; + + json.getString("client") + "' and ord.obposIsDeleted = false "; + + // Checking CrossStore + if (!json.isNull("crossStore") && json.getBoolean("isLayaway")) { + Set<String> orgTree = OBContext.getOBContext().getOrganizationStructureProvider() + .getNaturalTree(json.getString("crossStore")); + String orgList = ""; + for (String orgId : orgTree) { + if (orgId != "0") { + Organization Org = OBDal.getInstance().get(Organization.class, orgId); + orgList += ",'" + Org.getId() + "'"; + } + } + orgList = orgList.replaceFirst(",", ""); + hqlPaidReceipts += " and ord.organization.id in (" + orgList + ") "; + } else { + hqlPaidReceipts += " and ord.organization.id='" + json.getString("organization") + "'"; + } if (!json.getString("filterText").isEmpty()) { String hqlFilter = "ord.documentNo like :filterT1 or REPLACE(ord.documentNo, '/', '') like :filterT1 or upper(ord.businessPartner.name) like upper(:filterT1)"; @@ -78,16 +96,18 @@ } hqlPaidReceipts += " and (" + hqlFilter + ") "; } - if (!json.isNull("documentType")) { - JSONArray docTypes = json.getJSONArray("documentType"); - hqlPaidReceipts += " and ( "; - for (int docType_i = 0; docType_i < docTypes.length(); docType_i++) { - hqlPaidReceipts += "ord.documentType.id='" + docTypes.getString(docType_i) + "'"; - if (docType_i != docTypes.length() - 1) { - hqlPaidReceipts += " or "; + if (json.isNull("crossStore") && !json.getBoolean("isLayaway")) { + if (!json.isNull("documentType")) { + JSONArray docTypes = json.getJSONArray("documentType"); + hqlPaidReceipts += " and ( "; + for (int docType_i = 0; docType_i < docTypes.length(); docType_i++) { + hqlPaidReceipts += "ord.documentType.id='" + docTypes.getString(docType_i) + "'"; + if (docType_i != docTypes.length() - 1) { + hqlPaidReceipts += " or "; + } } + hqlPaidReceipts += " )"; } - hqlPaidReceipts += " )"; } if (!json.getString("docstatus").isEmpty() && !json.getString("docstatus").equals("null")) { hqlPaidReceipts += " and ord.documentStatus='" + json.getString("docstatus") + "'"; diff --git a/src/org/openbravo/retail/posterminal/term/TerminalProperties.java b/src/org/openbravo/retail/posterminal/term/TerminalProperties.java --- a/src/org/openbravo/retail/posterminal/term/TerminalProperties.java +++ b/src/org/openbravo/retail/posterminal/term/TerminalProperties.java @@ -75,6 +75,7 @@ list.add(new HQLProperty("pos.ismaster", "ismaster")); list.add(new HQLProperty( "CASE WHEN pos.masterterminal.id is not null THEN true ELSE false END", "isslave")); + list.add(new HQLProperty("pos.organization.obposCrossStore.id", "crossStore")); addTemplateProperty(Organization.PROPERTY_OBPOSCASHUPTEMPLATE, "printCashUpTemplate", list); addTemplateProperty(Organization.PROPERTY_OBPOSTICKETTEMPLATE, "printTicketTemplate", list); diff --git a/web/org.openbravo.retail.posterminal/js/components/modalmultiorders.js b/web/org.openbravo.retail.posterminal/js/components/modalmultiorders.js --- a/web/org.openbravo.retail.posterminal/js/components/modalmultiorders.js +++ b/web/org.openbravo.retail.posterminal/js/components/modalmultiorders.js @@ -68,8 +68,9 @@ initComponents: function () { this.setContent(OB.I18N.getLabel('OBPOS_LblEndDate')); }, - style: 'width 200px; margin: 0px 0px 2px 65px;' + style: 'width: 200px; margin: 0px 0px 2px 35px;' }] + }] }, { style: 'display: table;', @@ -97,7 +98,7 @@ name: 'endDate', size: '10', type: 'text', - style: 'width: 100px; margin: 0px 0px 8px 50px;', + style: 'width: 100px; margin: 0px 0px 8px 25px;', onchange: 'searchAction' }, { style: 'display: table-cell;', @@ -123,7 +124,8 @@ endDate: this.$.endDate.getValue(), pos: OB.MobileApp.model.get('terminal').id, client: OB.MobileApp.model.get('terminal').client, - organization: OB.MobileApp.model.get('terminal').organization + organization: OB.MobileApp.model.get('terminal').organization, + crossStore: OB.MobileApp.model.get('terminal').crossStore }; if (!this.getDateFilters()) { diff --git a/web/org.openbravo.retail.posterminal/js/components/modalpaidreceipts.js b/web/org.openbravo.retail.posterminal/js/components/modalpaidreceipts.js --- a/web/org.openbravo.retail.posterminal/js/components/modalpaidreceipts.js +++ b/web/org.openbravo.retail.posterminal/js/components/modalpaidreceipts.js @@ -194,7 +194,8 @@ filterText: this.$.filterText.getValue(), pos: OB.MobileApp.model.get('terminal').id, client: OB.MobileApp.model.get('terminal').client, - organization: OB.MobileApp.model.get('terminal').organization + organization: OB.MobileApp.model.get('terminal').organization, + crossStore: OB.MobileApp.model.get('terminal').crossStore }; if (!this.getDateFilters()) { CrossStore_pi.patch [^] (19,379 bytes) 2016-04-12 12:30 [Show Content] [Hide Content] # HG changeset patch # User Silambarasan Sekar <silambarasan@qualiantech.com> # Date 1458134165 -19800 # Wed Mar 16 18:46:05 2016 +0530 # Node ID d2c63e03f1429147c234243d39e5c597c81272de # Parent a1278c755b89281f896354a6d5cc93090b504b36 Added Automated test for CrossStore diff -r a1278c755b89 -r d2c63e03f142 src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/sales/I31592_LayawayInCrossStore.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/sales/I31592_LayawayInCrossStore.java Wed Mar 16 18:46:05 2016 +0530 @@ -0,0 +1,171 @@ +/* + ************************************************************************* + * 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.BUTTON_RECEIPTLIST_ROW1 + * The Original Code is Openbravo ERP. + * The Initial Developer of the Original Code is Openbravo S.L.U. + * All portions are Copyright (C) 2016 Openbravo S.L.U. + * All Rights Reserved. + * Contributor(s): Silambarasan. + ************************************************************************ + */ + +package org.openbravo.test.mobile.retail.pack.selenium.tests.sales; + +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.junit.Test; +import org.openbravo.test.mobile.common.selenium.SeleniumHelper; +import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperInsertUpdateOrDelete; +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.javascript.APIs.MobileCoreAPI; +import org.openbravo.test.mobile.common.selenium.terminals.WebPOSTerminalHelper; +import org.openbravo.test.mobile.common.selenium.utils.ApplicationWindow; +import org.openbravo.test.mobile.common.selenium.utils.OBConstants; +import org.openbravo.test.mobile.common.selenium.utils.OBUtils; + +public class I31592_LayawayInCrossStore extends WebPOSTerminalHelper { + + private static String orgId; + private static String receiptNo; + + @Test + public void test() { + + final String VBS1Uri = OBUtils.getCurrentHref(); + final String PS1Uri = VBS1Uri.replace("VBS1001", "PS-1"); + + boolean isTestSuccessful = true; + + try { + final String selectSQL = "select ad_org_id from ad_org where name='White Valley Spain S.A'"; + new DatabaseHelperSelect() { + @Override + protected void yieldResultSet(final ResultSet rs) throws SQLException { + orgId = rs.getString("ad_org_id"); + } + }.execute(selectSQL, 1); + logger.info(String.format("Verifying that the database record '%s' is one of the expected", + orgId)); + + // Create database changes + createDatabaseChanges(); + isTestSuccessful = false; + + // Update Terminal with Database Changes + updateTerminalAfterDatabaseChange(); + + createLayaway(); + MobileCoreAPI.localStorageClear(); + + logOut(); + + // Navigating to PS-1 + OBUtils.navigate(PS1Uri, ApplicationWindow.LOGIN); + login("posets"); + + // Setting permission + + setCrossStorePermission("OBPOS_CrossStore_LayawaySel", true); + + completeLayaway(); + + OBUtils.navigate(VBS1Uri, ApplicationWindow.LOGIN); + logIn(); + + restoreDatabaseChanges(); + + // Update Terminal with Database Changes + updateTerminalAfterDatabaseChange(); + + isTestSuccessful = true; + } finally { + if (!isTestSuccessful) { + restoreDatabaseChanges(); + } + } + + } + + private void createDatabaseChanges() { + new DatabaseHelperInsertUpdateOrDelete() + .execute( + String + .format( + "Update ad_org Set em_obpos_crossstore_id='%s' where name='Posets Store' or name='Vall Blanca Store'", + orgId), 2); + + } + + private void restoreDatabaseChanges() { + // Delete Preference + final String restoreSQL = "update ad_org set em_obpos_crossstore_id=NULL where name='Posets Store' or name='Vall Blanca Store'"; + new DatabaseHelperInsertUpdateOrDelete().execute(restoreSQL, 2); + + } + + private void createLayaway() { + + // 1. Simple layaway + + tap(TestId.BUTTON_RECEIPT_CUSTOMER); + write(TestId.FIELD_CUSTOMER_MODAL, "Arturo Montoro"); + tap(TestId.BUTTON_CUSTOMER_MODAL_SEARCH); + tap(TestId.BUTTON_CUSTOMER_SEARCH_ROW1); + verify(TestId.BUTTON_RECEIPT_CUSTOMER, "Arturo Montoro"); + + 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_WHISTLE); + receiptNo = BackboneHelper.getDocumentNo(); + + verify(TestId.LABEL_TOTALTOPAY, "2.90"); + tap(TestId.BUTTON_PAY); + tap(TestId.BUTTON_LAYAWAY); + verify(TestId.LABEL_TOTALTOPAY, "0.00"); + + } + + private void completeLayaway() { + + tap(TestId.BUTTON_MENU); + tap(TestId.BUTTON_MENU_LAYAWAYS); + write(TestId.FIELD_SEARCH_RECEIPT, receiptNo); + tap(TestId.BUTTON_RECEIPTS_SEARCH); + tap(TestId.BUTTON_VERIFIEDRETURNS_ROW1); + tap(TestId.BUTTON_PAY); + tap(TestId.BUTTON_PAY_EXACT); + tap(TestId.BUTTON_PAY_DONE); + verify(TestId.LABEL_TOTALTOPAY, "0.00"); + + } + + private void setCrossStorePermission(String selector, Boolean value) { + SeleniumHelper.executeScript("OB.MobileApp.model.attributes.permissions." + selector + "=" + + value + ""); + } + + private void login(final String newUsername) { + TestId.LABEL_LOGIN_OPENBRAVOMOBILE.enyoNode().waitUntilIsReady(); + OBUtils.pause(OBConstants.WAIT_AFTERWEBPOSLOGO); + write(TestId.FIELD_LOGIN_USERNAME, newUsername); + write(TestId.FIELD_LOGIN_PASSWORD, "openbravo"); + tap(TestId.BUTTON_LOGIN); + OBUtils.pause(OBConstants.WAIT_AFTERSUCCESSFULLOGIN); + TestId.TABLE_PRODUCTS.enyoNode().waitUntilIsReady(); + } + +} diff -r a1278c755b89 -r d2c63e03f142 src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/sales/I31592_PayOpenTicketsInCrossStore.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/sales/I31592_PayOpenTicketsInCrossStore.java Wed Mar 16 18:46:05 2016 +0530 @@ -0,0 +1,171 @@ +/* + ************************************************************************* + * 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.BUTTON_RECEIPTLIST_ROW1 + * The Original Code is Openbravo ERP. + * The Initial Developer of the Original Code is Openbravo S.L.U. + * All portions are Copyright (C) 2016 Openbravo S.L.U. + * All Rights Reserved. + * Contributor(s): Silambarasan. + ************************************************************************ + */ + +package org.openbravo.test.mobile.retail.pack.selenium.tests.sales; + +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.junit.Test; +import org.openbravo.test.mobile.common.selenium.SeleniumHelper; +import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperInsertUpdateOrDelete; +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.javascript.APIs.MobileCoreAPI; +import org.openbravo.test.mobile.common.selenium.terminals.WebPOSTerminalHelper; +import org.openbravo.test.mobile.common.selenium.utils.ApplicationWindow; +import org.openbravo.test.mobile.common.selenium.utils.OBConstants; +import org.openbravo.test.mobile.common.selenium.utils.OBUtils; + +public class I31592_PayOpenTicketsInCrossStore extends WebPOSTerminalHelper { + + private static String orgId; + private static String receiptNo; + + @Test + public void test() { + + final String VBS1Uri = OBUtils.getCurrentHref(); + final String PS1Uri = VBS1Uri.replace("VBS1001", "PS-1"); + + boolean isTestSuccessful = true; + + try { + final String selectSQL = "select ad_org_id from ad_org where name='White Valley Spain S.A'"; + new DatabaseHelperSelect() { + @Override + protected void yieldResultSet(final ResultSet rs) throws SQLException { + orgId = rs.getString("ad_org_id"); + } + }.execute(selectSQL, 1); + logger.info(String.format("Verifying that the database record '%s' is one of the expected", + orgId)); + + // Create database changes + createDatabaseChanges(); + isTestSuccessful = false; + + // Update Terminal with Database Changes + updateTerminalAfterDatabaseChange(); + + createLayaway(); + MobileCoreAPI.localStorageClear(); + + logOut(); + + // Navigating to PS-1 + OBUtils.navigate(PS1Uri, ApplicationWindow.LOGIN); + login("posets"); + + // Setting permission + + setCrossStorePermission("OBPOS_CrossStore_PayopenSel", true); + + completePayOpen(); + + OBUtils.navigate(VBS1Uri, ApplicationWindow.LOGIN); + logIn(); + + restoreDatabaseChanges(); + + // Update Terminal with Database Changes + updateTerminalAfterDatabaseChange(); + + isTestSuccessful = true; + } finally { + if (!isTestSuccessful) { + restoreDatabaseChanges(); + } + } + + } + + private void createDatabaseChanges() { + new DatabaseHelperInsertUpdateOrDelete() + .execute( + String + .format( + "Update ad_org Set em_obpos_crossstore_id='%s' where name='Posets Store' or name='Vall Blanca Store'", + orgId), 2); + + } + + private void restoreDatabaseChanges() { + // Delete Preference + final String restoreSQL = "update ad_org set em_obpos_crossstore_id=NULL where name='Posets Store' or name='Vall Blanca Store'"; + new DatabaseHelperInsertUpdateOrDelete().execute(restoreSQL, 2); + + } + + private void createLayaway() { + + // 1. Simple layaway + + tap(TestId.BUTTON_RECEIPT_CUSTOMER); + write(TestId.FIELD_CUSTOMER_MODAL, "Arturo Montoro"); + tap(TestId.BUTTON_CUSTOMER_MODAL_SEARCH); + tap(TestId.BUTTON_CUSTOMER_SEARCH_ROW1); + verify(TestId.BUTTON_RECEIPT_CUSTOMER, "Arturo Montoro"); + + 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_WHISTLE); + receiptNo = BackboneHelper.getDocumentNo(); + + verify(TestId.LABEL_TOTALTOPAY, "2.90"); + tap(TestId.BUTTON_PAY); + tap(TestId.BUTTON_LAYAWAY); + verify(TestId.LABEL_TOTALTOPAY, "0.00"); + + } + + private void completePayOpen() { + + tap(TestId.BUTTON_MENU); + tap(TestId.BUTTON_MENU_PAYOPENTICKETS); + write(TestId.FIELD_SEARCH_MULTIORDERS_TEXT, receiptNo); + tap(TestId.BUTTON_POPUP_OPENTICKETS_SEARCH); + tap(TestId.BUTTON_POPUP_OPENTICKETS_ROW1); + tap(TestId.BUTTON_POPUP_OPENTICKETS_DONE); + tap(TestId.BUTTON_PAY_EXACT); + tap(TestId.BUTTON_PAY_DONE); + verify(TestId.LABEL_TOTALTOPAY, "0.00"); + + } + + private void setCrossStorePermission(String selector, Boolean value) { + SeleniumHelper.executeScript("OB.MobileApp.model.attributes.permissions." + selector + "=" + + value + ""); + } + + private void login(final String newUsername) { + TestId.LABEL_LOGIN_OPENBRAVOMOBILE.enyoNode().waitUntilIsReady(); + OBUtils.pause(OBConstants.WAIT_AFTERWEBPOSLOGO); + write(TestId.FIELD_LOGIN_USERNAME, newUsername); + write(TestId.FIELD_LOGIN_PASSWORD, "openbravo"); + tap(TestId.BUTTON_LOGIN); + OBUtils.pause(OBConstants.WAIT_AFTERSUCCESSFULLOGIN); + TestId.TABLE_PRODUCTS.enyoNode().waitUntilIsReady(); + } + +} diff -r a1278c755b89 -r d2c63e03f142 src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/sales/I31592_ReceiptsInCrossStore.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/sales/I31592_ReceiptsInCrossStore.java Wed Mar 16 18:46:05 2016 +0530 @@ -0,0 +1,166 @@ +/* + ************************************************************************* + * 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.BUTTON_RECEIPTLIST_ROW1 + * The Original Code is Openbravo ERP. + * The Initial Developer of the Original Code is Openbravo S.L.U. + * All portions are Copyright (C) 2016 Openbravo S.L.U. + * All Rights Reserved. + * Contributor(s): Silambarasan. + ************************************************************************ + */ + +package org.openbravo.test.mobile.retail.pack.selenium.tests.sales; + +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.junit.Test; +import org.openbravo.test.mobile.common.selenium.SeleniumHelper; +import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperInsertUpdateOrDelete; +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.javascript.APIs.MobileCoreAPI; +import org.openbravo.test.mobile.common.selenium.terminals.WebPOSTerminalHelper; +import org.openbravo.test.mobile.common.selenium.utils.ApplicationWindow; +import org.openbravo.test.mobile.common.selenium.utils.OBConstants; +import org.openbravo.test.mobile.common.selenium.utils.OBUtils; + +public class I31592_ReceiptsInCrossStore extends WebPOSTerminalHelper { + + private static String orgId; + private static String receiptNo; + + @Test + public void test() { + + final String VBS1Uri = OBUtils.getCurrentHref(); + final String PS1Uri = VBS1Uri.replace("VBS1001", "PS-1"); + + boolean isTestSuccessful = true; + + try { + final String selectSQL = "select ad_org_id from ad_org where name='White Valley Spain S.A'"; + new DatabaseHelperSelect() { + @Override + protected void yieldResultSet(final ResultSet rs) throws SQLException { + orgId = rs.getString("ad_org_id"); + } + }.execute(selectSQL, 1); + logger.info(String.format("Verifying that the database record '%s' is one of the expected", + orgId)); + + // Create database changes + createDatabaseChanges(); + + isTestSuccessful = false; + + // Update Terminal with Database Changes + updateTerminalAfterDatabaseChange(); + + createLayaway(); + MobileCoreAPI.localStorageClear(); + + logOut(); + + // Navigating to PS-1 + OBUtils.navigate(PS1Uri, ApplicationWindow.LOGIN); + login("posets"); + + // Setting permission + + setCrossStorePermission("OBPOS_CrossStore_ReceiptSel", true); + + completeLayaway(); + + OBUtils.navigate(VBS1Uri, ApplicationWindow.LOGIN); + logIn(); + + restoreDatabaseChanges(); + + // Update Terminal with Database Changes + updateTerminalAfterDatabaseChange(); + + isTestSuccessful = true; + } finally { + if (!isTestSuccessful) { + restoreDatabaseChanges(); + } + } + + } + + private void createDatabaseChanges() { + new DatabaseHelperInsertUpdateOrDelete() + .execute( + String + .format( + "Update ad_org Set em_obpos_crossstore_id='%s' where name='Posets Store' or name='Vall Blanca Store'", + orgId), 2); + + } + + private void restoreDatabaseChanges() { + // Delete Preference + final String restoreSQL = "update ad_org set em_obpos_crossstore_id=NULL where name='Posets Store' or name='Vall Blanca Store'"; + new DatabaseHelperInsertUpdateOrDelete().execute(restoreSQL, 2); + + } + + private void createLayaway() { + + // 1. Simple layaway + + tap(TestId.BUTTON_RECEIPT_CUSTOMER); + write(TestId.FIELD_CUSTOMER_MODAL, "Arturo Montoro"); + tap(TestId.BUTTON_CUSTOMER_MODAL_SEARCH); + tap(TestId.BUTTON_CUSTOMER_SEARCH_ROW1); + verify(TestId.BUTTON_RECEIPT_CUSTOMER, "Arturo Montoro"); + tap(TestId.BUTTON_BROWSE); + tap(TestId.BUTTON_CATEGORY_BACKPACKSANDTRAVEL); + tap(TestId.BUTTON_PRODUCT_BACKPACKSANDTRAVEL_WHISTLE); + receiptNo = BackboneHelper.getDocumentNo(); + + verify(TestId.LABEL_TOTALTOPAY, "2.90"); + tap(TestId.BUTTON_PAY); + tap(TestId.BUTTON_PAY_EXACT); + tap(TestId.BUTTON_PAY_DONE); + + verify(TestId.LABEL_TOTALTOPAY, "0.00"); + + } + + private void completeLayaway() { + + tap(TestId.BUTTON_MENU); + tap(TestId.BUTTON_MENU_RECEIPTS); + write(TestId.FIELD_SEARCH_RECEIPT, receiptNo); + tap(TestId.BUTTON_RECEIPTS_SEARCH); + verify(TestId.LABEL_VERIFIEDRETURNS_ROW1_TITLE, receiptNo + " - Arturo Montoro"); + + } + + private void setCrossStorePermission(String selector, Boolean value) { + SeleniumHelper.executeScript("OB.MobileApp.model.attributes.permissions." + selector + "=" + + value + ""); + } + + private void login(final String newUsername) { + TestId.LABEL_LOGIN_OPENBRAVOMOBILE.enyoNode().waitUntilIsReady(); + OBUtils.pause(OBConstants.WAIT_AFTERWEBPOSLOGO); + write(TestId.FIELD_LOGIN_USERNAME, newUsername); + write(TestId.FIELD_LOGIN_PASSWORD, "openbravo"); + tap(TestId.BUTTON_LOGIN); + OBUtils.pause(OBConstants.WAIT_AFTERSUCCESSFULLOGIN); + TestId.TABLE_PRODUCTS.enyoNode().waitUntilIsReady(); + } + +} | |||||||||||
Relationships [ Relation Graph ] [ Dependency Graph ] | |
Issue History | |||
Date Modified | Username | Field | Change |
2015-11-26 09:17 | marvintm | New Issue | |
2015-11-26 09:17 | marvintm | Assigned To | => Retail |
2015-11-26 09:17 | marvintm | Triggers an Emergency Pack | => No |
2015-12-08 10:54 | simbu94 | File Added: crossStore.patch | |
2016-04-12 12:30 | simbu94 | File Added: CrossStore_pi.patch | |
2016-05-16 10:23 | Orekaria | Status | new => scheduled |
2016-05-16 10:23 | Orekaria | Assigned To | Retail => simbu94 |
Copyright © 2000 - 2009 MantisBT Group |