Attached Files | mobileCore17q2.diff [^] (6,451 bytes) 2018-10-18 10:30 [Show Content] [Hide Content]diff --git a/web/org.openbravo.mobile.core/source/data/ob-dal.js b/web/org.openbravo.mobile.core/source/data/ob-dal.js
--- a/web/org.openbravo.mobile.core/source/data/ob-dal.js
+++ b/web/org.openbravo.mobile.core/source/data/ob-dal.js
@@ -885,93 +885,42 @@
}
if (currentTransaction) {
- if (updateToBeChecked) {
- OB.Dal.getInTransaction(currentTransaction, modelDefinition, model.get('id'), function (result) {
- if (result) {
- if (result.get('hasbeenpaid') === 'Y') {
- OB.error('[checkBlocked][transaction][hasbeenpaid_is_yes] Wrong write in c_order avoided [' + result.get('id') + '][' + result.get('documentNo') + '] - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
+ try {
+ if (updateToBeChecked) {
+ currentTransaction.executeSql(sql + " AND hasbeenpaid = 'N'", params, function (trx, result) {
+ if (result.rowsAffected !== 1) {
+ OB.error('[checkBlocked][transaction]The order does not exists or is frozen. Wrong write in c_order avoided [' + model.get('id') + '][' + model.get('documentNo') + '] - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
+ }
+ if (successFunction) {
+ successFunction();
+ }
+ }, processError);
+
+ } else {
+ currentTransaction.executeSql(sql, params, silentFunction(successFunction), processError);
+ }
+ } catch (e) {
+ executeSqlErrorHandler('error', "OB.Dal.save: table", tableName, null, e, callerInfo);
+ }
+ } else {
+ OB.Data.localDB.transaction(function (tx) {
+ try {
+ if (updateToBeChecked) {
+ tx.executeSql(sql + " AND hasbeenpaid = 'N'", params, function (trx, result) {
+ if (result.rowsAffected !== 1) {
+ OB.error('[checkBlocked][transaction]The order does not exists or is frozen. Wrong write in c_order avoided [' + model.get('id') + '][' + model.get('documentNo') + '] - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
+ }
if (successFunction) {
successFunction();
}
- } else {
- try {
- currentTransaction.executeSql(sql, params, silentFunction(successFunction), processError);
- } catch (e) {
- executeSqlErrorHandler('error', "OB.Dal.save: table", tableName, null, e, callerInfo);
- }
- }
+ }, processError);
} else {
- //no results
- OB.warn('[checkBlocked][transaction] No result after getInTransaction for [' + model.get('id') + '][' + model.get('documentNo') + ']. This update doesnt make sense - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
- if (successFunction) {
- successFunction();
- }
+ tx.executeSql(sql, params, silentFunction(successFunction), processError);
}
- }, function () {
- OB.error('[checkBlocked][transaction] Error for [' + model.get('id') + '][' + model.get('documentNo') + '] - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
- if (error) {
- error();
- }
- }, function () {
- //no results
- OB.warn('[checkBlocked][transaction] No result after getInTransaction for [' + model.get('id') + '][' + model.get('documentNo') + ']. This update doesnt make sense - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
- if (successFunction) {
- successFunction();
- }
- });
- } else {
- try {
- currentTransaction.executeSql(sql, params, silentFunction(successFunction), processError);
} catch (e) {
executeSqlErrorHandler('error', "OB.Dal.save: table", tableName, null, e, callerInfo);
}
- }
- } else {
- if (updateToBeChecked) {
- OB.Data.localDB.transaction(function (tx) {
- OB.Dal.getInTransaction(tx, modelDefinition, model.get('id'), function (result) {
- if (result) {
- if (result.get('hasbeenpaid') === 'Y') {
- OB.error('[checkBlocked][no-transaction][hasbeenpaid_is_yes] Wrong write in c_order avoided [' + result.get('id') + '][' + result.get('documentNo') + '] - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
- if (successFunction) {
- successFunction();
- }
- } else {
- try {
- tx.executeSql(sql, params, silentFunction(successFunction), processError);
- } catch (e) {
- executeSqlErrorHandler('error', "OB.Dal.save: table", tableName, null, e, callerInfo);
- }
- }
- } else {
- //no results
- OB.warn('[checkBlocked][no-transaction] No result after getInTransaction for [' + model.get('id') + '][' + model.get('documentNo') + ']. This update doesnt make sense - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
- if (successFunction) {
- successFunction();
- }
- }
- }, function () {
- OB.error('[checkBlocked][no-transaction] Error for [' + model.get('id') + '][' + model.get('documentNo') + ']');
- if (error) {
- error();
- }
- }, function () {
- //no results
- OB.warn('[checkBlocked][no-transaction] No result after getInTransaction for [' + model.get('id') + '][' + model.get('documentNo') + ']. This update doesnt make sense - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
- if (successFunction) {
- successFunction();
- }
- });
- });
- } else {
- OB.Data.localDB.transaction(function (tx) {
- try {
- tx.executeSql(sql, params, silentFunction(successFunction), processError);
- } catch (e) {
- executeSqlErrorHandler('error', "OB.Dal.save: table", tableName, null, e, callerInfo);
- }
- });
- }
+ });
}
} else {
this.missingLocalStorageLogic();
mobileCore17Q33.diff [^] (10,822 bytes) 2018-10-18 10:30 [Show Content] [Hide Content]diff --git a/web/org.openbravo.mobile.core/source/component/ob-login.js b/web/org.openbravo.mobile.core/source/component/ob-login.js
--- a/web/org.openbravo.mobile.core/source/component/ob-login.js
+++ b/web/org.openbravo.mobile.core/source/component/ob-login.js
@@ -230,10 +230,11 @@
},
hasTerminalChanged: function () {
if (OB.UTIL.localStorage.getItem('loggedTerminalName') && (OB.UTIL.localStorage.getItem('loggedTerminalName') !== OB.MobileApp.model.get('terminalName'))) {
- OB.info('Terminal has been changed. Resetting database and local storage information.');
- OB.UTIL.localStorage.clear();
- OB.UTIL.localStorage.setItem('terminalName', OB.MobileApp.model.get('terminalName'));
- OB.MobileApp.model.logout();
+ OB.error('Terminal has been changed. Logged Terminal: ' + OB.UTIL.localStorage.getItem('loggedTerminalName') + ' new terminalName: ' + OB.MobileApp.model.get('terminalName'));
+ // OB.info('Terminal has been changed. Resetting database and local storage information.');
+ // OB.UTIL.localStorage.clear();
+ // OB.UTIL.localStorage.setItem('terminalName', OB.MobileApp.model.get('terminalName'));
+ // OB.MobileApp.model.logout();
}
},
diff --git a/web/org.openbravo.mobile.core/source/data/ob-dal.js b/web/org.openbravo.mobile.core/source/data/ob-dal.js
--- a/web/org.openbravo.mobile.core/source/data/ob-dal.js
+++ b/web/org.openbravo.mobile.core/source/data/ob-dal.js
@@ -897,93 +897,42 @@
}
if (currentTransaction) {
- if (updateToBeChecked) {
- OB.Dal.getInTransaction(currentTransaction, modelDefinition, model.get('id'), function (result) {
- if (result) {
- if (result.get('hasbeenpaid') === 'Y') {
- OB.error('[checkBlocked][transaction][hasbeenpaid_is_yes] Wrong write in c_order avoided [' + result.get('id') + '][' + result.get('documentNo') + '] - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
+ try {
+ if (updateToBeChecked) {
+ currentTransaction.executeSql(sql + " AND hasbeenpaid = 'N'", params, function (trx, result) {
+ if (result.rowsAffected !== 1) {
+ OB.error('[checkBlocked][transaction]The order does not exists or is frozen. Wrong write in c_order avoided [' + model.get('id') + '][' + model.get('documentNo') + '] - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
+ }
+ if (successFunction) {
+ successFunction();
+ }
+ }, processError);
+
+ } else {
+ currentTransaction.executeSql(sql, params, silentFunction(successFunction), processError);
+ }
+ } catch (e) {
+ executeSqlErrorHandler('error', "OB.Dal.save: table", tableName, null, e, callerInfo);
+ }
+ } else {
+ OB.Data.localDB.transaction(function (tx) {
+ try {
+ if (updateToBeChecked) {
+ tx.executeSql(sql + " AND hasbeenpaid = 'N'", params, function (trx, result) {
+ if (result.rowsAffected !== 1) {
+ OB.error('[checkBlocked][transaction]The order does not exists or is frozen. Wrong write in c_order avoided [' + model.get('id') + '][' + model.get('documentNo') + '] - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
+ }
if (successFunction) {
successFunction();
}
- } else {
- try {
- currentTransaction.executeSql(sql, params, silentFunction(successFunction), processError);
- } catch (e) {
- executeSqlErrorHandler('error', "OB.Dal.save: table", tableName, null, e, callerInfo);
- }
- }
+ }, processError);
} else {
- //no results
- OB.warn('[checkBlocked][transaction] No result after getInTransaction for [' + model.get('id') + '][' + model.get('documentNo') + ']. This update doesnt make sense - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
- if (successFunction) {
- successFunction();
- }
+ tx.executeSql(sql, params, silentFunction(successFunction), processError);
}
- }, function () {
- OB.error('[checkBlocked][transaction] Error for [' + model.get('id') + '][' + model.get('documentNo') + '] - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
- if (error) {
- error();
- }
- }, function () {
- //no results
- OB.warn('[checkBlocked][transaction] No result after getInTransaction for [' + model.get('id') + '][' + model.get('documentNo') + ']. This update doesnt make sense - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
- if (successFunction) {
- successFunction();
- }
- });
- } else {
- try {
- currentTransaction.executeSql(sql, params, silentFunction(successFunction), processError);
} catch (e) {
executeSqlErrorHandler('error', "OB.Dal.save: table", tableName, null, e, callerInfo);
}
- }
- } else {
- if (updateToBeChecked) {
- OB.Data.localDB.transaction(function (tx) {
- OB.Dal.getInTransaction(tx, modelDefinition, model.get('id'), function (result) {
- if (result) {
- if (result.get('hasbeenpaid') === 'Y') {
- OB.error('[checkBlocked][no-transaction][hasbeenpaid_is_yes] Wrong write in c_order avoided [' + result.get('id') + '][' + result.get('documentNo') + '] - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
- if (successFunction) {
- successFunction();
- }
- } else {
- try {
- tx.executeSql(sql, params, silentFunction(successFunction), processError);
- } catch (e) {
- executeSqlErrorHandler('error', "OB.Dal.save: table", tableName, null, e, callerInfo);
- }
- }
- } else {
- //no results
- OB.warn('[checkBlocked][no-transaction] No result after getInTransaction for [' + model.get('id') + '][' + model.get('documentNo') + ']. This update doesnt make sense - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
- if (successFunction) {
- successFunction();
- }
- }
- }, function () {
- OB.error('[checkBlocked][no-transaction] Error for [' + model.get('id') + '][' + model.get('documentNo') + ']');
- if (error) {
- error();
- }
- }, function () {
- //no results
- OB.warn('[checkBlocked][no-transaction] No result after getInTransaction for [' + model.get('id') + '][' + model.get('documentNo') + ']. This update doesnt make sense - Caller: ' + caller + ' - callerInfo: ' + callerInfo);
- if (successFunction) {
- successFunction();
- }
- });
- });
- } else {
- OB.Data.localDB.transaction(function (tx) {
- try {
- tx.executeSql(sql, params, silentFunction(successFunction), processError);
- } catch (e) {
- executeSqlErrorHandler('error', "OB.Dal.save: table", tableName, null, e, callerInfo);
- }
- });
- }
+ });
}
} else {
this.missingLocalStorageLogic();
diff --git a/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js b/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js
--- a/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js
+++ b/web/org.openbravo.mobile.core/source/model/ob-terminal-model.js
@@ -588,12 +588,13 @@
// check if terminal id has changed
if (OB.UTIL.localStorage.getItem('loggedTerminalName') && (OB.UTIL.localStorage.getItem('loggedTerminalName') !== OB.MobileApp.model.get('terminalName'))) {
- console.warn(OB.UTIL.argumentsToStringifyed("terminal changed (" + OB.UTIL.localStorage.getItem('loggedTerminalName') + " -> " + OB.MobileApp.model.get('terminalName') + ")"));
- OB.info('Terminal has been changed. Resetting database and local storage information.');
- OB.UTIL.localStorage.clear();
- OB.UTIL.localStorage.setItem('terminalName', OB.MobileApp.model.get('terminalName'));
- OB.MobileApp.model.logout();
- return;
+ OB.error('Terminal has been changed. Logged Terminal: ' + OB.UTIL.localStorage.getItem('loggedTerminalName') + ' new terminalName: ' + OB.MobileApp.model.get('terminalName'));
+ // console.warn(OB.UTIL.argumentsToStringifyed("terminal changed (" + OB.UTIL.localStorage.getItem('loggedTerminalName') + " -> " + OB.MobileApp.model.get('terminalName') + ")"));
+ // OB.info('Terminal has been changed. Resetting database and local storage information.');
+ // OB.UTIL.localStorage.clear();
+ // OB.UTIL.localStorage.setItem('terminalName', OB.MobileApp.model.get('terminalName'));
+ // OB.MobileApp.model.logout();
+ // return;
}
var tablesToDrop = [];
@@ -2042,7 +2043,9 @@
OB.UTIL.localStorage.setItem('loggedTerminalName', OB.MobileApp.model.get('terminalName'));
}
if ((!OB.UTIL.isNullOrUndefined(OB.MobileApp.model.get('terminalName')) || !OB.UTIL.isNullOrUndefined(OB.UTIL.localStorage.getItem('loggedTerminalName'))) && OB.MobileApp.model.get('terminalName') !== OB.UTIL.localStorage.getItem('loggedTerminalName')) {
- OB.UTIL.localStorage.clear();
+ OB.error('Terminal has been changed. Logged Terminal: ' + OB.UTIL.localStorage.getItem('loggedTerminalName') + ' new terminalName: ' + OB.MobileApp.model.get('terminalName'));
+ // OB.info('Terminal has been changed. Resetting database and local storage information.');
+ // OB.UTIL.localStorage.clear();
}
OB.MobileApp.model.set('orgUserId', inResponse.userId);
me.set('loggedOffline', false);
diff --git a/web/org.openbravo.mobile.core/source/utils/ob-localStorage.js b/web/org.openbravo.mobile.core/source/utils/ob-localStorage.js
--- a/web/org.openbravo.mobile.core/source/utils/ob-localStorage.js
+++ b/web/org.openbravo.mobile.core/source/utils/ob-localStorage.js
@@ -54,6 +54,7 @@
};
OB.UTIL.localStorage.clear = function () {
- window.localStorage.clear();
+ OB.error('Local Storage is going to be cleared.');
+ // window.localStorage.clear();
};
}());
\ No newline at end of file
posterminal17q2.diff [^] (18,856 bytes) 2018-10-18 10:30 [Show Content] [Hide Content]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
@@ -376,6 +376,7 @@
if (data) {
me.owner.owner.model.get('orderList').newPaidReceipt(data[0], function (order) {
order.set('loadedFromServer', true);
+ me.owner.owner.model.get('orderList').addMultiReceipt(order);
order.set('checked', iter.get('checked'));
OB.DATA.OrderTaxes(order);
order.set('belongsToMultiOrder', true);
diff --git a/web/org.openbravo.retail.posterminal/js/data/dataordersave.js b/web/org.openbravo.retail.posterminal/js/data/dataordersave.js
--- a/web/org.openbravo.retail.posterminal/js/data/dataordersave.js
+++ b/web/org.openbravo.retail.posterminal/js/data/dataordersave.js
@@ -85,6 +85,8 @@
var orderDate = new Date();
var normalizedCreationDate = OB.I18N.normalizeDate(context.receipt.get('creationDate'));
var creationDate;
+ var frozenReceipt = new OB.Model.Order(),
+ diffReceipt = new OB.Model.Order();
if (normalizedCreationDate === null) {
creationDate = new Date();
normalizedCreationDate = OB.I18N.normalizeDate(creationDate);
@@ -114,79 +116,77 @@
args.context.receipt.setIsCalculateGrossLockState(false);
return true;
}
-
+ OB.UTIL.clone(receipt, frozenReceipt);
receipt.trigger('checkOpenDrawer');
if (OB.UTIL.RfidController.isRfidConfigured()) {
- OB.UTIL.RfidController.processRemainingCodes(receipt);
+ OB.UTIL.RfidController.processRemainingCodes(frozenReceipt);
OB.UTIL.RfidController.updateEpcBuffers();
}
OB.trace('Execution of pre order save hook OK.');
- delete receipt.attributes.json;
- receipt.set('creationDate', normalizedCreationDate);
- receipt.set('timezoneOffset', creationDate.getTimezoneOffset());
- receipt.set('created', creationDate.getTime());
- receipt.set('obposCreatedabsolute', OB.I18N.formatDateISO(creationDate));
- receipt.set('orderDate', orderDate);
- receipt.set('movementDate', OB.I18N.normalizeDate(new Date()));
- receipt.set('accountingDate', OB.I18N.normalizeDate(new Date()));
- receipt.set('undo', null);
- receipt.set('multipleUndo', null);
+ delete frozenReceipt.attributes.json;
+ frozenReceipt.set('creationDate', normalizedCreationDate);
+ frozenReceipt.set('timezoneOffset', creationDate.getTimezoneOffset());
+ frozenReceipt.set('created', creationDate.getTime());
+ frozenReceipt.set('obposCreatedabsolute', OB.I18N.formatDateISO(creationDate));
+ frozenReceipt.set('orderDate', orderDate);
+ frozenReceipt.set('movementDate', OB.I18N.normalizeDate(new Date()));
+ frozenReceipt.set('accountingDate', OB.I18N.normalizeDate(new Date()));
+ frozenReceipt.set('undo', null);
+ frozenReceipt.set('multipleUndo', null);
- receipt.set('paymentMethodKind', null);
- if (receipt.get('payments').length === 1 && receipt.get('orderType') === 0 && !receipt.get('isLayaway') && !receipt.get('isQuotation')) {
- var payment = receipt.get('payments').models[0];
- receipt.set('paymentMethodKind', payment.get('kind'));
+ frozenReceipt.set('paymentMethodKind', null);
+ if (frozenReceipt.get('payments').length === 1 && frozenReceipt.get('orderType') === 0 && !frozenReceipt.get('isLayaway') && !frozenReceipt.get('isQuotation')) {
+ var payment = frozenReceipt.get('payments').models[0];
+ frozenReceipt.set('paymentMethodKind', payment.get('kind'));
}
// multiterminal support
// be sure that the active terminal is the one set as the order proprietary
- receipt.set('posTerminal', OB.MobileApp.model.get('terminal').id);
- receipt.set('posTerminal' + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER, OB.MobileApp.model.get('terminal')._identifier);
+ frozenReceipt.set('posTerminal', OB.MobileApp.model.get('terminal').id);
+ frozenReceipt.set('posTerminal' + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER, OB.MobileApp.model.get('terminal')._identifier);
- receipt.get("approvals").forEach(function (approval) {
+ frozenReceipt.get("approvals").forEach(function (approval) {
if (typeof (approval.approvalType) === 'object') {
approval.approvalMessage = OB.I18N.getLabel(approval.approvalType.message, approval.approvalType.params);
approval.approvalType = approval.approvalType.approval;
}
});
- receipt.set('obposAppCashup', OB.MobileApp.model.get('terminal').cashUpId);
+ frozenReceipt.set('obposAppCashup', OB.MobileApp.model.get('terminal').cashUpId);
// convert returns
- if (receipt.getGross() < 0 || !_.isUndefined(receipt.get('paidInNegativeStatusAmt'))) {
+ if (frozenReceipt.getGross() < 0 || !_.isUndefined(frozenReceipt.get('paidInNegativeStatusAmt'))) {
var paymentTotalAmt = OB.DEC.Zero;
- _.forEach(receipt.get('payments').models, function (item) {
- if (!item.get('isPrePayment') && !item.get('reversedPaymentId') && !receipt.get('isPaid')) {
+ _.forEach(frozenReceipt.get('payments').models, function (item) {
+ if (!item.get('isPrePayment') && !item.get('reversedPaymentId') && !frozenReceipt.get('isPaid')) {
item.set('amount', -item.get('amount'));
item.set('origAmount', -item.get('origAmount'));
item.set('paid', -item.get('paid'));
}
paymentTotalAmt = OB.DEC.add(paymentTotalAmt, item.get('origAmount'));
});
- if (!_.isUndefined(receipt.get('paidInNegativeStatusAmt'))) {
- receipt.set('payment', paymentTotalAmt);
+ if (!_.isUndefined(frozenReceipt.get('paidInNegativeStatusAmt'))) {
+ frozenReceipt.set('payment', paymentTotalAmt);
}
}
OB.trace('Calculationg cashup information.');
- OB.UTIL.cashUpReport(receipt, function (cashUp) {
- receipt.set('cashUpReportInformation', JSON.parse(cashUp.models[0].get('objToSend')));
- receipt.set('json', JSON.stringify(receipt.serializeToJSON()));
+ OB.UTIL.cashUpReport(frozenReceipt, function (cashUp) {
+ frozenReceipt.set('cashUpReportInformation', JSON.parse(cashUp.models[0].get('objToSend')));
+ frozenReceipt.set('json', JSON.stringify(frozenReceipt.serializeToJSON()));
// Important: at this point, the receipt is considered final. Nothing must alter it
- var frozenReceipt = new OB.Model.Order();
- OB.UTIL.clone(receipt, frozenReceipt);
- OB.info("[receipt.closed] Starting transaction. ReceiptId: " + receipt.get('id'));
+ OB.info("[receipt.closed] Starting transaction. ReceiptId: " + frozenReceipt.get('id'));
OB.Dal.transaction(function (tx) {
receipt.set('hasbeenpaid', 'Y');
frozenReceipt.set('hasbeenpaid', 'Y');
// when all the properties of the receipt have been set, keep a copy
if (OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) {
- OB.Dal.saveInTransaction(tx, receipt);
+ OB.Dal.saveInTransaction(tx, frozenReceipt);
} else {
OB.UTIL.calculateCurrentCash(null, tx);
- OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(receipt.get('documentnoSuffix'), receipt.get('quotationnoSuffix'), receipt.get('returnnoSuffix'), function () {
+ OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(frozenReceipt.get('documentnoSuffix'), frozenReceipt.get('quotationnoSuffix'), frozenReceipt.get('returnnoSuffix'), function () {
OB.trace('Saving receipt.');
- OB.Dal.saveInTransaction(tx, receipt, function () {
+ OB.Dal.saveInTransaction(tx, frozenReceipt, function () {
// the trigger is fired on the receipt object, as there is only 1 that is being updated
receipt.trigger('integrityOk'); // Is important for module print last receipt. This module listen trigger.
});
@@ -195,24 +195,25 @@
//}, tx);
}, function () {
// the transaction failed
- OB.error("[receipt.closed] The transaction failed to be commited. ReceiptId: " + receipt.get('id'));
+ OB.error("[receipt.closed] The transaction failed to be commited. ReceiptId: " + frozenReceipt.get('id'));
// rollback other changes
receipt.set('hasbeenpaid', 'N');
frozenReceipt.set('hasbeenpaid', 'N');
if (eventParams && eventParams.callback) {
eventParams.callback({
frozenReceipt: frozenReceipt,
+ diffReceipt: diffReceipt,
isCancelled: false
});
}
}, function () {
// success transaction...
- OB.info("[receipt.closed] Transaction success. ReceiptId: " + receipt.get('id'));
+ OB.info("[receipt.closed] Transaction success. ReceiptId: " + frozenReceipt.get('id'));
- function serverMessageForQuotation(receipt) {
- var isLayaway = (receipt.get('orderType') === 2 || receipt.get('isLayaway'));
- var currentDocNo = receipt.get('documentNo');
- if (receipt && receipt.get('isQuotation')) {
+ function serverMessageForQuotation(frozenReceipt) {
+ var isLayaway = (frozenReceipt.get('orderType') === 2 || frozenReceipt.get('isLayaway'));
+ var currentDocNo = frozenReceipt.get('documentNo');
+ if (frozenReceipt && frozenReceipt.get('isQuotation')) {
OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_QuotationSaved', [currentDocNo]));
} else {
if (isLayaway) {
@@ -230,13 +231,14 @@
// rollback other changes
receipt.set('hasbeenpaid', 'N');
frozenReceipt.set('hasbeenpaid', 'N');
-
+ diffReceipt.set('hasbeenpaid', 'N');
OB.Dal.save(receipt, function () {
OB.UTIL.calculateCurrentCash();
if (eventParams && eventParams.callback) {
eventParams.callback({
frozenReceipt: frozenReceipt,
+ diffReceipt: diffReceipt,
isCancelled: true
});
receipt.setIsCalculateReceiptLockState(false);
@@ -247,16 +249,18 @@
} else if (eventParams && eventParams.callback) {
eventParams.callback({
frozenReceipt: frozenReceipt,
+ diffReceipt: diffReceipt,
isCancelled: false
});
}
};
-
+ receipt.clearWith(frozenReceipt);
+ OB.UTIL.clone(receipt, diffReceipt);
// create a clone of the receipt to be used when executing the final callback
if (OB.UTIL.HookManager.get('OBPOS_PostSyncReceipt')) {
// create a clone of the receipt to be used within the hook
var receiptForPostSyncReceipt = new OB.Model.Order();
- OB.UTIL.clone(receipt, receiptForPostSyncReceipt);
+ OB.UTIL.clone(frozenReceipt, receiptForPostSyncReceipt);
//If there are elements in the hook, we are forced to execute the callback only after the synchronization process
//has been executed, to prevent race conditions with the callback processes (printing and deleting the receipt)
OB.trace('Execution Sync process.');
@@ -266,27 +270,24 @@
OB.UTIL.HookManager.executeHooks('OBPOS_PostSyncReceipt', {
receipt: receiptForPostSyncReceipt
}, function () {
- serverMessageForQuotation(receipt);
+ serverMessageForQuotation(frozenReceipt);
if (eventParams && eventParams.callback) {
eventParams.callback({
frozenReceipt: frozenReceipt,
+ diffReceipt: diffReceipt,
isCancelled: false
});
}
});
};
-
// in synchronized mode do the doc sequence update in the success
if (OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) {
- OB.UTIL.calculateCurrentCash();
OB.Dal.transaction(function (tx) {
- OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(receipt.get('documentnoSuffix'), receipt.get('quotationnoSuffix'), receipt.get('returnnoSuffix'), function () {
- OB.trace('Saving receipt.');
- OB.Dal.saveInTransaction(tx, receipt, function () {
- // the trigger is fired on the receipt object, as there is only 1 that is being updated
- receipt.trigger('integrityOk'); // Is important for module print last receipt. This module listen trigger.
- successStep();
- });
+ OB.UTIL.calculateCurrentCash(null, tx);
+ OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(frozenReceipt.get('documentnoSuffix'), frozenReceipt.get('quotationnoSuffix'), frozenReceipt.get('returnnoSuffix'), function () {
+ // the trigger is fired on the receipt object, as there is only 1 that is being updated
+ receipt.trigger('integrityOk'); // Is important for module print last receipt. This module listen trigger.
+ successStep();
}, tx);
});
} else {
@@ -304,6 +305,7 @@
if (!OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true) && eventParams && eventParams.callback) {
eventParams.callback({
frozenReceipt: frozenReceipt,
+ diffReceipt: diffReceipt,
isCancelled: false
});
}
@@ -312,18 +314,16 @@
if (OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) {
OB.UTIL.calculateCurrentCash();
OB.Dal.transaction(function (tx) {
- OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(receipt.get('documentnoSuffix'), receipt.get('quotationnoSuffix'), receipt.get('returnnoSuffix'), function () {
- OB.trace('Saving receipt.');
- OB.Dal.saveInTransaction(tx, receipt, function () {
- // the trigger is fired on the receipt object, as there is only 1 that is being updated
- receipt.trigger('integrityOk'); // Is important for module print last receipt. This module listen trigger.
- if (eventParams && eventParams.callback) {
- eventParams.callback({
- frozenReceipt: frozenReceipt,
- isCancelled: false
- });
- }
- });
+ OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(frozenReceipt.get('documentnoSuffix'), frozenReceipt.get('quotationnoSuffix'), frozenReceipt.get('returnnoSuffix'), function () {
+ // the trigger is fired on the receipt object, as there is only 1 that is being updated
+ receipt.trigger('integrityOk'); // Is important for module print last receipt. This module listen trigger.
+ if (eventParams && eventParams.callback) {
+ eventParams.callback({
+ frozenReceipt: frozenReceipt,
+ diffReceipt: diffReceipt,
+ isCancelled: false
+ });
+ }
}, tx);
});
}
diff --git a/web/org.openbravo.retail.posterminal/js/model/order.js b/web/org.openbravo.retail.posterminal/js/model/order.js
--- a/web/org.openbravo.retail.posterminal/js/model/order.js
+++ b/web/org.openbravo.retail.posterminal/js/model/order.js
@@ -428,7 +428,11 @@
if (callback === undefined || !callback instanceof Function) {
callback = function () {};
}
- if (!OB.MobileApp.model.get('preventOrderSave')) {
+ if (OB.MobileApp.model.get('preventOrderSave') || (this.get('isQuotation') && !this.get('isEditable')) || this.get('isCancelling')) {
+ if (callback) {
+ callback();
+ }
+ } else {
OB.Dal.save(this, function () {
if (callback) {
callback();
@@ -436,10 +440,6 @@
}, function () {
OB.error(arguments);
}, forceInsert);
- } else {
- if (callback) {
- callback();
- }
}
this.setUndo('SaveOrder', undoCopy);
},
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js b/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js
@@ -1265,7 +1265,6 @@
_.each(inEvent.value, function (iter) {
//iter.set('isMultiOrder', true);
iter.set('belongsToMultiOrder', true);
- me.model.get('orderList').addMultiReceipt(iter);
me.model.get('multiOrders').get('multiOrdersList').add(iter);
});
this.model.get('leftColumnViewManager').setMultiOrderMode();
posterminal17Q33.diff [^] (23,825 bytes) 2018-10-18 10:30 [Show Content] [Hide Content]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
@@ -389,6 +389,7 @@
if (data) {
me.owner.owner.model.get('orderList').newPaidReceipt(data[0], function (order) {
order.set('loadedFromServer', true);
+ me.owner.owner.model.get('orderList').addMultiReceipt(order);
order.set('checked', iter.get('checked'));
OB.DATA.OrderTaxes(order);
order.set('belongsToMultiOrder', true);
diff --git a/web/org.openbravo.retail.posterminal/js/data/dataordersave.js b/web/org.openbravo.retail.posterminal/js/data/dataordersave.js
--- a/web/org.openbravo.retail.posterminal/js/data/dataordersave.js
+++ b/web/org.openbravo.retail.posterminal/js/data/dataordersave.js
@@ -85,7 +85,8 @@
var orderDate = new Date();
var normalizedCreationDate = OB.I18N.normalizeDate(context.receipt.get('creationDate'));
var creationDate;
- var frozenReceipt = new OB.Model.Order();
+ var frozenReceipt = new OB.Model.Order(),
+ diffReceipt = new OB.Model.Order();
if (normalizedCreationDate === null) {
creationDate = new Date();
normalizedCreationDate = OB.I18N.normalizeDate(creationDate);
@@ -117,78 +118,78 @@
return true;
}
+ OB.UTIL.clone(receipt, frozenReceipt);
receipt.trigger('checkOpenDrawer');
if (OB.UTIL.RfidController.isRfidConfigured()) {
- OB.UTIL.RfidController.processRemainingCodes(receipt);
+ OB.UTIL.RfidController.processRemainingCodes(frozenReceipt);
OB.UTIL.RfidController.updateEpcBuffers();
}
OB.trace('Execution of pre order save hook OK.');
- delete receipt.attributes.json;
- receipt.set('creationDate', normalizedCreationDate);
- receipt.set('timezoneOffset', creationDate.getTimezoneOffset());
- receipt.set('created', creationDate.getTime());
- receipt.set('obposCreatedabsolute', OB.I18N.formatDateISO(creationDate));
- receipt.set('orderDate', orderDate);
- receipt.set('movementDate', OB.I18N.normalizeDate(new Date()));
- receipt.set('accountingDate', OB.I18N.normalizeDate(new Date()));
- receipt.set('undo', null);
- receipt.set('multipleUndo', null);
+ delete frozenReceipt.attributes.json;
+ frozenReceipt.set('creationDate', normalizedCreationDate);
+ frozenReceipt.set('timezoneOffset', creationDate.getTimezoneOffset());
+ frozenReceipt.set('created', creationDate.getTime());
+ frozenReceipt.set('obposCreatedabsolute', OB.I18N.formatDateISO(creationDate));
+ frozenReceipt.set('orderDate', orderDate);
+ frozenReceipt.set('movementDate', OB.I18N.normalizeDate(new Date()));
+ frozenReceipt.set('accountingDate', OB.I18N.normalizeDate(new Date()));
+ frozenReceipt.set('undo', null);
+ frozenReceipt.set('multipleUndo', null);
- receipt.set('paymentMethodKind', null);
- if (receipt.get('payments').length === 1 && receipt.get('orderType') === 0 && !receipt.get('isLayaway') && !receipt.get('isQuotation')) {
- var payment = receipt.get('payments').models[0];
- receipt.set('paymentMethodKind', payment.get('kind'));
+ frozenReceipt.set('paymentMethodKind', null);
+ if (frozenReceipt.get('payments').length === 1 && frozenReceipt.get('orderType') === 0 && !frozenReceipt.get('isLayaway') && !frozenReceipt.get('isQuotation')) {
+ var payment = frozenReceipt.get('payments').models[0];
+ frozenReceipt.set('paymentMethodKind', payment.get('kind'));
}
// multiterminal support
// be sure that the active terminal is the one set as the order proprietary
- receipt.set('posTerminal', OB.MobileApp.model.get('terminal').id);
- receipt.set('posTerminal' + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER, OB.MobileApp.model.get('terminal')._identifier);
+ frozenReceipt.set('posTerminal', OB.MobileApp.model.get('terminal').id);
+ frozenReceipt.set('posTerminal' + OB.Constants.FIELDSEPARATOR + OB.Constants.IDENTIFIER, OB.MobileApp.model.get('terminal')._identifier);
- receipt.get("approvals").forEach(function (approval) {
+ frozenReceipt.get("approvals").forEach(function (approval) {
if (typeof (approval.approvalType) === 'object') {
approval.approvalMessage = OB.I18N.getLabel(approval.approvalType.message, approval.approvalType.params);
approval.approvalType = approval.approvalType.approval;
}
});
- receipt.set('obposAppCashup', OB.MobileApp.model.get('terminal').cashUpId);
+ frozenReceipt.set('obposAppCashup', OB.MobileApp.model.get('terminal').cashUpId);
// convert returns
- if (receipt.getGross() < 0 || !_.isUndefined(receipt.get('paidInNegativeStatusAmt'))) {
+ if (frozenReceipt.getGross() < 0 || !_.isUndefined(frozenReceipt.get('paidInNegativeStatusAmt'))) {
var paymentTotalAmt = OB.DEC.Zero;
- _.forEach(receipt.get('payments').models, function (item) {
- if (!item.get('isPrePayment') && !item.get('reversedPaymentId') && !receipt.get('isPaid')) {
+ _.forEach(frozenReceipt.get('payments').models, function (item) {
+ if (!item.get('isPrePayment') && !item.get('reversedPaymentId') && !frozenReceipt.get('isPaid')) {
item.set('amount', -item.get('amount'));
item.set('origAmount', -item.get('origAmount'));
item.set('paid', -item.get('paid'));
}
paymentTotalAmt = OB.DEC.add(paymentTotalAmt, item.get('origAmount'));
});
- if (!_.isUndefined(receipt.get('paidInNegativeStatusAmt'))) {
- receipt.set('payment', paymentTotalAmt);
+ if (!_.isUndefined(frozenReceipt.get('paidInNegativeStatusAmt'))) {
+ frozenReceipt.set('payment', paymentTotalAmt);
}
}
- OB.info("[receipt.closed] Starting transaction. ReceiptId: " + receipt.get('id'));
+ OB.info("[receipt.closed] Starting transaction. ReceiptId: " + frozenReceipt.get('id'));
OB.Dal.transaction(function (tx) {
OB.trace('Calculationg cashup information.');
- OB.UTIL.cashUpReport(receipt, function (cashUp) {
- receipt.set('cashUpReportInformation', JSON.parse(cashUp.models[0].get('objToSend')));
- receipt.set('json', JSON.stringify(receipt.serializeToJSON()));
- receipt.set('hasbeenpaid', 'Y');
+ OB.UTIL.cashUpReport(frozenReceipt, function (cashUp) {
+ frozenReceipt.set('cashUpReportInformation', JSON.parse(cashUp.models[0].get('objToSend')));
+ frozenReceipt.set('json', JSON.stringify(frozenReceipt.serializeToJSON()));
+ frozenReceipt.set('hasbeenpaid', 'Y');
// Important: at this point, the receipt is considered final. Nothing must alter it
- OB.UTIL.clone(receipt, frozenReceipt);
// when all the properties of the receipt have been set, keep a copy
if (OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) {
- OB.Dal.saveInTransaction(tx, receipt);
+ OB.Dal.saveInTransaction(tx, frozenReceipt);
} else {
OB.UTIL.calculateCurrentCash(null, tx);
- OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(receipt.get('documentnoSuffix'), receipt.get('quotationnoSuffix'), receipt.get('returnnoSuffix'), function () {
+ OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(frozenReceipt.get('documentnoSuffix'), frozenReceipt.get('quotationnoSuffix'), frozenReceipt.get('returnnoSuffix'), function () {
OB.trace('Saving receipt.');
- OB.Dal.saveInTransaction(tx, receipt, function () {
+ OB.Dal.saveInTransaction(tx, frozenReceipt, function () {
// the trigger is fired on the receipt object, as there is only 1 that is being updated
receipt.trigger('integrityOk'); // Is important for module print last receipt. This module listen trigger.
});
@@ -197,24 +198,25 @@
}, tx);
}, function () {
// the transaction failed
- OB.error("[receipt.closed] The transaction failed to be commited. ReceiptId: " + receipt.get('id'));
+ OB.error("[receipt.closed] The transaction failed to be commited. ReceiptId: " + frozenReceipt.get('id'));
// rollback other changes
receipt.set('hasbeenpaid', 'N');
frozenReceipt.set('hasbeenpaid', 'N');
if (eventParams && eventParams.callback) {
eventParams.callback({
frozenReceipt: frozenReceipt,
+ diffReceipt: diffReceipt,
isCancelled: false
});
}
}, function () {
// success transaction...
- OB.info("[receipt.closed] Transaction success. ReceiptId: " + receipt.get('id'));
+ OB.info("[receipt.closed] Transaction success. ReceiptId: " + frozenReceipt.get('id'));
- function serverMessageForQuotation(receipt) {
- var isLayaway = (receipt.get('orderType') === 2 || receipt.get('isLayaway'));
- var currentDocNo = receipt.get('documentNo');
- if (receipt && receipt.get('isQuotation')) {
+ function serverMessageForQuotation(frozenReceipt) {
+ var isLayaway = (frozenReceipt.get('orderType') === 2 || frozenReceipt.get('isLayaway'));
+ var currentDocNo = frozenReceipt.get('documentNo');
+ if (frozenReceipt && frozenReceipt.get('isQuotation')) {
OB.UTIL.showSuccess(OB.I18N.getLabel('OBPOS_QuotationSaved', [currentDocNo]));
} else {
if (isLayaway) {
@@ -240,12 +242,14 @@
});
receipt.set('hasbeenpaid', 'N');
frozenReceipt.set('hasbeenpaid', 'N');
+ diffReceipt.set('hasbeenpaid', 'N');
OB.Dal.save(receipt, function () {
OB.UTIL.calculateCurrentCash();
if (eventParams && eventParams.callback) {
eventParams.callback({
frozenReceipt: frozenReceipt,
+ diffReceipt: diffReceipt,
isCancelled: true
});
receipt.setIsCalculateReceiptLockState(false);
@@ -257,11 +261,13 @@
} else if (eventParams && eventParams.callback) {
eventParams.callback({
frozenReceipt: frozenReceipt,
+ diffReceipt: diffReceipt,
isCancelled: false
});
}
};
-
+ receipt.clearWith(frozenReceipt);
+ OB.UTIL.clone(receipt, diffReceipt);
// create a clone of the receipt to be used when executing the final callback
if (OB.UTIL.HookManager.get('OBPOS_PostSyncReceipt')) {
// create a clone of the receipt to be used within the hook
@@ -277,10 +283,11 @@
receipt: receiptForPostSyncReceipt,
syncSuccess: true
}, function () {
- serverMessageForQuotation(receipt);
+ serverMessageForQuotation(frozenReceipt);
if (eventParams && eventParams.callback) {
eventParams.callback({
frozenReceipt: frozenReceipt,
+ diffReceipt: diffReceipt,
isCancelled: false
});
}
@@ -293,11 +300,9 @@
OB.Dal.transaction(function (tx) {
OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(receipt.get('documentnoSuffix'), receipt.get('quotationnoSuffix'), receipt.get('returnnoSuffix'), function () {
OB.trace('Saving receipt.');
- OB.Dal.saveInTransaction(tx, receipt, function () {
- // the trigger is fired on the receipt object, as there is only 1 that is being updated
- receipt.trigger('integrityOk'); // Is important for module print last receipt. This module listen trigger.
- successStep();
- });
+ // the trigger is fired on the receipt object, as there is only 1 that is being updated
+ receipt.trigger('integrityOk'); // Is important for module print last receipt. This module listen trigger.
+ successStep();
}, tx);
});
} else {
@@ -316,6 +321,7 @@
if (!OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true) && eventParams && eventParams.callback) {
eventParams.callback({
frozenReceipt: frozenReceipt,
+ diffReceipt: diffReceipt,
isCancelled: false
});
}
@@ -326,16 +332,15 @@
OB.Dal.transaction(function (tx) {
OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(receipt.get('documentnoSuffix'), receipt.get('quotationnoSuffix'), receipt.get('returnnoSuffix'), function () {
OB.trace('Saving receipt.');
- OB.Dal.saveInTransaction(tx, receipt, function () {
- // the trigger is fired on the receipt object, as there is only 1 that is being updated
- receipt.trigger('integrityOk'); // Is important for module print last receipt. This module listen trigger.
- if (eventParams && eventParams.callback) {
- eventParams.callback({
- frozenReceipt: frozenReceipt,
- isCancelled: false
- });
- }
- });
+ // the trigger is fired on the receipt object, as there is only 1 that is being updated
+ receipt.trigger('integrityOk'); // Is important for module print last receipt. This module listen trigger.
+ if (eventParams && eventParams.callback) {
+ eventParams.callback({
+ frozenReceipt: frozenReceipt,
+ diffReceipt: diffReceipt,
+ isCancelled: false
+ });
+ }
}, tx);
});
}
@@ -373,6 +378,8 @@
var normalizedCreationDate = OB.I18N.normalizeDate(currentReceipt.get('creationDate'));
var creationDate;
+ var frozenReceipt = new OB.Model.Order(),
+ diffReceipt = new OB.Model.Order();
if (normalizedCreationDate === null) {
creationDate = new Date();
normalizedCreationDate = OB.I18N.normalizeDate(creationDate);
diff --git a/web/org.openbravo.retail.posterminal/js/login/model/login-model.js b/web/org.openbravo.retail.posterminal/js/login/model/login-model.js
--- a/web/org.openbravo.retail.posterminal/js/login/model/login-model.js
+++ b/web/org.openbravo.retail.posterminal/js/login/model/login-model.js
@@ -14,6 +14,7 @@
OB.Model.POSTerminal = OB.Model.Terminal.extend({
setTerminalName: function (terminalName) {
+ OB.info("Set terminal Name change from: " + this.get('terminalName') + ' to: ' + terminalName);
this.set('terminalName', terminalName);
this.set('loginUtilsParams', {
terminalName: terminalName
diff --git a/web/org.openbravo.retail.posterminal/js/model/order.js b/web/org.openbravo.retail.posterminal/js/model/order.js
--- a/web/org.openbravo.retail.posterminal/js/model/order.js
+++ b/web/org.openbravo.retail.posterminal/js/model/order.js
@@ -438,7 +438,11 @@
if (callback === undefined || !callback instanceof Function) {
callback = function () {};
}
- if (!OB.MobileApp.model.get('preventOrderSave')) {
+ if (OB.MobileApp.model.get('preventOrderSave') || (this.get('isQuotation') && !this.get('isEditable')) || this.get('isCancelling')) {
+ if (callback) {
+ callback();
+ }
+ } else {
OB.Dal.save(this, function () {
if (callback) {
callback();
@@ -446,10 +450,6 @@
}, function () {
OB.error(arguments);
}, forceInsert);
- } else {
- if (callback) {
- callback();
- }
}
this.setUndo('SaveOrder', undoCopy);
},
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
@@ -363,56 +363,52 @@
return true;
}
}, this);
- receipt.set('json', JSON.stringify(receipt.serializeToJSON()));
- OB.Dal.save(receipt, function () {
- OB.UTIL.Debug.execute(function () {
- if (!args.frozenReceipt) {
- throw "A clone of the receipt must be provided because it is possible that some rogue process could have changed it";
- }
- if (OB.UTIL.isNullOrUndefined(args.isCancelled)) { // allow boolean values
- throw "The isCancelled flag must be set";
- }
+ OB.UTIL.Debug.execute(function () {
+ if (!args.frozenReceipt) {
+ throw "A clone of the receipt must be provided because it is possible that some rogue process could have changed it";
+ }
+ if (OB.UTIL.isNullOrUndefined(args.isCancelled)) { // allow boolean values
+ throw "The isCancelled flag must be set";
+ }
+ });
+
+ // verify that the receipt was not cancelled
+ if (args.isCancelled !== true) {
+ var orderToPrint = OB.UTIL.clone(args.frozenReceipt);
+ orderToPrint.get('payments').reset();
+ clonedCollection.each(function (model) {
+ orderToPrint.get('payments').add(new Backbone.Model(model.toJSON()), {
+ silent: true
+ });
+ });
+ orderToPrint.set('hasbeenpaid', 'Y');
+ receipt.trigger('print', orderToPrint, {
+ offline: true
});
- // verify that the receipt was not cancelled
- if (args.isCancelled !== true) {
- var orderToPrint = OB.UTIL.clone(args.frozenReceipt);
- orderToPrint.get('payments').reset();
- clonedCollection.each(function (model) {
- orderToPrint.get('payments').add(new Backbone.Model(model.toJSON()), {
- silent: true
- });
- });
- orderToPrint.set('hasbeenpaid', 'Y');
- receipt.trigger('print', orderToPrint, {
- offline: true
- });
+ // Verify that the receipt has not been changed while the ticket has being closed
+ var diff = OB.UTIL.diffJson(receipt.serializeToJSON(), args.frozenReceipt.serializeToJSON());
+ // hasBeenPaid and cashUpReportInformation are the only difference allowed in the receipt
+ delete diff.hasbeenpaid;
+ delete diff.cashUpReportInformation;
+ // isBeingClosed is a flag only used to log purposes
+ delete diff.isBeingClosed;
+ // verify if there have been any modification to the receipt
+ var diffStringified = JSON.stringify(diff, undefined, 2);
+ if (diffStringified !== '{}') {
+ OB.error("The receipt has been modified while it was being closed:\n" + diffStringified + "\n");
+ }
- // Verify that the receipt has not been changed while the ticket has being closed
- var diff = OB.UTIL.diffJson(receipt.serializeToJSON(), args.frozenReceipt.serializeToJSON());
- // hasBeenPaid and cashUpReportInformation are the only difference allowed in the receipt
- delete diff.hasbeenpaid;
- delete diff.cashUpReportInformation;
- // isBeingClosed is a flag only used to log purposes
- delete diff.isBeingClosed;
- // verify if there have been any modification to the receipt
- var diffStringified = JSON.stringify(diff, undefined, 2);
- if (diffStringified !== '{}') {
- OB.error("The receipt has been modified while it was being closed:\n" + diffStringified + "\n");
- }
+ orderList.deleteCurrent();
+ receipt.setIsCalculateReceiptLockState(false);
+ receipt.setIsCalculateGrossLockState(false);
- orderList.deleteCurrent();
- receipt.setIsCalculateReceiptLockState(false);
- receipt.setIsCalculateGrossLockState(false);
-
- orderList.synchronizeCurrentOrder();
- }
- if (OB.MobileApp.view.openedPopup === null) {
- enyo.$.scrim.hide();
- }
- OB.UTIL.SynchronizationHelper.finished(synchId, "receipt.paymentAccepted");
- }, null, false);
-
+ orderList.synchronizeCurrentOrder();
+ }
+ if (OB.MobileApp.view.openedPopup === null) {
+ enyo.$.scrim.hide();
+ }
+ OB.UTIL.SynchronizationHelper.finished(synchId, "receipt.paymentAccepted");
}
});
};
diff --git a/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js b/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js
--- a/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js
+++ b/web/org.openbravo.retail.posterminal/js/pointofsale/view/pointofsale.js
@@ -1276,7 +1276,6 @@
_.each(inEvent.value, function (iter) {
//iter.set('isMultiOrder', true);
iter.set('belongsToMultiOrder', true);
- me.model.get('orderList').addMultiReceipt(iter);
me.model.get('multiOrders').get('multiOrdersList').add(iter);
});
this.model.get('leftColumnViewManager').setMultiOrderMode();
|