# HG changeset patch
# User Rafa Alonso <ral@openbravo.com>
# Date 1438628451 -7200
#      Mon Aug 03 21:00:51 2015 +0200
# Node ID 80a83ac322e88a300535e5ab9c90fe2eca0db210
# Parent  71af5c2bd0119390d1c5a6007f5f90a792ee1e16
Related to issue 30472: The receipt information is frozen when the receipt is closed

diff -r 71af5c2bd011 -r 80a83ac322e8 web/org.openbravo.retail.posterminal/js/data/dataordersave.js
--- a/web/org.openbravo.retail.posterminal/js/data/dataordersave.js	Tue Aug 04 12:10:47 2015 +0200
+++ b/web/org.openbravo.retail.posterminal/js/data/dataordersave.js	Mon Aug 03 21:00:51 2015 +0200
@@ -93,7 +93,6 @@
           return true;
         }
         var receipt = args.context.receipt,
-            auxReceipt = new OB.Model.Order(),
             currentDocNo = receipt.get('documentNo') || docno;
 
         OB.trace('Execution of pre order save hook OK.');
@@ -128,14 +127,20 @@
         receipt.set('json', JSON.stringify(receipt.serializeToJSON()));
 
         OB.trace('Calculationg cashup information.');
+        
+        var auxReceipt = new OB.Model.Order();
+        auxReceipt.clearWith(receipt);
+        var auxReceipt2 = new OB.Model.Order();
+        auxReceipt2.clearWith(receipt);
+        var auxReceipt3 = new OB.Model.Order();
+        auxReceipt3.clearWith(receipt);
 
-        auxReceipt.clearWith(receipt);
         OB.Dal.transaction(function (tx) {
           OB.UTIL.cashUpReport(auxReceipt, function () {
             OB.UTIL.calculateCurrentCash(null, tx);
-            OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(receipt.get('documentnoSuffix'), receipt.get('quotationnoSuffix'), function () {
+            OB.MobileApp.model.updateDocumentSequenceWhenOrderSaved(auxReceipt2.get('documentnoSuffix'), auxReceipt2.get('quotationnoSuffix'), function () {
               OB.trace('Saving receipt.');
-              OB.Dal.saveInTransaction(tx, receipt);
+              OB.Dal.saveInTransaction(tx, auxReceipt2);
             }, tx);
           }, tx);
         }, null, function () {
@@ -171,7 +176,7 @@
 
             OB.MobileApp.model.runSyncProcess(function () {
               OB.UTIL.HookManager.executeHooks('OBPOS_PostSyncReceipt', {
-                receipt: auxReceipt
+                receipt: auxReceipt3
               }, function (args) {
                 successCallback();
                 if (eventParams && eventParams.callback) {
@@ -180,7 +185,7 @@
               });
             }, function () {
               OB.UTIL.HookManager.executeHooks('OBPOS_PostSyncReceipt', {
-                receipt: auxReceipt
+                receipt: auxReceipt3
               }, function (args) {
                 if (eventParams && eventParams.callback) {
                   eventParams.callback();
