# HG changeset patch
# User Mario Castello <mario.castello@peoplewalking.com>
# Date 1489080332 21600
#      jue mar 09 11:25:32 2017 -0600
# Node ID 86c8a48a69befc9c19ae5738b5917c3377e40876
# Parent  78837f4ae39bd44cab57072b31706343771f5fc7
Related to issue 35364: Added new modulescript to fix data

diff --git a/build/classes/org/openbravo/retail/posterminal/modulescript/FixDataIssue35364.class b/build/classes/org/openbravo/retail/posterminal/modulescript/FixDataIssue35364.class
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..17c94d82358d43420c76b00cd8caf1797b105998
GIT binary patch
literal 2564
zc$}qH>2e!I5dKC!R+i=XK1qlY5-gwV*z!T-*hsbvBJzPxOaL>M25FPk?y@^_%pabB
z_uwxss%(O*cmSS&r=jQ_$%%ZHfghTl?d|#c>tlNL=ik5o0bl}!5PA{UFdISu@gSc0
zaxRGZAU+Nv5kd!&zG|Tni%2zM37=^A)K{l9d=|uW4Ve&Hu^d7(Ry3^ouj2l)7Q*LP
zZ=l_VhE0Y#)6U0UGW2F_H?MPtXA44CIz40O^TLfYbgrj16Y0#}T4Le(-ty|=RwlKV
zUSw#?yyOR5H@TJ9H>7J=c`|NVuq{t=OKx+sBpB*v4a<;o3^mb#ZHC$fJ4f2)jA4nD
zQgL6nn|$9CKA4^5<~DZ?|GA>9l?B6NNGNi)BdmRwAK1DpBsWamu{|l=qG54UFWR}1
zDZH#}I8t9S4i~xPY0oQ(iOGqn81d4?p~#jbf!286n|{C-$tO#OnNtA=vJS)01*bVe
z+~=OqDL_kPrD0oZu6<xsjyS~gZW)vC^)**G+!eVE$)zX?OOg#E=bcq<Q-@jM_&9#r
z$T0hAnL8?SDkj7Gc_EioSQ{#=lnQ{%Ge*&n<nC#7-~z{US-9aWIjk*m!(!-)zPMaP
zRVeP}$w&JYuPGAA5S-1LmC}Yb?2?-mONL*wu1nb;^%26jj|fBeHCbm^FFBNA5wZ8F
zu6qvu!OvPz$by~Aa<5QwBA$>DUbIV=l=dqjoXE4tSmbp<xZ=Fp@FG^pG~<ylwy=F$
zWNKPh5+Pqzg?vu^7MWq?R-n?B-1IorqzbZ1Sp|4Img+3^f628jL7u6r;@`m+VeH~d
z4KKp@3SVpZCX79NONG6n55wTtXPEkLO~nuyn^;OD$7jY9)5)dS^x{PFNpd_ko>-Wg
zUYeeXO(yA9-GIG%rrs8=r|8^A)?acA^Z#=Kgz+IF8blc1As<E`-ec&$Wt=p`xI<<{
zV<dXTZMk8RbkZHZJTH8li&yvN@e-7F8JeLZdf6da4BQ%yAc)na0mU$OeQ?)}w7%=#
z(oCz2+%47E>I;x&Xe@9mXNr{T+C-(N+UI7$wO{-5PfeiuXgZztH})00ZW??S`{>^p
z`yRWm`4}=ZQ0mV1!_~YNOzwH{fongbctGFWUi!KRsQIY<XxE3kxCa{aO51`u+S8Dv
z^#N&gl8j{C;0f4~GI>aAy;64I16spn13bcGlFV=M%HhArx|U?>6oK6n)MSR*YL8L3
zGt^dJ7Ft;ZeKB~9hUMX*V}#zIF@TkkHwZKA{EUXoAZhO$DK~M<p$RpL#5lPIu@4ge
zX5!yPyzi0oNAz}psKsa(M?al-jCrE9h^QhQBeFsIf74IT)Us%!-yl(qLBkM+34NX{
zMlh;8rYeEy^wSXdQNvgrMfHT-m!nLgK^gX(qItKig`J{xx3(qN8v5x3Z6|2|<wDj*
ztFqQp0dF8Wu?k+AtOF#QPSHVG>&#H}UGGwVhxh@L6u}gMOe?Ui@&VFLkqi?1X@aE-
hi<!5@c&Ho#p>}lqhVEa{bEL}kj#wA1A1Oai{{gS4wyFRC

diff --git a/src-util/modulescript/src/org/openbravo/retail/posterminal/modulescript/FixDataIssue35364.java b/src-util/modulescript/src/org/openbravo/retail/posterminal/modulescript/FixDataIssue35364.java
new file mode 100644
--- /dev/null
+++ b/src-util/modulescript/src/org/openbravo/retail/posterminal/modulescript/FixDataIssue35364.java
@@ -0,0 +1,56 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2016-2017 Openbravo S.L.U.
+ * Licensed under the Openbravo Commercial License version 1.0
+ * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
+ * or in the legal folder of this module distribution.
+ ************************************************************************************
+ */
+
+package org.openbravo.retail.posterminal.modulescript;
+
+import java.sql.PreparedStatement;
+
+import org.apache.log4j.Logger;
+import org.openbravo.database.ConnectionProvider;
+import org.openbravo.modulescript.ModuleScript;
+import org.openbravo.modulescript.ModuleScriptExecutionLimits;
+import org.openbravo.modulescript.OpenbravoVersion;
+
+public class FixDataIssue35364 extends ModuleScript {
+
+  private static final Logger log4j = Logger.getLogger(FixDataIssue35364.class);
+  private static final String RETAIL_PACK_MODULE_ID = "03FAB282A7BF47D3B1B242AC67F7845B";
+
+  @Override
+  public void execute() {
+    try {
+      final StringBuilder sql = new StringBuilder();
+      sql.append("update obpos_paymentmethodcashup set amounttokeep = 0 where amounttokeep is null; ");
+      sql.append("update obpos_paymentmethodcashup set startingcash = 0 where startingcash is null; ");
+      sql.append("update obpos_paymentmethodcashup set totalsales = 0 where totalsales is null; ");
+      sql.append("update obpos_paymentmethodcashup set totalreturns = 0 where totalreturns is null; ");
+
+      ConnectionProvider cp = getConnectionProvider();
+      PreparedStatement ps = cp.getPreparedStatement(sql.toString());
+      ps.executeUpdate();
+    } catch (Exception e) {
+      handleError(e);
+    }
+  }
+
+  @Override
+  protected ModuleScriptExecutionLimits getModuleScriptExecutionLimits() {
+    // The module script needs to be executed only when updating from a version
+    // lower than 3.0RR17Q2 (Retail pack)(1.8.2700)
+    return new ModuleScriptExecutionLimits(RETAIL_PACK_MODULE_ID, null, new OpenbravoVersion(1, 8,
+        2700));
+  }
+
+  public static void main(String[] args) {
+
+    // This method is provided for testing purposes.
+    FixDataIssue35364 t = new FixDataIssue35364();
+    t.execute();
+  }
+}
\ No newline at end of file
