diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_ELEMENT.xml
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_ELEMENT.xml Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_ELEMENT.xml Thu Sep 11 12:13:21 2014 +0200
@@ -88,6 +88,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -102,6 +116,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -156,6 +184,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -208,6 +250,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -308,6 +378,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -322,6 +406,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -336,6 +434,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -616,6 +728,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -845,6 +971,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -911,6 +1051,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1021,6 +1175,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1107,6 +1275,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1147,6 +1329,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_FIELD.xml Thu Sep 11 12:13:21 2014 +0200
@@ -19379,7 +19379,7 @@
-
+
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_MESSAGE.xml Thu Sep 11 12:13:21 2014 +0200
@@ -817,6 +817,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_REFERENCE.xml
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_REFERENCE.xml Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/AD_REFERENCE.xml Thu Sep 11 12:13:21 2014 +0200
@@ -313,6 +313,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUIAPP_PARAMETER.xml Thu Sep 11 12:13:21 2014 +0200
@@ -49,6 +49,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -72,6 +98,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -93,7 +145,7 @@
-
+
@@ -149,6 +201,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -197,7 +275,7 @@
-
+
@@ -251,7 +329,7 @@
-
+
@@ -360,6 +438,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -380,7 +484,7 @@
-
+
@@ -438,6 +542,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -464,6 +594,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -560,7 +716,7 @@
-
+
@@ -612,6 +768,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -656,7 +838,7 @@
- 0]]>
+
@@ -688,6 +870,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -697,23 +931,51 @@
-
-
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -740,6 +1002,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -761,7 +1049,7 @@
- 0 & @received_from@!'' & (@issotrx@ == true | @generateCredit@ == 0)]]>
+
@@ -789,7 +1077,7 @@
-
+
@@ -848,6 +1136,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -917,7 +1257,7 @@
-
+
@@ -971,7 +1311,8 @@
-
+
+
@@ -998,12 +1339,39 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1024,8 +1392,8 @@
-
-
+
+
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR.xml
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR.xml Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR.xml Thu Sep 11 12:13:21 2014 +0200
@@ -1,5 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -39,7 +55,7 @@
-
+
@@ -170,7 +186,7 @@
-
+ '94EAA455D2644E04AB25D93BE5157B6D'))]]>
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR_FIELD.xml
--- a/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR_FIELD.xml Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src-db/database/sourcedata/OBUISEL_SELECTOR_FIELD.xml Thu Sep 11 12:13:21 2014 +0200
@@ -151,7 +151,7 @@
-
+
@@ -261,7 +261,7 @@
-
+
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentActionHandler.java Thu Sep 11 12:13:21 2014 +0200
@@ -82,13 +82,25 @@
protected JSONObject doExecute(Map parameters, String content) {
JSONObject jsonResponse = new JSONObject();
OBContext.setAdminMode(true);
+ boolean openedFromMenu = false;
try {
VariablesSecureApp vars = RequestContext.get().getVariablesSecureApp();
// Get Params
JSONObject jsonRequest = new JSONObject(content);
JSONObject jsonparams = jsonRequest.getJSONObject("_params");
- final String strOrgId = jsonRequest.getString("inpadOrgId");
+ if (jsonRequest.has("inpwindowId") && jsonRequest.get("inpwindowId") != JSONObject.NULL) {
+ openedFromMenu = false;
+ } else {
+ openedFromMenu = "null".equals(parameters.get("windowId").toString()) ? true : false;
+ }
+
+ String strOrgId = null;
+ if (jsonRequest.has("inpadOrgId") && jsonRequest.get("inpadOrgId") != JSONObject.NULL) {
+ strOrgId = jsonRequest.getString("inpadOrgId");
+ } else if (jsonparams.has("ad_org_id") && jsonparams.get("ad_org_id") != JSONObject.NULL) {
+ strOrgId = jsonparams.getString("ad_org_id");
+ }
Organization org = OBDal.getInstance().get(Organization.class, strOrgId);
boolean isReceipt = jsonparams.getBoolean("issotrx");
@@ -153,6 +165,7 @@
JSONObject errorMessage = new JSONObject();
errorMessage.put("severity", "error");
errorMessage.put("text", e.getMessage());
+ jsonResponse.put("retryExecution", openedFromMenu);
jsonResponse.put("message", errorMessage);
return jsonResponse;
}
@@ -177,7 +190,20 @@
errorMessage.put("severity", message.getType().toLowerCase());
errorMessage.put("title", message.getTitle());
errorMessage.put("text", message.getMessage());
+ jsonResponse.put("retryExecution", openedFromMenu);
jsonResponse.put("message", errorMessage);
+ jsonResponse.put("refreshParent", false);
+ JSONObject setSelectorValueFromRecord = new JSONObject();
+ JSONObject record = new JSONObject();
+ JSONObject responseActions = new JSONObject();
+ record.put("value", payment.getId());
+ record.put("map", payment.getIdentifier());
+ setSelectorValueFromRecord.put("record", record);
+ responseActions.put("setSelectorValueFromRecord", setSelectorValueFromRecord);
+ if (openedFromMenu) {
+ responseActions.put("reloadParameters", setSelectorValueFromRecord);
+ }
+ jsonResponse.put("responseActions", responseActions);
}
} catch (Exception e) {
@@ -191,6 +217,7 @@
JSONObject errorMessage = new JSONObject();
errorMessage.put("severity", "error");
errorMessage.put("text", message);
+ jsonResponse.put("retryExecution", openedFromMenu);
jsonResponse.put("message", errorMessage);
} catch (Exception ignore) {
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentDisplayLogicActionHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentDisplayLogicActionHandler.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,114 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.advpaymentmngt.actionHandler;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.servlet.http.HttpSession;
+
+import org.codehaus.jettison.json.JSONArray;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.client.application.Parameter;
+import org.openbravo.client.application.ParameterUtils;
+import org.openbravo.client.kernel.BaseActionHandler;
+import org.openbravo.client.kernel.KernelConstants;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.service.db.DbUtility;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AddPaymentDisplayLogicActionHandler extends BaseActionHandler {
+ private static Logger log = LoggerFactory.getLogger(AddPaymentDisplayLogicActionHandler.class);
+
+ @Override
+ protected final JSONObject execute(Map parameters, String data) {
+ JSONObject result = new JSONObject();
+ JSONObject values = new JSONObject();
+ JSONObject errorMessage = new JSONObject();
+ OBContext.setAdminMode(true);
+ try {
+ final JSONObject jsonData = new JSONObject(data);
+ final JSONArray affectedParams = jsonData.getJSONArray("affectedParams");
+ final JSONObject params = jsonData.getJSONObject("params");
+
+ Iterator keys = params.keys();
+ while (keys.hasNext()) {
+ String key = keys.next();
+ Object value = params.get(key);
+ parameters.put(key, value);
+ }
+
+ for (int i = 0; i < affectedParams.length(); i++) {
+ Parameter param = OBDal.getInstance().get(Parameter.class, affectedParams.getString(i));
+ Object defaultValue = null;
+ Map requestMap = fixRequestMap(parameters);
+ requestMap.put("currentParam", param.getDBColumnName());
+ defaultValue = ParameterUtils.getJSExpressionResult(requestMap,
+ (HttpSession) parameters.get(KernelConstants.HTTP_SESSION), param.getDefaultValue());
+ values.put(param.getDBColumnName(), defaultValue);
+ }
+ result.put("values", values);
+
+ String message = "Ok";
+ errorMessage.put("severity", "success");
+ errorMessage.put("text", message);
+ result.put("message", errorMessage);
+ } catch (Exception e) {
+ OBDal.getInstance().rollbackAndClose();
+ log.error(e.getMessage(), e);
+ try {
+ Throwable ex = DbUtility.getUnderlyingSQLException(e);
+ String message = OBMessageUtils.translateError(ex.getMessage()).getMessage();
+ errorMessage = new JSONObject();
+ errorMessage.put("severity", "error");
+ errorMessage.put("title", "Error");
+ errorMessage.put("text", message);
+ result.put("message", errorMessage);
+ } catch (Exception e2) {
+ log.error(e.getMessage(), e2);
+ // do nothing, give up
+ }
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ return result;
+ }
+
+ /*
+ * The request map is because includes the HTTP request and HTTP session, is not
+ * required to handle process parameters
+ */
+ protected Map fixRequestMap(Map parameters) {
+ final Map retval = new HashMap();
+ for (Entry entries : parameters.entrySet()) {
+ if (entries.getKey().equals(KernelConstants.HTTP_REQUEST)
+ || entries.getKey().equals(KernelConstants.HTTP_SESSION)) {
+ continue;
+ }
+ retval.put(entries.getKey(), entries.getValue().toString());
+ }
+ return retval;
+ }
+}
\ No newline at end of file
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentDocumentNoActionHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentDocumentNoActionHandler.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,52 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.advpaymentmngt.actionHandler;
+
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.advpaymentmngt.utility.FIN_Utility;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.client.kernel.BaseActionHandler;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.enterprise.Organization;
+
+public class AddPaymentDocumentNoActionHandler extends BaseActionHandler {
+
+ @Override
+ protected JSONObject execute(Map parameters, String data) {
+ try {
+ final JSONObject jsonData = new JSONObject(data);
+ JSONObject result = new JSONObject();
+ String strDocNo = null;
+ final String strOrganization = jsonData.getString("organization");
+ if (StringUtils.isNotEmpty(strOrganization)) {
+ Organization organization = OBDal.getInstance().get(Organization.class, strOrganization);
+ strDocNo = FIN_Utility.getDocumentNo(organization, jsonData.getString("issotrx").toString()
+ .equals("true") ? "ARR" : "APP", "FIN_Payment", false);
+ }
+ result.put("payment_documentno", "<" + strDocNo + ">");
+ return result;
+ } catch (Exception e) {
+ throw new OBException(e);
+ }
+ }
+}
\ No newline at end of file
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentOrganizationActionHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentOrganizationActionHandler.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,54 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.advpaymentmngt.actionHandler;
+
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.client.kernel.BaseActionHandler;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.currency.Currency;
+import org.openbravo.model.common.enterprise.Organization;
+
+public class AddPaymentOrganizationActionHandler extends BaseActionHandler {
+
+ @Override
+ protected JSONObject execute(Map parameters, String data) {
+ try {
+ final JSONObject jsonData = new JSONObject(data);
+ JSONObject result = new JSONObject();
+ Currency currency = null;
+ final String strOrganization = jsonData.getString("organization");
+ if (StringUtils.isNotEmpty(strOrganization)) {
+ Organization organization = OBDal.getInstance().get(Organization.class, strOrganization);
+ currency = OBContext.getOBContext().getOrganizationStructureProvider()
+ .getLegalEntity(organization).getCurrency();
+ }
+ result.put("currency", currency.getId());
+ result.put("currencyIdIdentifier", currency.getIdentifier());
+ return result;
+ } catch (Exception e) {
+ throw new OBException(e);
+ }
+ }
+}
\ No newline at end of file
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentReloadLabelsActionHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/AddPaymentReloadLabelsActionHandler.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,124 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.advpaymentmngt.actionHandler;
+
+import java.util.List;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONObject;
+import org.hibernate.criterion.Restrictions;
+import org.openbravo.client.application.Parameter;
+import org.openbravo.client.kernel.BaseActionHandler;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.openbravo.model.ad.system.Language;
+import org.openbravo.model.ad.ui.ElementTrl;
+import org.openbravo.service.db.DbUtility;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AddPaymentReloadLabelsActionHandler extends BaseActionHandler {
+ private static Logger log = LoggerFactory.getLogger(AddPaymentReloadLabelsActionHandler.class);
+
+ @Override
+ protected JSONObject execute(Map parameters, String data) {
+ JSONObject result = new JSONObject();
+ JSONObject values = new JSONObject();
+ JSONObject errorMessage = new JSONObject();
+ OBContext.setAdminMode(true);
+ try {
+ final String strBusinessPartner = (String) parameters.get("businessPartner");
+ final String strFinancialAccount = (String) parameters.get("financialAccount");
+ final String strIssotrx = (String) parameters.get("issotrx");
+ boolean issotrx = "true".equals(strIssotrx) ? true : false;
+ final Parameter businessPartner = OBDal.getInstance()
+ .get(Parameter.class, strBusinessPartner);
+ final Parameter financialAccount = OBDal.getInstance().get(Parameter.class,
+ strFinancialAccount);
+ final Language language = OBContext.getOBContext().getLanguage();
+
+ final OBCriteria obcBP = OBDal.getInstance().createCriteria(ElementTrl.class);
+ obcBP.add(Restrictions.eq(ElementTrl.PROPERTY_ID, businessPartner.getApplicationElement()
+ .getId()));
+ obcBP.add(Restrictions.eq(ElementTrl.PROPERTY_LANGUAGE, language));
+ final List obcListBP = obcBP.list();
+ if (obcListBP.size() > 0) {
+ if (issotrx) {
+ values.put("businessPartner", obcListBP.get(0).getName());
+ } else {
+ values.put("businessPartner", obcListBP.get(0).getPurchaseOrderName());
+ }
+ } else {
+ if (issotrx) {
+ values.put("businessPartner", businessPartner.getApplicationElement().getName());
+ } else {
+ values.put("businessPartner", businessPartner.getApplicationElement()
+ .getPurchaseOrderName());
+ }
+ }
+
+ final OBCriteria obcFA = OBDal.getInstance().createCriteria(ElementTrl.class);
+ obcFA.add(Restrictions.eq(ElementTrl.PROPERTY_ID, financialAccount.getApplicationElement()
+ .getId()));
+ obcFA.add(Restrictions.eq(ElementTrl.PROPERTY_LANGUAGE, language));
+ final List obcListFA = obcFA.list();
+ if (obcListFA.size() > 0) {
+ if (issotrx) {
+ values.put("financialAccount", obcListFA.get(0).getName());
+ } else {
+ values.put("financialAccount", obcListFA.get(0).getPurchaseOrderName());
+ }
+ } else {
+ if (issotrx) {
+ values.put("financialAccount", financialAccount.getApplicationElement().getName());
+ } else {
+ values.put("financialAccount", financialAccount.getApplicationElement()
+ .getPurchaseOrderName());
+ }
+ }
+
+ String message = "Ok";
+ errorMessage.put("severity", "success");
+ errorMessage.put("text", message);
+ result.put("values", values);
+ result.put("message", errorMessage);
+ } catch (Exception e) {
+ OBDal.getInstance().rollbackAndClose();
+ log.error(e.getMessage(), e);
+ try {
+ Throwable ex = DbUtility.getUnderlyingSQLException(e);
+ String message = OBMessageUtils.translateError(ex.getMessage()).getMessage();
+ errorMessage = new JSONObject();
+ errorMessage.put("severity", "error");
+ errorMessage.put("title", "Error");
+ errorMessage.put("text", message);
+ result.put("message", errorMessage);
+ } catch (Exception e2) {
+ log.error(e.getMessage(), e2);
+ // do nothing, give up
+ }
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ return result;
+ }
+}
\ No newline at end of file
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/PaymentMethodMulticurrencyActionHandler.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/PaymentMethodMulticurrencyActionHandler.java Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/PaymentMethodMulticurrencyActionHandler.java Thu Sep 11 12:13:21 2014 +0200
@@ -46,14 +46,24 @@
final String paymentMethodId = jsonData.getString("paymentMethodId");
final String financialAccountId = jsonData.getString("financialAccountId");
final boolean isSOTrx = jsonData.getBoolean("isSOTrx");
- final String currencyId = jsonData.getString("currencyId");
+ String currencyId = jsonData.getString("currencyId");
final String strPaymentDate = jsonData.getString("paymentDate");
Date paymentDate = JsonUtils.createDateFormat().parse(strPaymentDate);
final String strOrgId = jsonData.getString("orgId");
+ JSONObject result = new JSONObject();
+
+ if ("null".equals(currencyId) && !"null".equals(financialAccountId)
+ && !"".equals(financialAccountId)) {
+ FIN_FinancialAccount financialAccount = OBDal.getInstance().get(FIN_FinancialAccount.class,
+ financialAccountId);
+ currencyId = financialAccount.getCurrency().getId();
+ result.put("currencyIdIdentifier", financialAccount.getCurrency().getIdentifier());
+ result.put("currencyId", currencyId);
+ }
+
final FinAccPaymentMethod finAccPaymentMethod = getFinancialAccountPaymentMethod(
paymentMethodId, financialAccountId);
- JSONObject result = new JSONObject();
if (finAccPaymentMethod != null) {
result.put("isPayIsMulticurrency", isSOTrx ? finAccPaymentMethod.isPayinIsMulticurrency()
: finAccPaymentMethod.isPayoutIsMulticurrency());
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/ReceivedFromPaymentMethodActionHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/actionHandler/ReceivedFromPaymentMethodActionHandler.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,77 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.advpaymentmngt.actionHandler;
+
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.client.kernel.BaseActionHandler;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.financialmgmt.payment.FIN_FinancialAccount;
+import org.openbravo.model.financialmgmt.payment.FIN_PaymentMethod;
+import org.openbravo.model.financialmgmt.payment.FinAccPaymentMethod;
+
+public class ReceivedFromPaymentMethodActionHandler extends BaseActionHandler {
+
+ @Override
+ protected JSONObject execute(Map parameters, String data) {
+ try {
+ final JSONObject jsonData = new JSONObject(data);
+ JSONObject result = new JSONObject();
+ FIN_FinancialAccount financialAccount = OBDal.getInstance().get(FIN_FinancialAccount.class,
+ jsonData.getString("financialAccount"));
+ boolean contains = false;
+ String paymentMethod = null;
+
+ if (financialAccount != null) {
+ if (jsonData.has("receivedFrom") && jsonData.get("receivedFrom") != JSONObject.NULL) {
+ final String receivedFrom = jsonData.getString("receivedFrom");
+ BusinessPartner businessPartner = OBDal.getInstance().get(BusinessPartner.class,
+ receivedFrom);
+ if (jsonData.getString("isSOTrx").toString().equals("true")) {
+ paymentMethod = businessPartner.getPaymentMethod().getId();
+ } else {
+ paymentMethod = businessPartner.getPOPaymentMethod().getId();
+ }
+ for (FinAccPaymentMethod finAccPaymentMethod : financialAccount
+ .getFinancialMgmtFinAccPaymentMethodList()) {
+ if (finAccPaymentMethod.getPaymentMethod().equals(
+ OBDal.getInstance().get(FIN_PaymentMethod.class, paymentMethod))) {
+ contains = true;
+ } else {
+ contains = false;
+ }
+ }
+ }
+ } else {
+ contains = false;
+ }
+ if (!contains) {
+ paymentMethod = "";
+ }
+ result.put("paymentMethodId", paymentMethod);
+ return result;
+ } catch (Exception e) {
+ throw new OBException(e);
+ }
+ }
+}
\ No newline at end of file
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddOrderOrInvoiceFilterExpressionHandler.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddOrderOrInvoiceFilterExpressionHandler.java Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddOrderOrInvoiceFilterExpressionHandler.java Thu Sep 11 12:13:21 2014 +0200
@@ -48,6 +48,14 @@
protected abstract long getSeq();
+ /**
+ * This method gets called to obtain the default filtering values for the grid. It can be
+ * overwritten using Injections.
+ *
+ * @param requestMap
+ * @return String containing the value for the filter expression
+ * @throws JSONException
+ */
String getFilterExpression(Map requestMap) throws JSONException {
return getDefaultPaymentMethod(requestMap);
}
@@ -76,8 +84,8 @@
final String strWindowId = context.getString(OBBindingsConstants.WINDOW_ID_PARAM);
AddPaymentDefaultValuesHandler handler = getDefaultsHandler(strWindowId);
String paymentMethodId = handler.getDefaultPaymentMethod(requestMap);
- if (context.has("inpfinPaymentId") && context.get("inpfinPaymentId") != null
- && StringUtils.isNotBlank((String) context.get("inpfinPaymentId"))) {
+ if (context.has("inpfinPaymentId") && context.get("inpfinPaymentId") != JSONObject.NULL
+ && StringUtils.isNotBlank((String) context.getString("inpfinPaymentId"))) {
if (hasDetailsWithDifferentPaymentMethods((String) context.get("inpfinPaymentId"))) {
return "";
} else {
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesExpression.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesExpression.java Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesExpression.java Thu Sep 11 12:13:21 2014 +0200
@@ -102,6 +102,8 @@
return handler.getDefaultCurrency(requestMap);
case Organization:
return handler.getOrganization(requestMap);
+ case Document:
+ return handler.getDefaultDocument(requestMap);
}
} catch (Exception e) {
log.error("Error trying to get default value of " + strCurrentParam + " " + e.getMessage(),
@@ -118,8 +120,13 @@
private String getWindowId(Map requestMap) throws JSONException {
final String strContext = requestMap.get("context");
- JSONObject context = new JSONObject(strContext);
- return context.getString(OBBindingsConstants.WINDOW_ID_PARAM);
+ if (strContext != null) {
+ JSONObject context = new JSONObject(strContext);
+ if (context != null && context.has(OBBindingsConstants.WINDOW_ID_PARAM)) {
+ return context.getString(OBBindingsConstants.WINDOW_ID_PARAM);
+ }
+ }
+ return "NULLWINDOWID";
}
private AddPaymentDefaultValuesHandler getHandler(String strWindowId) {
@@ -147,7 +154,7 @@
"customer_credit"), IsSOTrx("issotrx"), Payment("fin_payment_id"), Invoice("c_invoice_id"), Order(
"c_order_id"), ConversionRate("conversion_rate"), ConvertedAmount("converted_amount"), StandardPrecision(
"StdPrecision"), GenerateCredit("generateCredit"), DocumentCategory("DOCBASETYPE"), ReferenceNo(
- "reference_no"), Currency("c_currency_id"), Organization("ad_org_id");
+ "reference_no"), Currency("c_currency_id"), Organization("ad_org_id"), Document("trxtype");
private String columnname;
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDefaultValuesHandler.java Thu Sep 11 12:13:21 2014 +0200
@@ -40,40 +40,53 @@
import org.openbravo.model.financialmgmt.payment.FIN_PaymentScheduleDetail;
@RequestScoped
-abstract class AddPaymentDefaultValuesHandler {
+public abstract class AddPaymentDefaultValuesHandler {
- abstract String getDefaultExpectedAmount(Map requestMap) throws JSONException;
+ public abstract String getDefaultExpectedAmount(Map requestMap)
+ throws JSONException;
- abstract String getDefaultActualAmount(Map requestMap) throws JSONException;
+ public abstract String getDefaultActualAmount(Map requestMap)
+ throws JSONException;
- abstract String getDefaultIsSOTrx(Map requestMap) throws JSONException;
+ public abstract String getDefaultIsSOTrx(Map requestMap) throws JSONException;
- abstract String getDefaultTransactionType(Map requestMap) throws JSONException;
+ public abstract String getDefaultTransactionType(Map requestMap)
+ throws JSONException;
- abstract String getDefaultPaymentType(Map requestMap) throws JSONException;
+ public abstract String getDefaultPaymentType(Map requestMap) throws JSONException;
- abstract String getDefaultOrderType(Map requestMap) throws JSONException;
+ public abstract String getDefaultOrderType(Map requestMap) throws JSONException;
- abstract String getDefaultInvoiceType(Map requestMap) throws JSONException;
+ public abstract String getDefaultInvoiceType(Map requestMap) throws JSONException;
- abstract String getDefaultConversionRate(Map requestMap) throws JSONException;
+ public abstract String getDefaultConversionRate(Map requestMap)
+ throws JSONException;
- abstract String getDefaultConvertedAmount(Map requestMap) throws JSONException;
+ public abstract String getDefaultConvertedAmount(Map requestMap)
+ throws JSONException;
- abstract String getDefaultReceivedFrom(Map requestMap) throws JSONException;
+ public abstract String getDefaultReceivedFrom(Map requestMap)
+ throws JSONException;
- abstract String getDefaultStandardPrecision(Map requestMap) throws JSONException;
+ public abstract String getDefaultStandardPrecision(Map requestMap)
+ throws JSONException;
- abstract String getDefaultCurrency(Map requestMap) throws JSONException;
+ public abstract String getDefaultCurrency(Map requestMap) throws JSONException;
- abstract String getOrganization(Map requestMap) throws JSONException;
+ public abstract String getOrganization(Map requestMap) throws JSONException;
- abstract String getDefaultPaymentDate(Map requestMap) throws JSONException;
+ public abstract String getDefaultDocument(Map requestMap) throws JSONException;
+
+ public abstract String getDefaultPaymentDate(Map requestMap) throws JSONException;
protected abstract long getSeq();
- String getDefaultCurrencyTo(Map requestMap) throws JSONException {
- JSONObject context = new JSONObject(requestMap.get("context"));
+ public String getDefaultCurrencyTo(Map requestMap) throws JSONException {
+ String strContext = requestMap.get("context");
+ if (strContext == null) {
+ return "";
+ }
+ JSONObject context = new JSONObject(strContext);
if (context.has("inpfinFinancialAccountId")
&& context.get("inpfinFinancialAccountId") != JSONObject.NULL
&& StringUtils.isNotEmpty(context.getString("inpfinFinancialAccountId"))) {
@@ -96,7 +109,7 @@
return null;
}
- String getDefaultCustomerCredit(Map requestMap) throws JSONException {
+ public String getDefaultCustomerCredit(Map requestMap) throws JSONException {
String strBusinessPartnerId = getDefaultReceivedFrom(requestMap);
String strOrgId = getOrganization(requestMap);
String strReceipt = getDefaultIsSOTrx(requestMap);
@@ -111,10 +124,14 @@
}
- String getDefaultDocumentNo(Map requestMap) throws JSONException {
- JSONObject context = new JSONObject(requestMap.get("context"));
+ public String getDefaultDocumentNo(Map requestMap) throws JSONException {
+ String strContext = requestMap.get("context");
+ String strOrgId = getOrganization(requestMap);
+ if (strContext == null) {
+ return "";
+ }
- Organization org = OBDal.getInstance().get(Organization.class, context.get("inpadOrgId"));
+ Organization org = OBDal.getInstance().get(Organization.class, strOrgId);
boolean isReceipt = "Y".equals(getDefaultIsSOTrx(requestMap));
String strDocNo = FIN_Utility.getDocumentNo(org, isReceipt ? "ARR" : "APP", "FIN_Payment",
@@ -124,11 +141,19 @@
}
public String getDefaultFinancialAccount(Map requestMap) throws JSONException {
- JSONObject context = new JSONObject(requestMap.get("context"));
+ String strContext = requestMap.get("context");
+ if (strContext == null) {
+ return "";
+ }
+ JSONObject context = new JSONObject(strContext);
if (context.has("inpfinFinancialAccountId")
&& context.get("inpfinFinancialAccountId") != JSONObject.NULL
&& StringUtils.isNotEmpty(context.getString("inpfinFinancialAccountId"))) {
return context.getString("inpfinFinancialAccountId");
+ } else if (context.has("Fin_Financial_Account_ID")
+ && context.get("Fin_Financial_Account_ID") != JSONObject.NULL
+ && StringUtils.isNotEmpty(context.getString("Fin_Financial_Account_ID"))) {
+ return context.getString("Fin_Financial_Account_ID");
}
String strBPartnerId = getDefaultReceivedFrom(requestMap);
@@ -160,8 +185,12 @@
return null;
}
- String getDefaultPaymentMethod(Map requestMap) throws JSONException {
- JSONObject context = new JSONObject(requestMap.get("context"));
+ public String getDefaultPaymentMethod(Map requestMap) throws JSONException {
+ String strContext = requestMap.get("context");
+ if (strContext == null) {
+ return "";
+ }
+ JSONObject context = new JSONObject(strContext);
if (context.has("inpfinPaymentmethodId")
&& context.get("inpfinPaymentmethodId") != JSONObject.NULL
&& StringUtils.isNotEmpty(context.getString("inpfinPaymentmethodId"))) {
@@ -181,7 +210,7 @@
return null;
}
- BigDecimal getPendingAmt(List pslist) {
+ public BigDecimal getPendingAmt(List pslist) {
BigDecimal pendingAmt = BigDecimal.ZERO;
for (FIN_PaymentSchedule ps : pslist) {
List psds = null;
@@ -199,12 +228,12 @@
return pendingAmt;
}
- String getDefaultGeneratedCredit(Map requestMap) throws JSONException {
+ public String getDefaultGeneratedCredit(Map requestMap) throws JSONException {
BigDecimal generateCredit = BigDecimal.ZERO;
return generateCredit.toPlainString();
}
- String getDefaultDocumentCategory(Map requestMap) throws JSONException {
+ public String getDefaultDocumentCategory(Map requestMap) throws JSONException {
boolean isSOTrx = "Y".equals(getDefaultIsSOTrx(requestMap));
if (isSOTrx) {
return "ARR";
@@ -215,7 +244,11 @@
}
public String getDefaultReferenceNo(Map requestMap) throws JSONException {
- JSONObject context = new JSONObject(requestMap.get("context"));
+ String strContext = requestMap.get("context");
+ if (strContext == null) {
+ return "";
+ }
+ JSONObject context = new JSONObject(strContext);
if (!context.has("inpfinPaymentId")) {
return null;
}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDisplayLogicsExpression.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDisplayLogicsExpression.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,135 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.util.Map;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.client.application.FilterExpression;
+import org.openbravo.client.application.OBBindingsConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AddPaymentDisplayLogicsExpression implements FilterExpression {
+ private static final Logger log = LoggerFactory
+ .getLogger(AddPaymentDisplayLogicsExpression.class);
+ @Inject
+ @Any
+ private Instance addPaymentFilterExpressionHandlers;
+
+ @Override
+ public String getExpression(Map requestMap) {
+ String strCurrentParam = "";
+ try {
+ OBContext.setAdminMode(true);
+ final String strWindowId = getWindowId(requestMap);
+
+ AddPaymentDisplayLogicsHandler handler = getHandler(strWindowId);
+ if (handler == null) {
+ throw new OBException(String.format(OBMessageUtils.messageBD("APRM_NOHANDLER")));
+ }
+ strCurrentParam = requestMap.get("currentParam");
+ Parameters param = Parameters.getParameter(strCurrentParam);
+ try {
+ switch (param) {
+ case Organization:
+ return handler.getOrganizationDisplayLogic(requestMap) ? "Y" : "N";
+ case Document:
+ return handler.getDocumentDisplayLogic(requestMap) ? "Y" : "N";
+ case CreditToUse:
+ return handler.getCreditToUseDisplayLogic(requestMap) ? "Y" : "N";
+ case OverpaymentAction:
+ return handler.getOverpaymentActionDisplayLogic(requestMap) ? "Y" : "N";
+ }
+ } catch (Exception e) {
+ log.error("Error trying to get default value of " + strCurrentParam + " " + e.getMessage(),
+ e);
+ return null;
+ }
+ } catch (JSONException ignore) {
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ log.error("No default value found for param: " + strCurrentParam);
+ return null;
+ }
+
+ private String getWindowId(Map requestMap) throws JSONException {
+ final String strContext = requestMap.get("context");
+ if (strContext != null) {
+ JSONObject context = new JSONObject(strContext);
+ if (context != null && context.has(OBBindingsConstants.WINDOW_ID_PARAM)) {
+ return context.getString(OBBindingsConstants.WINDOW_ID_PARAM);
+ }
+ }
+ return "NULLWINDOWID";
+ }
+
+ private AddPaymentDisplayLogicsHandler getHandler(String strWindowId) {
+ AddPaymentDisplayLogicsHandler handler = null;
+ for (AddPaymentDisplayLogicsHandler nextHandler : addPaymentFilterExpressionHandlers
+ .select(new ComponentProvider.Selector(strWindowId))) {
+ if (handler == null) {
+ handler = nextHandler;
+ } else if (nextHandler.getSeq() < handler.getSeq()) {
+ handler = nextHandler;
+ } else if (nextHandler.getSeq() == handler.getSeq()) {
+ log.warn(
+ "Trying to get handler for window with id {}, there are more than one instance with the same sequence",
+ strWindowId);
+ }
+ }
+ return handler;
+ }
+
+ private enum Parameters {
+ Organization("ad_org_id_display_logic"), Document("trxtype_display_logic"), CreditToUse(
+ "credit_to_use_display_logic"), OverpaymentAction("overpayment_action_display_logic");
+
+ private String columnname;
+
+ Parameters(String columnname) {
+ this.columnname = columnname;
+ }
+
+ public String getColumnName() {
+ return this.columnname;
+ }
+
+ static Parameters getParameter(String strColumnName) {
+ for (Parameters parameter : Parameters.values()) {
+ if (strColumnName.equals(parameter.getColumnName())) {
+ return parameter;
+ }
+ }
+ return null;
+ }
+ }
+
+}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDisplayLogicsHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentDisplayLogicsHandler.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,63 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import javax.enterprise.context.RequestScoped;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+
+@RequestScoped
+public abstract class AddPaymentDisplayLogicsHandler {
+
+ public abstract boolean getOrganizationDisplayLogic(Map requestMap)
+ throws JSONException;
+
+ public abstract boolean getDocumentDisplayLogic(Map requestMap)
+ throws JSONException;
+
+ public abstract boolean getCreditToUseDisplayLogic(Map requestMap)
+ throws JSONException;
+
+ protected abstract long getSeq();
+
+ public boolean getOverpaymentActionDisplayLogic(Map requestMap)
+ throws JSONException {
+ String strContext = requestMap.get("context");
+ if (strContext == null) {
+ return false;
+ }
+ JSONObject context = new JSONObject(strContext);
+ if (context.has("difference")) {
+ double diff = context.getDouble("difference");
+ BigDecimal difference = new BigDecimal(diff);
+ if (difference.signum() > 0) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+
+ }
+}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentReadOnlyLogicsExpression.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentReadOnlyLogicsExpression.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,148 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.util.Map;
+
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.base.exception.OBException;
+import org.openbravo.client.application.FilterExpression;
+import org.openbravo.client.application.OBBindingsConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.erpCommon.utility.OBMessageUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AddPaymentReadOnlyLogicsExpression implements FilterExpression {
+ private static final Logger log = LoggerFactory
+ .getLogger(AddPaymentReadOnlyLogicsExpression.class);
+ @Inject
+ @Any
+ private Instance addPaymentFilterExpressionHandlers;
+
+ @Override
+ public String getExpression(Map requestMap) {
+ String strCurrentParam = "";
+ try {
+ OBContext.setAdminMode(true);
+ final String strWindowId = getWindowId(requestMap);
+
+ AddPaymentReadOnlyLogicsHandler handler = getHandler(strWindowId);
+ if (handler == null) {
+ throw new OBException(String.format(OBMessageUtils.messageBD("APRM_NOHANDLER")));
+ }
+ strCurrentParam = requestMap.get("currentParam");
+ Parameters param = Parameters.getParameter(strCurrentParam);
+ try {
+ switch (param) {
+ case PaymentDocumentNo:
+ return handler.getPaymentDocumentNoReadOnlyLogic(requestMap) ? "Y" : "N";
+ case ReceivedFrom:
+ return handler.getReceivedFromReadOnlyLogic(requestMap) ? "Y" : "N";
+ case PaymentMethod:
+ return handler.getPaymentMethodReadOnlyLogic(requestMap) ? "Y" : "N";
+ case ActualPayment:
+ return handler.getActualPaymentReadOnlyLogic(requestMap) ? "Y" : "N";
+ case ConvertedAmount:
+ return handler.getConvertedAmountReadOnlyLogic(requestMap) ? "Y" : "N";
+ case PaymentDate:
+ return handler.getPaymentDateReadOnlyLogic(requestMap) ? "Y" : "N";
+ case FinancialAccount:
+ return handler.getFinancialAccountReadOnlyLogic(requestMap) ? "Y" : "N";
+ case ConversionRate:
+ return handler.getConversionRateReadOnlyLogic(requestMap) ? "Y" : "N";
+ case Currency:
+ return handler.getCurrencyReadOnlyLogic(requestMap) ? "Y" : "N";
+ }
+ } catch (Exception e) {
+ log.error("Error trying to get default value of " + strCurrentParam + " " + e.getMessage(),
+ e);
+ return null;
+ }
+ } catch (JSONException ignore) {
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ log.error("No default value found for param: " + strCurrentParam);
+ return null;
+ }
+
+ private String getWindowId(Map requestMap) throws JSONException {
+ final String strContext = requestMap.get("context");
+ if (strContext != null) {
+ JSONObject context = new JSONObject(strContext);
+ if (context != null && context.has(OBBindingsConstants.WINDOW_ID_PARAM)) {
+ return context.getString(OBBindingsConstants.WINDOW_ID_PARAM);
+ }
+ }
+ return "NULLWINDOWID";
+ }
+
+ private AddPaymentReadOnlyLogicsHandler getHandler(String strWindowId) {
+ AddPaymentReadOnlyLogicsHandler handler = null;
+ for (AddPaymentReadOnlyLogicsHandler nextHandler : addPaymentFilterExpressionHandlers
+ .select(new ComponentProvider.Selector(strWindowId))) {
+ if (handler == null) {
+ handler = nextHandler;
+ } else if (nextHandler.getSeq() < handler.getSeq()) {
+ handler = nextHandler;
+ } else if (nextHandler.getSeq() == handler.getSeq()) {
+ log.warn(
+ "Trying to get handler for window with id {}, there are more than one instance with the same sequence",
+ strWindowId);
+ }
+ }
+ return handler;
+ }
+
+ private enum Parameters {
+ PaymentDocumentNo("payment_documentno_readonly_logic"), ReceivedFrom(
+ "received_from_readonly_logic"), PaymentMethod("payment_method_readonly_logic"), ActualPayment(
+ "actual_payment_readonly_logic"), ConvertedAmount("converted_amount_readonly_logic"), PaymentDate(
+ "payment_date_readonly_logic"), FinancialAccount("fin_financial_account_id_readonly_logic"), ConversionRate(
+ "conversion_rate_readonly_logic"), Currency("c_currency_id_readonly_logic");
+
+ private String columnname;
+
+ Parameters(String columnname) {
+ this.columnname = columnname;
+ }
+
+ public String getColumnName() {
+ return this.columnname;
+ }
+
+ static Parameters getParameter(String strColumnName) {
+ for (Parameters parameter : Parameters.values()) {
+ if (strColumnName.equals(parameter.getColumnName())) {
+ return parameter;
+ }
+ }
+ return null;
+ }
+ }
+
+}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentReadOnlyLogicsHandler.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/AddPaymentReadOnlyLogicsHandler.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,126 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.util.Map;
+
+import javax.enterprise.context.RequestScoped;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.dal.core.OBContext;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.erpCommon.utility.PropertyException;
+import org.openbravo.erpCommon.utility.PropertyNotFoundException;
+import org.openbravo.model.ad.ui.Window;
+import org.openbravo.scheduling.ProcessLogger;
+
+@RequestScoped
+public abstract class AddPaymentReadOnlyLogicsHandler {
+
+ private static ProcessLogger logger;
+
+ public abstract boolean getPaymentDocumentNoReadOnlyLogic(Map requestMap)
+ throws JSONException;
+
+ public abstract boolean getReceivedFromReadOnlyLogic(Map requestMap)
+ throws JSONException;
+
+ public abstract boolean getPaymentMethodReadOnlyLogic(Map requestMap)
+ throws JSONException;
+
+ public abstract boolean getActualPaymentReadOnlyLogic(Map requestMap)
+ throws JSONException;
+
+ public abstract boolean getPaymentDateReadOnlyLogic(Map requestMap)
+ throws JSONException;
+
+ public abstract boolean getFinancialAccountReadOnlyLogic(Map requestMap)
+ throws JSONException;
+
+ public abstract boolean getCurrencyReadOnlyLogic(Map requestMap)
+ throws JSONException;
+
+ protected abstract long getSeq();
+
+ public boolean getConvertedAmountReadOnlyLogic(Map requestMap)
+ throws JSONException {
+ String strContext = requestMap.get("context");
+ if (strContext == null) {
+ return false;
+ }
+ OBContext.setAdminMode();
+ JSONObject context = new JSONObject(strContext);
+ String strWindow = context.getString("inpwindowId");
+ Window window = OBDal.getInstance().get(Window.class, strWindow == null ? "" : strWindow);
+
+ try {
+ String value = org.openbravo.erpCommon.businessUtility.Preferences.getPreferenceValue(
+ "NotAllowChangeExchange", true, OBContext.getOBContext().getCurrentClient(), OBContext
+ .getOBContext().getCurrentOrganization(), OBContext.getOBContext().getUser(),
+ OBContext.getOBContext().getRole(), window);
+ if ("Y".equals(value)) {
+ return true;
+ } else {
+ return false;
+ }
+ } catch (PropertyNotFoundException e) {
+ // logger.log("Property not found \n");
+ return false;
+ } catch (PropertyException e) {
+ // logger.log("PropertyException, there is a conflict for NotAllowChangeExchange property\n");
+ return false;
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ }
+
+ public boolean getConversionRateReadOnlyLogic(Map requestMap)
+ throws JSONException {
+ String strContext = requestMap.get("context");
+ if (strContext == null) {
+ return false;
+ }
+ OBContext.setAdminMode();
+ JSONObject context = new JSONObject(strContext);
+ String strWindow = context.getString("inpwindowId");
+ Window window = OBDal.getInstance().get(Window.class, strWindow == null ? "" : strWindow);
+
+ try {
+ String value = org.openbravo.erpCommon.businessUtility.Preferences.getPreferenceValue(
+ "NotAllowChangeExchange", true, OBContext.getOBContext().getCurrentClient(), OBContext
+ .getOBContext().getCurrentOrganization(), OBContext.getOBContext().getUser(),
+ OBContext.getOBContext().getRole(), window);
+ if ("Y".equals(value)) {
+ return true;
+ } else {
+ return false;
+ }
+ } catch (PropertyNotFoundException e) {
+ // logger.log("Property not found \n");
+ return false;
+ } catch (PropertyException e) {
+ // logger.log("PropertyException, there is a conflict for NotAllowChangeExchange property\n");
+ return false;
+ } finally {
+ OBContext.restorePreviousMode();
+ }
+ }
+
+}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/BusinessPartnerCustomerFilterExpression.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/BusinessPartnerCustomerFilterExpression.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,52 @@
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.openbravo.client.application.FilterExpression;
+import org.openbravo.client.application.OBBindingsConstants;
+import org.openbravo.client.application.ParameterUtils;
+import org.openbravo.client.kernel.RequestContext;
+
+public class BusinessPartnerCustomerFilterExpression implements FilterExpression {
+ private Logger log = Logger.getLogger(BusinessPartnerCustomerFilterExpression.class);
+ private Map requestMap;
+ private String windowId;
+ private String financialAccountWindowId = "94EAA455D2644E04AB25D93BE5157B6D";
+ private String issotrx = null;
+ String result = null;
+
+ @Override
+ public String getExpression(Map _requestMap) {
+ requestMap = _requestMap;
+ windowId = requestMap.get(OBBindingsConstants.WINDOW_ID_PARAM);
+ if (requestMap.get("issotrx") != null
+ && (financialAccountWindowId.equals(windowId) || windowId == null)) {
+ issotrx = requestMap.get("issotrx");
+ if ("true".equals(issotrx)) {
+ return "true";
+ } else {
+ return "";
+ }
+ } else if (requestMap.get("IsSOTrx") != null && financialAccountWindowId.equals(windowId)) {
+ issotrx = requestMap.get("IsSOTrx");
+ if ("Y".equals(issotrx)) {
+ return "true";
+ } else {
+ return "";
+ }
+ } else {
+ try {
+ result = (String) ParameterUtils.getJSExpressionResult(_requestMap, RequestContext.get()
+ .getSession(), "if (OB.isSalesTransaction() == true) { 'true' } else {''}");
+ return result;
+ } catch (Exception e) {
+ log.error(
+ "Error evaluating filter expression: if (OB.isSalesTransaction() == false) { 'true' } else {''}",
+ e);
+ }
+ return "";
+ }
+ }
+
+}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/BusinessPartnerVendorFilterExpression.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/BusinessPartnerVendorFilterExpression.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,52 @@
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.openbravo.client.application.FilterExpression;
+import org.openbravo.client.application.OBBindingsConstants;
+import org.openbravo.client.application.ParameterUtils;
+import org.openbravo.client.kernel.RequestContext;
+
+public class BusinessPartnerVendorFilterExpression implements FilterExpression {
+ private Logger log = Logger.getLogger(BusinessPartnerVendorFilterExpression.class);
+ private Map requestMap;
+ private String windowId;
+ private String financialAccountWindowId = "94EAA455D2644E04AB25D93BE5157B6D";
+ private String issotrx = null;
+ String result = null;
+
+ @Override
+ public String getExpression(Map _requestMap) {
+ requestMap = _requestMap;
+ windowId = requestMap.get(OBBindingsConstants.WINDOW_ID_PARAM);
+ if (requestMap.get("issotrx") != null
+ && (financialAccountWindowId.equals(windowId) || windowId == null)) {
+ issotrx = requestMap.get("issotrx");
+ if ("false".equals(issotrx)) {
+ return "true";
+ } else {
+ return "";
+ }
+ } else if (requestMap.get("IsSOTrx") != null && financialAccountWindowId.equals(windowId)) {
+ issotrx = requestMap.get("IsSOTrx");
+ if ("N".equals(issotrx)) {
+ return "true";
+ } else {
+ return "";
+ }
+ } else {
+ try {
+ result = (String) ParameterUtils.getJSExpressionResult(_requestMap, RequestContext.get()
+ .getSession(), "if (OB.isSalesTransaction() == false) { 'true' } else {''}");
+ return result;
+ } catch (Exception e) {
+ log.error(
+ "Error evaluating filter expression: if (OB.isSalesTransaction() == false) { 'true' } else {''}",
+ e);
+ return "";
+ }
+ }
+ }
+
+}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentDefaultValues.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentDefaultValues.java Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentDefaultValues.java Thu Sep 11 12:13:21 2014 +0200
@@ -39,47 +39,47 @@
}
@Override
- String getDefaultExpectedAmount(Map requestMap) throws JSONException {
+ public String getDefaultExpectedAmount(Map requestMap) throws JSONException {
// Expected amount is the amount on the editing payment
BigDecimal pendingAmt = getPayment(requestMap).getAmount();
return pendingAmt.toPlainString();
}
@Override
- String getDefaultActualAmount(Map requestMap) throws JSONException {
+ public String getDefaultActualAmount(Map requestMap) throws JSONException {
// Actual amount is the amount on the editing payment
BigDecimal pendingAmt = getPayment(requestMap).getAmount();
return pendingAmt.toPlainString();
}
@Override
- String getDefaultIsSOTrx(Map requestMap) {
+ public String getDefaultIsSOTrx(Map requestMap) {
return "Y";
}
@Override
- String getDefaultTransactionType(Map requestMap) {
+ public String getDefaultTransactionType(Map requestMap) {
return "I";
}
@Override
- String getDefaultPaymentType(Map requestMap) throws JSONException {
+ public String getDefaultPaymentType(Map requestMap) throws JSONException {
JSONObject context = new JSONObject(requestMap.get("context"));
return context.getString("inpfinPaymentId");
}
@Override
- String getDefaultOrderType(Map requestMap) throws JSONException {
+ public String getDefaultOrderType(Map requestMap) throws JSONException {
return "";
}
@Override
- String getDefaultInvoiceType(Map requestMap) throws JSONException {
+ public String getDefaultInvoiceType(Map requestMap) throws JSONException {
return "";
}
@Override
- String getDefaultDocumentNo(Map requestMap) throws JSONException {
+ public String getDefaultDocumentNo(Map requestMap) throws JSONException {
// Document Number of the current Payment
FIN_Payment payment = getPayment(requestMap);
return payment.getDocumentNo();
@@ -100,21 +100,21 @@
}
@Override
- String getDefaultConversionRate(Map requestMap) throws JSONException {
+ public String getDefaultConversionRate(Map requestMap) throws JSONException {
// Conversion Rate of the current Payment
FIN_Payment payment = getPayment(requestMap);
return payment.getFinancialTransactionConvertRate().toPlainString();
}
@Override
- String getDefaultConvertedAmount(Map requestMap) throws JSONException {
+ public String getDefaultConvertedAmount(Map requestMap) throws JSONException {
// Converted Amount of the current Payment
FIN_Payment payment = getPayment(requestMap);
return payment.getFinancialTransactionAmount().toPlainString();
}
@Override
- String getDefaultReceivedFrom(Map requestMap) throws JSONException {
+ public String getDefaultReceivedFrom(Map requestMap) throws JSONException {
// Business Partner of the current Payment
FIN_Payment payment = getPayment(requestMap);
if (payment.getBusinessPartner() != null) {
@@ -125,29 +125,35 @@
}
@Override
- String getDefaultStandardPrecision(Map requestMap) throws JSONException {
+ public String getDefaultStandardPrecision(Map requestMap) throws JSONException {
// Standard Precision of the currency
FIN_Payment payment = getPayment(requestMap);
return payment.getCurrency().getStandardPrecision().toString();
}
@Override
- String getDefaultCurrency(Map requestMap) throws JSONException {
+ public String getDefaultCurrency(Map requestMap) throws JSONException {
// Currency of the current Payment
FIN_Payment payment = getPayment(requestMap);
return payment.getCurrency().getId();
}
@Override
- String getOrganization(Map requestMap) throws JSONException {
+ public String getOrganization(Map requestMap) throws JSONException {
// Organization of the current Payment
return getPayment(requestMap).getOrganization().getId();
}
@Override
- String getDefaultPaymentDate(Map requestMap) throws JSONException {
+ public String getDefaultPaymentDate(Map requestMap) throws JSONException {
// Payment Date of the current payment
return OBDateUtils.formatDate(getPayment(requestMap).getPaymentDate());
}
+ @Override
+ public String getDefaultDocument(Map requestMap) throws JSONException {
+ // Document Type
+ return "";
+ }
+
}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentDisplayLogics.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentDisplayLogics.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,87 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.financialmgmt.payment.FIN_Payment;
+
+@ComponentProvider.Qualifier(APRMConstants.PAYMENT_IN_WINDOW_ID)
+public class PaymentInAddPaymentDisplayLogics extends AddPaymentDisplayLogicsHandler {
+
+ private static final long SEQUENCE = 100l;
+
+ protected long getSeq() {
+ return SEQUENCE;
+ }
+
+ @Override
+ public boolean getOrganizationDisplayLogic(Map requestMap) throws JSONException {
+ // Organization
+ return false;
+ }
+
+ @Override
+ public boolean getDocumentDisplayLogic(Map requestMap) throws JSONException {
+ // Document Type
+ return false;
+ }
+
+ @Override
+ public boolean getCreditToUseDisplayLogic(Map requestMap) throws JSONException {
+ // "@customer_credit@ > 0 & @received_from@!'' & (@issotrx@ == true | @generateCredit@ == 0)";
+ FIN_Payment paymentIn = getPayment(requestMap);
+ BusinessPartner bpartner = paymentIn.getBusinessPartner();
+ if (bpartner != null) {
+ Organization org = paymentIn.getOrganization();
+ BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, true, org);
+ if (customerCredit.signum() > 0) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ private FIN_Payment getPayment(Map requestMap) throws JSONException {
+ // Current Payment
+ JSONObject context = new JSONObject(requestMap.get("context"));
+ String strFinPaymentId = "";
+ if (context.has("inpfinPaymentId") && !context.isNull("inpfinPaymentId")) {
+ strFinPaymentId = context.getString("inpfinPaymentId");
+ }
+ if (context.has("Fin_Payment_ID") && !context.isNull("Fin_Payment_ID")) {
+ strFinPaymentId = context.getString("Fin_Payment_ID");
+ }
+ FIN_Payment payment = OBDal.getInstance().get(FIN_Payment.class, strFinPaymentId);
+ return payment;
+ }
+
+}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentReadOnlyLogics.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentInAddPaymentReadOnlyLogics.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,72 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+
+@ComponentProvider.Qualifier(APRMConstants.PAYMENT_IN_WINDOW_ID)
+public class PaymentInAddPaymentReadOnlyLogics extends AddPaymentReadOnlyLogicsHandler {
+
+ private static final long SEQUENCE = 100l;
+
+ protected long getSeq() {
+ return SEQUENCE;
+ }
+
+ @Override
+ public boolean getPaymentDocumentNoReadOnlyLogic(Map requestMap)
+ throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getReceivedFromReadOnlyLogic(Map requestMap) throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getPaymentMethodReadOnlyLogic(Map requestMap) throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getActualPaymentReadOnlyLogic(Map requestMap) throws JSONException {
+ return false;
+ }
+
+ @Override
+ public boolean getPaymentDateReadOnlyLogic(Map requestMap) throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getFinancialAccountReadOnlyLogic(Map requestMap)
+ throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getCurrencyReadOnlyLogic(Map requestMap) throws JSONException {
+ return true;
+ }
+}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentDefaultValues.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentDefaultValues.java Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentDefaultValues.java Thu Sep 11 12:13:21 2014 +0200
@@ -39,21 +39,21 @@
}
@Override
- String getDefaultExpectedAmount(Map requestMap) throws JSONException {
+ public String getDefaultExpectedAmount(Map requestMap) throws JSONException {
// Expected amount is the amount on the editing payment
BigDecimal pendingAmt = getPayment(requestMap).getAmount();
return pendingAmt.toPlainString();
}
@Override
- String getDefaultActualAmount(Map requestMap) throws JSONException {
+ public String getDefaultActualAmount(Map requestMap) throws JSONException {
// Actual amount is the amount on the editing payment
BigDecimal pendingAmt = getPayment(requestMap).getAmount();
return pendingAmt.toPlainString();
}
@Override
- String getDefaultGeneratedCredit(Map requestMap) throws JSONException {
+ public String getDefaultGeneratedCredit(Map requestMap) throws JSONException {
// Generated Credit of the current Payment
BigDecimal generateCredit = getPayment(requestMap).getGeneratedCredit();
if (generateCredit == null) {
@@ -64,33 +64,33 @@
}
@Override
- String getDefaultIsSOTrx(Map requestMap) {
+ public String getDefaultIsSOTrx(Map requestMap) {
return "N";
}
@Override
- String getDefaultTransactionType(Map requestMap) {
+ public String getDefaultTransactionType(Map requestMap) {
return "I";
}
@Override
- String getDefaultPaymentType(Map requestMap) throws JSONException {
+ public String getDefaultPaymentType(Map requestMap) throws JSONException {
JSONObject context = new JSONObject(requestMap.get("context"));
return context.getString("inpfinPaymentId");
}
@Override
- String getDefaultOrderType(Map requestMap) throws JSONException {
+ public String getDefaultOrderType(Map requestMap) throws JSONException {
return "";
}
@Override
- String getDefaultInvoiceType(Map requestMap) throws JSONException {
+ public String getDefaultInvoiceType(Map requestMap) throws JSONException {
return "";
}
@Override
- String getDefaultDocumentNo(Map requestMap) throws JSONException {
+ public String getDefaultDocumentNo(Map requestMap) throws JSONException {
// Document Number of the current Payment
FIN_Payment payment = getPayment(requestMap);
return payment.getDocumentNo();
@@ -111,21 +111,21 @@
}
@Override
- String getDefaultConversionRate(Map requestMap) throws JSONException {
+ public String getDefaultConversionRate(Map requestMap) throws JSONException {
// Conversion Rate of the current Payment
FIN_Payment payment = getPayment(requestMap);
return payment.getFinancialTransactionConvertRate().toPlainString();
}
@Override
- String getDefaultConvertedAmount(Map requestMap) throws JSONException {
+ public String getDefaultConvertedAmount(Map requestMap) throws JSONException {
// Converted Amount of the current Payment
FIN_Payment payment = getPayment(requestMap);
return payment.getFinancialTransactionAmount().toPlainString();
}
@Override
- String getDefaultReceivedFrom(Map requestMap) throws JSONException {
+ public String getDefaultReceivedFrom(Map requestMap) throws JSONException {
// Business Partner of the current Payment
FIN_Payment payment = getPayment(requestMap);
if (payment.getBusinessPartner() != null) {
@@ -136,29 +136,35 @@
}
@Override
- String getDefaultStandardPrecision(Map requestMap) throws JSONException {
+ public String getDefaultStandardPrecision(Map requestMap) throws JSONException {
// Standard Precision of the currency
FIN_Payment payment = getPayment(requestMap);
return payment.getCurrency().getStandardPrecision().toString();
}
@Override
- String getDefaultCurrency(Map requestMap) throws JSONException {
+ public String getDefaultCurrency(Map requestMap) throws JSONException {
// Currency of the current Payment
FIN_Payment payment = getPayment(requestMap);
return payment.getCurrency().getId();
}
@Override
- String getOrganization(Map requestMap) throws JSONException {
+ public String getOrganization(Map requestMap) throws JSONException {
// Organization of the current Payment
return getPayment(requestMap).getOrganization().getId();
}
@Override
- String getDefaultPaymentDate(Map requestMap) throws JSONException {
+ public String getDefaultPaymentDate(Map requestMap) throws JSONException {
// Payment Date of the current payment
return OBDateUtils.formatDate(getPayment(requestMap).getPaymentDate());
}
+ @Override
+ public String getDefaultDocument(Map requestMap) throws JSONException {
+ // Document Type
+ return "";
+ }
+
}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentDisplayLogics.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentDisplayLogics.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,95 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.financialmgmt.payment.FIN_Payment;
+
+@ComponentProvider.Qualifier(APRMConstants.PAYMENT_OUT_WINDOW_ID)
+public class PaymentOutAddPaymentDisplayLogics extends AddPaymentDisplayLogicsHandler {
+
+ private static final long SEQUENCE = 100l;
+
+ protected long getSeq() {
+ return SEQUENCE;
+ }
+
+ @Override
+ public boolean getOrganizationDisplayLogic(Map requestMap) throws JSONException {
+ // Organization
+ return false;
+ }
+
+ @Override
+ public boolean getDocumentDisplayLogic(Map requestMap) throws JSONException {
+ // Document Type
+ return false;
+ }
+
+ @Override
+ public boolean getCreditToUseDisplayLogic(Map requestMap) throws JSONException {
+ FIN_Payment paymentOut = getPayment(requestMap);
+ if (getGeneratedCredit(requestMap).signum() == 0) {
+ BusinessPartner bpartner = paymentOut.getBusinessPartner();
+ if (bpartner != null) {
+ Organization org = paymentOut.getOrganization();
+ BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, false, org);
+ if (customerCredit.signum() > 0) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ private FIN_Payment getPayment(Map requestMap) throws JSONException {
+ // Current Payment
+ JSONObject context = new JSONObject(requestMap.get("context"));
+ String strFinPaymentId = "";
+ if (context.has("inpfinPaymentId") && !context.isNull("inpfinPaymentId")) {
+ strFinPaymentId = context.getString("inpfinPaymentId");
+ }
+ if (context.has("Fin_Payment_ID") && !context.isNull("Fin_Payment_ID")) {
+ strFinPaymentId = context.getString("Fin_Payment_ID");
+ }
+ FIN_Payment payment = OBDal.getInstance().get(FIN_Payment.class, strFinPaymentId);
+ return payment;
+ }
+
+ BigDecimal getGeneratedCredit(Map requestMap) throws JSONException {
+ // Generated Credit of the current Payment
+ return getPayment(requestMap).getGeneratedCredit();
+ }
+
+}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentReadOnlyLogics.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PaymentOutAddPaymentReadOnlyLogics.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,73 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+
+@ComponentProvider.Qualifier(APRMConstants.PAYMENT_OUT_WINDOW_ID)
+public class PaymentOutAddPaymentReadOnlyLogics extends AddPaymentReadOnlyLogicsHandler {
+
+ private static final long SEQUENCE = 100l;
+
+ protected long getSeq() {
+ return SEQUENCE;
+ }
+
+ @Override
+ public boolean getPaymentDocumentNoReadOnlyLogic(Map requestMap)
+ throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getReceivedFromReadOnlyLogic(Map requestMap) throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getPaymentMethodReadOnlyLogic(Map requestMap) throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getActualPaymentReadOnlyLogic(Map requestMap) throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getPaymentDateReadOnlyLogic(Map requestMap) throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getFinancialAccountReadOnlyLogic(Map requestMap)
+ throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getCurrencyReadOnlyLogic(Map requestMap) throws JSONException {
+ return true;
+ }
+
+}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentDefaultValues.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentDefaultValues.java Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentDefaultValues.java Thu Sep 11 12:13:21 2014 +0200
@@ -47,7 +47,7 @@
}
@Override
- String getDefaultActualAmount(Map requestMap) throws JSONException {
+ public String getDefaultActualAmount(Map requestMap) throws JSONException {
// Actual amount is the amount on the editing Purchase Invoice
BigDecimal pendingAmt = getPendingAmount(requestMap);
return pendingAmt.toPlainString();
@@ -60,43 +60,43 @@
}
@Override
- String getDefaultIsSOTrx(Map requestMap) {
+ public String getDefaultIsSOTrx(Map requestMap) {
return "N";
}
@Override
- String getDefaultTransactionType(Map requestMap) {
+ public String getDefaultTransactionType(Map requestMap) {
return "I";
}
@Override
- String getDefaultPaymentType(Map requestMap) {
+ public String getDefaultPaymentType(Map requestMap) {
return "";
}
@Override
- String getDefaultOrderType(Map requestMap) {
+ public String getDefaultOrderType(Map requestMap) {
return "";
}
@Override
- String getDefaultInvoiceType(Map requestMap) throws JSONException {
+ public String getDefaultInvoiceType(Map requestMap) throws JSONException {
JSONObject context = new JSONObject(requestMap.get("context"));
return context.getString("inpcInvoiceId");
}
@Override
- String getDefaultConversionRate(Map requestMap) throws JSONException {
+ public String getDefaultConversionRate(Map requestMap) throws JSONException {
return "";
}
@Override
- String getDefaultConvertedAmount(Map requestMap) throws JSONException {
+ public String getDefaultConvertedAmount(Map requestMap) throws JSONException {
return "";
}
@Override
- String getDefaultReceivedFrom(Map requestMap) throws JSONException {
+ public String getDefaultReceivedFrom(Map requestMap) throws JSONException {
// Business Partner of the current Purchase Invoice
JSONObject context = new JSONObject(requestMap.get("context"));
Invoice invoice = getInvoice(context);
@@ -104,7 +104,7 @@
}
@Override
- String getDefaultStandardPrecision(Map requestMap) throws JSONException {
+ public String getDefaultStandardPrecision(Map requestMap) throws JSONException {
// Standard Precision of the currency
JSONObject context = new JSONObject(requestMap.get("context"));
Invoice invoice = getInvoice(context);
@@ -112,7 +112,7 @@
}
@Override
- String getDefaultCurrency(Map requestMap) throws JSONException {
+ public String getDefaultCurrency(Map requestMap) throws JSONException {
// Currency of the current Purchase Invoice
JSONObject context = new JSONObject(requestMap.get("context"));
Invoice invoice = getInvoice(context);
@@ -120,17 +120,23 @@
}
@Override
- String getOrganization(Map requestMap) throws JSONException {
+ public String getOrganization(Map requestMap) throws JSONException {
// Currency of the current Purchase Invoice
return getInvoice(new JSONObject(requestMap.get("context"))).getOrganization().getId();
}
+ @Override
+ public String getDefaultDocument(Map requestMap) throws JSONException {
+ // Document Type
+ return "";
+ }
+
Invoice getInvoice(JSONObject context) throws JSONException {
return OBDal.getInstance().get(Invoice.class, context.getString("inpcInvoiceId"));
}
@Override
- String getDefaultPaymentDate(Map requestMap) throws JSONException {
+ public String getDefaultPaymentDate(Map requestMap) throws JSONException {
return OBDateUtils.formatDate(new Date());
}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentDisplayLogics.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentDisplayLogics.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,85 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.common.invoice.Invoice;
+
+@ComponentProvider.Qualifier(APRMConstants.PURCHASE_INVOICE_WINDOW_ID)
+public class PurchaseInvoiceAddPaymentDisplayLogics extends AddPaymentDisplayLogicsHandler {
+
+ private static final long SEQUENCE = 100l;
+
+ protected long getSeq() {
+ return SEQUENCE;
+ }
+
+ @Override
+ public boolean getOrganizationDisplayLogic(Map requestMap) throws JSONException {
+ // Organization
+ return false;
+ }
+
+ @Override
+ public boolean getDocumentDisplayLogic(Map requestMap) throws JSONException {
+ // Document Type
+ return false;
+ }
+
+ @Override
+ public boolean getCreditToUseDisplayLogic(Map requestMap) throws JSONException {
+ JSONObject context = new JSONObject(requestMap.get("context"));
+ Invoice invoice = getInvoice(context);
+ if (getDefaultGeneratedCredit(requestMap).signum() == 0) {
+ BusinessPartner bpartner = invoice.getBusinessPartner();
+ if (bpartner != null) {
+ Organization org = invoice.getOrganization();
+ BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, false, org);
+ if (customerCredit.signum() > 0) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ Invoice getInvoice(JSONObject context) throws JSONException {
+ return OBDal.getInstance().get(Invoice.class, context.getString("inpcInvoiceId"));
+ }
+
+ BigDecimal getDefaultGeneratedCredit(Map requestMap) throws JSONException {
+ return BigDecimal.ZERO;
+ }
+
+}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentReadOnlyLogics.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseInvoiceAddPaymentReadOnlyLogics.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,73 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+
+@ComponentProvider.Qualifier(APRMConstants.PURCHASE_INVOICE_WINDOW_ID)
+public class PurchaseInvoiceAddPaymentReadOnlyLogics extends AddPaymentReadOnlyLogicsHandler {
+
+ private static final long SEQUENCE = 100l;
+
+ protected long getSeq() {
+ return SEQUENCE;
+ }
+
+ @Override
+ public boolean getPaymentDocumentNoReadOnlyLogic(Map requestMap)
+ throws JSONException {
+ return false;
+ }
+
+ @Override
+ public boolean getReceivedFromReadOnlyLogic(Map requestMap) throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getPaymentMethodReadOnlyLogic(Map requestMap) throws JSONException {
+ return false;
+ }
+
+ @Override
+ public boolean getActualPaymentReadOnlyLogic(Map requestMap) throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getPaymentDateReadOnlyLogic(Map requestMap) throws JSONException {
+ return false;
+ }
+
+ @Override
+ public boolean getFinancialAccountReadOnlyLogic(Map requestMap)
+ throws JSONException {
+ return false;
+ }
+
+ @Override
+ public boolean getCurrencyReadOnlyLogic(Map requestMap) throws JSONException {
+ return true;
+ }
+
+}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentDefaultValues.java
--- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentDefaultValues.java Mon Aug 04 07:44:51 2014 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentDefaultValues.java Thu Sep 11 12:13:21 2014 +0200
@@ -40,7 +40,7 @@
}
@Override
- String getDefaultExpectedAmount(Map requestMap) throws JSONException {
+ public String getDefaultExpectedAmount(Map requestMap) throws JSONException {
// Expected amount is the amount pending to pay on the Purchase Order
JSONObject context = new JSONObject(requestMap.get("context"));
String strOrderId = context.getString("inpcOrderId");
@@ -49,7 +49,7 @@
}
@Override
- String getDefaultActualAmount(Map requestMap) throws JSONException {
+ public String getDefaultActualAmount(Map requestMap) throws JSONException {
// Actual amount is the amount pending to pay on the Purchase Order
JSONObject context = new JSONObject(requestMap.get("context"));
String strOrderId = context.getString("inpcOrderId");
@@ -58,12 +58,12 @@
}
@Override
- String getDefaultIsSOTrx(Map requestMap) {
+ public String getDefaultIsSOTrx(Map requestMap) {
return "N";
}
@Override
- String getDefaultTransactionType(Map requestMap) {
+ public String getDefaultTransactionType(Map requestMap) {
return "O";
}
@@ -74,33 +74,33 @@
}
@Override
- String getDefaultPaymentType(Map requestMap) throws JSONException {
+ public String getDefaultPaymentType(Map requestMap) throws JSONException {
return "";
}
@Override
- String getDefaultOrderType(Map requestMap) throws JSONException {
+ public String getDefaultOrderType(Map requestMap) throws JSONException {
JSONObject context = new JSONObject(requestMap.get("context"));
return context.getString("inpcOrderId");
}
@Override
- String getDefaultInvoiceType(Map requestMap) throws JSONException {
+ public String getDefaultInvoiceType(Map requestMap) throws JSONException {
return "";
}
@Override
- String getDefaultConversionRate(Map requestMap) throws JSONException {
+ public String getDefaultConversionRate(Map requestMap) throws JSONException {
return "";
}
@Override
- String getDefaultConvertedAmount(Map requestMap) throws JSONException {
+ public String getDefaultConvertedAmount(Map requestMap) throws JSONException {
return "";
}
@Override
- String getDefaultReceivedFrom(Map requestMap) throws JSONException {
+ public String getDefaultReceivedFrom(Map requestMap) throws JSONException {
// Business Partner of the current Purchase Order
JSONObject context = new JSONObject(requestMap.get("context"));
Order order = getOrder(context);
@@ -108,7 +108,7 @@
}
@Override
- String getDefaultStandardPrecision(Map requestMap) throws JSONException {
+ public String getDefaultStandardPrecision(Map requestMap) throws JSONException {
// Standard Precision of the currency
JSONObject context = new JSONObject(requestMap.get("context"));
Order order = getOrder(context);
@@ -116,7 +116,7 @@
}
@Override
- String getDefaultCurrency(Map requestMap) throws JSONException {
+ public String getDefaultCurrency(Map requestMap) throws JSONException {
// Currency of the current Purchase Order
JSONObject context = new JSONObject(requestMap.get("context"));
Order order = getOrder(context);
@@ -124,17 +124,23 @@
}
@Override
- String getOrganization(Map requestMap) throws JSONException {
+ public String getOrganization(Map requestMap) throws JSONException {
// Organization of the current Purchase Order
return getOrder(new JSONObject(requestMap.get("context"))).getOrganization().getId();
}
+ @Override
+ public String getDefaultDocument(Map requestMap) throws JSONException {
+ // Document Type
+ return "";
+ }
+
Order getOrder(JSONObject context) throws JSONException {
return OBDal.getInstance().get(Order.class, context.getString("inpcOrderId"));
}
@Override
- String getDefaultPaymentDate(Map requestMap) throws JSONException {
+ public String getDefaultPaymentDate(Map requestMap) throws JSONException {
return OBDateUtils.formatDate(new Date());
}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentDisplayLogics.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentDisplayLogics.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,85 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.math.BigDecimal;
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+import org.openbravo.advpaymentmngt.dao.AdvPaymentMngtDao;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+import org.openbravo.dal.service.OBDal;
+import org.openbravo.model.common.businesspartner.BusinessPartner;
+import org.openbravo.model.common.enterprise.Organization;
+import org.openbravo.model.common.order.Order;
+
+@ComponentProvider.Qualifier(APRMConstants.PURCHASE_ORDER_WINDOW_ID)
+public class PurchaseOrderAddPaymentDisplayLogics extends AddPaymentDisplayLogicsHandler {
+
+ private static final long SEQUENCE = 100l;
+
+ protected long getSeq() {
+ return SEQUENCE;
+ }
+
+ @Override
+ public boolean getOrganizationDisplayLogic(Map requestMap) throws JSONException {
+ // Organization
+ return false;
+ }
+
+ @Override
+ public boolean getDocumentDisplayLogic(Map requestMap) throws JSONException {
+ // Document Type
+ return false;
+ }
+
+ @Override
+ public boolean getCreditToUseDisplayLogic(Map requestMap) throws JSONException {
+ JSONObject context = new JSONObject(requestMap.get("context"));
+ Order order = getOrder(context);
+ if (getDefaultGeneratedCredit(requestMap).signum() == 0) {
+ BusinessPartner bpartner = order.getBusinessPartner();
+ if (bpartner != null) {
+ Organization org = order.getOrganization();
+ BigDecimal customerCredit = new AdvPaymentMngtDao().getCustomerCredit(bpartner, false, org);
+ if (customerCredit.signum() > 0) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ private Order getOrder(JSONObject context) throws JSONException {
+ return OBDal.getInstance().get(Order.class, context.getString("inpcOrderId"));
+ }
+
+ BigDecimal getDefaultGeneratedCredit(Map requestMap) throws JSONException {
+ return BigDecimal.ZERO;
+ }
+
+}
diff -r d7d2abe0f424 -r f12e5b66c79e modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentReadOnlyLogics.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/filterexpression/PurchaseOrderAddPaymentReadOnlyLogics.java Thu Sep 11 12:13:21 2014 +0200
@@ -0,0 +1,73 @@
+/*
+ *************************************************************************
+ * The contents of this file are subject to the Openbravo Public License
+ * Version 1.1 (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 SLU
+ * All portions are Copyright (C) 2014 Openbravo SLU
+ * All Rights Reserved.
+ * Contributor(s): ______________________________________.
+ ************************************************************************
+ */
+package org.openbravo.advpaymentmngt.filterexpression;
+
+import java.util.Map;
+
+import org.codehaus.jettison.json.JSONException;
+import org.openbravo.advpaymentmngt.utility.APRMConstants;
+import org.openbravo.client.kernel.ComponentProvider;
+
+@ComponentProvider.Qualifier(APRMConstants.PURCHASE_ORDER_WINDOW_ID)
+public class PurchaseOrderAddPaymentReadOnlyLogics extends AddPaymentReadOnlyLogicsHandler {
+
+ private static final long SEQUENCE = 100l;
+
+ protected long getSeq() {
+ return SEQUENCE;
+ }
+
+ @Override
+ public boolean getPaymentDocumentNoReadOnlyLogic(Map requestMap)
+ throws JSONException {
+ return false;
+ }
+
+ @Override
+ public boolean getReceivedFromReadOnlyLogic(Map requestMap) throws JSONException {
+ return true;
+ }
+
+ @Override
+ public boolean getPaymentMethodReadOnlyLogic(Map