# HG changeset patch
# User Rafa Alonso <ral@openbravo.com>
# Date 1438338717 -7200
#      Fri Jul 31 12:31:57 2015 +0200
# Node ID 8bc4e8c08ab7f01ff5df93950a605d42fa5969b9
# Parent  ecbbe2ac59b98a094810c98a735580932449909e
Fix the incoming 'creationDate' in case it is not correct

diff -r ecbbe2ac59b9 -r 8bc4e8c08ab7 web/org.openbravo.retail.posterminal/js/data/dataordersave.js
--- a/web/org.openbravo.retail.posterminal/js/data/dataordersave.js	Fri Jul 17 14:55:29 2015 +0200
+++ b/web/org.openbravo.retail.posterminal/js/data/dataordersave.js	Fri Jul 31 12:31:57 2015 +0200
@@ -69,14 +69,19 @@
           docno = this.receipt.get('documentNo'),
           isLayaway = (this.receipt.get('orderType') === 2 || this.receipt.get('isLayaway')),
           json = this.receipt.serializeToJSON(),
-          receiptId = this.receipt.get('id'),
-          creationDate = this.receipt.get('creationDate') || new Date();
+          receiptId = this.receipt.get('id');
 
       if (this.receipt.get('isbeingprocessed') === 'Y') {
         //The receipt has already been sent, it should not be sent again
         return;
       }
 
+      var creationDate = this.receipt.get('creationDate');
+      if (!creationDate || !creationDate.getTimezoneOffset) {
+        OB.info("Ticket closed: 'creationDate' set to '" + new Date() + "' (was '" + creationDate + "')");
+        creationDate = new Date();
+      }
+
       this.receipt.set('hasbeenpaid', 'Y');
 
       OB.trace('Executing pre order save hook.');
