Openbravo Issue Tracking System - Retail Modules
View Issue Details
0034968Retail ModulesWeb POSpublic2017-01-16 16:452017-02-10 13:03
aaroncalero 
mario_castello 
highmajoralways
closedfixed 
5
 
RR17Q2 
marvintm
No
0034968: Using pay open tickets option might end up with non synchronized receipts
If there is any asynchronous implementation of the OBPOS_PreOrderSave hook, paying two tickets with the Pay Open Ticket option will result in one of the tickets synchronized to the backend, and the other ticket pending in web pos, although apparently removed (it is visible after refreshing the pos).
Verify that the Web POS Synchronized Mode is not active.
Login in web pos
Using the browser console, add the following hook:

OB.UTIL.HookManager.registerHook('OBPOS_PreOrderSave', function (args, callback) {
  setTimeout(function(){
    OB.UTIL.HookManager.callbackExecutor(args, callback);
  }, 0)
});

Create a new ticket and add a product. Do not pay it.
Create a second ticket and add a product.
Open the menu and click on the pay open tickets option.
Search and select both of the tickets created.
Click on Done.
Pay the multiorder.
Go to the backend and verify that only one of the receipts is there.
Refresh the pos and verify that the missing ticket is still there.
The code which closes all the receipts that are part of a multiorder is the following:

https://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/file/19f6ed6b5883/web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js#l586 [^]

This code triggers the close event and immediately calls another function, which eventually adds an empty new ticket.
Adding that extra asynchrony with the hook causes the addNewOrder function to modify one of the current receipts, changing the hasbeenpaid value to N and preventing the synchronization.
No tags attached.
Issue History
2017-01-16 16:45aaroncaleroNew Issue
2017-01-16 16:45aaroncaleroAssigned To => Retail
2017-01-16 16:45aaroncaleroResolution time => 1485730800
2017-01-16 16:45aaroncaleroTriggers an Emergency Pack => No
2017-01-17 15:10mario_castelloAssigned ToRetail => mario_castello
2017-01-17 15:11mario_castelloStatusnew => acknowledged
2017-01-17 15:11mario_castelloStatusacknowledged => scheduled
2017-01-26 15:38hgbotCheckin
2017-01-26 15:38hgbotNote Added: 0093843
2017-01-26 15:38hgbotStatusscheduled => resolved
2017-01-26 15:38hgbotResolutionopen => fixed
2017-01-26 15:38hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/7f1ed45fd2517cfda1a1fe2d7534f724e4b183be [^]
2017-01-26 15:39hgbotCheckin
2017-01-26 15:39hgbotNote Added: 0093844
2017-01-26 18:08marvintmNote Added: 0093851
2017-01-26 18:08marvintmStatusresolved => new
2017-01-26 18:08marvintmResolutionfixed => open
2017-01-26 18:14hgbotCheckin
2017-01-26 18:14hgbotNote Added: 0093852
2017-01-26 18:17mario_castelloStatusnew => acknowledged
2017-01-26 18:17mario_castelloStatusacknowledged => scheduled
2017-01-26 18:18mario_castelloNote Added: 0093853
2017-02-04 18:00hgbotCheckin
2017-02-04 18:00hgbotNote Added: 0094056
2017-02-04 18:00hgbotStatusscheduled => resolved
2017-02-04 18:00hgbotResolutionopen => fixed
2017-02-04 18:00hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/7f1ed45fd2517cfda1a1fe2d7534f724e4b183be [^] => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/16f53f09075de0565263f7311a7f7de75aa0a26a [^]
2017-02-06 10:13marvintmNote Added: 0094064
2017-02-06 10:13marvintmStatusresolved => new
2017-02-06 10:13marvintmResolutionfixed => open
2017-02-07 23:07hgbotCheckin
2017-02-07 23:07hgbotNote Added: 0094137
2017-02-07 23:07hgbotStatusnew => resolved
2017-02-07 23:07hgbotResolutionopen => fixed
2017-02-07 23:07hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/16f53f09075de0565263f7311a7f7de75aa0a26a [^] => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/3a29833e5de41e3461855ef23d67b6f444fa8fdb [^]
2017-02-08 09:18marvintmReview Assigned To => marvintm
2017-02-08 09:18marvintmStatusresolved => closed
2017-02-08 09:18marvintmFixed in Version => RR17Q2
2017-02-08 17:24marvintmNote Added: 0094154
2017-02-08 17:24marvintmStatusclosed => new
2017-02-08 17:24marvintmResolutionfixed => open
2017-02-08 17:24marvintmFixed in VersionRR17Q2 =>
2017-02-08 17:34mario_castelloStatusnew => acknowledged
2017-02-08 17:34mario_castelloStatusacknowledged => scheduled
2017-02-09 14:36hgbotCheckin
2017-02-09 14:36hgbotNote Added: 0094179
2017-02-09 14:37hgbotCheckin
2017-02-09 14:37hgbotNote Added: 0094180
2017-02-09 14:37hgbotStatusscheduled => resolved
2017-02-09 14:37hgbotResolutionopen => fixed
2017-02-09 14:37hgbotFixed in SCM revisionhttp://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/3a29833e5de41e3461855ef23d67b6f444fa8fdb [^] => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/8f3c0f3dfbde2d6c3a04d402456966e974e92bac [^]
2017-02-10 13:03marvintmStatusresolved => closed
2017-02-10 13:03marvintmFixed in Version => RR17Q2

Notes
(0093843)
hgbot   
2017-01-26 15:38   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 7f1ed45fd2517cfda1a1fe2d7534f724e4b183be
Author: Mario Castello <mario.castello <at> peoplewalking.com>
Date: Thu Jan 26 08:10:43 2017 -0600
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/7f1ed45fd2517cfda1a1fe2d7534f724e4b183be [^]

Fixed issue 0034968: Using pay open tickets option might end up with non synchronized receipts

- Moved the code that set all properties of the receipt inside the hook OBPOS_PreOrderSave

---
M web/org.openbravo.retail.posterminal/js/data/dataordersave.js
---
(0093844)
hgbot   
2017-01-26 15:39   
Repository: tools/automation/pi-mobile
Changeset: a7e79c5ed758c350d1a829cd82a1d01b7d82f39f
Author: Mario Castello <mario.castello <at> peoplewalking.com>
Date: Wed Jan 18 08:45:29 2017 -0600
URL: http://code.openbravo.com/tools/automation/pi-mobile/rev/a7e79c5ed758c350d1a829cd82a1d01b7d82f39f [^]

Related to issue 34968: Added automated test I34968_ReceiptPayOpenTicket

---
A src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/receipts/I34968_ReceiptPayOpenTicket.java
---
(0093851)
marvintm   
2017-01-26 18:08   
The solution is not correct, because it changes the API of the hook (now the hook wouldn't receive the properties which have been moved to the hook callback).

A different solution based on callbacks of the function which iterates all receipts of the main multiorder should be implemented instead.
(0093852)
hgbot   
2017-01-26 18:14   
Repository: tools/automation/pi-mobile
Changeset: 8918f5d32ec7476f7bb28d18b37735a3e69fda35
Author: Mario Castello <mario.castello <at> peoplewalking.com>
Date: Thu Jan 26 11:13:42 2017 -0600
URL: http://code.openbravo.com/tools/automation/pi-mobile/rev/8918f5d32ec7476f7bb28d18b37735a3e69fda35 [^]

Verifies issue 34968: Disable test and wait for the correct solution of issue

---
M src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/receipts/I34968_ReceiptPayOpenTicket.java
---
(0093853)
mario_castello   
2017-01-26 18:18   
Remove the previous changes:

https://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/3816e3697eca [^]
(0094056)
hgbot   
2017-02-04 18:00   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 16f53f09075de0565263f7311a7f7de75aa0a26a
Author: Mario Castello <mario.castello <at> peoplewalking.com>
Date: Thu Feb 02 09:51:53 2017 -0600
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/16f53f09075de0565263f7311a7f7de75aa0a26a [^]

Fixed issue 0034968: Using pay open tickets option might end up with non synchronized receipts

- Added syncronization to save multiorder process
- Execute the readyToSendFunction only one time to prevent create more than one empty receipt

---
M web/org.openbravo.retail.posterminal/js/data/dataordersave.js
M web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
---
(0094064)
marvintm   
2017-02-06 10:13   
The solution now seems to work correctly, but still, executing the call to readyToSendFunction in the first element of the collection instead of the last is a bit weird, and may cause problems in the future:

 me.get('multiOrders').trigger('closed', receiptMulti, function () {
                    if (index === 0) {
                      readyToSendFunction();
                    }
                  });

Instead of doing this, it would be better if the readyToSendFunction is called at the end of the collection.
(0094137)
hgbot   
2017-02-07 23:07   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 3a29833e5de41e3461855ef23d67b6f444fa8fdb
Author: Mario Castello <mario.castello <at> peoplewalking.com>
Date: Mon Feb 06 09:08:24 2017 -0600
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/3a29833e5de41e3461855ef23d67b6f444fa8fdb [^]

Fixed issue 0034968: Using pay open tickets option might end up with non synchronized receipts

- Changes the validation in function readyToSendFunction
- Called readyToSendFunction when all pending ticket have been processed

---
M web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
---
(0094154)
marvintm   
2017-02-08 17:24   
A small change is still required. Currently the recursive call to setMultiOrderCashUpReport is being done out of the callback of the trigger('closed') call, and this means that every 'closed' event will be generated without waiting for the previous one to finish. This should be changed.

Another thing which should also be changed is that the callback of the multiOrdersFunction function in dataordersave.js file should be called inside the callback of the OB.Dal.get call.
(0094179)
hgbot   
2017-02-09 14:36   
Repository: tools/automation/pi-mobile
Changeset: bf88c67eae3758f13c357cb3e2bf7dde26c36448
Author: Mario Castello <mario.castello <at> peoplewalking.com>
Date: Wed Feb 08 10:45:55 2017 -0600
URL: http://code.openbravo.com/tools/automation/pi-mobile/rev/bf88c67eae3758f13c357cb3e2bf7dde26c36448 [^]

Related to issue 34968: Activate test I34968_ReceiptPayOpenTicket

---
M src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/receipts/I34968_ReceiptPayOpenTicket.java
---
(0094180)
hgbot   
2017-02-09 14:37   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 8f3c0f3dfbde2d6c3a04d402456966e974e92bac
Author: Mario Castello <mario.castello <at> peoplewalking.com>
Date: Wed Feb 08 10:47:32 2017 -0600
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/8f3c0f3dfbde2d6c3a04d402456966e974e92bac [^]

Fixed issue 34968: Using pay open tickets option might end up with non synchronized receipts

- Execute one callback in case that the hook PreOrderSave failed
- Moved the callback from the OB.Dal.Save to OB.Dal.Get
- Moved the call function setMultiOrderCashUpReport to inside the callback of trigger closed

---
M web/org.openbravo.retail.posterminal/js/data/dataordersave.js
M web/org.openbravo.retail.posterminal/js/pointofsale/model/pointofsale-model.js
---