Attached Files | 45390.png [^] (174,906 bytes) 2020-11-06 11:56

I45390_20Q3.patch [^] (18,166 bytes) 2020-11-13 15:11 [Show Content] [Hide Content]From 9222a199e438b4d4b2eb8a2318c41f44cf92c01f Mon Sep 17 00:00:00 2001
From: Prakash M <prakash@qualiantech.com>
Date: Fri, 13 Nov 2020 19:35:54 +0530
Subject: [PATCH] Fixed BUG-45390: Fixes js error on moving to 2nd step in
Count Safe Box * This is because paymentExpectedList is empty *
paymentExpectedList is created in CloseCash - initializationProcess
(cashup-model.js) * But however this CloseCash - initializationProcess method
is overrided in countsafebox-model.js * And created of paymentExpectedList,
paymentEmptyList is not implemented in new method * Moved paymentList
creation to separate function * Therefore it can be shared by both cashup and
safe boxes models
---
.../js/closecash/model/cashup/cashup-model.js | 196 +-----------------
.../js/closecash/model/closecash-model.js | 191 +++++++++++++++++
.../model/countsafebox/countsafebox-model.js | 2 +
3 files changed, 203 insertions(+), 186 deletions(-)
diff --git a/web/org.openbravo.retail.posterminal/js/closecash/model/cashup/cashup-model.js b/web/org.openbravo.retail.posterminal/js/closecash/model/cashup/cashup-model.js
index 422668d92..5516d6824 100644
--- a/web/org.openbravo.retail.posterminal/js/closecash/model/cashup/cashup-model.js
+++ b/web/org.openbravo.retail.posterminal/js/closecash/model/cashup/cashup-model.js
@@ -7,7 +7,7 @@
************************************************************************************
*/
-/*global OB, Backbone, _ */
+/*global OB, Backbone */
OB.OBPOSCashUp = OB.OBPOSCashUp || {};
OB.OBPOSCashUp.Model = OB.OBPOSCashUp.Model || {};
@@ -98,192 +98,16 @@ OB.OBPOSCashUp.Model.CashUp = OB.OBPOSCloseCash.Model.CloseCash.extend({
this.set('orderlist', new OB.Collection.OrderList());
- OB.Dal.find(
- OB.Model.CashUp,
- {
- isprocessed: 'N'
- },
- cashUp => {
- OB.Dal.find(
- OB.Model.PaymentMethodCashUp,
- {
- cashup_id: cashUp.at(0).get('id'),
- _orderByClause: 'lineNo asc'
- },
- payMthds => {
- //OB.Dal.find success
- // Get list of active payments
- let activePaymentsList = [],
- tempList = new Backbone.Collection();
- OB.MobileApp.model.get('payments').forEach(payment => {
- if (
- payment.payment.active === true &&
- payment.paymentMethod.countpaymentincashup &&
- !payment.paymentMethod.issafebox
- ) {
- activePaymentsList.push(payment);
- }
- });
- activePaymentsList.forEach((payment, index) => {
- let expected = 0;
- const auxPay = payMthds.filter(function(payMthd) {
- return payMthd.get('paymentmethod_id') === payment.payment.id;
- })[0];
- if (!auxPay) {
- //We cannot find this payment in local database, it must be a new payment method, we skip it.
- return;
- }
+ this.setPaymentList(true);
- // Not add shared payment to slave terminal
- if (
- !terminalSlave ||
- !OB.MobileApp.model.paymentnames[payment.payment.searchKey]
- .paymentMethod.isshared
- ) {
- auxPay.set('_id', payment.payment.searchKey);
- auxPay.set('isocode', payment.isocode);
- auxPay.set('paymentMethod', payment.paymentMethod);
- auxPay.set('id', payment.payment.id);
- if (auxPay.get('totalDeposits') === null) {
- auxPay.set('totalDeposits', 0);
- }
- if (auxPay.get('totalDrops') === null) {
- auxPay.set('totalDrops', 0);
- }
- const cStartingCash = auxPay.get('startingCash'),
- cTotalReturns = auxPay.get('totalReturns'),
- cTotalSales = auxPay.get('totalSales'),
- cTotalDeposits = OB.DEC.sub(
- auxPay.get('totalDeposits'),
- OB.DEC.abs(auxPay.get('totalDrops'))
- );
- expected = OB.DEC.add(
- OB.DEC.add(
- cStartingCash,
- OB.DEC.sub(
- cTotalSales,
- cTotalReturns,
- payment.obposPosprecision
- ),
- payment.obposPosprecision
- ),
- cTotalDeposits,
- payment.obposPosprecision
- );
- const fromCurrencyId = auxPay.get('paymentMethod').currency;
- auxPay.set(
- 'expected',
- OB.UTIL.currency.toDefaultCurrency(fromCurrencyId, expected)
- );
- auxPay.set('foreignExpected', expected);
- const paymentShared =
- (OB.POS.modelterminal.get('terminal').ismaster ||
- OB.POS.modelterminal.get('terminal').isslave) &&
- OB.MobileApp.model.paymentnames[payment.payment.searchKey]
- .paymentMethod.isshared;
- if (paymentShared) {
- auxPay.set(
- 'name',
- auxPay.get('name') +
- (paymentShared
- ? OB.I18N.getLabel('OBPOS_LblPaymentMethodShared')
- : '')
- );
- }
- tempList.add(auxPay);
- }
-
- if (index === activePaymentsList.length - 1) {
- if (terminalSlave && tempList.length === 0) {
- // Desactivate all steps
- this.stepsDefinition[
- this.stepIndex('OB.CloseCash.PaymentMethods')
- ].active = false;
- }
- if (
- OB.MobileApp.model.hasPermission(
- 'OBPOS_retail.cashupGroupExpectedPayment',
- true
- )
- ) {
- // Split payment methods
- const expectedList = _.filter(tempList.models, function(pm) {
- return pm.get('expected') !== 0;
- }),
- emptyList = _.filter(tempList.models, function(pm) {
- return pm.get('expected') === 0;
- });
-
- this.set(
- 'paymentExpectedList',
- new Backbone.Collection(expectedList)
- );
- this.set(
- 'paymentEmptyList',
- new Backbone.Collection(emptyList)
- );
-
- if (emptyList.length > 0) {
- emptyList[0].set('firstEmptyPayment', true);
- }
- const models = expectedList.concat(emptyList);
-
- this.get('paymentList').reset(models);
- } else {
- this.get('paymentList').reset(tempList.models);
- }
- // Active/Desactive CashPayments and CashToKeep tabs
- let cashPayments = false,
- cashToKeep = false;
- const paymentsIndex = this.stepIndex(
- 'OB.CloseCash.CashPayments'
- ),
- toKeepIndex = this.stepIndex('OB.CloseCash.CashToKeep');
- for (let i = 0; i < tempList.length; i++) {
- if (
- this.closeCashSteps[paymentsIndex].isSubstepAvailable(
- this,
- i
- )
- ) {
- cashPayments = true;
- }
- if (
- this.closeCashSteps[toKeepIndex].isSubstepAvailable(this, i)
- ) {
- cashToKeep = true;
- }
- }
- this.stepsDefinition[paymentsIndex].active = cashPayments;
- this.stepsDefinition[toKeepIndex].active = cashToKeep;
- this.set(
- 'totalExpected',
- this.get('paymentList').models.reduce((total, model) => {
- return OB.DEC.add(total, model.get('expected'));
- }, 0)
- );
- this.set(
- 'totalDifference',
- OB.DEC.sub(
- this.get('totalDifference'),
- this.get('totalExpected')
- )
- );
- this.setIgnoreStep3();
- }
- });
- this.stepsDefinition[
- this.stepIndex('OB.CloseCash.CashPayments')
- ].loaded = true;
- this.stepsDefinition[
- this.stepIndex('OB.CloseCash.PaymentMethods')
- ].loaded = true;
- synch1 = true;
- finish();
- }
- );
- }
- );
+ this.stepsDefinition[
+ this.stepIndex('OB.CloseCash.CashPayments')
+ ].loaded = true;
+ this.stepsDefinition[
+ this.stepIndex('OB.CloseCash.PaymentMethods')
+ ].loaded = true;
+ synch1 = true;
+ finish();
OB.Dal.find(
OB.Model.CashUp,
diff --git a/web/org.openbravo.retail.posterminal/js/closecash/model/closecash-model.js b/web/org.openbravo.retail.posterminal/js/closecash/model/closecash-model.js
index e905649da..f5599d62c 100644
--- a/web/org.openbravo.retail.posterminal/js/closecash/model/closecash-model.js
+++ b/web/org.openbravo.retail.posterminal/js/closecash/model/closecash-model.js
@@ -435,5 +435,196 @@ OB.OBPOSCloseCash.Model.CloseCash = OB.Model.TerminalWindowModel.extend({
},
processAndFinishCloseCash: function() {
this.processAndFinish();
+ },
+ setPaymentList: function(validateSteps) {
+ const terminalSlave =
+ !OB.POS.modelterminal.get('terminal').ismaster &&
+ OB.POS.modelterminal.get('terminal').isslave;
+
+ OB.Dal.find(
+ OB.Model.CashUp,
+ {
+ isprocessed: 'N'
+ },
+ cashUp => {
+ OB.Dal.find(
+ OB.Model.PaymentMethodCashUp,
+ {
+ cashup_id: cashUp.at(0).get('id'),
+ _orderByClause: 'lineNo asc'
+ },
+ payMthds => {
+ //OB.Dal.find success
+ // Get list of active payments
+ let activePaymentsList = [],
+ tempList = new Backbone.Collection();
+ OB.MobileApp.model.get('payments').forEach(payment => {
+ if (
+ payment.payment.active === true &&
+ payment.paymentMethod.countpaymentincashup &&
+ !payment.paymentMethod.issafebox
+ ) {
+ activePaymentsList.push(payment);
+ }
+ });
+ activePaymentsList.forEach((payment, index) => {
+ let expected = 0;
+ const auxPay = payMthds.filter(function(payMthd) {
+ return payMthd.get('paymentmethod_id') === payment.payment.id;
+ })[0];
+ if (!auxPay) {
+ //We cannot find this payment in local database, it must be a new payment method, we skip it.
+ return;
+ }
+
+ // Not add shared payment to slave terminal
+ if (
+ !terminalSlave ||
+ !OB.MobileApp.model.paymentnames[payment.payment.searchKey]
+ .paymentMethod.isshared
+ ) {
+ auxPay.set('_id', payment.payment.searchKey);
+ auxPay.set('isocode', payment.isocode);
+ auxPay.set('paymentMethod', payment.paymentMethod);
+ auxPay.set('id', payment.payment.id);
+ if (auxPay.get('totalDeposits') === null) {
+ auxPay.set('totalDeposits', 0);
+ }
+ if (auxPay.get('totalDrops') === null) {
+ auxPay.set('totalDrops', 0);
+ }
+ const cStartingCash = auxPay.get('startingCash'),
+ cTotalReturns = auxPay.get('totalReturns'),
+ cTotalSales = auxPay.get('totalSales'),
+ cTotalDeposits = OB.DEC.sub(
+ auxPay.get('totalDeposits'),
+ OB.DEC.abs(auxPay.get('totalDrops'))
+ );
+ expected = OB.DEC.add(
+ OB.DEC.add(
+ cStartingCash,
+ OB.DEC.sub(
+ cTotalSales,
+ cTotalReturns,
+ payment.obposPosprecision
+ ),
+ payment.obposPosprecision
+ ),
+ cTotalDeposits,
+ payment.obposPosprecision
+ );
+ const fromCurrencyId = auxPay.get('paymentMethod').currency;
+ auxPay.set(
+ 'expected',
+ OB.UTIL.currency.toDefaultCurrency(fromCurrencyId, expected)
+ );
+ auxPay.set('foreignExpected', expected);
+ const paymentShared =
+ (OB.POS.modelterminal.get('terminal').ismaster ||
+ OB.POS.modelterminal.get('terminal').isslave) &&
+ OB.MobileApp.model.paymentnames[payment.payment.searchKey]
+ .paymentMethod.isshared;
+ if (paymentShared) {
+ auxPay.set(
+ 'name',
+ auxPay.get('name') +
+ (paymentShared
+ ? OB.I18N.getLabel('OBPOS_LblPaymentMethodShared')
+ : '')
+ );
+ }
+ tempList.add(auxPay);
+ }
+
+ if (index === activePaymentsList.length - 1) {
+ if (
+ OB.MobileApp.model.hasPermission(
+ 'OBPOS_retail.cashupGroupExpectedPayment',
+ true
+ )
+ ) {
+ // Split payment methods
+ const expectedList = _.filter(tempList.models, function(pm) {
+ return pm.get('expected') !== 0;
+ }),
+ emptyList = _.filter(tempList.models, function(pm) {
+ return pm.get('expected') === 0;
+ });
+
+ this.set(
+ 'paymentExpectedList',
+ new Backbone.Collection(expectedList)
+ );
+ this.set(
+ 'paymentEmptyList',
+ new Backbone.Collection(emptyList)
+ );
+
+ if (emptyList.length > 0) {
+ emptyList[0].set('firstEmptyPayment', true);
+ }
+ const models = expectedList.concat(emptyList);
+
+ this.get('paymentList').reset(models);
+ } else {
+ this.get('paymentList').reset(tempList.models);
+ }
+
+ if (validateSteps) {
+ if (terminalSlave && tempList.length === 0) {
+ // Desactivate all steps
+ this.stepsDefinition[
+ this.stepIndex('OB.CloseCash.PaymentMethods')
+ ].active = false;
+ }
+
+ // Active/Desactive CashPayments and CashToKeep tabs
+ let cashPayments = false,
+ cashToKeep = false;
+ const paymentsIndex = this.stepIndex(
+ 'OB.CloseCash.CashPayments'
+ ),
+ toKeepIndex = this.stepIndex('OB.CloseCash.CashToKeep');
+ for (let i = 0; i < tempList.length; i++) {
+ if (
+ this.closeCashSteps[paymentsIndex].isSubstepAvailable(
+ this,
+ i
+ )
+ ) {
+ cashPayments = true;
+ }
+ if (
+ this.closeCashSteps[toKeepIndex].isSubstepAvailable(
+ this,
+ i
+ )
+ ) {
+ cashToKeep = true;
+ }
+ }
+ this.stepsDefinition[paymentsIndex].active = cashPayments;
+ this.stepsDefinition[toKeepIndex].active = cashToKeep;
+ this.set(
+ 'totalExpected',
+ this.get('paymentList').models.reduce((total, model) => {
+ return OB.DEC.add(total, model.get('expected'));
+ }, 0)
+ );
+ this.set(
+ 'totalDifference',
+ OB.DEC.sub(
+ this.get('totalDifference'),
+ this.get('totalExpected')
+ )
+ );
+ this.setIgnoreStep3();
+ }
+ }
+ });
+ }
+ );
+ }
+ );
}
});
diff --git a/web/org.openbravo.retail.posterminal/js/closecash/model/countsafebox/countsafebox-model.js b/web/org.openbravo.retail.posterminal/js/closecash/model/countsafebox/countsafebox-model.js
index a8c7071d3..d30dda181 100644
--- a/web/org.openbravo.retail.posterminal/js/closecash/model/countsafebox/countsafebox-model.js
+++ b/web/org.openbravo.retail.posterminal/js/closecash/model/countsafebox/countsafebox-model.js
@@ -71,6 +71,8 @@ OB.OBPOSCountSafeBox.Model.CountSafeBox = OB.OBPOSCloseCash.Model.CloseCash.exte
this.set('safeBoxesList', new Backbone.Collection());
+ this.setPaymentList(false);
+
initModelsCallback();
const indexStepSafeBoxList = this.stepIndex(
--
2.20.1
I45390_20Q3_Fix2.patch [^] (7,190 bytes) 2020-11-15 03:04 [Show Content] [Hide Content]From 8f983358dd01cc595ccbb235f0d0909927ec66c6 Mon Sep 17 00:00:00 2001
From: Prakash M <prakash@qualiantech.com>
Date: Sat, 14 Nov 2020 21:49:55 +0530
Subject: [PATCH] Fixed BUG-45390: Fixed try errors in countsafebox * Due to
OB.Dal.Find in setPaymentList method it is executed asynchronously * Because
of this remaining part of code in initializationProcess executed before this
* Fixed by adding call back
---
.../js/closecash/model/cashup/cashup-model.js | 23 ++---
.../js/closecash/model/closecash-model.js | 3 +-
.../model/countsafebox/countsafebox-model.js | 88 ++++++++++---------
3 files changed, 60 insertions(+), 54 deletions(-)
diff --git a/web/org.openbravo.retail.posterminal/js/closecash/model/cashup/cashup-model.js b/web/org.openbravo.retail.posterminal/js/closecash/model/cashup/cashup-model.js
index 5516d6824..7fd04e91e 100644
--- a/web/org.openbravo.retail.posterminal/js/closecash/model/cashup/cashup-model.js
+++ b/web/org.openbravo.retail.posterminal/js/closecash/model/cashup/cashup-model.js
@@ -75,7 +75,8 @@ OB.OBPOSCashUp.Model.CashUp = OB.OBPOSCloseCash.Model.CloseCash.extend({
let closeCashReport,
synch1 = false,
synch2 = false,
- synch3 = false;
+ synch3 = false,
+ me = this;
const finish = () => {
if (synch1 && synch2 && synch3) {
@@ -98,16 +99,16 @@ OB.OBPOSCashUp.Model.CashUp = OB.OBPOSCloseCash.Model.CloseCash.extend({
this.set('orderlist', new OB.Collection.OrderList());
- this.setPaymentList(true);
-
- this.stepsDefinition[
- this.stepIndex('OB.CloseCash.CashPayments')
- ].loaded = true;
- this.stepsDefinition[
- this.stepIndex('OB.CloseCash.PaymentMethods')
- ].loaded = true;
- synch1 = true;
- finish();
+ this.setPaymentList(true, function() {
+ me.stepsDefinition[
+ me.stepIndex('OB.CloseCash.CashPayments')
+ ].loaded = true;
+ me.stepsDefinition[
+ me.stepIndex('OB.CloseCash.PaymentMethods')
+ ].loaded = true;
+ synch1 = true;
+ finish();
+ });
OB.Dal.find(
OB.Model.CashUp,
diff --git a/web/org.openbravo.retail.posterminal/js/closecash/model/closecash-model.js b/web/org.openbravo.retail.posterminal/js/closecash/model/closecash-model.js
index f5599d62c..980eff72e 100644
--- a/web/org.openbravo.retail.posterminal/js/closecash/model/closecash-model.js
+++ b/web/org.openbravo.retail.posterminal/js/closecash/model/closecash-model.js
@@ -436,7 +436,7 @@ OB.OBPOSCloseCash.Model.CloseCash = OB.Model.TerminalWindowModel.extend({
processAndFinishCloseCash: function() {
this.processAndFinish();
},
- setPaymentList: function(validateSteps) {
+ setPaymentList: function(validateSteps, callback) {
const terminalSlave =
!OB.POS.modelterminal.get('terminal').ismaster &&
OB.POS.modelterminal.get('terminal').isslave;
@@ -622,6 +622,7 @@ OB.OBPOSCloseCash.Model.CloseCash = OB.Model.TerminalWindowModel.extend({
}
}
});
+ callback();
}
);
}
diff --git a/web/org.openbravo.retail.posterminal/js/closecash/model/countsafebox/countsafebox-model.js b/web/org.openbravo.retail.posterminal/js/closecash/model/countsafebox/countsafebox-model.js
index d30dda181..0632170f3 100644
--- a/web/org.openbravo.retail.posterminal/js/closecash/model/countsafebox/countsafebox-model.js
+++ b/web/org.openbravo.retail.posterminal/js/closecash/model/countsafebox/countsafebox-model.js
@@ -59,6 +59,7 @@ OB.OBPOSCountSafeBox.Model.CountSafeBox = OB.OBPOSCloseCash.Model.CloseCash.exte
});
},
initializationProcess: function(initModelsCallback) {
+ let me = this;
this.stepsDefinition[
this.stepIndex('OB.CountSafeBox.StepSafeBoxList')
].loaded = false;
@@ -71,52 +72,55 @@ OB.OBPOSCountSafeBox.Model.CountSafeBox = OB.OBPOSCloseCash.Model.CloseCash.exte
this.set('safeBoxesList', new Backbone.Collection());
- this.setPaymentList(false);
+ this.setPaymentList(false, function() {
+ initModelsCallback();
- initModelsCallback();
-
- const indexStepSafeBoxList = this.stepIndex(
- 'OB.CountSafeBox.StepSafeBoxList'
- );
+ const indexStepSafeBoxList = me.stepIndex(
+ 'OB.CountSafeBox.StepSafeBoxList'
+ );
- if (
- OB.MobileApp.model.hasPermission('OBPOS_approval.manager.safebox', true)
- ) {
- this.stepsDefinition[indexStepSafeBoxList].active = true;
- this.stepsDefinition[indexStepSafeBoxList].loaded = true;
- this.stepsDefinition[
- this.stepIndex('OB.CloseCash.CashPayments')
- ].loaded = true;
- this.stepsDefinition[
- this.stepIndex('OB.CloseCash.PaymentMethods')
- ].loaded = true;
- } else {
- this.stepsDefinition[indexStepSafeBoxList].loaded = true;
- }
+ if (
+ OB.MobileApp.model.hasPermission(
+ 'OBPOS_approval.manager.safebox',
+ true
+ )
+ ) {
+ me.stepsDefinition[indexStepSafeBoxList].active = true;
+ me.stepsDefinition[indexStepSafeBoxList].loaded = true;
+ me.stepsDefinition[
+ me.stepIndex('OB.CloseCash.CashPayments')
+ ].loaded = true;
+ me.stepsDefinition[
+ me.stepIndex('OB.CloseCash.PaymentMethods')
+ ].loaded = true;
+ } else {
+ me.stepsDefinition[indexStepSafeBoxList].loaded = true;
+ }
- this.loadSafeBoxesInformation(
- safeBoxes => {
- if (
- OB.MobileApp.model.hasPermission(
- 'OBPOS_approval.manager.safebox',
- true
- ) &&
- safeBoxes.length > 0
- ) {
- // Insert all safe boxes in safeBoxList
- this.get('safeBoxesList').reset(safeBoxes);
- this.finishLoad();
- } else if (safeBoxes.length === 1) {
- // At this point, only 1 safeBox should we received
- const safeBox = safeBoxes[0];
- this.prepareCashUpReport(safeBox, () => this.finishLoad());
+ me.loadSafeBoxesInformation(
+ safeBoxes => {
+ if (
+ OB.MobileApp.model.hasPermission(
+ 'OBPOS_approval.manager.safebox',
+ true
+ ) &&
+ safeBoxes.length > 0
+ ) {
+ // Insert all safe boxes in safeBoxList
+ me.get('safeBoxesList').reset(safeBoxes);
+ me.finishLoad();
+ } else if (safeBoxes.length === 1) {
+ // At this point, only 1 safeBox should we received
+ const safeBox = safeBoxes[0];
+ me.prepareCashUpReport(safeBox, () => me.finishLoad());
+ }
+ },
+ () => {
+ initModelsCallback();
+ me.finishLoad();
}
- },
- () => {
- initModelsCallback();
- this.finishLoad();
- }
- );
+ );
+ });
},
prepareCashUpReport: function(safeBox, callback) {
let safeBoxPayments = new Backbone.Collection();
--
2.20.1
|