Projects:Modify Ticket/Technical Documentation
Contents |
Introduction
To achieve this, the Web POS module will be modified.
There are two main changes to be done. How to save the ticket in the backend and how to manipulate it in Web POS.
Web POS Changes
In the POS itself the ability to change a loaded ticket needs to be added as well as the information about that operation.
Model
In the Order module a new flag is added and set to true when the ticket is modified: isModified
Files
web/org.openbravo.retail.posterminal/js/model/order.js
This is the class responsible for manipulating tickets. Here it is added all the logic related to the model change and also a new method to turn the ticket editable.
turnEditable: function () { if (this.get('payment') > 0 || this.get('isPartiallyDelivered') || this.get('isFullyDelivered')) { return; } this.set('isModified', true); this.set('isEditable', true); if (this.get('isLayaway')) { this.set('isLayaway', false); this.set('orderType', 2); } this.unset('skipApplyPromotions'); }
Backend Changes
In the backend the only important change is in the process that saves tickets sent from the POS. From now on not all the tickets are new and need to be saved, they can be existing tickets that need to be updated.
Classes
src/org/openbravo/retail/posterminal/OrderLoader.java
This class contains almost all the logic related to saving tickets that arrive from the POS.
This class needs to be changed to update the Order if it already exists. It needs to update the header and then create, update or delete all the children entities (ex: order lines, payment plan...)
Also, for backward compatibility, all the hooks are duplicated. The old ones continue to be called only for new orders and a new one is created for updated orders.
src/org/openbravo/retail/posterminal/OrderLoaderModifiedHook.java
New hook similar to OrderLoaderHook but for modified orders.
src/org/openbravo/retail/posterminal/OrderLoaderModifiedPreProcessHook.java
New hook similar to OrderLoaderPreProcessHook but for modified orders.