Attached Files | issue #31757 posterminal Source 5550.patch [^] (5,747 bytes) 2015-12-29 07:56 [Show Content] [Hide Content]# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1451372048 -19800
# Node ID 363f7b95b170d9cff9307710dba6114ef90f797e
# Parent f3bbe3cfee462d018951ff4d1665c5c92c9ab16d
Realted to issue 31757 : Create Cash Mgmt Transaction based on WEBPOS Date
diff --git a/src/org/openbravo/retail/posterminal/ProcessCashMgmt.java b/src/org/openbravo/retail/posterminal/ProcessCashMgmt.java
--- a/src/org/openbravo/retail/posterminal/ProcessCashMgmt.java
+++ b/src/org/openbravo/retail/posterminal/ProcessCashMgmt.java
@@ -9,8 +9,10 @@
package org.openbravo.retail.posterminal;
import java.math.BigDecimal;
+import java.util.Calendar;
import java.util.Date;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.codehaus.jettison.json.JSONObject;
import org.openbravo.advpaymentmngt.dao.TransactionsDao;
@@ -19,6 +21,7 @@
import org.openbravo.dal.service.OBDal;
import org.openbravo.mobile.core.process.DataSynchronizationImportProcess;
import org.openbravo.mobile.core.process.DataSynchronizationProcess.DataSynchronization;
+import org.openbravo.mobile.core.utils.OBMOBCUtils;
import org.openbravo.model.financialmgmt.gl.GLItem;
import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction;
import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount;
@@ -64,6 +67,32 @@
if (jsonsent.has("glItem")) {
glItemMain = OBDal.getInstance().get(GLItem.class, jsonsent.getString("glItem"));
}
+
+ // get and prepare the cashMgmtTrxDate
+ Date cashMgmtTrxDate = new Date();
+ if (jsonsent.has("creationDate") && jsonsent.get("creationDate") != null
+ && StringUtils.isNotEmpty(jsonsent.getString("creationDate"))) {
+ final String strCashUpDate = jsonsent.getString("creationDate");
+ if (!strCashUpDate.substring(strCashUpDate.length() - 1).equals("Z")) {
+ log.error(String.format(
+ "The cashup date must be provided in ISO 8601 format and be an UTC date (value: '%s')",
+ strCashUpDate));
+ }
+ // get the timezoneOffset
+ final long timezoneOffset;
+ if (jsonsent.has("timezoneOffset") && jsonsent.get("timezoneOffset") != null
+ && StringUtils.isNotEmpty(jsonsent.getString("timezoneOffset"))) {
+ timezoneOffset = Long.parseLong(jsonsent.getString("timezoneOffset"));
+ } else {
+ timezoneOffset = -((Calendar.getInstance().get(Calendar.ZONE_OFFSET) + Calendar
+ .getInstance().get(Calendar.DST_OFFSET)) / (60 * 1000));
+ log.error("Error processing cash close (1): error retrieving the timezoneOffset. Using the current timezoneOffset");
+ }
+ cashMgmtTrxDate = OBMOBCUtils.calculateClientDatetime(strCashUpDate, timezoneOffset);
+ } else {
+ log.debug("Error processing cash close (2): error retrieving cashUp date. Using current server date");
+ }
+
FIN_FinancialAccount account = paymentMethod.getFinancialAccount();
FIN_FinaccTransaction transaction = OBProvider.getInstance().get(FIN_FinaccTransaction.class);
@@ -84,8 +113,8 @@
transaction.setProcessed(true);
transaction.setTransactionType("BPW");
transaction.setDescription(description);
- transaction.setDateAcct(new Date());
- transaction.setTransactionDate(new Date());
+ transaction.setDateAcct(cashMgmtTrxDate);
+ transaction.setTransactionDate(cashMgmtTrxDate);
transaction.setStatus("RDNC");
OBDal.getInstance().save(transaction);
@@ -116,8 +145,8 @@
secondTransaction.setProcessed(true);
secondTransaction.setTransactionType("BPW");
secondTransaction.setDescription(description);
- secondTransaction.setDateAcct(new Date());
- secondTransaction.setTransactionDate(new Date());
+ secondTransaction.setDateAcct(cashMgmtTrxDate);
+ secondTransaction.setTransactionDate(cashMgmtTrxDate);
secondTransaction.setStatus("RDNC");
OBDal.getInstance().save(secondTransaction);
}
diff --git a/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js b/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js
--- a/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js
+++ b/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js
@@ -48,7 +48,8 @@
OB.Dal.find(OB.Model.CashUp, {
'isprocessed': 'N'
}, function (cashUp) {
- var addedCashMgmt = new OB.Model.CashManagement({
+ var now = new Date();
+ var cashMgmt = {
id: OB.UTIL.get_UUID(),
description: p.identifier + ' - ' + model.get('name'),
amount: p.amount,
@@ -63,7 +64,12 @@
glItem: p.glItem,
cashup_id: cashUp.at(0).get('id'),
isbeingprocessed: 'N'
- });
+ };
+ var objToSend = JSON.parse(JSON.stringify(cashMgmt));
+ objToSend.creationDate = OB.I18N.normalizeDate(now);
+ objToSend.timezoneOffset = now.getTimezoneOffset();
+ cashMgmt.objToSend = JSON.stringify(objToSend);
+ var addedCashMgmt = new OB.Model.CashManagement(cashMgmt);
me.depsdropstosave.add(addedCashMgmt);
var selectedPayment = me.payments.filter(function (payment) {
diff --git a/web/org.openbravo.retail.posterminal/js/model/cashmanagement.js b/web/org.openbravo.retail.posterminal/js/model/cashmanagement.js
--- a/web/org.openbravo.retail.posterminal/js/model/cashmanagement.js
+++ b/web/org.openbravo.retail.posterminal/js/model/cashmanagement.js
@@ -77,6 +77,10 @@
name: 'isbeingprocessed',
column: 'isbeingprocessed',
type: 'TEXT'
+ }, {
+ name: 'objToSend',
+ column: 'objToSend',
+ type: 'TEXT'
}]);
CashManagement.addIndex([{
issue #31757 Test 4855.patch [^] (5,429 bytes) 2015-12-29 07:56 [Show Content] [Hide Content]# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1451372052 -19800
# Node ID e964836eb48bbb0a7cbb9df18b3468da67f3221d
# Parent 2d4657a16e454116219c6c95a42c8926573e6c83
Verifies issue 31757: Added automated test 'I31757_CashMgmtTrxDate'
diff --git a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashmanagement/I31757_CashMgmtTrxDate.java b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashmanagement/I31757_CashMgmtTrxDate.java
new file mode 100644
--- /dev/null
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashmanagement/I31757_CashMgmtTrxDate.java
@@ -0,0 +1,108 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.0 (the "License"), being the Mozilla Public License
+ * Version 1.1 with a permitted attribution clause; you may not use this
+ * file except in compliance with the License. You may obtain a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo S.L.U.
+ * All portions are Copyright (C) 2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author JGA
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.cashmanagement;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.common.selenium.database.WebPOSDatabaseConstants;
+import org.openbravo.test.mobile.common.selenium.javascript.TestId;
+import org.openbravo.test.mobile.common.selenium.terminals.WebPOSTerminalHelper;
+import org.openbravo.test.mobile.common.selenium.testhelpers.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.OBUtils;
+
+public class I31757_CashMgmtTrxDate extends WebPOSTerminalHelper {
+
+ @Test
+ public void test() {
+ WebPOSSnippet.cleanCashup(this);
+
+ final String actualCashUpId = (String) SeleniumHelper
+ .executeScriptWithReturn("OB.MobileApp.model.get('terminal').cashUpId");
+ final String cashUpAmount = "10.57";
+
+ depositCash(cashUpAmount);
+
+ final StringBuffer jsGetCashUpDetails = new StringBuffer();
+ jsGetCashUpDetails.append("OBCustomVariable1 = ''; OBCustomVariable2 = '';");
+ jsGetCashUpDetails.append("OB.Dal.find(OB.Model.CashManagement, {}, function(cashMgmt) { ");
+ jsGetCashUpDetails
+ .append("OBCustomVariable1 = JSON.parse(cashMgmt.at(0).get('objToSend')).creationDate;");
+ jsGetCashUpDetails.append("});");
+
+ SeleniumHelper.executeScript(jsGetCashUpDetails.toString());
+ OBUtils.pause(1000);
+ final String cashMgmtTrxDateTime = (String) SeleniumHelper
+ .executeScriptWithReturn("OBCustomVariable1");
+
+ final DateFormat dateFormatISO = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
+ final TimeZone tz = TimeZone.getTimeZone("UTC");
+ dateFormatISO.setTimeZone(tz);
+
+ final String cashMgmtTrxISODateTime = cashMgmtTrxDateTime.substring(0,
+ cashMgmtTrxDateTime.length() - 8)
+ + "Z";
+
+ // Checking Front office Created date with Back office Transaction Date
+ final String sqlBackoffice = String
+ .format(
+ "select statementdate, dateacct from fin_finacc_transaction "
+ + " where fin_financial_account_id = '%s' and em_obpos_app_cashup_id = '%s' and depositamt = %s "
+ + " order by created desc",
+ WebPOSDatabaseConstants.VBS1001_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID, actualCashUpId,
+ cashUpAmount);
+ new DatabaseHelperSelect() {
+ @Override
+ protected void yieldResultSet(final ResultSet rs) throws SQLException {
+ assertThat("Cash Management Time from front office differs from Transaction date",
+ cashMgmtTrxISODateTime, equalTo(dateFormatISO.format(rs.getTimestamp("statementdate"))));
+ assertThat("Cash Management Time from front office differs from Accounting date",
+ cashMgmtTrxISODateTime, equalTo(dateFormatISO.format(rs.getTimestamp("statementdate"))));
+ }
+ }.execute(sqlBackoffice, 1);
+
+ WebPOSSnippet.cleanCashup(this);
+ }
+
+ private void depositCash(final String cashUpAmount) {
+ tap(TestId.BUTTON_MENU);
+ tap(TestId.BUTTON_MENU_CASHMANAGEMENT);
+
+ tap(TestId.BUTTON_CASHMANAGEMENT_CASHDEPOSIT);
+ write(TestId.INPUT_KEYPAD_CASHMGMT_EDITBOX, cashUpAmount);
+ tap(TestId.BUTTON_KEYPAD_ENTER);
+ tap(TestId.BUTTON_SELECTDEPOSIT_BACOFFICEVBS);
+ tap(TestId.BUTTON_CASHMANAGEMENT_DONE);
+ tap(TestId.BUTTON_POPUP_OK);
+ verify(TestId.LABEL_TOTALTOPAY, "0.00");
+ }
+}
issue #31757 Source v2 5553.patch [^] (8,391 bytes) 2015-12-31 09:55 [Show Content] [Hide Content]# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1451482656 -19800
# Node ID e7b4021aa9b837b3a07c7baa5dbb3956da21c081
# Parent 494c265c879769563a40bf9349854ae4c6bf617d
Realted to issue 31757 : Create Cash Mgmt Transaction Date based on WEBPOS Date
diff --git a/src/org/openbravo/retail/posterminal/ProcessCashMgmt.java b/src/org/openbravo/retail/posterminal/ProcessCashMgmt.java
--- a/src/org/openbravo/retail/posterminal/ProcessCashMgmt.java
+++ b/src/org/openbravo/retail/posterminal/ProcessCashMgmt.java
@@ -9,8 +9,10 @@
package org.openbravo.retail.posterminal;
import java.math.BigDecimal;
+import java.util.Calendar;
import java.util.Date;
+import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.codehaus.jettison.json.JSONObject;
import org.openbravo.advpaymentmngt.dao.TransactionsDao;
@@ -19,6 +21,7 @@
import org.openbravo.dal.service.OBDal;
import org.openbravo.mobile.core.process.DataSynchronizationImportProcess;
import org.openbravo.mobile.core.process.DataSynchronizationProcess.DataSynchronization;
+import org.openbravo.mobile.core.utils.OBMOBCUtils;
import org.openbravo.model.financialmgmt.gl.GLItem;
import org.openbravo.model.financialmgmt.payment.FIN_FinaccTransaction;
import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount;
@@ -64,6 +67,32 @@
if (jsonsent.has("glItem")) {
glItemMain = OBDal.getInstance().get(GLItem.class, jsonsent.getString("glItem"));
}
+
+ // get and prepare the cashMgmtTrxDate
+ Date cashMgmtTrxDate = new Date();
+ if (jsonsent.has("dateTime") && jsonsent.get("dateTime") != null
+ && StringUtils.isNotEmpty(jsonsent.getString("dateTime"))) {
+ final String strCashMgmtTrxDate = jsonsent.getString("dateTime");
+ if (!strCashMgmtTrxDate.substring(strCashMgmtTrxDate.length() - 1).equals("Z")) {
+ log.error(String.format(
+ "The cashup date must be provided in ISO 8601 format and be an UTC date (value: '%s')",
+ strCashMgmtTrxDate));
+ }
+ // get the timezoneOffset
+ final long timezoneOffset;
+ if (jsonsent.has("timezoneOffset") && jsonsent.get("timezoneOffset") != null
+ && StringUtils.isNotEmpty(jsonsent.getString("timezoneOffset"))) {
+ timezoneOffset = Long.parseLong(jsonsent.getString("timezoneOffset"));
+ } else {
+ timezoneOffset = -((Calendar.getInstance().get(Calendar.ZONE_OFFSET) + Calendar
+ .getInstance().get(Calendar.DST_OFFSET)) / (60 * 1000));
+ log.error("Error processing cash close (1): error retrieving the timezoneOffset. Using the current timezoneOffset");
+ }
+ cashMgmtTrxDate = OBMOBCUtils.calculateClientDatetime(strCashMgmtTrxDate, timezoneOffset);
+ } else {
+ log.debug("Error processing cash close (2): error retrieving cashUp date. Using current server date");
+ }
+
FIN_FinancialAccount account = paymentMethod.getFinancialAccount();
FIN_FinaccTransaction transaction = OBProvider.getInstance().get(FIN_FinaccTransaction.class);
@@ -84,8 +113,8 @@
transaction.setProcessed(true);
transaction.setTransactionType("BPW");
transaction.setDescription(description);
- transaction.setDateAcct(new Date());
- transaction.setTransactionDate(new Date());
+ transaction.setDateAcct(cashMgmtTrxDate);
+ transaction.setTransactionDate(cashMgmtTrxDate);
transaction.setStatus("RDNC");
OBDal.getInstance().save(transaction);
@@ -116,8 +145,8 @@
secondTransaction.setProcessed(true);
secondTransaction.setTransactionType("BPW");
secondTransaction.setDescription(description);
- secondTransaction.setDateAcct(new Date());
- secondTransaction.setTransactionDate(new Date());
+ secondTransaction.setDateAcct(cashMgmtTrxDate);
+ secondTransaction.setTransactionDate(cashMgmtTrxDate);
secondTransaction.setStatus("RDNC");
OBDal.getInstance().save(secondTransaction);
}
diff --git a/src/org/openbravo/retail/posterminal/master/Cashup.java b/src/org/openbravo/retail/posterminal/master/Cashup.java
--- a/src/org/openbravo/retail/posterminal/master/Cashup.java
+++ b/src/org/openbravo/retail/posterminal/master/Cashup.java
@@ -11,12 +11,10 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;
import javax.servlet.ServletException;
-import javax.xml.bind.DatatypeConverter;
import org.apache.log4j.Logger;
import org.codehaus.jettison.json.JSONArray;
@@ -227,10 +225,6 @@
JSONObject result = new JSONObject();
Float totalamt = Float.parseFloat(cashMgmtJSON.get("paymentAmount").toString())
+ Float.parseFloat(cashMgmtJSON.get("depositAmount").toString());
- Calendar c = DatatypeConverter.parseDateTime(cashMgmtJSON.get("creationDate").toString());
- int hour = c.get(Calendar.HOUR_OF_DAY);
- int minute = c.get(Calendar.MINUTE);
- String creationDate = hour + ":" + minute;
// Get Payment Method ID and Reason ID
String financialacct = cashMgmtJSON.get("account").toString();
@@ -257,7 +251,8 @@
: "drop");
result.put("reasonId", reasonId);
result.put("paymentMethodId", paymentmethodId);
- result.put("time", creationDate);
+ result.put("creationDate", cashMgmtJSON.get("creationDate").toString());
+ result.put("timezoneOffset", "0");
result.put("userId", cashMgmtJSON.get("createdBy"));
result.put("user", cashMgmtJSON.get("createdBy$_identifier"));
result.put("isocode", cashMgmtJSON.get("currency$_identifier"));
diff --git a/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js b/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js
--- a/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js
+++ b/web/org.openbravo.retail.posterminal/js/cashmgmt/model/cashmgmt-model.js
@@ -48,6 +48,7 @@
OB.Dal.find(OB.Model.CashUp, {
'isprocessed': 'N'
}, function (cashUp) {
+ var now = new Date();
var addedCashMgmt = new OB.Model.CashManagement({
id: OB.UTIL.get_UUID(),
description: p.identifier + ' - ' + model.get('name'),
@@ -58,7 +59,8 @@
paymentMethodId: p.id,
user: OB.MobileApp.model.get('context').user._identifier,
userId: OB.MobileApp.model.get('context').user.id,
- time: new Date().toString().substring(16, 21),
+ creationDate: OB.I18N.normalizeDate(now),
+ timezoneOffset: now.getTimezoneOffset(),
isocode: p.isocode,
glItem: p.glItem,
cashup_id: cashUp.at(0).get('id'),
diff --git a/web/org.openbravo.retail.posterminal/js/cashmgmt/view/listdepositsdrops.js b/web/org.openbravo.retail.posterminal/js/cashmgmt/view/listdepositsdrops.js
--- a/web/org.openbravo.retail.posterminal/js/cashmgmt/view/listdepositsdrops.js
+++ b/web/org.openbravo.retail.posterminal/js/cashmgmt/view/listdepositsdrops.js
@@ -57,10 +57,10 @@
amnt = OB.I18N.formatCurrency(OB.DEC.add(0, this.model.get('amount')));
}
}
-
+ var creationDate = new Date(this.model.get('creationDate'));
this.$.description.setContent(lbl + this.model.get('description'));
this.$.user.setContent(this.model.get('user'));
- this.$.time.setContent(this.model.get('time'));
+ this.$.time.setContent(OB.UTIL.padNumber(creationDate.getHours(), 2) + ':' + OB.UTIL.padNumber(creationDate.getMinutes(), 2));
if (foreignAmt && ((this.model.get('rate') && this.model.get('rate') !== '1') || amnt !== foreignAmt)) {
this.$.foreignAmt.setContent('(' + foreignAmt + ' ' + this.model.get('isocode') + ')');
}
diff --git a/web/org.openbravo.retail.posterminal/js/model/cashmanagement.js b/web/org.openbravo.retail.posterminal/js/model/cashmanagement.js
--- a/web/org.openbravo.retail.posterminal/js/model/cashmanagement.js
+++ b/web/org.openbravo.retail.posterminal/js/model/cashmanagement.js
@@ -58,8 +58,12 @@
column: 'userId',
type: 'TEXT'
}, {
- name: 'time',
- column: 'time',
+ name: 'creationDate',
+ column: 'creationDate',
+ type: 'TEXT'
+ }, {
+ name: 'timezoneOffset',
+ column: 'timezoneOffset',
type: 'TEXT'
}, {
name: 'isocode',
issue #31757 Test v2 4858.patch [^] (5,373 bytes) 2015-12-31 09:56 [Show Content] [Hide Content]# HG changeset patch
# User Ranjith S R <ranjith@qualiantech.com>
# Date 1451482375 -19800
# Node ID 2f3d8275d561a357b90c866fc97f41097aa31290
# Parent 3fe078e17f75a26e6b92da3bef0dd2930f393cde
Verifies issue 31757: Added automated test 'I31757_CashMgmtTrxDate'
diff --git a/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashmanagement/I31757_CashMgmtTrxDate.java b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashmanagement/I31757_CashMgmtTrxDate.java
new file mode 100644
--- /dev/null
+++ b/src-test/org/openbravo/test/mobile/retail/pack/selenium/tests/cashmanagement/I31757_CashMgmtTrxDate.java
@@ -0,0 +1,107 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.0 (the "License"), being the Mozilla Public License
+ * Version 1.1 with a permitted attribution clause; you may not use this
+ * file except in compliance with the License. You may obtain a copy of
+ * the License at http://www.openbravo.com/legal/license.html
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * The Original Code is Openbravo ERP.
+ * The Initial Developer of the Original Code is Openbravo S.L.U.
+ * All portions are Copyright (C) 2015 Openbravo S.L.U.
+ * All Rights Reserved.
+ * Contributor(s):
+ ************************************************************************
+ *
+ * @author JGA
+ *
+ */
+
+package org.openbravo.test.mobile.retail.pack.selenium.tests.cashmanagement;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.TimeZone;
+
+import org.junit.Test;
+import org.openbravo.test.mobile.common.selenium.SeleniumHelper;
+import org.openbravo.test.mobile.common.selenium.database.DatabaseHelperSelect;
+import org.openbravo.test.mobile.common.selenium.database.WebPOSDatabaseConstants;
+import org.openbravo.test.mobile.common.selenium.javascript.TestId;
+import org.openbravo.test.mobile.common.selenium.terminals.WebPOSTerminalHelper;
+import org.openbravo.test.mobile.common.selenium.testhelpers.WebPOSSnippet;
+import org.openbravo.test.mobile.common.selenium.utils.OBUtils;
+
+public class I31757_CashMgmtTrxDate extends WebPOSTerminalHelper {
+
+ @Test
+ public void test() {
+ WebPOSSnippet.cleanCashup(this);
+
+ final String actualCashUpId = (String) SeleniumHelper
+ .executeScriptWithReturn("OB.MobileApp.model.get('terminal').cashUpId");
+ final String cashUpAmount = "10.57";
+
+ depositCash(cashUpAmount);
+
+ final StringBuffer jsGetCashUpDetails = new StringBuffer();
+ jsGetCashUpDetails.append("OBCustomVariable1 = '';");
+ jsGetCashUpDetails.append("OB.Dal.find(OB.Model.CashManagement, {}, function(cashMgmt) { ");
+ jsGetCashUpDetails.append("OBCustomVariable1 = cashMgmt.at(0).get('creationDate');");
+ jsGetCashUpDetails.append("});");
+
+ SeleniumHelper.executeScript(jsGetCashUpDetails.toString());
+ OBUtils.pause(1000);
+ final String cashMgmtTrxDateTime = (String) SeleniumHelper
+ .executeScriptWithReturn("OBCustomVariable1");
+
+ final DateFormat dateFormatISO = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
+ final TimeZone tz = TimeZone.getTimeZone("UTC");
+ dateFormatISO.setTimeZone(tz);
+
+ final String cashMgmtTrxISODateTime = cashMgmtTrxDateTime.substring(0,
+ cashMgmtTrxDateTime.length() - 8)
+ + "Z";
+
+ // Checking Front office Created date with Back office Transaction Date
+ final String sqlBackoffice = String
+ .format(
+ "select statementdate, dateacct from fin_finacc_transaction "
+ + " where fin_financial_account_id = '%s' and em_obpos_app_cashup_id = '%s' and depositamt = %s "
+ + " order by created desc",
+ WebPOSDatabaseConstants.VBS1001_CASHBOOK_STORE_CASH_FIN_ACCOUNT_ID, actualCashUpId,
+ cashUpAmount);
+ new DatabaseHelperSelect() {
+ @Override
+ protected void yieldResultSet(final ResultSet rs) throws SQLException {
+ assertThat("Cash Management Time from front office differs from Transaction date",
+ cashMgmtTrxISODateTime, equalTo(dateFormatISO.format(rs.getTimestamp("statementdate"))));
+ assertThat("Cash Management Time from front office differs from Accounting date",
+ cashMgmtTrxISODateTime, equalTo(dateFormatISO.format(rs.getTimestamp("statementdate"))));
+ }
+ }.execute(sqlBackoffice, 1);
+
+ WebPOSSnippet.cleanCashup(this);
+ }
+
+ private void depositCash(final String cashUpAmount) {
+ tap(TestId.BUTTON_MENU);
+ tap(TestId.BUTTON_MENU_CASHMANAGEMENT);
+
+ tap(TestId.BUTTON_CASHMANAGEMENT_CASHDEPOSIT);
+ write(TestId.INPUT_KEYPAD_CASHMGMT_EDITBOX, cashUpAmount);
+ tap(TestId.BUTTON_KEYPAD_ENTER);
+ tap(TestId.BUTTON_SELECTDEPOSIT_BACOFFICEVBS);
+ tap(TestId.BUTTON_CASHMANAGEMENT_DONE);
+ tap(TestId.BUTTON_POPUP_OK);
+ verify(TestId.LABEL_TOTALTOPAY, "0.00");
+ }
+}
|