Attached Files | issue 35392 source posterminal.patch [^] (4,782 bytes) 2017-03-01 15:52 [Show Content] [Hide Content]# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1488375406 -19800
# Wed Mar 01 19:06:46 2017 +0530
# Node ID c6c274d968d2818fa6207c545fef4342f9756744
# Parent c04938eafe0f8067af8fcad75f5ea21a7dfacac6
Related to issue 35392 : Service Product should be not deleted if quantity rule is configured
* To delete the service product, If service quantity rule is defined as "As per product", all the services must be selected
diff -r c04938eafe0f -r c6c274d968d2 web/org.openbravo.retail.posterminal/js/components/order.js
--- a/web/org.openbravo.retail.posterminal/js/components/order.js Thu Feb 23 17:47:42 2017 +0530
+++ b/web/org.openbravo.retail.posterminal/js/components/order.js Wed Mar 01 19:06:46 2017 +0530
@@ -755,16 +755,14 @@
// Split/Remove services lines
var siblingServicesLines = getSiblingServicesLines(line.get('product').id, line.get('relatedLines')[0].orderlineId);
- if (!me.order.get('deleting')) {
- if (siblingServicesLines.length < qtyService) {
- var i, p, newLine;
- for (i = 0; i < qtyService - siblingServicesLines.length; i++) {
- p = line.get('product').clone();
- p.set('groupProduct', false);
- newLine = me.order.createLine(p, qtyLineServ);
- newLine.set('relatedLines', siblingServicesLines[0].get('relatedLines'));
- newLine.set('groupService', false);
- }
+ if (!me.order.get('deleting') && siblingServicesLines.length < qtyService) {
+ var i, p, newLine;
+ for (i = 0; i < qtyService - siblingServicesLines.length; i++) {
+ p = line.get('product').clone();
+ p.set('groupProduct', false);
+ newLine = me.order.createLine(p, qtyLineServ);
+ newLine.set('relatedLines', siblingServicesLines[0].get('relatedLines'));
+ newLine.set('groupService', false);
}
} else if (siblingServicesLines.length > qtyService) {
linesToRemove = OB.UTIL.mergeArrays(linesToRemove, _.initial(siblingServicesLines, qtyService));
diff -r c04938eafe0f -r c6c274d968d2 web/org.openbravo.retail.posterminal/js/pointofsale/view/editline.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/editline.js Thu Feb 23 17:47:42 2017 +0530
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/editline.js Wed Mar 01 19:06:46 2017 +0530
@@ -201,7 +201,8 @@
classes: 'btnlink-orange',
tap: function () {
var me = this,
- order = this.model.get('order');
+ order = this.model.get('order'),
+ unGroupedServiceLines;
function callback() {
OB.UTIL.HookManager.executeHooks('OBPOS_PostDeleteLine', {
@@ -226,6 +227,39 @@
});
return;
}
+
+ unGroupedServiceLines = _.filter(me.owner.owner.selectedModels, function (line) {
+ return line.has('relatedLines') && line.get('relatedLines').length > 0 && !line.get('originalOrderLineId') && line.get('product').get('quantityRule') === 'PP' && !line.get('groupService');
+ });
+
+ function getServiceQty(service) {
+ return _.filter(unGroupedServiceLines, function (line) {
+ return line.get('product').get('id') === service.get('product').get('id') && line.get('relatedLines')[0].orderlineId === service.get('relatedLines')[0].orderlineId;
+ }).length;
+ }
+
+ function getProductQty(service) {
+ return _.find(order.get('lines').models, function (line) {
+ return _.indexOf(_.pluck(service.get('relatedLines'), 'orderlineId'), line.get('id')) !== -1;
+ }).get('qty');
+ }
+ if (unGroupedServiceLines && unGroupedServiceLines.length > 0) {
+ var i, j, serviceQty, productQty, uniqueServices;
+ uniqueServices = _.uniq(unGroupedServiceLines, false, function (line) {
+ return line.get('product').get('id') + line.get('relatedLines')[0].orderlineId;
+ });
+ for (i = 0; i < uniqueServices.length; i++) {
+ serviceQty = getServiceQty(uniqueServices[i]);
+ productQty = getProductQty(uniqueServices[i]);
+ if (productQty && productQty !== serviceQty) {
+ OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBPOS_LineCanNotBeDeleted'), OB.I18N.getLabel('OBPOS_AllServiceLineMustSelectToDelete'), [{
+ label: OB.I18N.getLabel('OBMOBC_LblOk')
+ }]);
+ return;
+ }
+ }
+ }
+
OB.UTIL.Approval.requestApproval(
me.model, 'OBPOS_approval.deleteLine', function (approved, supervisor, approvalType) {
if (approved) {
issue 35392 test.patch [^] (6,292 bytes) 2017-03-01 15:53 [Show Content] [Hide Content]# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1488379183 -19800
# Wed Mar 01 20:09:43 2017 +0530
# Node ID 5d32e71d7dfa48d88420fdadbb77b00662eb7507
# Parent 935fce295c0c966b2261337816577b3f6019ffa9
Verifies issue 35392 : Added automated test 'I35392_VerifyServiceWithQuantityRule'
diff -r 935fce295c0c -r 5d32e71d7dfa src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/services/I35392_VerifyServiceWithQuantityRule.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/services/I35392_VerifyServiceWithQuantityRule.java Wed Mar 01 20:09:43 2017 +0530
@@ -0,0 +1,127 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.0 (the "License"), being the Mozilla Public License
+ * Version 1.1 with a permitted attribution clause; you may not use this
+ * file except in compliance with the License. You may obtain a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo S.L.U.
+ * All portions are Copyright (C) 2017 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author RAN
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.services;
+
+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.mobilecore.annotations.TestClassAnnotations;
+import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
+import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
+import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSTerminalHelper;
+
+@TestClassAnnotations(isHighVolumeCompatible = true)
+public class I35392_VerifyServiceWithQuantityRule extends WebPOSTerminalHelper {
+
+ final private String productRepairBoots = "6E193FBB335E418390CAB05CBA01F35B";
+
+ @Test
+ public void test() {
+ // Add Product
+ tap(TestIdPack.BUTTON_SEARCH);
+ write(TestIdPack.FIELD_SEARCH_TEXT, TestIdPack.BUTTON_SEARCHPRODUCT_ALPINEPOLES.getRowName());
+ tap(TestIdPack.BUTTON_SEARCH_EXECUTE);
+ tap(TestIdPack.BUTTON_SEARCHPRODUCT_ALPINEPOLES);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "36.50");
+
+ // Add Service
+ tap(TestIdPack.BUTTON_RECEIPT_ROW1_SHOWRELATEDSERVICES);
+ tap(TestIdPack.BUTTON_SEARCHPRODUCT_REPAIRBOOTS);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "44.50");
+ verify(TestIdPack.LABEL_RECEIPT_ROW1_TITLE,
+ TestIdPack.BUTTON_SEARCHPRODUCT_ALPINEPOLES.getRowName());
+ verify(TestIdPack.LABEL_RECEIPT_ROW1_QTY, "1");
+ verify(TestIdPack.LABEL_RECEIPT_ROW2_TITLE,
+ TestIdPack.BUTTON_SEARCHPRODUCT_REPAIRBOOTS.getRowName());
+
+ // Update Quantity With "1"
+ tap(TestIdPack.BUTTON_RECEIPT_ROW1);
+ tap(TestIdPack.BUTTON_KEYPAD_PLUS);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "89.00");
+ verify(TestIdPack.LABEL_RECEIPT_ROW1_QTY, "2");
+ verify(TestIdPack.LABEL_RECEIPT_ROW2_TITLE,
+ TestIdPack.BUTTON_SEARCHPRODUCT_REPAIRBOOTS.getRowName());
+ verify(TestIdPack.LABEL_RECEIPT_ROW3_TITLE,
+ TestIdPack.BUTTON_SEARCHPRODUCT_REPAIRBOOTS.getRowName());
+
+ // Update Quantity With "1"
+ tap(TestIdPack.BUTTON_RECEIPT_ROW1);
+ tap(TestIdPack.BUTTON_KEYPAD_PLUS);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "133.50");
+ verify(TestIdPack.LABEL_RECEIPT_ROW1_QTY, "3");
+ verify(TestIdPack.LABEL_RECEIPT_ROW2_TITLE,
+ TestIdPack.BUTTON_SEARCHPRODUCT_REPAIRBOOTS.getRowName());
+ verify(TestIdPack.LABEL_RECEIPT_ROW3_TITLE,
+ TestIdPack.BUTTON_SEARCHPRODUCT_REPAIRBOOTS.getRowName());
+ verify(TestIdPack.LABEL_RECEIPT_ROW4_TITLE,
+ TestIdPack.BUTTON_SEARCHPRODUCT_REPAIRBOOTS.getRowName());
+
+ // Reduce Quantity With "1"
+ tap(TestIdPack.BUTTON_RECEIPT_ROW1);
+ tap(TestIdPack.BUTTON_KEYPAD_MINUS);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "89.00");
+ verify(TestIdPack.LABEL_RECEIPT_ROW1_QTY, "2");
+ verify(TestIdPack.LABEL_RECEIPT_ROW2_TITLE,
+ TestIdPack.BUTTON_SEARCHPRODUCT_REPAIRBOOTS.getRowName());
+ verify(TestIdPack.LABEL_RECEIPT_ROW3_TITLE,
+ TestIdPack.BUTTON_SEARCHPRODUCT_REPAIRBOOTS.getRowName());
+
+ // Delete Service
+ final String labelLineNotDelete = (String) SeleniumHelper
+ .executeScriptWithReturn("OB.I18N.getLabel('OBPOS_LineCanNotBeDeleted')");
+ tap(TestIdPack.BUTTON_RECEIPT_ROW3);
+ tap(TestIdPack.BUTTON_EDIT_DELETELINE);
+ isVisible(TestIdPack.CONFIRMATION_POPUP, true);
+ verify(TestIdPack.LABEL_POPUP_TITLE, labelLineNotDelete);
+ tap(TestIdExtModules.BUTTON_POPUP_OK);
+ // Select All services to delete
+ tap(TestIdExtModules.BUTTON_MULTISELECTION_BTN_SINGLESELECTION);
+ tap(TestIdPack.BUTTON_RECEIPT_ROW2);
+ tap(TestIdPack.BUTTON_EDIT_DELETELINE);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "73.00");
+ verify(TestIdPack.LABEL_RECEIPT_ROW1_TITLE,
+ TestIdPack.BUTTON_SEARCHPRODUCT_ALPINEPOLES.getRowName());
+ verify(TestIdPack.LABEL_RECEIPT_ROW1_QTY, "2");
+
+ tap(TestIdPack.BUTTON_DELETERECEIPT);
+ tap(TestIdPack.BUTTON_DELETERECEIPT_CONFIRM);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+ }
+
+ @Override
+ public void beforeWithReload() {
+ updateServiceProduct(true);
+ }
+
+ @Override
+ public void afterWithReload() {
+ updateServiceProduct(false);
+ }
+
+ private void updateServiceProduct(final boolean isForTest) {
+ new DatabaseHelperInsertUpdateOrDelete().execute(String.format(
+ "UPDATE m_product SET em_obpos_groupedproduct = '%s', "
+ + "quantity_rule = '%s' where m_product_id = '%s'", (isForTest ? "N" : "Y"),
+ (isForTest ? "PP" : "UQ"), productRepairBoots), 1);
+ }
+}
|