Attached Files | issue31720.diff [^] (46,075 bytes) 2015-12-18 13:50 [Show Content] [Hide Content]diff --git a/src-db/database/sourcedata/AD_MESSAGE.xml b/src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml
@@ -156,6 +156,18 @@
<!--40EFDFEF332947689981F92CEA5241A8--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--40EFDFEF332947689981F92CEA5241A8--></AD_MESSAGE>
+<!--4B0E2EEC39AC445088521D45B291D981--><AD_MESSAGE>
+<!--4B0E2EEC39AC445088521D45B291D981--> <AD_MESSAGE_ID><![CDATA[4B0E2EEC39AC445088521D45B291D981]]></AD_MESSAGE_ID>
+<!--4B0E2EEC39AC445088521D45B291D981--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--4B0E2EEC39AC445088521D45B291D981--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--4B0E2EEC39AC445088521D45B291D981--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--4B0E2EEC39AC445088521D45B291D981--> <VALUE><![CDATA[POSS_LblCloseStore]]></VALUE>
+<!--4B0E2EEC39AC445088521D45B291D981--> <MSGTEXT><![CDATA[Close Store]]></MSGTEXT>
+<!--4B0E2EEC39AC445088521D45B291D981--> <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--4B0E2EEC39AC445088521D45B291D981--> <AD_MODULE_ID><![CDATA[58A5C9704E1E4503B0121D47A8109FC7]]></AD_MODULE_ID>
+<!--4B0E2EEC39AC445088521D45B291D981--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--4B0E2EEC39AC445088521D45B291D981--></AD_MESSAGE>
+
<!--4B4CA343AC714FD4BCC6408CF1CE2C01--><AD_MESSAGE>
<!--4B4CA343AC714FD4BCC6408CF1CE2C01--> <AD_MESSAGE_ID><![CDATA[4B4CA343AC714FD4BCC6408CF1CE2C01]]></AD_MESSAGE_ID>
<!--4B4CA343AC714FD4BCC6408CF1CE2C01--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -492,6 +504,18 @@
<!--C790706540C04C7BB0D7C8582532EA9D--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--C790706540C04C7BB0D7C8582532EA9D--></AD_MESSAGE>
+<!--CB0B51F9DCB6452398734C454764D4D8--><AD_MESSAGE>
+<!--CB0B51F9DCB6452398734C454764D4D8--> <AD_MESSAGE_ID><![CDATA[CB0B51F9DCB6452398734C454764D4D8]]></AD_MESSAGE_ID>
+<!--CB0B51F9DCB6452398734C454764D4D8--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--CB0B51F9DCB6452398734C454764D4D8--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--CB0B51F9DCB6452398734C454764D4D8--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--CB0B51F9DCB6452398734C454764D4D8--> <VALUE><![CDATA[POSS_CloseStoreMsg]]></VALUE>
+<!--CB0B51F9DCB6452398734C454764D4D8--> <MSGTEXT><![CDATA[The Cash Up process was completed successfully. Do you want to close the store?]]></MSGTEXT>
+<!--CB0B51F9DCB6452398734C454764D4D8--> <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--CB0B51F9DCB6452398734C454764D4D8--> <AD_MODULE_ID><![CDATA[58A5C9704E1E4503B0121D47A8109FC7]]></AD_MODULE_ID>
+<!--CB0B51F9DCB6452398734C454764D4D8--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--CB0B51F9DCB6452398734C454764D4D8--></AD_MESSAGE>
+
<!--D08A480EBD384657B08EDC59E498D68B--><AD_MESSAGE>
<!--D08A480EBD384657B08EDC59E498D68B--> <AD_MESSAGE_ID><![CDATA[D08A480EBD384657B08EDC59E498D68B]]></AD_MESSAGE_ID>
<!--D08A480EBD384657B08EDC59E498D68B--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -528,6 +552,18 @@
<!--D2A132885E104B7181A3F523C1B4DBC9--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--D2A132885E104B7181A3F523C1B4DBC9--></AD_MESSAGE>
+<!--DAC5D25281984F038D38EB5F71BE1C93--><AD_MESSAGE>
+<!--DAC5D25281984F038D38EB5F71BE1C93--> <AD_MESSAGE_ID><![CDATA[DAC5D25281984F038D38EB5F71BE1C93]]></AD_MESSAGE_ID>
+<!--DAC5D25281984F038D38EB5F71BE1C93--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--DAC5D25281984F038D38EB5F71BE1C93--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--DAC5D25281984F038D38EB5F71BE1C93--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--DAC5D25281984F038D38EB5F71BE1C93--> <VALUE><![CDATA[POSS_CloseStoreMsgError]]></VALUE>
+<!--DAC5D25281984F038D38EB5F71BE1C93--> <MSGTEXT><![CDATA[There was an error closing the store.]]></MSGTEXT>
+<!--DAC5D25281984F038D38EB5F71BE1C93--> <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--DAC5D25281984F038D38EB5F71BE1C93--> <AD_MODULE_ID><![CDATA[58A5C9704E1E4503B0121D47A8109FC7]]></AD_MODULE_ID>
+<!--DAC5D25281984F038D38EB5F71BE1C93--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--DAC5D25281984F038D38EB5F71BE1C93--></AD_MESSAGE>
+
<!--E168CA407FB4445692A3F29270F74AED--><AD_MESSAGE>
<!--E168CA407FB4445692A3F29270F74AED--> <AD_MESSAGE_ID><![CDATA[E168CA407FB4445692A3F29270F74AED]]></AD_MESSAGE_ID>
<!--E168CA407FB4445692A3F29270F74AED--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -540,6 +576,18 @@
<!--E168CA407FB4445692A3F29270F74AED--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
<!--E168CA407FB4445692A3F29270F74AED--></AD_MESSAGE>
+<!--E3AED2CEB4164FEF8D0DA633E08E466D--><AD_MESSAGE>
+<!--E3AED2CEB4164FEF8D0DA633E08E466D--> <AD_MESSAGE_ID><![CDATA[E3AED2CEB4164FEF8D0DA633E08E466D]]></AD_MESSAGE_ID>
+<!--E3AED2CEB4164FEF8D0DA633E08E466D--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--E3AED2CEB4164FEF8D0DA633E08E466D--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--E3AED2CEB4164FEF8D0DA633E08E466D--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--E3AED2CEB4164FEF8D0DA633E08E466D--> <VALUE><![CDATA[POSS_CloseStoreMsgSuccess]]></VALUE>
+<!--E3AED2CEB4164FEF8D0DA633E08E466D--> <MSGTEXT><![CDATA[Store closed successfuly]]></MSGTEXT>
+<!--E3AED2CEB4164FEF8D0DA633E08E466D--> <MSGTYPE><![CDATA[I]]></MSGTYPE>
+<!--E3AED2CEB4164FEF8D0DA633E08E466D--> <AD_MODULE_ID><![CDATA[58A5C9704E1E4503B0121D47A8109FC7]]></AD_MODULE_ID>
+<!--E3AED2CEB4164FEF8D0DA633E08E466D--> <ISINCLUDEINI18N><![CDATA[N]]></ISINCLUDEINI18N>
+<!--E3AED2CEB4164FEF8D0DA633E08E466D--></AD_MESSAGE>
+
<!--EC46D5B924DA4DB39E1A6927513902A7--><AD_MESSAGE>
<!--EC46D5B924DA4DB39E1A6927513902A7--> <AD_MESSAGE_ID><![CDATA[EC46D5B924DA4DB39E1A6927513902A7]]></AD_MESSAGE_ID>
<!--EC46D5B924DA4DB39E1A6927513902A7--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff --git a/src-db/database/sourcedata/AD_REF_LIST.xml b/src-db/database/sourcedata/AD_REF_LIST.xml
--- a/src-db/database/sourcedata/AD_REF_LIST.xml
+++ b/src-db/database/sourcedata/AD_REF_LIST.xml
@@ -34,6 +34,17 @@
<!--49BFAEEFEB064B459CEF1847D7C397A8--> <AD_MODULE_ID><![CDATA[58A5C9704E1E4503B0121D47A8109FC7]]></AD_MODULE_ID>
<!--49BFAEEFEB064B459CEF1847D7C397A8--></AD_REF_LIST>
+<!--51F5D7A49C9E492994966192BF5372B1--><AD_REF_LIST>
+<!--51F5D7A49C9E492994966192BF5372B1--> <AD_REF_LIST_ID><![CDATA[51F5D7A49C9E492994966192BF5372B1]]></AD_REF_LIST_ID>
+<!--51F5D7A49C9E492994966192BF5372B1--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--51F5D7A49C9E492994966192BF5372B1--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--51F5D7A49C9E492994966192BF5372B1--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--51F5D7A49C9E492994966192BF5372B1--> <VALUE><![CDATA[POSS_CloseStore]]></VALUE>
+<!--51F5D7A49C9E492994966192BF5372B1--> <NAME><![CDATA[Enable Close Store process in Web POS]]></NAME>
+<!--51F5D7A49C9E492994966192BF5372B1--> <AD_REFERENCE_ID><![CDATA[A26BA480E2014707B47257024C3CBFF7]]></AD_REFERENCE_ID>
+<!--51F5D7A49C9E492994966192BF5372B1--> <AD_MODULE_ID><![CDATA[58A5C9704E1E4503B0121D47A8109FC7]]></AD_MODULE_ID>
+<!--51F5D7A49C9E492994966192BF5372B1--></AD_REF_LIST>
+
<!--56D7B998878E4DBC92940FC785F067A9--><AD_REF_LIST>
<!--56D7B998878E4DBC92940FC785F067A9--> <AD_REF_LIST_ID><![CDATA[56D7B998878E4DBC92940FC785F067A9]]></AD_REF_LIST_ID>
<!--56D7B998878E4DBC92940FC785F067A9--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -45,6 +56,19 @@
<!--56D7B998878E4DBC92940FC785F067A9--> <AD_MODULE_ID><![CDATA[58A5C9704E1E4503B0121D47A8109FC7]]></AD_MODULE_ID>
<!--56D7B998878E4DBC92940FC785F067A9--></AD_REF_LIST>
+<!--587B0851D19E4C4BA9E42A9EA6EB9417--><AD_REF_LIST>
+<!--587B0851D19E4C4BA9E42A9EA6EB9417--> <AD_REF_LIST_ID><![CDATA[587B0851D19E4C4BA9E42A9EA6EB9417]]></AD_REF_LIST_ID>
+<!--587B0851D19E4C4BA9E42A9EA6EB9417--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--587B0851D19E4C4BA9E42A9EA6EB9417--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--587B0851D19E4C4BA9E42A9EA6EB9417--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--587B0851D19E4C4BA9E42A9EA6EB9417--> <VALUE><![CDATA[POSS_OpenSessionPOS]]></VALUE>
+<!--587B0851D19E4C4BA9E42A9EA6EB9417--> <NAME><![CDATA[POSS_OpenSessionPOS]]></NAME>
+<!--587B0851D19E4C4BA9E42A9EA6EB9417--> <DESCRIPTION><![CDATA[POSS_OpenSessionPOS]]></DESCRIPTION>
+<!--587B0851D19E4C4BA9E42A9EA6EB9417--> <AD_REFERENCE_ID><![CDATA[11F86B630ECB4A57B28927193F8AB99D]]></AD_REFERENCE_ID>
+<!--587B0851D19E4C4BA9E42A9EA6EB9417--> <AD_MODULE_ID><![CDATA[58A5C9704E1E4503B0121D47A8109FC7]]></AD_MODULE_ID>
+<!--587B0851D19E4C4BA9E42A9EA6EB9417--> <SEQNO><![CDATA[110]]></SEQNO>
+<!--587B0851D19E4C4BA9E42A9EA6EB9417--></AD_REF_LIST>
+
<!--683FB16C11A840A28601D8D31A646227--><AD_REF_LIST>
<!--683FB16C11A840A28601D8D31A646227--> <AD_REF_LIST_ID><![CDATA[683FB16C11A840A28601D8D31A646227]]></AD_REF_LIST_ID>
<!--683FB16C11A840A28601D8D31A646227--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -90,6 +114,19 @@
<!--905031EF744248A0B08350B23AC488D8--> <AD_MODULE_ID><![CDATA[58A5C9704E1E4503B0121D47A8109FC7]]></AD_MODULE_ID>
<!--905031EF744248A0B08350B23AC488D8--></AD_REF_LIST>
+<!--95CBEA09076847C29F3C0E3DF45BD061--><AD_REF_LIST>
+<!--95CBEA09076847C29F3C0E3DF45BD061--> <AD_REF_LIST_ID><![CDATA[95CBEA09076847C29F3C0E3DF45BD061]]></AD_REF_LIST_ID>
+<!--95CBEA09076847C29F3C0E3DF45BD061--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--95CBEA09076847C29F3C0E3DF45BD061--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--95CBEA09076847C29F3C0E3DF45BD061--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--95CBEA09076847C29F3C0E3DF45BD061--> <VALUE><![CDATA[POSS_WebPOSCloseStore]]></VALUE>
+<!--95CBEA09076847C29F3C0E3DF45BD061--> <NAME><![CDATA[POSS_WebPOSCloseStore]]></NAME>
+<!--95CBEA09076847C29F3C0E3DF45BD061--> <DESCRIPTION><![CDATA[POSS_WebPOSCloseStore]]></DESCRIPTION>
+<!--95CBEA09076847C29F3C0E3DF45BD061--> <AD_REFERENCE_ID><![CDATA[11F86B630ECB4A57B28927193F8AB99D]]></AD_REFERENCE_ID>
+<!--95CBEA09076847C29F3C0E3DF45BD061--> <AD_MODULE_ID><![CDATA[58A5C9704E1E4503B0121D47A8109FC7]]></AD_MODULE_ID>
+<!--95CBEA09076847C29F3C0E3DF45BD061--> <SEQNO><![CDATA[120]]></SEQNO>
+<!--95CBEA09076847C29F3C0E3DF45BD061--></AD_REF_LIST>
+
<!--9D590378E9EF405C8376F2C8BCE27081--><AD_REF_LIST>
<!--9D590378E9EF405C8376F2C8BCE27081--> <AD_REF_LIST_ID><![CDATA[9D590378E9EF405C8376F2C8BCE27081]]></AD_REF_LIST_ID>
<!--9D590378E9EF405C8376F2C8BCE27081--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -169,4 +206,17 @@
<!--EACA5E8434614D589B4FDFBC72B46FDE--> <SEQNO><![CDATA[20]]></SEQNO>
<!--EACA5E8434614D589B4FDFBC72B46FDE--></AD_REF_LIST>
+<!--EE47114FD15B4B9980B67D38895A5AF1--><AD_REF_LIST>
+<!--EE47114FD15B4B9980B67D38895A5AF1--> <AD_REF_LIST_ID><![CDATA[EE47114FD15B4B9980B67D38895A5AF1]]></AD_REF_LIST_ID>
+<!--EE47114FD15B4B9980B67D38895A5AF1--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--EE47114FD15B4B9980B67D38895A5AF1--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--EE47114FD15B4B9980B67D38895A5AF1--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--EE47114FD15B4B9980B67D38895A5AF1--> <VALUE><![CDATA[POSS_SetBusinessDate]]></VALUE>
+<!--EE47114FD15B4B9980B67D38895A5AF1--> <NAME><![CDATA[POSS_SetBusinessDate]]></NAME>
+<!--EE47114FD15B4B9980B67D38895A5AF1--> <DESCRIPTION><![CDATA[POSS_SetBusinessDate]]></DESCRIPTION>
+<!--EE47114FD15B4B9980B67D38895A5AF1--> <AD_REFERENCE_ID><![CDATA[11F86B630ECB4A57B28927193F8AB99D]]></AD_REFERENCE_ID>
+<!--EE47114FD15B4B9980B67D38895A5AF1--> <AD_MODULE_ID><![CDATA[58A5C9704E1E4503B0121D47A8109FC7]]></AD_MODULE_ID>
+<!--EE47114FD15B4B9980B67D38895A5AF1--> <SEQNO><![CDATA[100]]></SEQNO>
+<!--EE47114FD15B4B9980B67D38895A5AF1--></AD_REF_LIST>
+
</data>
diff --git a/src-db/database/sourcedata/OBMOBC_SERVICES.xml b/src-db/database/sourcedata/OBMOBC_SERVICES.xml
--- a/src-db/database/sourcedata/OBMOBC_SERVICES.xml
+++ b/src-db/database/sourcedata/OBMOBC_SERVICES.xml
@@ -8,7 +8,7 @@
<!--005A9E0C715048B8A3CEC60799DC98D2--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
<!--005A9E0C715048B8A3CEC60799DC98D2--> <SERVICE><![CDATA[org.openbravo.retail.sessions.SetBusinessDate]]></SERVICE>
<!--005A9E0C715048B8A3CEC60799DC98D2--> <DESCRIPTION><![CDATA[Sets the Business Date of the store]]></DESCRIPTION>
-<!--005A9E0C715048B8A3CEC60799DC98D2--> <ROUTINGTYPE><![CDATA[Failover]]></ROUTINGTYPE>
+<!--005A9E0C715048B8A3CEC60799DC98D2--> <ROUTINGTYPE><![CDATA[Transaction]]></ROUTINGTYPE>
<!--005A9E0C715048B8A3CEC60799DC98D2--></OBMOBC_SERVICES>
<!--1CE44FCFDEBB4C9990676BAE223CB858--><OBMOBC_SERVICES>
@@ -19,9 +19,20 @@
<!--1CE44FCFDEBB4C9990676BAE223CB858--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
<!--1CE44FCFDEBB4C9990676BAE223CB858--> <SERVICE><![CDATA[org.openbravo.retail.sessions.OpenSessionPOS]]></SERVICE>
<!--1CE44FCFDEBB4C9990676BAE223CB858--> <DESCRIPTION><![CDATA[It opens a session for a terminal]]></DESCRIPTION>
-<!--1CE44FCFDEBB4C9990676BAE223CB858--> <ROUTINGTYPE><![CDATA[Failover]]></ROUTINGTYPE>
+<!--1CE44FCFDEBB4C9990676BAE223CB858--> <ROUTINGTYPE><![CDATA[Transaction]]></ROUTINGTYPE>
<!--1CE44FCFDEBB4C9990676BAE223CB858--></OBMOBC_SERVICES>
+<!--3C89D2F9C23548B5AE24944DC5BEE7F4--><OBMOBC_SERVICES>
+<!--3C89D2F9C23548B5AE24944DC5BEE7F4--> <OBMOBC_SERVICES_ID><![CDATA[3C89D2F9C23548B5AE24944DC5BEE7F4]]></OBMOBC_SERVICES_ID>
+<!--3C89D2F9C23548B5AE24944DC5BEE7F4--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--3C89D2F9C23548B5AE24944DC5BEE7F4--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--3C89D2F9C23548B5AE24944DC5BEE7F4--> <AD_MODULE_ID><![CDATA[58A5C9704E1E4503B0121D47A8109FC7]]></AD_MODULE_ID>
+<!--3C89D2F9C23548B5AE24944DC5BEE7F4--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--3C89D2F9C23548B5AE24944DC5BEE7F4--> <SERVICE><![CDATA[org.openbravo.retail.sessions.WebPOSCloseStore]]></SERVICE>
+<!--3C89D2F9C23548B5AE24944DC5BEE7F4--> <DESCRIPTION><![CDATA[Close Store from Web POS]]></DESCRIPTION>
+<!--3C89D2F9C23548B5AE24944DC5BEE7F4--> <ROUTINGTYPE><![CDATA[Transaction]]></ROUTINGTYPE>
+<!--3C89D2F9C23548B5AE24944DC5BEE7F4--></OBMOBC_SERVICES>
+
<!--4C13D32F4ED94685A3D6A3FBFDEF6643--><OBMOBC_SERVICES>
<!--4C13D32F4ED94685A3D6A3FBFDEF6643--> <OBMOBC_SERVICES_ID><![CDATA[4C13D32F4ED94685A3D6A3FBFDEF6643]]></OBMOBC_SERVICES_ID>
<!--4C13D32F4ED94685A3D6A3FBFDEF6643--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff --git a/src/org/openbravo/retail/sessions/CountOpenTills.java b/src/org/openbravo/retail/sessions/CountOpenTills.java
new file mode 100644
--- /dev/null
+++ b/src/org/openbravo/retail/sessions/CountOpenTills.java
@@ -0,0 +1,67 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2015 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.sessions;
+
+import javax.servlet.ServletException;
+
+import org.apache.log4j.Logger;
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.hibernate.criterion.Restrictions;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.mobile.core.process.JSONProcessSimple;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.retail.posterminal.OBPOSApplications;
+import org.openbravo.retail.sessions.org.openbravo.retail.sessions.TerminalSessions;
+import org.openbravo.service.json.JsonConstants;
+
+public class CountOpenTills extends JSONProcessSimple {
+
+ private static final Logger logger = Logger.getLogger(CountOpenTills.class);
+
+ @Override
+ public JSONObject exec(JSONObject jsonsent) throws JSONException, ServletException {
+ final JSONObject result = new JSONObject();
+ try {
+ OBContext.setAdminMode(false);
+ final String orgid = (String) jsonsent.getString("store");
+ Organization org = OBDal.getInstance().get(Organization.class, orgid);
+ final String terminalid = (String) jsonsent.getString("terminal");
+ OBPOSApplications terminal = OBDal.getInstance().get(OBPOSApplications.class, terminalid);
+
+ OBCriteria<TerminalSessions> openSessionCriteria = OBDal.getInstance().createCriteria(
+ TerminalSessions.class);
+ openSessionCriteria.add(Restrictions.isNull(TerminalSessions.PROPERTY_CLOSED));
+ openSessionCriteria.add(Restrictions.eq(TerminalSessions.PROPERTY_ORGANIZATION, org));
+ openSessionCriteria.add(Restrictions.ne(TerminalSessions.PROPERTY_POSTERMINAL, terminal));
+ result.put(JsonConstants.RESPONSE_DATA, openSessionCriteria.count());
+ result.put(JsonConstants.RESPONSE_STATUS, JsonConstants.RPCREQUEST_STATUS_SUCCESS);
+ return result;
+ } catch (Exception e) {
+ // log, but for the rest just return anything
+ logger.error(e.getMessage(), e);
+ result.put("success", false);
+ return result;
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ }
+
+ @Override
+ protected boolean bypassPreferenceCheck() {
+ return true;
+ }
+
+ @Override
+ protected boolean bypassSecurity() {
+ return true;
+ }
+}
diff --git a/src/org/openbravo/retail/sessions/OpenSessionPOS.java b/src/org/openbravo/retail/sessions/OpenSessionPOS.java
--- a/src/org/openbravo/retail/sessions/OpenSessionPOS.java
+++ b/src/org/openbravo/retail/sessions/OpenSessionPOS.java
@@ -5,8 +5,6 @@
import java.text.SimpleDateFormat;
import java.util.Date;
-import javax.servlet.ServletException;
-
import org.apache.log4j.Logger;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
@@ -16,22 +14,24 @@
import org.openbravo.dal.core.OBContext;
import org.openbravo.dal.service.OBCriteria;
import org.openbravo.dal.service.OBDal;
-import org.openbravo.retail.posterminal.JSONProcessSimple;
+import org.openbravo.mobile.core.process.DataSynchronizationImportProcess;
import org.openbravo.retail.posterminal.OBPOSApplications;
+import org.openbravo.retail.posterminal.POSDataSynchronizationProcess;
import org.openbravo.retail.sessions.org.openbravo.retail.sessions.TerminalSessions;
import org.openbravo.service.json.JsonConstants;
-public class OpenSessionPOS extends JSONProcessSimple {
+public class OpenSessionPOS extends POSDataSynchronizationProcess implements
+ DataSynchronizationImportProcess {
private static final Logger logger = Logger.getLogger(OpenSessionPOS.class);
private static final DateFormat isodatefmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
@Override
- public JSONObject exec(JSONObject jsonsent) throws JSONException, ServletException {
+ public JSONObject saveRecord(JSONObject jsonRecord) throws Exception {
OBContext.setAdminMode(false);
- String termid = jsonsent.getString("terminalId");
- JSONArray bdSessionsToOpen = jsonsent.getJSONArray("bdSessions");
+ String termid = jsonRecord.getString("terminalId");
+ JSONArray bdSessionsToOpen = jsonRecord.getJSONArray("bdSessions");
OBPOSApplications terminal = OBDal.getInstance().get(OBPOSApplications.class, termid);
for (int i = 0; i < bdSessionsToOpen.length(); i++) {
@@ -82,5 +82,10 @@
jsonResponse.put(JsonConstants.RESPONSE_DATA, new JSONObject());
jsonResponse.put("result", "0");
return jsonResponse;
+
+ }
+
+ protected String getImportQualifier() {
+ return "POSS_OpenSessionPOS";
}
}
diff --git a/src/org/openbravo/retail/sessions/OpenSessionPOSEntryProcessor.java b/src/org/openbravo/retail/sessions/OpenSessionPOSEntryProcessor.java
new file mode 100644
--- /dev/null
+++ b/src/org/openbravo/retail/sessions/OpenSessionPOSEntryProcessor.java
@@ -0,0 +1,105 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2015 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.sessions;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.codehaus.jettison.json.JSONObject;
+import org.hibernate.Query;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.base.weld.WeldUtils;
+import org.openbravo.dal.core.DalUtil;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.mobile.core.process.DataSynchronizationProcess;
+import org.openbravo.mobile.core.process.MobileImportEntryProcessorRunnable;
+import org.openbravo.service.importprocess.ImportEntry;
+import org.openbravo.service.importprocess.ImportEntryManager.ImportEntryQualifier;
+import org.openbravo.service.importprocess.ImportEntryProcessor;
+
+/**
+ * Encapsulates the {@link OpenSessionPOS} in a thread.
+ *
+ * @author mdejuana
+ */
+@ImportEntryQualifier(entity = "POSS_OpenSessionPOS")
+@ApplicationScoped
+public class OpenSessionPOSEntryProcessor extends ImportEntryProcessor {
+
+ protected ImportEntryProcessRunnable createImportEntryProcessRunnable() {
+ return WeldUtils.getInstanceFromStaticBeanManager(OpenSessionPOSRunnable.class);
+ }
+
+ protected boolean canHandleImportEntry(ImportEntry importEntryInformation) {
+ return "POSS_OpenSessionPOS".equals(importEntryInformation.getTypeofdata());
+ }
+
+ protected String getProcessSelectionKey(ImportEntry importEntry) {
+ return (String) DalUtil.getId(importEntry.getOrganization());
+ }
+
+ private static class OpenSessionPOSRunnable extends MobileImportEntryProcessorRunnable {
+ protected Class<? extends DataSynchronizationProcess> getDataSynchronizationClass() {
+ return OpenSessionPOS.class;
+ }
+
+ protected void processEntry(ImportEntry importEntry) throws Exception {
+ try {
+ OBContext.setAdminMode(false);
+
+ JSONObject json = new JSONObject(importEntry.getJsonInfo());
+ if (json.has("data") && json.getJSONArray("data").length() > 0) {
+ json = json.getJSONArray("data").getJSONObject(0);
+ }
+ if (thereIsDataInImportQueue(importEntry)) {
+ // close and commit
+ OBDal.getInstance().commitAndClose();
+ return;
+ }
+
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ super.processEntry(importEntry);
+ }
+
+ private boolean thereIsDataInImportQueue(ImportEntry importEntry) {
+ try {
+ OBContext.setAdminMode(false);
+
+ if (0 < countEntries("Error", importEntry)) {
+ // if there are related error entries before this one then this is an error
+ // throw an exception to move this entry also to error status
+ throw new OBException("There are error records before this record " + importEntry
+ + ", moving this entry also to error status.");
+ }
+
+ return 0 < countEntries("Initial", importEntry);
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ }
+
+ private int countEntries(String importStatus, ImportEntry importEntry) {
+ final String whereClause = ImportEntry.PROPERTY_IMPORTSTATUS + "='" + importStatus
+ + "' and (" + ImportEntry.PROPERTY_TYPEOFDATA + "='POSS_OpenSessionPOS' or "
+ + ImportEntry.PROPERTY_TYPEOFDATA + "='POSS_SetBusinessDate') and "
+ + ImportEntry.PROPERTY_CREATIONDATE + "<:creationDate and "
+ + ImportEntry.PROPERTY_OBPOSPOSTERMINAL + "=:terminal and id!=:id";
+ final Query qry = OBDal.getInstance().getSession()
+ .createQuery("select count(*) from " + ImportEntry.ENTITY_NAME + " where " + whereClause);
+ qry.setParameter("id", importEntry.getId());
+ qry.setTimestamp("creationDate", importEntry.getCreationDate());
+ qry.setParameter("terminal", importEntry.getOBPOSPOSTerminal());
+
+ return ((Number) qry.uniqueResult()).intValue();
+ }
+ }
+
+}
diff --git a/src/org/openbravo/retail/sessions/SetBusinessDate.java b/src/org/openbravo/retail/sessions/SetBusinessDate.java
--- a/src/org/openbravo/retail/sessions/SetBusinessDate.java
+++ b/src/org/openbravo/retail/sessions/SetBusinessDate.java
@@ -13,31 +13,30 @@
import java.text.SimpleDateFormat;
import java.util.Date;
-import javax.servlet.ServletException;
-
-import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.hibernate.criterion.Restrictions;
import org.openbravo.dal.core.OBContext;
import org.openbravo.dal.service.OBCriteria;
import org.openbravo.dal.service.OBDal;
+import org.openbravo.mobile.core.process.DataSynchronizationImportProcess;
import org.openbravo.model.common.enterprise.Organization;
-import org.openbravo.retail.posterminal.JSONProcessSimple;
import org.openbravo.retail.posterminal.OBPOSApplications;
+import org.openbravo.retail.posterminal.POSDataSynchronizationProcess;
import org.openbravo.retail.sessions.org.openbravo.retail.sessions.TerminalSessions;
import org.openbravo.service.json.JsonConstants;
-public class SetBusinessDate extends JSONProcessSimple {
+public class SetBusinessDate extends POSDataSynchronizationProcess implements
+ DataSynchronizationImportProcess {
private static final DateFormat isodatefmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
@Override
- public JSONObject exec(JSONObject jsonsent) throws JSONException, ServletException {
+ public JSONObject saveRecord(JSONObject jsonRecord) throws Exception {
OBContext.setAdminMode(false);
try {
- String termid = jsonsent.getString("terminalId");
- Date businessDate = isodatefmt.parse(jsonsent.getString("businessDate"));
+ String termid = jsonRecord.getString("terminalId");
+ Date businessDate = isodatefmt.parse(jsonRecord.getString("businessDate"));
OBPOSApplications terminal = OBDal.getInstance().get(OBPOSApplications.class, termid);
Organization org = terminal.getOrganization();
if (org.getPOSSBusinessDate() == null) {
@@ -77,5 +76,10 @@
jsonResponse.put(JsonConstants.RESPONSE_DATA, new JSONObject());
jsonResponse.put("result", "0");
return jsonResponse;
+
+ }
+
+ protected String getImportQualifier() {
+ return "POSS_SetBusinessDate";
}
}
diff --git a/src/org/openbravo/retail/sessions/SetBusinessDateEntryProcessor.java b/src/org/openbravo/retail/sessions/SetBusinessDateEntryProcessor.java
new file mode 100644
--- /dev/null
+++ b/src/org/openbravo/retail/sessions/SetBusinessDateEntryProcessor.java
@@ -0,0 +1,104 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2015 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.sessions;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.codehaus.jettison.json.JSONObject;
+import org.hibernate.Query;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.base.weld.WeldUtils;
+import org.openbravo.dal.core.DalUtil;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.mobile.core.process.DataSynchronizationProcess;
+import org.openbravo.mobile.core.process.MobileImportEntryProcessorRunnable;
+import org.openbravo.service.importprocess.ImportEntry;
+import org.openbravo.service.importprocess.ImportEntryManager.ImportEntryQualifier;
+import org.openbravo.service.importprocess.ImportEntryProcessor;
+
+/**
+ * Encapsulates the {@link SetBusinessDate} in a thread.
+ *
+ * @author mdejuana
+ */
+@ImportEntryQualifier(entity = "POSS_SetBusinessDate")
+@ApplicationScoped
+public class SetBusinessDateEntryProcessor extends ImportEntryProcessor {
+
+ protected ImportEntryProcessRunnable createImportEntryProcessRunnable() {
+ return WeldUtils.getInstanceFromStaticBeanManager(SetBusinessDateRunnable.class);
+ }
+
+ protected boolean canHandleImportEntry(ImportEntry importEntryInformation) {
+ return "POSS_SetBusinessDate".equals(importEntryInformation.getTypeofdata());
+ }
+
+ protected String getProcessSelectionKey(ImportEntry importEntry) {
+ return (String) DalUtil.getId(importEntry.getOrganization());
+ }
+
+ private static class SetBusinessDateRunnable extends MobileImportEntryProcessorRunnable {
+ protected Class<? extends DataSynchronizationProcess> getDataSynchronizationClass() {
+ return SetBusinessDate.class;
+ }
+
+ protected void processEntry(ImportEntry importEntry) throws Exception {
+ try {
+ OBContext.setAdminMode(false);
+
+ JSONObject json = new JSONObject(importEntry.getJsonInfo());
+ if (json.has("data") && json.getJSONArray("data").length() > 0) {
+ json = json.getJSONArray("data").getJSONObject(0);
+ }
+ if (thereIsDataInImportQueue(importEntry)) {
+ // close and commit
+ OBDal.getInstance().commitAndClose();
+ return;
+ }
+
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ super.processEntry(importEntry);
+ }
+
+ private boolean thereIsDataInImportQueue(ImportEntry importEntry) {
+ try {
+ OBContext.setAdminMode(false);
+
+ if (0 < countEntries("Error", importEntry)) {
+ // if there are related error entries before this one then this is an error
+ // throw an exception to move this entry also to error status
+ throw new OBException("There are error records before this record " + importEntry
+ + ", moving this entry also to error status.");
+ }
+
+ return 0 < countEntries("Initial", importEntry);
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ }
+
+ private int countEntries(String importStatus, ImportEntry importEntry) {
+ final String whereClause = ImportEntry.PROPERTY_IMPORTSTATUS + "='" + importStatus + "' and "
+ + ImportEntry.PROPERTY_TYPEOFDATA + "='POSS_SetBusinessDate' and "
+ + ImportEntry.PROPERTY_CREATIONDATE + "<:creationDate and "
+ + ImportEntry.PROPERTY_OBPOSPOSTERMINAL + "=:terminal and id!=:id";
+ final Query qry = OBDal.getInstance().getSession()
+ .createQuery("select count(*) from " + ImportEntry.ENTITY_NAME + " where " + whereClause);
+ qry.setParameter("id", importEntry.getId());
+ qry.setTimestamp("creationDate", importEntry.getCreationDate());
+ qry.setParameter("terminal", importEntry.getOBPOSPOSTerminal());
+
+ return ((Number) qry.uniqueResult()).intValue();
+ }
+ }
+
+}
diff --git a/src/org/openbravo/retail/sessions/WebPOSCloseStore.java b/src/org/openbravo/retail/sessions/WebPOSCloseStore.java
new file mode 100644
--- /dev/null
+++ b/src/org/openbravo/retail/sessions/WebPOSCloseStore.java
@@ -0,0 +1,50 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2013 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.sessions;
+
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.mobile.core.process.DataSynchronizationImportProcess;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.retail.posterminal.POSDataSynchronizationProcess;
+import org.openbravo.service.json.JsonConstants;
+
+public class WebPOSCloseStore extends POSDataSynchronizationProcess implements
+ DataSynchronizationImportProcess {
+
+ @Override
+ public JSONObject saveRecord(JSONObject jsonRecord) throws Exception {
+
+ OBContext.setAdminMode(false);
+ try {
+ final String orgid = (String) jsonRecord.getString("store");
+ Organization org = OBDal.getInstance().get(Organization.class, orgid);
+
+ org.setPOSSBusinessDate(null);
+ OBDal.getInstance().save(org);
+
+ OBDal.getInstance().flush();
+ } catch (Exception e) {
+ throw new OBException("Error in WebPOSCloseStore: ", e);
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ JSONObject jsonResponse = new JSONObject();
+ jsonResponse.put(JsonConstants.RESPONSE_STATUS, JsonConstants.RPCREQUEST_STATUS_SUCCESS);
+ jsonResponse.put(JsonConstants.RESPONSE_DATA, new JSONObject());
+ jsonResponse.put("result", "0");
+ return jsonResponse;
+ }
+
+ protected String getImportQualifier() {
+ return "POSS_WebPOSCloseStore";
+ }
+}
diff --git a/src/org/openbravo/retail/sessions/WebPOSCloseStoreEntryProcessor.java b/src/org/openbravo/retail/sessions/WebPOSCloseStoreEntryProcessor.java
new file mode 100644
--- /dev/null
+++ b/src/org/openbravo/retail/sessions/WebPOSCloseStoreEntryProcessor.java
@@ -0,0 +1,106 @@
+/*
+ ************************************************************************************
+ * Copyright (C) 2015 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.sessions;
+
+import javax.enterprise.context.ApplicationScoped;
+
+import org.codehaus.jettison.json.JSONObject;
+import org.hibernate.Query;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.base.weld.WeldUtils;
+import org.openbravo.dal.core.DalUtil;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.mobile.core.process.DataSynchronizationProcess;
+import org.openbravo.mobile.core.process.MobileImportEntryProcessorRunnable;
+import org.openbravo.service.importprocess.ImportEntry;
+import org.openbravo.service.importprocess.ImportEntryManager.ImportEntryQualifier;
+import org.openbravo.service.importprocess.ImportEntryProcessor;
+
+/**
+ * Encapsulates the {@link WebPOSCloseStore} in a thread.
+ *
+ * @author mdejuana
+ */
+@ImportEntryQualifier(entity = "POSS_WebPOSCloseStore")
+@ApplicationScoped
+public class WebPOSCloseStoreEntryProcessor extends ImportEntryProcessor {
+
+ protected ImportEntryProcessRunnable createImportEntryProcessRunnable() {
+ return WeldUtils.getInstanceFromStaticBeanManager(WebPOSCloseStoreRunnable.class);
+ }
+
+ protected boolean canHandleImportEntry(ImportEntry importEntryInformation) {
+ return "POSS_WebPOSCloseStore".equals(importEntryInformation.getTypeofdata());
+ }
+
+ protected String getProcessSelectionKey(ImportEntry importEntry) {
+ return (String) DalUtil.getId(importEntry.getOrganization());
+ }
+
+ private static class WebPOSCloseStoreRunnable extends MobileImportEntryProcessorRunnable {
+ protected Class<? extends DataSynchronizationProcess> getDataSynchronizationClass() {
+ return WebPOSCloseStore.class;
+ }
+
+ protected void processEntry(ImportEntry importEntry) throws Exception {
+ try {
+ OBContext.setAdminMode(false);
+
+ JSONObject json = new JSONObject(importEntry.getJsonInfo());
+ if (json.has("data") && json.getJSONArray("data").length() > 0) {
+ json = json.getJSONArray("data").getJSONObject(0);
+ }
+ if (thereIsDataInImportQueue(importEntry)) {
+ // close and commit
+ OBDal.getInstance().commitAndClose();
+ return;
+ }
+
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ super.processEntry(importEntry);
+ }
+
+ private boolean thereIsDataInImportQueue(ImportEntry importEntry) {
+ try {
+ OBContext.setAdminMode(false);
+
+ if (0 < countEntries("Error", importEntry)) {
+ // if there are related error entries before this one then this is an error
+ // throw an exception to move this entry also to error status
+ throw new OBException("There are error records before this record " + importEntry
+ + ", moving this entry also to error status.");
+ }
+
+ return 0 < countEntries("Initial", importEntry);
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ }
+
+ private int countEntries(String importStatus, ImportEntry importEntry) {
+ final String whereClause = ImportEntry.PROPERTY_IMPORTSTATUS + "='" + importStatus
+ + "' and (" + ImportEntry.PROPERTY_TYPEOFDATA + "='POSS_WebPOSCloseStore' or "
+ + ImportEntry.PROPERTY_TYPEOFDATA + "='Order' or " + ImportEntry.PROPERTY_TYPEOFDATA
+ + "='FIN_Finacc_Transaction' or " + ImportEntry.PROPERTY_TYPEOFDATA
+ + "='OBPOS_App_Cashup') and " + ImportEntry.PROPERTY_CREATIONDATE + "<:creationDate and "
+ + ImportEntry.PROPERTY_OBPOSPOSTERMINAL + "=:terminal and id!=:id";
+ final Query qry = OBDal.getInstance().getSession()
+ .createQuery("select count(*) from " + ImportEntry.ENTITY_NAME + " where " + whereClause);
+ qry.setParameter("id", importEntry.getId());
+ qry.setTimestamp("creationDate", importEntry.getCreationDate());
+ qry.setParameter("terminal", importEntry.getOBPOSPOSTerminal());
+
+ return ((Number) qry.uniqueResult()).intValue();
+ }
+ }
+
+}
diff --git a/web/org.openbravo.retail.sessions/js/components/BusinessDateModel.js b/web/org.openbravo.retail.sessions/js/components/BusinessDateModel.js
--- a/web/org.openbravo.retail.sessions/js/components/BusinessDateModel.js
+++ b/web/org.openbravo.retail.sessions/js/components/BusinessDateModel.js
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2013 Openbravo S.L.U.
+ * Copyright (C) 2013-2015 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.
@@ -50,9 +50,13 @@
callbackFunc();
} else {
var server = new OB.DS.Process('org.openbravo.retail.sessions.SetBusinessDate');
- server.exec({
+ var objToSend = {
businessDate: OB.I18N.formatDateISO(this.get('businessdate')),
terminalId: OB.MobileApp.model.get('terminal').id
+ };
+ server.exec({
+ messageId: OB.UTIL.get_UUID(),
+ data: [objToSend]
}, function (data) {
window.localStorage.removeItem('newBusinessDate');
callbackFunc();
diff --git a/web/org.openbravo.retail.sessions/js/components/loginhook.js b/web/org.openbravo.retail.sessions/js/components/loginhook.js
--- a/web/org.openbravo.retail.sessions/js/components/loginhook.js
+++ b/web/org.openbravo.retail.sessions/js/components/loginhook.js
@@ -1,6 +1,6 @@
/*
************************************************************************************
- * Copyright (C) 2013 Openbravo S.L.U.
+ * Copyright (C) 2013-2015 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.
@@ -151,10 +151,10 @@
terminalId: window.localStorage.getItem('terminalId'),
bdSessions: pendingSessions
};
- server.exec(objToSend, function (data) {
- if (!data.error && !data.exception) {
- window.localStorage.removeItem('pendingSessions');
- }
+ server.exec({
+ messageId: OB.UTIL.get_UUID(),
+ data: [objToSend]
+ }, function () {
OB.UTIL.HookManager.callbackExecutor(args, callbacks);
}, function () {
OB.UTIL.HookManager.callbackExecutor(args, callbacks);
@@ -166,9 +166,13 @@
if (window.localStorage.getItem('newBusinessDate')) {
var server = new OB.DS.Process('org.openbravo.retail.sessions.SetBusinessDate');
- server.exec({
+ var objToSend = {
businessDate: OB.I18N.formatDateISO(OB.I18N.parseServerDate(window.localStorage.getItem('newBusinessDate'))),
terminalId: window.localStorage.getItem('terminalId')
+ };
+ server.exec({
+ messageId: OB.UTIL.get_UUID(),
+ data: [objToSend]
}, function (data) {
window.localStorage.removeItem('newBusinessDate');
pendingSessionsCallback();
@@ -208,8 +212,98 @@
};
OB.UTIL.HookManager.registerHook('OBPOS_AfterCashUpSent', function (args, callbacks) {
- window.localStorage.setItem('poss_sessionactive', JSON.stringify({
- isActive: false
- }));
- OB.UTIL.HookManager.callbackExecutor(args, callbacks);
+ //If we are online and preference is enabled, start close store process
+ if (OB.MobileApp.model.get('connectedToERP') && OB.MobileApp.model.hasPermission("POSS_CloseStore", true)) {
+ window.localStorage.setItem('poss_sessionactive', JSON.stringify({
+ isActive: false
+ }));
+ var server = new OB.DS.Process('org.openbravo.retail.sessions.CountOpenTills');
+ //Check if all terminals already did cashup process
+ server.exec({
+ store: OB.POS.modelterminal.get('terminal').organization,
+ terminal: OB.POS.modelterminal.get('terminal').id
+ }, function (data) {
+ if (data && data.exception) {
+ OB.UTIL.showError(OB.I18N.getLabel('POSS_CloseStoreMsgError'));
+ OB.UTIL.HookManager.callbackExecutor(args, callbacks);
+ } else if (data && data > 0) {
+ OB.UTIL.HookManager.callbackExecutor(args, callbacks);
+ } else {
+ //All till are closed, ask to close the store
+ OB.UTIL.showConfirmation.display(OB.I18N.getLabel('POSS_LblCloseStore'), OB.I18N.getLabel('POSS_CloseStoreMsg'), [{
+ label: OB.I18N.getLabel('OBMOBC_LblOk'),
+ isConfirmButton: true,
+ action: function () {
+ //Close store process
+ var process = new OB.DS.Process('org.openbravo.retail.sessions.WebPOSCloseStore');
+ process.exec({
+ messageId: OB.UTIL.get_UUID(),
+ data: [{
+ store: OB.POS.modelterminal.get('terminal').organization
+ }]
+ }, function (data) {
+ if (data && data.exception) {
+ //Error when closing store
+ OB.UTIL.showConfirmation.display(OB.I18N.getLabel('POSS_LblCloseStore'), OB.I18N.getLabel('POSS_CloseStoreMsgError'), [{
+ label: OB.I18N.getLabel('OBMOBC_LblOk'),
+ isConfirmButton: true,
+ action: function () {
+ OB.UTIL.showLoggingOut(true);
+ OB.MobileApp.model.logout();
+ }
+ }]);
+ } else {
+ // Close store success
+ OB.UTIL.showConfirmation.display(OB.I18N.getLabel('POSS_LblCloseStore'), OB.I18N.getLabel('POSS_CloseStoreMsgSuccess'), [{
+ label: OB.I18N.getLabel('OBMOBC_LblOk'),
+ isConfirmButton: true,
+ action: function () {
+ window.localStorage.setItem('poss_sessionactive', JSON.stringify({
+ isActive: false
+ }));
+ window.localStorage.setItem('businessdate', undefined);
+ OB.UTIL.showLoggingOut(true);
+ OB.MobileApp.model.logout();
+ return true;
+ }
+ }], {
+ autoDismiss: false
+ });
+
+ }
+ }, function (error) {
+ //Error when closing the store (request error)
+ if (error) {
+ OB.UTIL.showError(OB.I18N.getLabel('POSS_CloseStoreMsgError'));
+ }
+ OB.UTIL.HookManager.callbackExecutor(args, callbacks);
+ });
+ return true;
+ }
+ }, {
+ label: OB.I18N.getLabel('OBMOBC_LblCancel'),
+ action: function () {
+ //Refuse to close the store
+ OB.UTIL.showLoggingOut(true);
+ OB.MobileApp.model.logout();
+ }
+ }], {
+ autoDismiss: false
+ });
+ }
+ }, function (error) {
+ //Error when closing counting tills
+ if (error) {
+ OB.UTIL.showError(OB.I18N.getLabel('POSS_CloseStoreMsgError'));
+ }
+ OB.UTIL.HookManager.callbackExecutor(args, callbacks);
+ });
+ //Regular flow
+ } else {
+ window.localStorage.setItem('poss_sessionactive', JSON.stringify({
+ isActive: false
+ }));
+ OB.UTIL.HookManager.callbackExecutor(args, callbacks);
+ }
+
});
\ No newline at end of file
diff --git a/web/org.openbravo.retail.sessions/js/countcash/countcash-model.js b/web/org.openbravo.retail.sessions/js/countcash/countcash-model.js
--- a/web/org.openbravo.retail.sessions/js/countcash/countcash-model.js
+++ b/web/org.openbravo.retail.sessions/js/countcash/countcash-model.js
@@ -312,11 +312,11 @@
}));
//ready to send to the server
- server.exec(objToSend, function (data) {
+ server.exec({
+ messageId: OB.UTIL.get_UUID(),
+ data: [objToSend]
+ }, function (data) {
me.set('cashcountSent', false);
- if (data.error || data.exception) {
- me.addToPendingSessions(objToSend.bdSessions[0]);
- }
OB.UTIL.showLoading(false);
me.set("finished", true);
}, function () {
Selection_139.png [^] (288,023 bytes) 2016-02-16 15:31 |