Attached Files | 38848_PI.diff [^] (9,109 bytes) 2018-06-28 17:21 [Show Content] [Hide Content]# HG changeset patch
# User Guillermo Alvarez de Eulate <guillermo.alvarez@openbravo.com>
# Date 1530199083 -7200
# Thu Jun 28 17:18:03 2018 +0200
# Node ID f5bfcf07fbdb6c953d4305fe4d63a14937313032
# Parent 4b82add38cba7853b18aa3ececcab1386f042546
Fixed Issue 38848: Added log to the cash managment process
Added log to the process to add events (drop/deposit)
Added log to the synchronization process (executed when done is pressed)
diff -r 4b82add38cba -r f5bfcf07fbdb web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js
--- a/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js Thu Jun 28 17:08:10 2018 +0200
+++ b/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js Thu Jun 28 17:18:03 2018 +0200
@@ -113,6 +113,7 @@
}, this);
var makeDepositsFunction = function (me) {
+ OB.info('[CashMgmntSync] Cash managment synchronization started. ' + (me.depsdropstosave.size ? me.depsdropstosave.size() : 0) + ' To be synched');
TestRegistry.CashMgmt = TestRegistry.CashMgmt || {};
TestRegistry.CashMgmt.isCashDepositPrinted = false;
@@ -120,6 +121,7 @@
if (me.depsdropstosave.length === 0) {
// Nothing to do go to main window
+ OB.info('[CashMgmntSync] Cash managment synchronization exited. Nothing to sync');
OB.POS.navigate('retail.pointofsale');
return true;
}
@@ -130,26 +132,37 @@
function runSync() {
if (OB.MobileApp.model.get('connectedToERP')) {
+ OB.info('[CashMgmntSync][RunSync] Started ONLINE');
OB.MobileApp.model.runSyncProcess(function () {
OB.UTIL.showLoading(false);
me.set("finished", true);
if (OB.MobileApp.model.hasPermission('OBPOS_print.cashmanagement')) {
+ OB.info('[CashMgmntSync][RunSync] Online -> PRINT');
me.printCashMgmt.print(me.depsdropstosave.toJSON());
}
+ OB.info('[CashMgmntSync][RunSync] Finished ONLINE');
}, function () {
if (OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) {
+ OB.info('[CashMgmntSync][RunSync] continues ONLINE. OBMOBC_SynchronizedMode is ACTIVE');
// fail, remove everything and go away
OB.Dal.removeAll(OB.Model.CashManagement, null, function () {
+ OB.info('[CashMgmntSync][RunSync][removeAll] RemoveAll because OBMOBC_SynchronizedMode is ACTIVE');
OB.UTIL.calculateCurrentCash();
me.depsdropstosave = new Backbone.Collection();
+ OB.info('[CashMgmntSync][RunSync] Finished ONLINE with OBMOBC_SynchronizedMode is ACTIVE');
});
+ return;
}
+ OB.error('[CashMgmntSync][RunSync] Failed ONLINE');
});
} else {
+ OB.info('[CashMgmntSync][RunSync] Started OFFLINE');
OB.UTIL.showLoading(false);
me.set("finished", true);
if (OB.MobileApp.model.hasPermission('OBPOS_print.cashmanagement')) {
+ OB.info('[CashMgmntSync][RunSync] Offline -> PRINT');
me.printCashMgmt.print(me.depsdropstosave.toJSON());
+ OB.info('[CashMgmntSync][RunSync] Finished OFFLINE');
}
}
}
@@ -203,6 +216,10 @@
}
}, this);
+ OB.info('[CashMgmntSync] grouped info after sync: ' + JSON.stringify(paymentList.models.map(function (item) {
+ return JSON.stringify(item);
+ })));
+
// Sending drops/deposits to backend
var updateCashupAndAddCashupInfo = null;
var updateCashupInfo = null;
@@ -210,7 +227,9 @@
setCashupObjectInCashMgmt = function (depdrops, cashUp, index) {
if (index === depdrops.length) {
+ OB.info('[CashMgmntSync][setCashupObjectInCashMgmt] Finished. Execute CalculateCurrentCash');
OB.UTIL.calculateCurrentCash(function () {
+ OB.info('[CashMgmntSync][setCashupObjectInCashMgmt][calculateCurrentCash] Executed. Run Sync');
runSync();
});
} else {
@@ -218,11 +237,14 @@
var depDropJson = JSON.stringify(depdrop.serializeToJSON());
depdrop.set('cashUpReportInformation', JSON.parse(cashUp.models[0].get('objToSend')));
depdrop.set('json', depDropJson);
+ OB.info('[CashMgmntSync][setCashupObjectInCashMgmt][saveCashMgmnt] execute save for deposit/drop in local DB:' + depDropJson);
OB.Dal.save(depdrop, function () {
+ OB.info('[CashMgmntSync][saveCashMgmnt] Successfully saved deposit/drop in local DB:' + depdrop.id);
setCashupObjectInCashMgmt(depdrops, cashUp, index + 1);
}, function () {
OB.UTIL.showLoading(false);
me.set("finishedWrongly", true);
+ OB.error('[CashMgmntSync][setCashupObjectInCashMgmt][saveCashMgmnt] Error saving deposit/drop in local DB:' + depdrop.id);
return;
}, true);
}
@@ -232,13 +254,19 @@
if (index === paymentList.length && callback) {
callback(cashUpReport);
} else {
+ OB.info('[CashMgmntSync][preSumCashManagementToCashup] for payment: ' + JSON.stringify(paymentList[index]));
OB.UTIL.sumCashManagementToCashup(paymentList[index], function (cashUp) {
+ OB.info('[CashMgmntSync][preUpdateCashupInfo][postSumCashManagementToCashup] for paymentList:' + JSON.stringify(paymentList[index]));
updateCashupInfo(paymentList, index + 1, cashUp, callback);
});
}
};
updateCashupInfo(paymentList.models, 0, null, function (cashUpReport) {
+ if (cashUpReport && cashUpReport.size && cashUpReport.size() === 1) {
+ OB.info('[CashMgmntSync][postUpdateCashupInfo]: ' + cashUpReport.at(0).get('objToSend'));
+ }
+ OB.info('[CashMgmntSync][setCashupObjectInCashMgmt]: Call to setCashupObjectInCashMgmt for ' + me.depsdropstosave.size() + ' models');
setCashupObjectInCashMgmt(me.depsdropstosave.models, cashUpReport, 0);
});
diff -r 4b82add38cba -r f5bfcf07fbdb web/org.openbravo.retail.posterminal/js/cashmgmt/view/cashmgmt.js
--- a/web/org.openbravo.retail.posterminal/js/cashmgmt/view/cashmgmt.js Thu Jun 28 17:08:10 2018 +0200
+++ b/web/org.openbravo.retail.posterminal/js/cashmgmt/view/cashmgmt.js Thu Jun 28 17:18:03 2018 +0200
@@ -162,8 +162,12 @@
this.model.get('cashMgmtDepositEvents').on('click', function (model) {
var me = this;
this.model.depsdropstosave.trigger('paymentDone', model, this.currentPayment, function () {
+ OB.info('[CashMgmntEvent] Item Added. Current Cash Mgmnt items: ' + JSON.stringify(me.model.depsdropstosave.models.map(function (item) {
+ return item.getRelevantInformationString();
+ })));
delete me.currentPayment;
- }, function () {
+ }, function (error) {
+ OB.error('[CashMgmntEvent] Error executing paymentDone ' + error);
delete me.currentPayment;
});
}, this);
@@ -171,8 +175,12 @@
this.model.get('cashMgmtDropEvents').on('click', function (model) {
var me = this;
this.model.depsdropstosave.trigger('paymentDone', model, this.currentPayment, function () {
+ OB.info('[CashMgmntEvent] Item Added. Current Cash Mgmnt items: ' + JSON.stringify(me.model.depsdropstosave.models.map(function (item) {
+ return item.getRelevantInformationString();
+ })));
delete me.currentPayment;
- }, function () {
+ }, function (error) {
+ OB.error('[CashMgmntEvent] Error executing paymentDone ' + error);
delete me.currentPayment;
});
}, this);
diff -r 4b82add38cba -r f5bfcf07fbdb web/org.openbravo.retail.posterminal/js/model/cashmanagement.js
--- a/web/org.openbravo.retail.posterminal/js/model/cashmanagement.js Thu Jun 28 17:08:10 2018 +0200
+++ b/web/org.openbravo.retail.posterminal/js/model/cashmanagement.js Thu Jun 28 17:18:03 2018 +0200
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2013-2016 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.
@@ -19,6 +19,9 @@
local: true,
serializeToJSON: function () {
return JSON.parse(JSON.stringify(this.toJSON()));
+ },
+ getRelevantInformationString: function () {
+ return 'Id: ' + this.get('id') + ' Amount: ' + this.get('amount') + ' origAmount: ' + this.get('origAmount') + ' currency: ' + this.get('isocode') + ' paymentMethodId: ' + this.get('paymentMethodId') + ' cashup_id: ' + this.get('cashup_id');
}
});
38848_2_PI.diff [^] (5,660 bytes) 2018-07-02 14:06 [Show Content] [Hide Content]diff -r 2028a4884b06 web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js
--- a/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js Mon Jul 02 13:00:19 2018 +0200
+++ b/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js Mon Jul 02 14:05:42 2018 +0200
@@ -113,7 +113,7 @@
}, this);
var makeDepositsFunction = function (me) {
- OB.info('[CashMgmntSync] Cash managment synchronization started. ' + (me.depsdropstosave.size ? me.depsdropstosave.size() : 0) + ' To be synched');
+ OB.info('[CashMgmntSync][1] Cash management synchronization started. ' + (me.depsdropstosave.size ? me.depsdropstosave.size() : 0) + ' To be synched');
TestRegistry.CashMgmt = TestRegistry.CashMgmt || {};
TestRegistry.CashMgmt.isCashDepositPrinted = false;
@@ -132,15 +132,15 @@
function runSync() {
if (OB.MobileApp.model.get('connectedToERP')) {
- OB.info('[CashMgmntSync][RunSync] Started ONLINE');
+ OB.info('[CashMgmntSync][11][RunSync] Started ONLINE');
OB.MobileApp.model.runSyncProcess(function () {
OB.UTIL.showLoading(false);
me.set("finished", true);
if (OB.MobileApp.model.hasPermission('OBPOS_print.cashmanagement')) {
- OB.info('[CashMgmntSync][RunSync] Online -> PRINT');
+ OB.info('[CashMgmntSync][12][RunSync] Online -> PRINT');
me.printCashMgmt.print(me.depsdropstosave.toJSON());
}
- OB.info('[CashMgmntSync][RunSync] Finished ONLINE');
+ OB.info('[CashMgmntSync][13][RunSync] Finished ONLINE');
}, function () {
if (OB.MobileApp.model.hasPermission('OBMOBC_SynchronizedMode', true)) {
OB.info('[CashMgmntSync][RunSync] continues ONLINE. OBMOBC_SynchronizedMode is ACTIVE');
@@ -216,8 +216,8 @@
}
}, this);
- OB.info('[CashMgmntSync] grouped info after sync: ' + JSON.stringify(paymentList.models.map(function (item) {
- return JSON.stringify(item);
+ OB.info('[CashMgmntSync][2] grouped info before sync: ' + JSON.stringify(paymentList.models.map(function (item) {
+ return item;
})));
// Sending drops/deposits to backend
@@ -227,9 +227,9 @@
setCashupObjectInCashMgmt = function (depdrops, cashUp, index) {
if (index === depdrops.length) {
- OB.info('[CashMgmntSync][setCashupObjectInCashMgmt] Finished. Execute CalculateCurrentCash');
+ OB.info('[CashMgmntSync][9][setCashupObjectInCashMgmt] Finished. Execute CalculateCurrentCash');
OB.UTIL.calculateCurrentCash(function () {
- OB.info('[CashMgmntSync][setCashupObjectInCashMgmt][calculateCurrentCash] Executed. Run Sync');
+ OB.info('[CashMgmntSync][10][setCashupObjectInCashMgmt][calculateCurrentCash] Executed. Run Sync');
runSync();
});
} else {
@@ -238,9 +238,9 @@
depdrop.set('cashUpReportInformation', JSON.parse(cashUp.models[0].get('objToSend')));
depDropJson = JSON.stringify(depdrop.serializeToJSON());
depdrop.set('json', depDropJson);
- OB.info('[CashMgmntSync][setCashupObjectInCashMgmt][saveCashMgmnt] execute save for deposit/drop in local DB:' + depDropJson);
+ OB.info('[CashMgmntSync][7][setCashupObjectInCashMgmt][saveCashMgmnt] execute save for deposit/drop in local DB:' + depDropJson);
OB.Dal.save(depdrop, function () {
- OB.info('[CashMgmntSync][saveCashMgmnt] Successfully saved deposit/drop in local DB:' + depdrop.id);
+ OB.info('[CashMgmntSync][8][saveCashMgmnt] Successfully saved deposit/drop in local DB:' + depdrop.id);
setCashupObjectInCashMgmt(depdrops, cashUp, index + 1);
}, function () {
OB.UTIL.showLoading(false);
@@ -255,9 +255,9 @@
if (index === paymentList.length && callback) {
callback(cashUpReport);
} else {
- OB.info('[CashMgmntSync][preSumCashManagementToCashup] for payment: ' + JSON.stringify(paymentList[index]));
+ OB.info('[CashMgmntSync][3][preSumCashManagementToCashup] for payment: ' + JSON.stringify(paymentList[index]));
OB.UTIL.sumCashManagementToCashup(paymentList[index], function (cashUp) {
- OB.info('[CashMgmntSync][preUpdateCashupInfo][postSumCashManagementToCashup] for paymentList:' + JSON.stringify(paymentList[index]));
+ OB.info('[CashMgmntSync][4][preUpdateCashupInfo][postSumCashManagementToCashup] for paymentList:' + JSON.stringify(paymentList[index]));
updateCashupInfo(paymentList, index + 1, cashUp, callback);
});
}
@@ -265,9 +265,9 @@
updateCashupInfo(paymentList.models, 0, null, function (cashUpReport) {
if (cashUpReport && cashUpReport.size && cashUpReport.size() === 1) {
- OB.info('[CashMgmntSync][postUpdateCashupInfo]: ' + cashUpReport.at(0).get('objToSend'));
+ OB.info('[CashMgmntSync][5][postUpdateCashupInfo]: ' + cashUpReport.at(0).get('objToSend'));
}
- OB.info('[CashMgmntSync][setCashupObjectInCashMgmt]: Call to setCashupObjectInCashMgmt for ' + me.depsdropstosave.size() + ' models');
+ OB.info('[CashMgmntSync][6][setCashupObjectInCashMgmt]: Call to setCashupObjectInCashMgmt for ' + me.depsdropstosave.size() + ' models');
setCashupObjectInCashMgmt(me.depsdropstosave.models, cashUpReport, 0);
});
|