Fixes issue 30212: Wrong error message when posting an invoice
authorAlvaro Ferraz <alvaro.ferraz@openbravo.com>
Tue, 23 Jun 2015 18:35:47 +0200
changeset 27148 dbdd3e64a7d1
parent 27147 48fee56d37da
child 27149 988d6933a2bd
child 27154 65f6b2e875a7
Fixes issue 30212: Wrong error message when posting an invoice

Wrong error message was shown when posting an invoice with a deferred revenue in a closed period.
Now, PeriodNotAvailable error message will be shown.
src/org/openbravo/erpCommon/ad_forms/AcctServer.java
src/org/openbravo/erpCommon/ad_forms/DocInvoice.java
--- a/src/org/openbravo/erpCommon/ad_forms/AcctServer.java	Wed Jun 24 14:03:00 2015 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/AcctServer.java	Tue Jun 23 18:35:47 2015 +0200
@@ -1115,6 +1115,8 @@
         setMessageResult(OBMessageUtils.translateError(strMessageError));
         if ("@NotConvertible@".equals(strMessageError)) {
           return STATUS_NotConvertible;
+        } else if (StringUtils.equals(strMessageError, "@PeriodNotAvailable@")) {
+          return STATUS_PeriodClosed;
         }
       }
       return STATUS_Error;
--- a/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java	Wed Jun 24 14:03:00 2015 +0000
+++ b/src/org/openbravo/erpCommon/ad_forms/DocInvoice.java	Tue Jun 23 18:35:47 2015 +0200
@@ -28,6 +28,7 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
+import org.openbravo.base.exception.OBException;
 import org.openbravo.base.secureApp.VariablesSecureApp;
 import org.openbravo.client.kernel.RequestContext;
 import org.openbravo.dal.core.OBContext;
@@ -1194,7 +1195,7 @@
             DocumentType, AD_Org_ID, OBDateUtils.formatDate(period.getEndingDate()));
         if ("".equals(data[0].period)) {
           setStatus(STATUS_PeriodClosed);
-          throw new IllegalStateException("DocInvoice - Error getting next year period");
+          throw new OBException("@PeriodNotAvailable@");
         }
       } catch (ServletException e) {
         log4j.warn("DocInvoice - Error checking period open.", e);