Attached Files | issue37673.diff [^] (13,829 bytes) 2018-08-07 12:37 [Show Content] [Hide Content]diff --git a/src-db/database/sourcedata/AD_MESSAGE.xml b/src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml
@@ -408,6 +408,18 @@
<!--494B8A0AA2A54C3D946DEE183F10684A--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--494B8A0AA2A54C3D946DEE183F10684A--></AD_MESSAGE>
+<!--4A840C6EC7C44A3DAB8D7582E89824D2--><AD_MESSAGE>
+<!--4A840C6EC7C44A3DAB8D7582E89824D2--> <AD_MESSAGE_ID><![CDATA[4A840C6EC7C44A3DAB8D7582E89824D2]]></AD_MESSAGE_ID>
+<!--4A840C6EC7C44A3DAB8D7582E89824D2--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--4A840C6EC7C44A3DAB8D7582E89824D2--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--4A840C6EC7C44A3DAB8D7582E89824D2--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--4A840C6EC7C44A3DAB8D7582E89824D2--> <VALUE><![CDATA[GCNV_ForbidAnonymousCustomerUseCreditNote]]></VALUE>
+<!--4A840C6EC7C44A3DAB8D7582E89824D2--> <MSGTEXT><![CDATA[It is not allowed to create nor use a Credit Note for an anonymous customer. Please, change the customer or the payment method]]></MSGTEXT>
+<!--4A840C6EC7C44A3DAB8D7582E89824D2--> <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--4A840C6EC7C44A3DAB8D7582E89824D2--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID>
+<!--4A840C6EC7C44A3DAB8D7582E89824D2--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--4A840C6EC7C44A3DAB8D7582E89824D2--></AD_MESSAGE>
+
<!--4B73BFA4D5654D918491D4BAC7D51D37--><AD_MESSAGE>
<!--4B73BFA4D5654D918491D4BAC7D51D37--> <AD_MESSAGE_ID><![CDATA[4B73BFA4D5654D918491D4BAC7D51D37]]></AD_MESSAGE_ID>
<!--4B73BFA4D5654D918491D4BAC7D51D37--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -972,6 +984,18 @@
<!--A96E1350841A4AAC8BA765FA26CA0B9D--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--A96E1350841A4AAC8BA765FA26CA0B9D--></AD_MESSAGE>
+<!--A8DDA7F6267542E2B5422EF117F01BF6--><AD_MESSAGE>
+<!--A8DDA7F6267542E2B5422EF117F01BF6--> <AD_MESSAGE_ID><![CDATA[A8DDA7F6267542E2B5422EF117F01BF6]]></AD_MESSAGE_ID>
+<!--A8DDA7F6267542E2B5422EF117F01BF6--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--A8DDA7F6267542E2B5422EF117F01BF6--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--A8DDA7F6267542E2B5422EF117F01BF6--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--A8DDA7F6267542E2B5422EF117F01BF6--> <VALUE><![CDATA[GCNV_ForbidUseCreditNoteWithDifferentCustomer]]></VALUE>
+<!--A8DDA7F6267542E2B5422EF117F01BF6--> <MSGTEXT><![CDATA[It can not use a credit note related to a customer different than the assigned to the receipt. Please, select another one]]></MSGTEXT>
+<!--A8DDA7F6267542E2B5422EF117F01BF6--> <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--A8DDA7F6267542E2B5422EF117F01BF6--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID>
+<!--A8DDA7F6267542E2B5422EF117F01BF6--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--A8DDA7F6267542E2B5422EF117F01BF6--></AD_MESSAGE>
+
<!--ABE29F03922A498398B1C6DE914D611F--><AD_MESSAGE>
<!--ABE29F03922A498398B1C6DE914D611F--> <AD_MESSAGE_ID><![CDATA[ABE29F03922A498398B1C6DE914D611F]]></AD_MESSAGE_ID>
<!--ABE29F03922A498398B1C6DE914D611F--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff --git a/src-db/database/sourcedata/AD_PREFERENCE.xml b/src-db/database/sourcedata/AD_PREFERENCE.xml
--- a/src-db/database/sourcedata/AD_PREFERENCE.xml
+++ b/src-db/database/sourcedata/AD_PREFERENCE.xml
@@ -1,5 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<data>
+<!--5EACCDBDFCD54DBF9AA6A9957568D431--><AD_PREFERENCE>
+<!--5EACCDBDFCD54DBF9AA6A9957568D431--> <AD_PREFERENCE_ID><![CDATA[5EACCDBDFCD54DBF9AA6A9957568D431]]></AD_PREFERENCE_ID>
+<!--5EACCDBDFCD54DBF9AA6A9957568D431--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--5EACCDBDFCD54DBF9AA6A9957568D431--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--5EACCDBDFCD54DBF9AA6A9957568D431--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--5EACCDBDFCD54DBF9AA6A9957568D431--> <VALUE><![CDATA[N]]></VALUE>
+<!--5EACCDBDFCD54DBF9AA6A9957568D431--> <PROPERTY><![CDATA[GCNV_ForbidUseCreditNoteForDifferentCustomer]]></PROPERTY>
+<!--5EACCDBDFCD54DBF9AA6A9957568D431--> <ISPROPERTYLIST><![CDATA[Y]]></ISPROPERTYLIST>
+<!--5EACCDBDFCD54DBF9AA6A9957568D431--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID>
+<!--5EACCDBDFCD54DBF9AA6A9957568D431--></AD_PREFERENCE>
+
<!--76DE78A78B044FD2AB5D3469536684A4--><AD_PREFERENCE>
<!--76DE78A78B044FD2AB5D3469536684A4--> <AD_PREFERENCE_ID><![CDATA[76DE78A78B044FD2AB5D3469536684A4]]></AD_PREFERENCE_ID>
<!--76DE78A78B044FD2AB5D3469536684A4--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -22,6 +33,17 @@
<!--780E45E09F9841648E1D89FC5EE70578--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID>
<!--780E45E09F9841648E1D89FC5EE70578--></AD_PREFERENCE>
+<!--8D7E13D51009435BA2ADE9948C3EE9FF--><AD_PREFERENCE>
+<!--8D7E13D51009435BA2ADE9948C3EE9FF--> <AD_PREFERENCE_ID><![CDATA[8D7E13D51009435BA2ADE9948C3EE9FF]]></AD_PREFERENCE_ID>
+<!--8D7E13D51009435BA2ADE9948C3EE9FF--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--8D7E13D51009435BA2ADE9948C3EE9FF--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--8D7E13D51009435BA2ADE9948C3EE9FF--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--8D7E13D51009435BA2ADE9948C3EE9FF--> <VALUE><![CDATA[N]]></VALUE>
+<!--8D7E13D51009435BA2ADE9948C3EE9FF--> <PROPERTY><![CDATA[GCNV_ForbidAnonymousCustomerUseCreditNote]]></PROPERTY>
+<!--8D7E13D51009435BA2ADE9948C3EE9FF--> <ISPROPERTYLIST><![CDATA[Y]]></ISPROPERTYLIST>
+<!--8D7E13D51009435BA2ADE9948C3EE9FF--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID>
+<!--8D7E13D51009435BA2ADE9948C3EE9FF--></AD_PREFERENCE>
+
<!--984AAFF6049547989E1D3F332481ADAF--><AD_PREFERENCE>
<!--984AAFF6049547989E1D3F332481ADAF--> <AD_PREFERENCE_ID><![CDATA[984AAFF6049547989E1D3F332481ADAF]]></AD_PREFERENCE_ID>
<!--984AAFF6049547989E1D3F332481ADAF--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff --git a/src-db/database/sourcedata/AD_REF_LIST.xml b/src-db/database/sourcedata/AD_REF_LIST.xml
--- a/src-db/database/sourcedata/AD_REF_LIST.xml
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml
@@ -237,6 +237,18 @@
<!--7AD5698CF16B48B48582E3F101100EE4--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID>
<!--7AD5698CF16B48B48582E3F101100EE4--></AD_REF_LIST>
+<!--80B24D22A9EE45B8A5238B396D3632C1--><AD_REF_LIST>
+<!--80B24D22A9EE45B8A5238B396D3632C1--> <AD_REF_LIST_ID><![CDATA[80B24D22A9EE45B8A5238B396D3632C1]]></AD_REF_LIST_ID>
+<!--80B24D22A9EE45B8A5238B396D3632C1--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--80B24D22A9EE45B8A5238B396D3632C1--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--80B24D22A9EE45B8A5238B396D3632C1--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--80B24D22A9EE45B8A5238B396D3632C1--> <VALUE><![CDATA[GCNV_ForbidUseCreditNoteForDifferentCustomer]]></VALUE>
+<!--80B24D22A9EE45B8A5238B396D3632C1--> <NAME><![CDATA[Web POS Forbid use a Credit Note with a different Customer]]></NAME>
+<!--80B24D22A9EE45B8A5238B396D3632C1--> <DESCRIPTION><![CDATA[Not allow to use a credit note related to a different customer than the assigned to the receipt]]></DESCRIPTION>
+<!--80B24D22A9EE45B8A5238B396D3632C1--> <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--80B24D22A9EE45B8A5238B396D3632C1--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID>
+<!--80B24D22A9EE45B8A5238B396D3632C1--></AD_REF_LIST>
+
<!--8BF0AC7674A1416491ED5301E2CBFAF2--><AD_REF_LIST>
<!--8BF0AC7674A1416491ED5301E2CBFAF2--> <AD_REF_LIST_ID><![CDATA[8BF0AC7674A1416491ED5301E2CBFAF2]]></AD_REF_LIST_ID>
<!--8BF0AC7674A1416491ED5301E2CBFAF2--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -249,6 +261,17 @@
<!--8BF0AC7674A1416491ED5301E2CBFAF2--> <SEQNO><![CDATA[40]]></SEQNO>
<!--8BF0AC7674A1416491ED5301E2CBFAF2--></AD_REF_LIST>
+<!--96FEEECF68CC467BBC5A2118F21FA3D8--><AD_REF_LIST>
+<!--96FEEECF68CC467BBC5A2118F21FA3D8--> <AD_REF_LIST_ID><![CDATA[96FEEECF68CC467BBC5A2118F21FA3D8]]></AD_REF_LIST_ID>
+<!--96FEEECF68CC467BBC5A2118F21FA3D8--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--96FEEECF68CC467BBC5A2118F21FA3D8--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--96FEEECF68CC467BBC5A2118F21FA3D8--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--96FEEECF68CC467BBC5A2118F21FA3D8--> <VALUE><![CDATA[GCNV_ForbidAnonymousCustomerUseCreditNote]]></VALUE>
+<!--96FEEECF68CC467BBC5A2118F21FA3D8--> <NAME><![CDATA[Web POS Forbid Anonymous Customer use a Credit Note ]]></NAME>
+<!--96FEEECF68CC467BBC5A2118F21FA3D8--> <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--96FEEECF68CC467BBC5A2118F21FA3D8--> <AD_MODULE_ID><![CDATA[17B5337C4B1948DF857B12FD3ABE5094]]></AD_MODULE_ID>
+<!--96FEEECF68CC467BBC5A2118F21FA3D8--></AD_REF_LIST>
+
<!--9EB05A5FF291479AB2F41E94B2B8C32E--><AD_REF_LIST>
<!--9EB05A5FF291479AB2F41E94B2B8C32E--> <AD_REF_LIST_ID><![CDATA[9EB05A5FF291479AB2F41E94B2B8C32E]]></AD_REF_LIST_ID>
<!--9EB05A5FF291479AB2F41E94B2B8C32E--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff --git a/src/org/openbravo/retail/giftcards/GCNVComponentProvider.java b/src/org/openbravo/retail/giftcards/GCNVComponentProvider.java
--- a/src/org/openbravo/retail/giftcards/GCNVComponentProvider.java
+++ b/src/org/openbravo/retail/giftcards/GCNVComponentProvider.java
@@ -70,8 +70,10 @@
grhelper.add("hooks/PreReversePaymentHook.js");
grhelper.add("hooks/precustomersavehook.js");
grhelper.add("hooks/preSaveCashManagementsHook.js");
+ grhelper.add("hooks/afterPaymentSelectedHook.js");
grhelper.add("hooks/predeletelinehook.js");
grhelper.add("hooks/checkGiftCardMandatoryFields.js");
+ grhelper.add("hooks/preOrderSaveHook.js");
grhelper.addStyle("gcnv.css");
diff --git a/web/org.openbravo.retail.giftcards/js/components/GiftCardDetails.js b/web/org.openbravo.retail.giftcards/js/components/GiftCardDetails.js
--- a/web/org.openbravo.retail.giftcards/js/components/GiftCardDetails.js
+++ b/web/org.openbravo.retail.giftcards/js/components/GiftCardDetails.js
@@ -66,6 +66,11 @@
if (this.disabled) {
return;
}
+ if (OB.MobileApp.model.hasPermission('GCNV_ForbidUseCreditNoteForDifferentCustomer', true) && this.owner.owner.args.receipt.get('bp').id !== this.owner.owner.args.giftcard.businessPartner) {
+ this.owner.owner.doHideThisPopup();
+ OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBMOBC_Error'), OB.I18N.getLabel('GCNV_ForbidUseCreditNoteWithDifferentCustomer'));
+ return;
+ }
this.doAcceptButton();
},
initComponents: function () {
diff --git a/web/org.openbravo.retail.giftcards/js/hooks/afterPaymentSelectedHook.js b/web/org.openbravo.retail.giftcards/js/hooks/afterPaymentSelectedHook.js
new file mode 100644
--- /dev/null
+++ b/web/org.openbravo.retail.giftcards/js/hooks/afterPaymentSelectedHook.js
@@ -0,0 +1,24 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2017 Openbravo S.L.U.
+ * Licensed under the Openbravo Commercial License version 1.0
+ * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
+ * or in the legal folder of this module distribution.
+ ************************************************************************************
+ */
+
+/*global OB, enyo, Backbone, _ */
+
+(function () {
+
+ OB.UTIL.HookManager.registerHook('OBPOS_PrePaymentSelected', function (args, callbacks) {
+ if (OB.MobileApp.model.hasPermission('GCNV_ForbidAnonymousCustomerUseCreditNote', true) && args.paymentSelected && args.paymentSelected.name === 'GCNV_payment.creditnote' && args.receipt.get('bp').id === OB.MobileApp.model.get('businessPartner').id) {
+ if (args.paymentSelected.definition.includedInPopUp) {
+ args.paymentSelected.owner.owner.owner.owner.hide();
+ }
+ OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBMOBC_Error'), OB.I18N.getLabel('GCNV_ForbidAnonymousCustomerUseCreditNote'));
+ args.cancellation = true;
+ }
+ OB.UTIL.HookManager.callbackExecutor(args, callbacks);
+ });
+}());
\ No newline at end of file
diff --git a/web/org.openbravo.retail.giftcards/js/hooks/preOrderSaveHook.js b/web/org.openbravo.retail.giftcards/js/hooks/preOrderSaveHook.js
new file mode 100644
--- /dev/null
+++ b/web/org.openbravo.retail.giftcards/js/hooks/preOrderSaveHook.js
@@ -0,0 +1,25 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2017 Openbravo S.L.U.
+ * Licensed under the Openbravo Commercial License version 1.0
+ * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
+ * or in the legal folder of this module distribution.
+ ************************************************************************************
+ */
+
+(function () {
+ OB.UTIL.HookManager.registerHook('OBPOS_PreOrderSave', function (args, callbacks) {
+ args.receipt.get('payments').forEach(function (p) {
+ if (p.get('kind') === 'GCNV_payment.creditnote' && OB.MobileApp.model.hasPermission('GCNV_ForbidAnonymousCustomerUseCreditNote', true)) {
+ if (args.receipt.get('bp').id === OB.MobileApp.model.get('businessPartner').id) {
+ OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBMOBC_Error'), OB.I18N.getLabel('GCNV_ForbidAnonymousCustomerUseCreditNote'));
+ args.cancellation = true;
+ } else if (args.receipt.get('bp').id !== p.get('paymentData').creditNote.businessPartnerId) {
+ OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBMOBC_Error'), OB.I18N.getLabel('GCNV_ForbidUseCreditNoteWithDifferentCustomer'));
+ args.cancellation = true;
+ }
+ }
+ });
+ OB.UTIL.HookManager.callbackExecutor(args, callbacks);
+ });
+}());
\ No newline at end of file
AnonymousCustomerLimitationsFinalTests.diff [^] (37,822 bytes) 2018-08-07 12:38 [Show Content] [Hide Content]diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/TestIdExtModules.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/TestIdExtModules.java
--- a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/TestIdExtModules.java
+++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/TestIdExtModules.java
@@ -337,6 +337,8 @@
"payment.creditnote_button", EnyoKind.BUTTON); //
public static TestIdConstructor BUTTON_PAYMENT_GIFTCERTIFICATE = new TestIdConstructor(
"payment.giftcard_button", EnyoKind.BUTTON); //
+ public static TestIdConstructor BUTTON_FIRSTROW_CREDITNOTE = new TestIdConstructor(
+ "stGCAssignToReceipt_row1_listGCsSelectorLine", EnyoKind.BUTTON); //
// Best Deal Case
public static TestIdConstructor BUTTON_SEARCHPRODUCT_WHISTLE_SHOWPRODSK = new TestIdConstructor(
diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/CreateCreditNoteWithAnonymous.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/CreateCreditNoteWithAnonymous.java
new file mode 100644
--- /dev/null
+++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/CreateCreditNoteWithAnonymous.java
@@ -0,0 +1,125 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2012-2018 Openbravo S.L.U.
+ * Licensed under the Openbravo Commercial License version 1.0
+ * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
+ * or in the legal folder of this module distribution.
+ ************************************************************************************
+ */
+package org.openbravo.test.mobile.retail.extmodules.selenium.tests.creditnote;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.retail.extmodules.selenium.TestIdExtModules;
+import org.openbravo.test.mobile.retail.extmodules.selenium.terminals.WebPOSExtModulesTerminalHelper;
+import org.openbravo.test.mobile.retail.mobilecore.annotations.TestClassAnnotations;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.mobilecore.utils.RetailUtils;
+
+@TestClassAnnotations(isHighVolumeCompatible = true)
+public class CreateCreditNoteWithAnonymous extends WebPOSExtModulesTerminalHelper {
+ final static String prefId1 = RetailUtils.getRandomUUID();
+ final static String prefId2 = RetailUtils.getRandomUUID();
+
+ @Override
+ public void beforeWithReload() {
+ createPreferences();
+ }
+
+ @Override
+ public void afterWithReload() {
+ deletePreferences();
+ }
+
+ /**
+ * Create a ticket with Anonymous Customer. Verified return of the previously created ticket and
+ * use credit note as payment method
+ */
+ @Test
+ public void test() {
+
+ CreateTicket();
+
+ tap(TestIdExtModules.BUTTON_MENU);
+ tap(TestIdExtModules.BUTTON_MENU_VERIFIEDRETURN);
+ tap(TestIdExtModules.BUTTON_RECEIPTS_SEARCH);
+ tap(TestIdExtModules.BUTTON_RECEIPTS_ROW1);
+
+ // Select Product and add quantity
+ tap(TestIdExtModules.BUTTON_VERIFIEDRETURNS_LINES_CHECKROW1);
+ tap(TestIdExtModules.BUTTON_POPUP_APPLY);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "-150.50");
+ tap(TestIdExtModules.BUTTON_PAY);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CREDITNOTE);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ verify(
+ TestIdExtModules.LABEL_POPUP_CONFIRMATION_TITLE,
+ "It is not allowed to create nor use a Credit Note for an anonymous customer. Please, change the customer or the payment method");
+ tap(TestIdExtModules.BUTTON_POPUP_CONFIRMATION_OK);
+ tap(TestIdExtModules.BUTTON_RECEIPT_PAYMENT_ROW1_REMOVE);
+ verify(TestIdExtModules.LABEL_POPUP_TITLE, "Payment Method");
+ verify(TestIdExtModules.LABEL_POPUP_CONFIRMATION_TITLE,
+ "Payment has been confirmed. Do you really want to remove it?");
+ tap(TestIdExtModules.BUTTON_POPUP_OK);
+
+ // Verify if cash is the payment method selected
+ tap(TestIdExtModules.BUTTON_MORE_PAYMENTS_DIV);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CASH);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "0.00");
+ }
+
+ private void CreateTicket() {
+ tap(TestIdExtModules.BUTTON_SEARCH);
+ write(TestIdExtModules.FIELD_SEARCH_TEXT, "Avalanche transceiver");
+ tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVEREXT);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "150.50");
+ tap(TestIdExtModules.BUTTON_PAY);
+
+ // Check More Selected Payment with Cash
+ verify(TestIdExtModules.BUTTON_MORE_PAYMENTS, "More... (Cash)");
+ checkMoreButtonSelected();
+
+ // Add Cash Payment
+ tap(TestIdExtModules.BUTTON_MORE_PAYMENTS_DIV);
+ isVisible(TestIdExtModules.POPUP_PAYMENTMETHOD, true);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CASH);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "0.00");
+ }
+
+ private void checkMoreButtonSelected() {
+ final boolean isSelected = (boolean) TestIdExtModules.BUTTON_MORE_PAYMENTS.enyoNode()
+ .executeExtensionWithReturn(".attributes.class.indexOf('btnactive-green') >= 0");
+ assertThat("Payment method is not selected", true, equalTo(isSelected));
+ }
+
+ private void createPreferences() {
+ final String sqlAdPreference1 = String
+ .format(
+ "INSERT INTO ad_preference(ad_preference_id, ad_client_id, ad_org_id, isactive, createdby, updatedby, value, property, ispropertylist, selected) VALUES ('%s"
+ + "','39363B0921BB4293B48383844325E84C','0','Y','100','100','Y','GCNV_ForbidAnonymousCustomerUseCreditNote','Y','Y')",
+ prefId1);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference1, 1);
+
+ final String sqlAdPreference2 = String
+ .format(
+ "INSERT INTO ad_preference(ad_preference_id, ad_client_id, ad_org_id, isactive, createdby, updatedby, value, property, ispropertylist, selected) VALUES ('%s"
+ + "','39363B0921BB4293B48383844325E84C','0','Y','100','100','Y','GCNV_ForbidUseCreditNoteForDifferentCustomer','Y','Y')",
+ prefId2);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference2, 1);
+ }
+
+ private void deletePreferences() {
+ final String sqlAdPreference = String.format(
+ "DELETE FROM ad_preference WHERE ad_preference_id IN ('%s', '%s')", prefId1, prefId2);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference, 2);
+ }
+
+}
diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/ForbidCustomerDifferentAssignedTicketUseCreditNote.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/ForbidCustomerDifferentAssignedTicketUseCreditNote.java
new file mode 100644
--- /dev/null
+++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/ForbidCustomerDifferentAssignedTicketUseCreditNote.java
@@ -0,0 +1,123 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2012-2018 Openbravo S.L.U.
+ * Licensed under the Openbravo Commercial License version 1.0
+ * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
+ * or in the legal folder of this module distribution.
+ ************************************************************************************
+ */
+package org.openbravo.test.mobile.retail.extmodules.selenium.tests.creditnote;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.retail.extmodules.selenium.TestIdExtModules;
+import org.openbravo.test.mobile.retail.extmodules.selenium.terminals.WebPOSExtModulesTerminalHelper;
+import org.openbravo.test.mobile.retail.mobilecore.annotations.TestClassAnnotations;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.mobilecore.selenium.TestIdConstructor;
+import org.openbravo.test.mobile.retail.mobilecore.utils.RetailUtils;
+
+@TestClassAnnotations(isHighVolumeCompatible = true)
+public class ForbidCustomerDifferentAssignedTicketUseCreditNote extends
+ WebPOSExtModulesTerminalHelper {
+ final static String prefId1 = RetailUtils.getRandomUUID();
+ final static String prefId2 = RetailUtils.getRandomUUID();
+
+ @Override
+ public void beforeWithReload() {
+ createPreferences();
+ }
+
+ @Override
+ public void afterWithReload() {
+ deletePreferences();
+ }
+
+ /**
+ * Create a new ticket and try to pay using a credit note related to another customer
+ */
+ @Test
+ public void test() {
+
+ // Create a credit note for Carl Studson
+ CreateCreditNote(TestIdExtModules.BUTTON_CUSTOMER_CARLSTUDSON);
+
+ // Create a ticket for Carl Studson and change the customer after add the payment
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Carl Studson");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_CUSTOMER_CARLSTUDSON);
+ tap(TestIdExtModules.BUTTON_SEARCH);
+ write(TestIdExtModules.FIELD_SEARCH_TEXT, "Avalanche transceiver");
+ tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVEREXT);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "150.50");
+ tap(TestIdExtModules.BUTTON_PAY);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CREDITNOTE);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_CREDITNOTE_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_FIRSTROW_CREDITNOTE);
+ tap(TestIdExtModules.BUTTON_CREDITNOTE_MODAL_APPLY);
+
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Mara Palliot");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MARAPALLIOT);
+ tap(TestIdExtModules.BUTTON_PAY);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ verify(
+ TestIdExtModules.LABEL_POPUP_DINAMIC_CONFIRMATION_TITLE,
+ "It can not use a credit note related to a customer different than the assigned to the receipt. Please, select another one");
+ tap(TestIdExtModules.BUTTON_POPUP_CONFIRMATION_OK);
+
+ // Change again the customer and complete the order
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Carl Studson");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_CUSTOMER_CARLSTUDSON);
+ tap(TestIdExtModules.BUTTON_PAY);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+
+ }
+
+ private void CreateCreditNote(TestIdConstructor customer) {
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Carl Studson");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(customer);
+ tap(TestIdExtModules.BUTTON_SEARCH);
+ write(TestIdExtModules.FIELD_SEARCH_TEXT, "Avalanche transceiver");
+ tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVEREXT);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "150.50");
+ tap(TestIdExtModules.BUTTON_EDIT);
+ tap(TestIdExtModules.BUTTON_EDIT_RETURNLINE);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "-150.50");
+ tap(TestIdExtModules.BUTTON_PAY);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CREDITNOTE);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "0.00");
+ }
+
+ private void createPreferences() {
+ final String sqlAdPreference1 = String
+ .format(
+ "INSERT INTO ad_preference(ad_preference_id, ad_client_id, ad_org_id, isactive, createdby, updatedby, value, property, ispropertylist, selected) VALUES ('%s"
+ + "','39363B0921BB4293B48383844325E84C','0','Y','100','100','Y','GCNV_ForbidAnonymousCustomerUseCreditNote','Y','Y')",
+ prefId1);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference1, 1);
+
+ final String sqlAdPreference2 = String
+ .format(
+ "INSERT INTO ad_preference(ad_preference_id, ad_client_id, ad_org_id, isactive, createdby, updatedby, value, property, ispropertylist, selected) VALUES ('%s"
+ + "','39363B0921BB4293B48383844325E84C','0','Y','100','100','Y','GCNV_ForbidUseCreditNoteForDifferentCustomer','Y','Y')",
+ prefId2);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference2, 1);
+ }
+
+ private void deletePreferences() {
+ final String sqlAdPreference = String.format(
+ "DELETE FROM ad_preference WHERE ad_preference_id IN ('%s', '%s')", prefId1, prefId2);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference, 2);
+ }
+}
diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/ForbidCustomerDifferentAssignedTicketUseCreditNoteInPayOpenTickets.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/ForbidCustomerDifferentAssignedTicketUseCreditNoteInPayOpenTickets.java
new file mode 100644
--- /dev/null
+++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/ForbidCustomerDifferentAssignedTicketUseCreditNoteInPayOpenTickets.java
@@ -0,0 +1,157 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2012-2018 Openbravo S.L.U.
+ * Licensed under the Openbravo Commercial License version 1.0
+ * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
+ * or in the legal folder of this module distribution.
+ ************************************************************************************
+ */
+package org.openbravo.test.mobile.retail.extmodules.selenium.tests.creditnote;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.retail.extmodules.selenium.TestIdExtModules;
+import org.openbravo.test.mobile.retail.extmodules.selenium.terminals.WebPOSExtModulesTerminalHelper;
+import org.openbravo.test.mobile.retail.mobilecore.annotations.TestClassAnnotations;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.mobilecore.selenium.TestIdConstructor;
+import org.openbravo.test.mobile.retail.mobilecore.utils.RetailUtils;
+
+@TestClassAnnotations(isHighVolumeCompatible = true)
+public class ForbidCustomerDifferentAssignedTicketUseCreditNoteInPayOpenTickets extends
+ WebPOSExtModulesTerminalHelper {
+ final static String prefId1 = RetailUtils.getRandomUUID();
+ final static String prefId2 = RetailUtils.getRandomUUID();
+
+ @Override
+ public void beforeWithReload() {
+ createPreferences();
+ }
+
+ @Override
+ public void afterWithReload() {
+ deletePreferences();
+ }
+
+ /**
+ * Create a new ticket and try to pay using a credit note related to another customer
+ */
+ @Test
+ public void test() {
+
+ // Create a credit note for Carl Studson
+ CreateCreditNote(TestIdExtModules.BUTTON_CUSTOMER_CARLSTUDSON);
+
+ // Create a ticket for Carl Studson and change the customer after add the payment
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Carl Studson");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_CUSTOMER_CARLSTUDSON);
+ tap(TestIdExtModules.BUTTON_SEARCH);
+ write(TestIdExtModules.FIELD_SEARCH_TEXT, "Avalanche transceiver");
+ tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVEREXT);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "150.50");
+ tap(TestIdExtModules.BUTTON_PAY);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CREDITNOTE);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_CREDITNOTE_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_FIRSTROW_CREDITNOTE);
+ tap(TestIdExtModules.BUTTON_CREDITNOTE_MODAL_APPLY);
+
+ // Change the customer
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Mara Palliot");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MARAPALLIOT);
+
+ // Create a new ticket for pay open tickets
+ tap(TestIdExtModules.BUTTON_NEWRECEIPT);
+ tap(TestIdExtModules.BUTTON_SEARCH);
+ write(TestIdExtModules.FIELD_SEARCH_TEXT, "Avalanche transceiver");
+ tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVEREXT);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "150.50");
+
+ // Pay Open Tickets
+ tap(TestIdExtModules.BUTTON_MENU);
+ tap(TestIdExtModules.BUTTON_MENU_PAYOPENTICKETS);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_SEARCH);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_ROW1);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_ROW2);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_DONE);
+
+ // Add a cash payment and try to complete the order
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ verify(
+ TestIdExtModules.LABEL_POPUP_DINAMIC_CONFIRMATION_TITLE,
+ "It can not use a credit note related to a customer different than the assigned to the receipt. Please, select another one");
+ tap(TestIdExtModules.BUTTON_POPUP_CONFIRMATION_OK);
+
+ // Change again the customer and complete the order
+ tap(TestIdExtModules.BUTTON_MULTIORDER_PAYMENT_ROW1_REMOVE);
+ tap(TestIdExtModules.BUTTON_DELETERECEIPT);
+ tap(TestIdExtModules.BUTTON_RECEIPT_COUNTER);
+ tap(TestIdExtModules.BUTTON_RECEIPTLIST_ROW2);
+ tap(TestIdExtModules.BUTTON_RECEIPTLIST_ROW2);
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Carl Studson");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_CUSTOMER_CARLSTUDSON);
+
+ // Pay Open Tickets
+ tap(TestIdExtModules.BUTTON_MENU);
+ tap(TestIdExtModules.BUTTON_MENU_PAYOPENTICKETS);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_SEARCH);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_ROW1);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_ROW2);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_DONE);
+
+ // Add a cash payment to complete the orders
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+
+ }
+
+ private void CreateCreditNote(TestIdConstructor customer) {
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Carl Studson");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(customer);
+ tap(TestIdExtModules.BUTTON_SEARCH);
+ write(TestIdExtModules.FIELD_SEARCH_TEXT, "Avalanche transceiver");
+ tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVEREXT);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "150.50");
+ tap(TestIdExtModules.BUTTON_EDIT);
+ tap(TestIdExtModules.BUTTON_EDIT_RETURNLINE);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "-150.50");
+ tap(TestIdExtModules.BUTTON_PAY);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CREDITNOTE);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "0.00");
+ }
+
+ private void createPreferences() {
+ final String sqlAdPreference1 = String
+ .format(
+ "INSERT INTO ad_preference(ad_preference_id, ad_client_id, ad_org_id, isactive, createdby, updatedby, value, property, ispropertylist, selected) VALUES ('%s"
+ + "','39363B0921BB4293B48383844325E84C','0','Y','100','100','Y','GCNV_ForbidAnonymousCustomerUseCreditNote','Y','Y')",
+ prefId1);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference1, 1);
+
+ final String sqlAdPreference2 = String
+ .format(
+ "INSERT INTO ad_preference(ad_preference_id, ad_client_id, ad_org_id, isactive, createdby, updatedby, value, property, ispropertylist, selected) VALUES ('%s"
+ + "','39363B0921BB4293B48383844325E84C','0','Y','100','100','Y','GCNV_ForbidUseCreditNoteForDifferentCustomer','Y','Y')",
+ prefId2);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference2, 1);
+ }
+
+ private void deletePreferences() {
+ final String sqlAdPreference = String.format(
+ "DELETE FROM ad_preference WHERE ad_preference_id IN ('%s', '%s')", prefId1, prefId2);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference, 2);
+ }
+}
diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/UseCreditNoteWithAnonymousCustomer.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/UseCreditNoteWithAnonymousCustomer.java
new file mode 100644
--- /dev/null
+++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/UseCreditNoteWithAnonymousCustomer.java
@@ -0,0 +1,139 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2012-2018 Openbravo S.L.U.
+ * Licensed under the Openbravo Commercial License version 1.0
+ * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
+ * or in the legal folder of this module distribution.
+ ************************************************************************************
+ */
+package org.openbravo.test.mobile.retail.extmodules.selenium.tests.creditnote;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.core.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.retail.extmodules.selenium.TestIdExtModules;
+import org.openbravo.test.mobile.retail.extmodules.selenium.terminals.WebPOSExtModulesTerminalHelper;
+import org.openbravo.test.mobile.retail.mobilecore.annotations.TestClassAnnotations;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.mobilecore.selenium.TestIdConstructor;
+import org.openbravo.test.mobile.retail.mobilecore.utils.RetailUtils;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+
+@TestClassAnnotations(isHighVolumeCompatible = true)
+public class UseCreditNoteWithAnonymousCustomer extends WebPOSExtModulesTerminalHelper {
+ final static String prefId1 = RetailUtils.getRandomUUID();
+ final static String prefId2 = RetailUtils.getRandomUUID();
+
+ @Override
+ public void beforeWithReload() {
+ createPreferences();
+ setEnableStockValidation(false);
+ }
+
+ @Override
+ public void afterWithReload() {
+ deletePreferences();
+ setEnableStockValidation(true);
+ }
+
+ /**
+ * Create a ticket, using a customer different to anonymous customer. Pay using credit note as
+ * payment method and change the customer to anonymous
+ */
+ @Test
+ public void test() {
+
+ // Create a credit note for Carl Studson
+ CreateCreditNote(TestIdExtModules.BUTTON_CUSTOMER_CARLSTUDSON);
+
+ // Create a ticket for Carl Studson and change the customer after add the payment
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Carl Studson");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_CUSTOMER_CARLSTUDSON);
+
+ tap(TestIdExtModules.BUTTON_SEARCH);
+ write(TestIdExtModules.FIELD_SEARCH_TEXT, "Avalanche transceiver");
+ tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVEREXT);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "150.50");
+ tap(TestIdExtModules.BUTTON_PAY);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CREDITNOTE);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_CREDITNOTE_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_FIRSTROW_CREDITNOTE);
+ tap(TestIdExtModules.BUTTON_CREDITNOTE_MODAL_APPLY);
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Arturo Montoro");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_CUSTOMER_ARTUROMONTORO);
+ verify(TestIdPack.BUTTON_RECEIPT_CUSTOMER, "Arturo Montoro");
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ verify(
+ TestIdExtModules.LABEL_POPUP_DINAMIC_CONFIRMATION_TITLE,
+ "It is not allowed to create nor use a Credit Note for an anonymous customer. Please, change the customer or the payment method");
+ tap(TestIdExtModules.BUTTON_POPUP_CONFIRMATION_OK);
+ tap(TestIdExtModules.BUTTON_RECEIPT_PAYMENT_ROW1_REMOVE);
+
+ // Change again the customer and complete the order
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Carl Studson");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_CUSTOMER_CARLSTUDSON);
+
+ // Add Cash Payment
+ tap(TestIdExtModules.BUTTON_MORE_PAYMENTS_DIV);
+ isVisible(TestIdExtModules.POPUP_PAYMENTMETHOD, true);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CASH);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ }
+
+ private void createPreferences() {
+ final String sqlAdPreference1 = String
+ .format(
+ "INSERT INTO ad_preference(ad_preference_id, ad_client_id, ad_org_id, isactive, createdby, updatedby, value, property, ispropertylist, selected) VALUES ('%s"
+ + "','39363B0921BB4293B48383844325E84C','0','Y','100','100','Y','GCNV_ForbidAnonymousCustomerUseCreditNote','Y','Y')",
+ prefId1);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference1, 1);
+
+ final String sqlAdPreference2 = String
+ .format(
+ "INSERT INTO ad_preference(ad_preference_id, ad_client_id, ad_org_id, isactive, createdby, updatedby, value, property, ispropertylist, selected) VALUES ('%s"
+ + "','39363B0921BB4293B48383844325E84C','0','Y','100','100','Y','GCNV_ForbidUseCreditNoteForDifferentCustomer','Y','Y')",
+ prefId2);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference2, 1);
+ }
+
+ private void deletePreferences() {
+ final String sqlAdPreference = String.format(
+ "DELETE FROM ad_preference WHERE ad_preference_id IN ('%s', '%s')", prefId1, prefId2);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference, 2);
+ }
+
+ private void CreateCreditNote(TestIdConstructor customer) {
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Carl Studson");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(customer);
+ tap(TestIdExtModules.BUTTON_SEARCH);
+ write(TestIdExtModules.FIELD_SEARCH_TEXT, "Avalanche transceiver");
+ tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVEREXT);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "150.50");
+ tap(TestIdExtModules.BUTTON_EDIT);
+ tap(TestIdExtModules.BUTTON_EDIT_RETURNLINE);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "-150.50");
+ tap(TestIdExtModules.BUTTON_PAY);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CREDITNOTE);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "0.00");
+ }
+
+ private void setEnableStockValidation(boolean status) {
+ SeleniumHelper.executeScript("OB.MobileApp.model.attributes.permissions."
+ + "OBPOSSV_EnableStockValidation = " + status + ";");
+ }
+
+}
diff --git a/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/UseCreditNoteWithAnonymousCustomerInPayOpenTickets.java b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/UseCreditNoteWithAnonymousCustomerInPayOpenTickets.java
new file mode 100644
--- /dev/null
+++ b/src-test/org/openbravo/test/mobile/retail/extmodules/selenium/tests/creditnote/UseCreditNoteWithAnonymousCustomerInPayOpenTickets.java
@@ -0,0 +1,169 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2012-2018 Openbravo S.L.U.
+ * Licensed under the Openbravo Commercial License version 1.0
+ * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
+ * or in the legal folder of this module distribution.
+ ************************************************************************************
+ */
+package org.openbravo.test.mobile.retail.extmodules.selenium.tests.creditnote;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.core.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.retail.extmodules.selenium.TestIdExtModules;
+import org.openbravo.test.mobile.retail.extmodules.selenium.terminals.WebPOSExtModulesTerminalHelper;
+import org.openbravo.test.mobile.retail.mobilecore.annotations.TestClassAnnotations;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.mobilecore.selenium.TestIdConstructor;
+import org.openbravo.test.mobile.retail.mobilecore.utils.RetailUtils;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+
+@TestClassAnnotations(isHighVolumeCompatible = true)
+public class UseCreditNoteWithAnonymousCustomerInPayOpenTickets extends
+ WebPOSExtModulesTerminalHelper {
+ final static String prefId1 = RetailUtils.getRandomUUID();
+ final static String prefId2 = RetailUtils.getRandomUUID();
+
+ @Override
+ public void beforeWithReload() {
+ createPreferences();
+ setEnableStockValidation(false);
+ }
+
+ @Override
+ public void afterWithReload() {
+ deletePreferences();
+ setEnableStockValidation(true);
+ }
+
+ /**
+ * Create a ticket, using a customer different to anonymous customer. Pay using credit note as
+ * payment method, change the customer to anonymous and try to complete the order using Pay Open
+ * Tickets
+ */
+ @Test
+ public void test() {
+
+ // Create a credit note for Carl Studson
+ CreateCreditNote(TestIdExtModules.BUTTON_CUSTOMER_CARLSTUDSON);
+
+ // Create a ticket for Carl Studson and change the customer after add the payment
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Carl Studson");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_CUSTOMER_CARLSTUDSON);
+
+ tap(TestIdExtModules.BUTTON_SEARCH);
+ write(TestIdExtModules.FIELD_SEARCH_TEXT, "Avalanche transceiver");
+ tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVEREXT);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "150.50");
+ tap(TestIdExtModules.BUTTON_PAY);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CREDITNOTE);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_CREDITNOTE_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_FIRSTROW_CREDITNOTE);
+ tap(TestIdExtModules.BUTTON_CREDITNOTE_MODAL_APPLY);
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Arturo Montoro");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_CUSTOMER_ARTUROMONTORO);
+ verify(TestIdPack.BUTTON_RECEIPT_CUSTOMER, "Arturo Montoro");
+
+ // Create a new ticket for pay open tickets
+ tap(TestIdExtModules.BUTTON_NEWRECEIPT);
+ tap(TestIdExtModules.BUTTON_SEARCH);
+ write(TestIdExtModules.FIELD_SEARCH_TEXT, "Avalanche transceiver");
+ tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVEREXT);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "150.50");
+
+ // Pay Open Tickets
+ tap(TestIdExtModules.BUTTON_MENU);
+ tap(TestIdExtModules.BUTTON_MENU_PAYOPENTICKETS);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_SEARCH);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_ROW1);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_ROW2);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_DONE);
+ tap(TestIdExtModules.BUTTON_MORE_PAYMENTS_DIV);
+ isVisible(TestIdExtModules.POPUP_PAYMENTMETHOD, true);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CASH);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ verify(
+ TestIdExtModules.LABEL_POPUP_DINAMIC_CONFIRMATION_TITLE,
+ "It is not allowed to create nor use a Credit Note for an anonymous customer. Please, change the customer or the payment method");
+ tap(TestIdExtModules.BUTTON_POPUP_CONFIRMATION_OK);
+
+ // Change again the customer and complete the order
+ tap(TestIdExtModules.BUTTON_MULTIORDER_PAYMENT_ROW1_REMOVE);
+ tap(TestIdExtModules.BUTTON_DELETERECEIPT);
+ tap(TestIdExtModules.BUTTON_RECEIPT_COUNTER);
+ tap(TestIdExtModules.BUTTON_RECEIPTLIST_ROW2);
+ tap(TestIdExtModules.BUTTON_RECEIPTLIST_ROW2);
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Carl Studson");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(TestIdExtModules.BUTTON_CUSTOMER_CARLSTUDSON);
+
+ // Pay Open Tickets
+ tap(TestIdExtModules.BUTTON_MENU);
+ tap(TestIdExtModules.BUTTON_MENU_PAYOPENTICKETS);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_SEARCH);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_ROW1);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_ROW2);
+ tap(TestIdExtModules.BUTTON_POPUP_OPENTICKETS_DONE);
+ tap(TestIdExtModules.BUTTON_MORE_PAYMENTS_DIV);
+ isVisible(TestIdExtModules.POPUP_PAYMENTMETHOD, true);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CASH);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ }
+
+ private void createPreferences() {
+ final String sqlAdPreference1 = String
+ .format(
+ "INSERT INTO ad_preference(ad_preference_id, ad_client_id, ad_org_id, isactive, createdby, updatedby, value, property, ispropertylist, selected) VALUES ('%s"
+ + "','39363B0921BB4293B48383844325E84C','0','Y','100','100','Y','GCNV_ForbidAnonymousCustomerUseCreditNote','Y','Y')",
+ prefId1);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference1, 1);
+
+ final String sqlAdPreference2 = String
+ .format(
+ "INSERT INTO ad_preference(ad_preference_id, ad_client_id, ad_org_id, isactive, createdby, updatedby, value, property, ispropertylist, selected) VALUES ('%s"
+ + "','39363B0921BB4293B48383844325E84C','0','Y','100','100','Y','GCNV_ForbidUseCreditNoteForDifferentCustomer','Y','Y')",
+ prefId2);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference2, 1);
+ }
+
+ private void deletePreferences() {
+ final String sqlAdPreference = String.format(
+ "DELETE FROM ad_preference WHERE ad_preference_id IN ('%s', '%s')", prefId1, prefId2);
+ new DatabaseHelperInsertUpdateOrDelete().execute(sqlAdPreference, 2);
+ }
+
+ private void CreateCreditNote(TestIdConstructor customer) {
+ tap(TestIdExtModules.BUTTON_RECEIPT_CUSTOMER);
+ write(TestIdExtModules.FIELD_CUSTOMER_MODAL, "Carl Studson");
+ tap(TestIdExtModules.BUTTON_CUSTOMER_MODAL_SEARCH);
+ tap(customer);
+ tap(TestIdExtModules.BUTTON_SEARCH);
+ write(TestIdExtModules.FIELD_SEARCH_TEXT, "Avalanche transceiver");
+ tap(TestIdExtModules.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdExtModules.BUTTON_SEARCHPRODUCT_AVALANCHETRANSCEIVEREXT);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "150.50");
+ tap(TestIdExtModules.BUTTON_EDIT);
+ tap(TestIdExtModules.BUTTON_EDIT_RETURNLINE);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "-150.50");
+ tap(TestIdExtModules.BUTTON_PAY);
+ tap(TestIdExtModules.BUTTON_PAYMENT_CREDITNOTE);
+ tap(TestIdExtModules.BUTTON_PAY_EXACT);
+ tap(TestIdExtModules.BUTTON_PAY_DONE);
+ verify(TestIdExtModules.LABEL_TOTALTOPAY, "0.00");
+ }
+
+ private void setEnableStockValidation(boolean status) {
+ SeleniumHelper.executeScript("OB.MobileApp.model.attributes.permissions."
+ + "OBPOSSV_EnableStockValidation = " + status + ";");
+ }
+}
diff --git a/src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java b/src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/TestIdPack.java
@@ -2494,6 +2494,8 @@
"Arturo Montoro", EnyoKind.CUSTOMER); //
public static TestIdConstructor BUTTON_CUSTOMER_CARLSTUDSON = new TestIdConstructor(
"Carl Studson", EnyoKind.CUSTOMER); //
+ public static TestIdConstructor BUTTON_CUSTOMER_MARAPALLIOT = new TestIdConstructor(
+ "Mara Palliot", EnyoKind.CUSTOMER); //
public static TestIdConstructor TABLE_CUSTOMER_SEARCH = new TestIdConstructor(
"stBPAssignToReceipt_tbody"); //
public static TestIdConstructor LABEL_CUSTOMER_SEARCH_IDENTIFIER = new TestIdConstructor(
issue37673_POSTerminal.diff [^] (1,516 bytes) 2018-08-07 13:33 [Show Content] [Hide Content]changeset: 9604:749b60ecc71c
tag: tip
user: Kepa Choperena <kepa.choperena@openbravo.com>
date: Tue Aug 07 09:37:01 2018 +0200
files: web/org.openbravo.retail.posterminal/js/pointofsale/view/keyboard-toolbars.js
description:
[CreditNoteAnonymousLimitations]: Added a hook before select a payment method
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/view/keyboard-toolbars.js b/web/org.openbravo.retail.posterminal/js/pointofsale/view/keyboard-toolbars.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/keyboard-toolbars.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/keyboard-toolbars.js
@@ -256,6 +256,22 @@
};
},
addPaymentButton: function (btncomponent, countbuttons, paymentsbuttons, dialogbuttons, payment) {
+ if (btncomponent.btn.command.indexOf('paymentMethodCategory.showitems.') < 0) {
+ btncomponent.btn.definition.canTap = function (callback) {
+ OB.UTIL.HookManager.executeHooks('OBPOS_PrePaymentSelected', {
+ paymentSelected: payment,
+ receipt: btncomponent.btn.definition.scope.receipt,
+ btnDefintion: btncomponent.btn.definition
+ }, function (args) {
+ if (args && args.cancellation && args.cancellation === true) {
+ callback(false);
+ } else {
+ callback(true);
+ }
+ });
+ };
+ }
+
if (countbuttons < paymentsbuttons) {
this.createComponent(btncomponent);
} else {
|