Attached Files | issue 37706 soure returns.patch [^] (21,555 bytes) 2018-02-06 07:03 [Show Content] [Hide Content]# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1517896843 -19800
# Tue Feb 06 11:30:43 2018 +0530
# Node ID 27dbee54e37b03c31bb21f69cf227f4e5bd57a54
# Parent ef437a40ba5d6bee5c3ccb1fef1e4ce579dcc3cf
Related to issue 37706 : Added new API for creating verified return lines
diff -r ef437a40ba5d -r 27dbee54e37b src/org/openbravo/retail/returns/ReturnsComponentProvider.java
--- a/src/org/openbravo/retail/returns/ReturnsComponentProvider.java Thu Jan 25 09:29:02 2018 +0100
+++ b/src/org/openbravo/retail/returns/ReturnsComponentProvider.java Tue Feb 06 11:30:43 2018 +0530
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2013-2017 Openbravo S.L.U.
+ * Copyright (C) 2013-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.
@@ -45,7 +45,7 @@
final String prefix = "web/org.openbravo.retail.returns/";
- final String[] resourceDependency = { "returnReceiptButton", "modalReturnLines",
+ final String[] resourceDependency = { "returnUtils", "returnReceiptButton", "modalReturnLines",
"hookReturnPaidOrder", "hookReturnChangeQty", "hookRenderOrderLine",
"modalproductattributeverifiedreturns" };
diff -r ef437a40ba5d -r 27dbee54e37b web/org.openbravo.retail.returns/js/modalReturnLines.js
--- a/web/org.openbravo.retail.returns/js/modalReturnLines.js Thu Jan 25 09:29:02 2018 +0100
+++ b/web/org.openbravo.retail.returns/js/modalReturnLines.js Tue Feb 06 11:30:43 2018 +0530
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2014-2017 Openbravo S.L.U.
+ * Copyright (C) 2014-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.
@@ -470,18 +470,16 @@
}
},
callbackExecutor: function (inSender, inEvent) {
- var me = this,
- i;
- if (me.args.args.order.receiptLines.length === 0) {
+ if (this.args.args.order.receiptLines.length === 0) {
OB.UTIL.showLoading(false);
return;
}
- var nameLocation = "";
- var oldbp = me.args.args.context.model.get('order').get('bp');
- var bpLoc = me.args.args.order.bpLocId;
- var bpBillLoc;
- var noFoundProduct = true,
- NoFoundCustomer = true,
+ var i, bpBillLoc, nameLocation = '',
+ me = this,
+ receipt = me.args.args.context.model.get('order'),
+ oldbp = receipt.get('bp'),
+ bpLoc = me.args.args.order.bpLocId,
+ noFoundCustomer = true,
isLoadedPartiallyFromBackend = false;
var findBusinessPartner = function (bp) {
@@ -505,85 +503,6 @@
});
}
var locationForBpartner = function (bpLoc, billLoc) {
- var finishOrderCreation = function () {
- me.args.args.context.model.get('order').calculateReceipt(function () {
- me.args.args.context.model.get('order').save(function () {
- me.args.args.context.model.get('orderList').saveCurrent();
- OB.UTIL.showLoading(false);
- });
- });
- },
- finishOrder = _.after(me.args.args.order.receiptLines.length, finishOrderCreation),
- createOrderLines = function (ignoreReturnApproval) {
- _.each(me.args.args.order.receiptLines, function (line) {
- if (!line.exceedsQuantity) {
- var createLineFunction = function (prod) {
- line.originalOrderLineId = line.lineId;
- line.originalDocumentNo = me.args.args.order.documentNo;
- line.skipApplyPromotions = true;
- delete line.id;
- delete line.lineId;
- delete line.deliveredQuantity;
- var order = me.args.args.context.model.get('order');
- var qty = line.selectedQuantity;
- if (order.get('orderType') !== 1) {
- qty = qty ? -qty : -1;
- }
- prod.set('ignorePromotions', true);
- prod.set('standardPrice', line.priceIncludesTax ? line.unitPrice : line.baseNetUnitPrice);
- prod.set('ignoreReturnApproval', ignoreReturnApproval);
- order.addProductToOrder(prod, qty, {
- isVerifiedReturn: true,
- isEditable: false,
- blockAddProduct: true,
- originalOrder: me.args.args.order,
- // Plain JS Object, no Backbone Order
- originalLine: line
- // Plain JS Object, no Backbone Order
- }, line, function () {
- me.args.args.cancelOperation = true;
- OB.UTIL.HookManager.callbackExecutor(me.args.args, me.args.callbacks);
- finishOrder();
- });
- };
-
- _.each(line.promotions, function (promotion) {
- promotion.amt = -promotion.amt;
- promotion.actualAmt = -promotion.actualAmt;
- promotion.displayedTotalAmount = -promotion.displayedTotalAmount;
- });
- OB.Dal.get(OB.Model.Product, line.id, function (product) {
- createLineFunction(product);
- }, null, function () {
- new OB.DS.Request('org.openbravo.retail.posterminal.master.LoadedProduct').exec({
- productId: line.id
- }, function (data) {
- createLineFunction(OB.Dal.transform(OB.Model.Product, data[0]));
- }, function () {
- if (noFoundProduct) {
- noFoundProduct = false;
- OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBRETUR_InformationTitle'), OB.I18N.getLabel('OBRETUR_NoReturnLoadedText'), [{
- label: OB.I18N.getLabel('OBPOS_LblOk'),
- isConfirmButton: true
- }]);
- }
- });
- });
- } else {
- me.args.args.cancelOperation = true;
- OB.UTIL.HookManager.callbackExecutor(me.args.args, me.args.callbacks);
- finishOrder();
- }
- });
- },
- approvalNeeded = false,
- currentDate = new Date(),
- approvalList = [],
- servicesToApprove = '',
- servicesToApproveArr = [],
- overdueServicesToApprove = '',
- overdueServicesToApproveArr = [];
-
bp.set('shipLocName', bpLoc.get('name'));
bp.set('shipLocId', bpLoc.get('id'));
bp.set('shipPostalCode', bpLoc.get('postalCode'));
@@ -602,61 +521,19 @@
bp.set('countryName', billLoc.get('countryName'));
bp.set('locationBillModel', billLoc);
}
-
-
me.nameLocation = bpLoc.get('name');
- //If we do not let user to select qty to return of shipment lines, we do it automatically
- if (!OB.MobileApp.model.hasPermission("OBPOS_SplitLinesInShipments", true)) {
- me.args.args.order.receiptLines = me.autoSplitShipmentLines(me.args.args.order.receiptLines);
- }
- me.args.args.context.model.get('order').setBPandBPLoc(bp, false, true, function () {
- currentDate.setHours(0);
- currentDate.setMinutes(0);
- currentDate.setSeconds(0);
- currentDate.setMilliseconds(0);
- for (i = 0; i < me.args.args.order.receiptLines.length; i++) {
- var line = me.args.args.order.receiptLines[i];
- if (!line.notReturnable) {
- servicesToApprove += '<br>· ' + line.name;
- servicesToApproveArr.push(' * ' + line.name);
- approvalNeeded = true;
- if (line.overdueReturnDays < 0 || ((currentDate.getTime() - line.overdueReturnDays * 86400000) > (new Date(me.args.args.order.orderDate)).getTime())) {
- overdueServicesToApprove += '<br>· ' + line.name;
- overdueServicesToApproveArr.push(' * ' + line.name);
- }
- }
- }
- if (approvalNeeded) {
- if (!OB.MobileApp.model.hasPermission('OBPOS_approval.returnService', true)) {
- approvalList.push({
- approval: 'OBPOS_approval.returnService',
- message: 'OBPOS_approval.returnService',
- params: [servicesToApprove]
- });
- }
- if (!OB.MobileApp.model.hasPermission('OBRETUR_approval.overdueService', true) && overdueServicesToApprove.length > 0) {
- approvalList.push({
- approval: 'OBRETUR_approval.overdueService',
- message: 'OBRETUR_returnService_OutOfDate_warning',
- params: [overdueServicesToApprove]
+ receipt.setBPandBPLoc(bp, false, true, function () {
+ OB.UTIL.ReturnUtils.addReturnLines(me, receipt, me.args.args.order, me.args.args.order.receiptLines, function () {
+ receipt.calculateReceipt(function () {
+ receipt.save(function () {
+ OB.MobileApp.model.orderList.saveCurrent();
+ OB.UTIL.showLoading(false);
});
- }
-
- OB.UTIL.showLoading(false);
- OB.UTIL.Approval.requestApproval(
- OB.MobileApp.view.$.containerWindow.getRoot().model, approvalList, function (approved, supervisor) {
- if (approved) {
- if (supervisor.id === OB.POS.terminal.terminal.usermodel.id && overdueServicesToApprove.length > 0) {
- OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBMOBC_LblWarning'), OB.I18N.getLabel('OBRETUR_returnService_OutOfDate_warning', [overdueServicesToApproveArr]));
- }
- OB.UTIL.showLoading(true);
- createOrderLines(true);
- }
});
- } else {
- createOrderLines();
- }
+ me.args.args.cancelOperation = true;
+ OB.UTIL.HookManager.callbackExecutor(me.args.args, me.args.callbacks);
+ });
});
};
if (isLoadedPartiallyFromBackend) {
@@ -700,8 +577,8 @@
}
findBusinessPartner(OB.Dal.transform(OB.Model.BusinessPartner, data[0]));
}, function () {
- if (NoFoundCustomer) {
- NoFoundCustomer = false;
+ if (noFoundCustomer) {
+ noFoundCustomer = false;
OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBPOS_InformationTitle'), OB.I18N.getLabel('OBPOS_NoReceiptLoadedText'), [{
label: OB.I18N.getLabel('OBPOS_LblOk'),
isConfirmButton: true
diff -r ef437a40ba5d -r 27dbee54e37b web/org.openbravo.retail.returns/js/returnUtils.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/org.openbravo.retail.returns/js/returnUtils.js Tue Feb 06 11:30:43 2018 +0530
@@ -0,0 +1,215 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 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.
+ ************************************************************************************
+ */
+
+/*global OB, enyo, _ */
+
+(function () {
+
+ OB.UTIL.ReturnUtils = {};
+
+ // originalReceipt -> Plain JS Object, no Backbone Order
+ OB.UTIL.ReturnUtils.addReturnLines = function (context, receipt, originalReceipt, returnLines, callback) {
+
+ if (OB.UTIL.isNullOrUndefined(receipt) || OB.UTIL.isNullOrUndefined(originalReceipt) || OB.UTIL.isNullOrUndefined(returnLines) || (_.isArray(returnLines) && returnLines.length === 0)) {
+ OB.UTIL.showLoading(false);
+ return;
+ }
+
+ var i, autoSplitShipmentLines, finishOrder, createOrderLines, noFoundProduct = true,
+ approvalNeeded = false,
+ currentDate = new Date(),
+ approvalList = [],
+ servicesToApprove = '',
+ servicesToApproveArr = [],
+ overdueServicesToApprove = '',
+ overdueServicesToApproveArr = [];
+
+ currentDate.setHours(0);
+ currentDate.setMinutes(0);
+ currentDate.setSeconds(0);
+ currentDate.setMilliseconds(0);
+
+ autoSplitShipmentLines = function (lines) {
+ var newlines = [];
+ enyo.forEach(lines, function (line) {
+ if (line.shipmentlines && line.shipmentlines.length > 1) {
+ enyo.forEach(line.shipmentlines, function (sline) {
+ var attr, splitline = {};
+ if (line.selectedQuantity > 0 && sline.remainingQty > 0) {
+ for (attr in line) {
+ if (line.hasOwnProperty(attr) && !OB.UTIL.isNullOrUndefined(line[attr]) && typeof line[attr] !== 'object') {
+ splitline[attr] = line[attr];
+ }
+ }
+ splitline.compname = line.lineId + sline.shipLineId;
+ splitline.quantity = sline.qty;
+ splitline.shiplineNo = sline.shipmentlineNo;
+ splitline.shipment = sline.shipment;
+ splitline.shipmentlineId = sline.shipLineId;
+ splitline.selectedQuantity = parseInt(splitline.selectedQuantity, 10);
+ if (sline.remainingQty < splitline.selectedQuantity) {
+ splitline.selectedQuantity = sline.remainingQty;
+ }
+ line.selectedQuantity = OB.DEC.sub(line.selectedQuantity, splitline.selectedQuantity);
+ // delete confusing properties
+ delete splitline.linegrossamount;
+ delete splitline.warehouse;
+ delete splitline.warehousename;
+ // split promotions
+ splitline.promotions = [];
+ if (line.promotions.length > 0) {
+ enyo.forEach(line.promotions, function (p) {
+ if (!OB.UTIL.isNullOrUndefined(p)) {
+ var attr, splitpromo = {};
+ for (attr in p) {
+ if (p.hasOwnProperty(attr) && !OB.UTIL.isNullOrUndefined(p[attr]) && typeof p[attr] !== 'object') {
+ splitpromo[attr] = p[attr];
+ }
+ }
+ splitpromo.amt = OB.DEC.mul(p.amt, (splitline.selectedQuantity / line.quantity));
+ splitpromo.actualAmt = OB.DEC.mul(p.actualAmt, (splitline.selectedQuantity / line.quantity));
+ splitpromo.displayedTotalAmount = OB.DEC.mul(p.displayedTotalAmount, (splitline.selectedQuantity / line.quantity));
+ splitline.promotions.push(splitpromo);
+ }
+ });
+ }
+
+ newlines.push(splitline);
+ }
+ }, this);
+ } else {
+ line.compname = line.lineId;
+ if (line.shipmentlines && line.shipmentlines.length === 1) {
+ line.shipmentlineId = line.shipmentlines[0].shipLineId;
+ }
+ // delete confusing properties
+ delete line.linegrossamount;
+ delete line.warehouse;
+ delete line.warehousename;
+ newlines.push(line);
+ }
+ }, this);
+ return newlines;
+ };
+
+ finishOrder = _.after(returnLines.length, function () {
+ if (callback) {
+ callback();
+ }
+ });
+
+ createOrderLines = function (ignoreReturnApproval) {
+ _.each(returnLines, function (line) {
+ if (!line.exceedsQuantity) {
+ var createLineFunction = function (prod) {
+ line.originalOrderLineId = line.lineId;
+ line.originalDocumentNo = originalReceipt.documentNo;
+ line.skipApplyPromotions = true;
+ delete line.id;
+ delete line.lineId;
+ delete line.deliveredQuantity;
+ var qty = line.selectedQuantity;
+ if (receipt.get('orderType') !== 1) {
+ qty = qty ? -qty : -1;
+ }
+ prod.set('ignorePromotions', true);
+ prod.set('standardPrice', line.priceIncludesTax ? line.unitPrice : line.baseNetUnitPrice);
+ prod.set('ignoreReturnApproval', ignoreReturnApproval);
+ receipt.addProductToOrder(prod, qty, {
+ isVerifiedReturn: true,
+ isEditable: false,
+ blockAddProduct: true,
+ originalOrder: originalReceipt,
+ // Plain JS Object, no Backbone Order
+ originalLine: line
+ // Plain JS Object, no Backbone Order
+ }, line, function () {
+ finishOrder();
+ });
+ };
+
+ _.each(line.promotions, function (promotion) {
+ promotion.amt = -promotion.amt;
+ promotion.actualAmt = -promotion.actualAmt;
+ promotion.displayedTotalAmount = -promotion.displayedTotalAmount;
+ });
+ OB.Dal.get(OB.Model.Product, line.id, function (product) {
+ createLineFunction(product);
+ }, null, function () {
+ new OB.DS.Request('org.openbravo.retail.posterminal.master.LoadedProduct').exec({
+ productId: line.id
+ }, function (data) {
+ createLineFunction(OB.Dal.transform(OB.Model.Product, data[0]));
+ }, function () {
+ if (noFoundProduct) {
+ noFoundProduct = false;
+ OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBRETUR_InformationTitle'), OB.I18N.getLabel('OBRETUR_NoReturnLoadedText'), [{
+ label: OB.I18N.getLabel('OBPOS_LblOk'),
+ isConfirmButton: true
+ }]);
+ }
+ });
+ });
+ } else {
+ finishOrder();
+ }
+ });
+ };
+
+ //If we do not let user to select qty to return of shipment lines, we do it automatically
+ if (!OB.MobileApp.model.hasPermission("OBPOS_SplitLinesInShipments", true)) {
+ returnLines = autoSplitShipmentLines(returnLines);
+ }
+
+ for (i = 0; i < returnLines.length; i++) {
+ var line = returnLines[i];
+ if (!line.notReturnable) {
+ servicesToApprove += '<br>· ' + line.name;
+ servicesToApproveArr.push(' * ' + line.name);
+ approvalNeeded = true;
+ if (line.overdueReturnDays < 0 || ((currentDate.getTime() - line.overdueReturnDays * 86400000) > (new Date(originalReceipt.orderDate)).getTime())) {
+ overdueServicesToApprove += '<br>· ' + line.name;
+ overdueServicesToApproveArr.push(' * ' + line.name);
+ }
+ }
+ }
+
+ if (approvalNeeded) {
+ if (!OB.MobileApp.model.hasPermission('OBPOS_approval.returnService', true)) {
+ approvalList.push({
+ approval: 'OBPOS_approval.returnService',
+ message: 'OBPOS_approval.returnService',
+ params: [servicesToApprove]
+ });
+ }
+ if (!OB.MobileApp.model.hasPermission('OBRETUR_approval.overdueService', true) && overdueServicesToApprove.length > 0) {
+ approvalList.push({
+ approval: 'OBRETUR_approval.overdueService',
+ message: 'OBRETUR_returnService_OutOfDate_warning',
+ params: [overdueServicesToApprove]
+ });
+ }
+
+ OB.UTIL.showLoading(false);
+ OB.UTIL.Approval.requestApproval(
+ OB.MobileApp.view.$.containerWindow.getRoot().model, approvalList, function (approved, supervisor) {
+ if (approved) {
+ if (supervisor.id === OB.POS.terminal.terminal.usermodel.id && overdueServicesToApprove.length > 0) {
+ OB.UTIL.showConfirmation.display(OB.I18N.getLabel('OBMOBC_LblWarning'), OB.I18N.getLabel('OBRETUR_returnService_OutOfDate_warning', [overdueServicesToApproveArr]));
+ }
+ OB.UTIL.showLoading(true);
+ createOrderLines(true);
+ }
+ });
+ } else {
+ createOrderLines();
+ }
+ };
+
+}());
\ No newline at end of file
issue 37706 soure test.patch [^] (4,460 bytes) 2018-02-06 07:03 [Show Content] [Hide Content]# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1517896876 -19800
# Tue Feb 06 11:31:16 2018 +0530
# Node ID d7a3f07b9a9701e1cc6140499cf11d606850cc68
# Parent 77363b563aee01450253db52d856acae105db4db
Verifies issue 37706 : Modified automated test 'I33227_VerifyReceiptAfterLockScreen'
diff -r 77363b563aee -r d7a3f07b9a97 src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I33227_VerifyReceiptAfterLockScreen.java
--- a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I33227_VerifyReceiptAfterLockScreen.java Mon Feb 05 14:03:36 2018 +0530
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/system/I33227_VerifyReceiptAfterLockScreen.java Tue Feb 06 11:31:16 2018 +0530
@@ -21,69 +21,47 @@
*/
package org.openbravo.test.mobile.retail.pack.selenium.tests.system;
-import java.util.UUID;
-
import org.junit.Test;
import org.openbravo.test.mobile.retail.mobilecore.database.DatabaseHelperInsertUpdateOrDelete;
import org.openbravo.test.mobile.retail.mobilecore.javascript.BackboneHelper;
+import org.openbravo.test.mobile.retail.mobilecore.utils.RetailUtils;
import org.openbravo.test.mobile.retail.pack.selenium.TestIdPack;
import org.openbravo.test.mobile.retail.pack.selenium.terminals.WebPOSTerminalHelper;
public class I33227_VerifyReceiptAfterLockScreen extends WebPOSTerminalHelper {
- private final String preferenceId = getUUID();
+ private final String preferenceId = RetailUtils.getRandomUUID();
@Test
public void test() {
- boolean isTestSuccessful = false;
- try {
- // Create database changes
- createDatabaseChanges();
-
- // Reload Terminal
- reload();
+ // Add Product
+ tap(TestIdPack.BUTTON_BROWSE);
+ tap(TestIdPack.BUTTON_CATEGORY_LIGHTINGANDELECTRONICS);
+ tap(TestIdPack.BUTTON_PRODUCT_LIGHTINGANDELECTRONICS_HEADLAMP);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "18.90");
- // Add Product
- tap(TestIdPack.BUTTON_BROWSE);
- tap(TestIdPack.BUTTON_CATEGORY_LIGHTINGANDELECTRONICS);
- tap(TestIdPack.BUTTON_PRODUCT_LIGHTINGANDELECTRONICS_HEADLAMP);
- verify(TestIdPack.LABEL_TOTALTOPAY, "18.90");
-
- // Change price to 0
- tap(TestIdPack.BUTTON_RECEIPT_ROW1);
- tap(TestIdPack.BUTTON_KEYPAD_0);
- tap(TestIdPack.BUTTON_KEYPAD_PRICE);
- verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+ // Change price to 0
+ tap(TestIdPack.BUTTON_RECEIPT_ROW1);
+ tap(TestIdPack.BUTTON_KEYPAD_0);
+ tap(TestIdPack.BUTTON_KEYPAD_PRICE);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
- // Lock Screen
- tap(TestIdPack.BUTTON_MENU);
- tap(TestIdPack.BUTTON_MENU_ONLINE);
- tap(TestIdPack.BUTTON_LOCKSCREEN);
-
- // Login
- logIn();
-
- verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
- tap(TestIdPack.BUTTON_DELETERECEIPT);
- tap(TestIdPack.BUTTON_DELETERECEIPT_CONFIRM);
- verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+ // Lock Screen
+ tap(TestIdPack.BUTTON_MENU);
+ tap(TestIdPack.BUTTON_MENU_ONLINE);
+ tap(TestIdPack.BUTTON_LOCKSCREEN);
- // Reset to default values
- restoreDatabaseChanges();
-
- // Reload Terminal
- reload();
+ // Login
+ logIn();
- isTestSuccessful = true;
- } finally {
- if (!isTestSuccessful) {
- // Restore database changes
- restoreDatabaseChanges();
- }
- }
+ verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
+ tap(TestIdPack.BUTTON_DELETERECEIPT);
+ tap(TestIdPack.BUTTON_DELETERECEIPT_CONFIRM);
+ verify(TestIdPack.LABEL_TOTALTOPAY, "0.00");
}
- private void createDatabaseChanges() {
+ @Override
+ public void beforeWithReload() {
// Add preference
final String clientId = BackboneHelper.getTerminalValue("client");
final String sqlInsertPreference = String
@@ -94,15 +72,10 @@
new DatabaseHelperInsertUpdateOrDelete().execute(sqlInsertPreference, 1);
}
- private void restoreDatabaseChanges() {
+ @Override
+ public void afterWithReload() {
// Delete Preference
new DatabaseHelperInsertUpdateOrDelete().execute(String.format("delete from ad_preference "
+ "where ad_preference_id = '%s'", preferenceId), 1);
}
-
- private String getUUID() {
- String randomUUID = UUID.randomUUID().toString();
- randomUUID = randomUUID.toUpperCase();
- return randomUUID.replace("-", "");
- }
}
\ No newline at end of file
issue 37706 source returns v2.patch [^] (5,475 bytes) 2018-02-16 09:54 [Show Content] [Hide Content]# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1518771172 -19800
# Fri Feb 16 14:22:52 2018 +0530
# Node ID 48a77cc4a74e8b2fa4862146fa15727c86147c49
# Parent b1ef44a6d077fd4dc220ab381cae5343a04ec9b7
Fixed issue 37706 : Refactored addReturnLines API
* Split shipment lines should be in modalReturnLines
diff -r b1ef44a6d077 -r 48a77cc4a74e web/org.openbravo.retail.returns/js/modalReturnLines.js
--- a/web/org.openbravo.retail.returns/js/modalReturnLines.js Thu Feb 15 14:41:15 2018 +0530
+++ b/web/org.openbravo.retail.returns/js/modalReturnLines.js Fri Feb 16 14:22:52 2018 +0530
@@ -531,6 +531,12 @@
me.nameLocation = bpLoc.get('name');
receipt.setBPandBPLoc(bp, false, true, function () {
+
+ //If we do not let user to select qty to return of shipment lines, we do it automatically
+ if (!OB.MobileApp.model.hasPermission("OBPOS_SplitLinesInShipments", true)) {
+ me.args.args.order.receiptLines = me.autoSplitShipmentLines(me.args.args.order.receiptLines);
+ }
+
OB.UTIL.ReturnUtils.addReturnLines(receipt, me.args.args.order, me.args.args.order.receiptLines, function () {
receipt.calculateReceipt(function () {
receipt.save(function () {
diff -r b1ef44a6d077 -r 48a77cc4a74e web/org.openbravo.retail.returns/js/returnUtils.js
--- a/web/org.openbravo.retail.returns/js/returnUtils.js Thu Feb 15 14:41:15 2018 +0530
+++ b/web/org.openbravo.retail.returns/js/returnUtils.js Fri Feb 16 14:22:52 2018 +0530
@@ -21,7 +21,7 @@
return;
}
- var i, autoSplitShipmentLines, finishOrder, createOrderLines, noFoundProduct = true,
+ var i, finishOrder, createOrderLines, noFoundProduct = true,
approvalNeeded = false,
currentDate = new Date(),
approvalList = [],
@@ -35,69 +35,6 @@
currentDate.setSeconds(0);
currentDate.setMilliseconds(0);
- autoSplitShipmentLines = function (lines) {
- var newlines = [];
- enyo.forEach(lines, function (line) {
- if (line.shipmentlines && line.shipmentlines.length > 1) {
- enyo.forEach(line.shipmentlines, function (sline) {
- var attr, splitline = {};
- if (line.selectedQuantity > 0 && sline.remainingQty > 0) {
- for (attr in line) {
- if (line.hasOwnProperty(attr) && !OB.UTIL.isNullOrUndefined(line[attr]) && typeof line[attr] !== 'object') {
- splitline[attr] = line[attr];
- }
- }
- splitline.compname = line.lineId + sline.shipLineId;
- splitline.quantity = sline.qty;
- splitline.shiplineNo = sline.shipmentlineNo;
- splitline.shipment = sline.shipment;
- splitline.shipmentlineId = sline.shipLineId;
- splitline.selectedQuantity = parseInt(splitline.selectedQuantity, 10);
- if (sline.remainingQty < splitline.selectedQuantity) {
- splitline.selectedQuantity = sline.remainingQty;
- }
- line.selectedQuantity = OB.DEC.sub(line.selectedQuantity, splitline.selectedQuantity);
- // delete confusing properties
- delete splitline.linegrossamount;
- delete splitline.warehouse;
- delete splitline.warehousename;
- // split promotions
- splitline.promotions = [];
- if (line.promotions.length > 0) {
- enyo.forEach(line.promotions, function (p) {
- if (!OB.UTIL.isNullOrUndefined(p)) {
- var attr, splitpromo = {};
- for (attr in p) {
- if (p.hasOwnProperty(attr) && !OB.UTIL.isNullOrUndefined(p[attr]) && typeof p[attr] !== 'object') {
- splitpromo[attr] = p[attr];
- }
- }
- splitpromo.amt = OB.DEC.mul(p.amt, (splitline.selectedQuantity / line.quantity));
- splitpromo.actualAmt = OB.DEC.mul(p.actualAmt, (splitline.selectedQuantity / line.quantity));
- splitpromo.displayedTotalAmount = OB.DEC.mul(p.displayedTotalAmount, (splitline.selectedQuantity / line.quantity));
- splitline.promotions.push(splitpromo);
- }
- });
- }
-
- newlines.push(splitline);
- }
- }, this);
- } else {
- line.compname = line.lineId;
- if (line.shipmentlines && line.shipmentlines.length === 1) {
- line.shipmentlineId = line.shipmentlines[0].shipLineId;
- }
- // delete confusing properties
- delete line.linegrossamount;
- delete line.warehouse;
- delete line.warehousename;
- newlines.push(line);
- }
- }, this);
- return newlines;
- };
-
finishOrder = _.after(returnLines.length, function () {
if (callback) {
callback();
@@ -162,11 +99,6 @@
});
};
- //If we do not let user to select qty to return of shipment lines, we do it automatically
- if (!OB.MobileApp.model.hasPermission("OBPOS_SplitLinesInShipments", true)) {
- returnLines = autoSplitShipmentLines(returnLines);
- }
-
for (i = 0; i < returnLines.length; i++) {
var line = returnLines[i];
if (!line.notReturnable) {
|