details: https://code.openbravo.com/erp/devel/pi/rev/475e5dd573e7
changeset: 16692:475e5dd573e7
user: Javier Etxarri <javier.echarri <at> openbravo.com>
date: Tue May 29 18:41:57 2012 +0200
summary: Fixes issue 20504: "Copy Lines" process should
should shown proper error message instead of "Process failed during execution".
Issue 20336: Should not be possible to create several periods for same date
range in different years. I have updated the message with id
0FF0EC6915A04F4EA5FB2FD09DA82F14, because now the previous message was
incomplete to new code
diffstat:
src-db/database/sourcedata/AD_MESSAGE.xml | 24 +++-
src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java | 67
++++++++++
2 files changed, 90 insertions(+), 1 deletions(-)
diffs (152 lines):
diff -r 57b7ee4c01b3 -r 475e5dd573e7 src-db/database/sourcedata/AD_MESSAGE.xml
--- a/src-db/database/sourcedata/AD_MESSAGE.xml Tue May 29 13:51:51 2012 +0200
+++ b/src-db/database/sourcedata/AD_MESSAGE.xml Tue May 29 18:41:57 2012 +0200
@@ -14734,7 +14734,7 @@
<!--0FF0EC6915A04F4EA5FB2FD09DA82F14--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
<!--0FF0EC6915A04F4EA5FB2FD09DA82F14--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
<!--0FF0EC6915A04F4EA5FB2FD09DA82F14-->
<VALUE><![CDATA[DatesOverlapped]]></VALUE>
-<!--0FF0EC6915A04F4EA5FB2FD09DA82F14--> <MSGTEXT><![CDATA[The dates period
defined is overlapped with another period of the same year.]]></MSGTEXT>
+<!--0FF0EC6915A04F4EA5FB2FD09DA82F14--> <MSGTEXT><![CDATA[Saving failed. The
dates period defined is overlapped with another period of an existing
year.]]></MSGTEXT>
<!--0FF0EC6915A04F4EA5FB2FD09DA82F14--> <MSGTYPE><![CDATA[E]]></MSGTYPE>
<!--0FF0EC6915A04F4EA5FB2FD09DA82F14-->
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
<!--0FF0EC6915A04F4EA5FB2FD09DA82F14--></AD_MESSAGE>
@@ -16869,6 +16869,17 @@
<!--61DD25C13AC94CAF895C25FFFB7A1103-->
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
<!--61DD25C13AC94CAF895C25FFFB7A1103--></AD_MESSAGE>
+<!--61E8F84D26B046AEB1BA9BAB8FEB2951--><AD_MESSAGE>
+<!--61E8F84D26B046AEB1BA9BAB8FEB2951-->
<AD_MESSAGE_ID><![CDATA[61E8F84D26B046AEB1BA9BAB8FEB2951]]></AD_MESSAGE_ID>
+<!--61E8F84D26B046AEB1BA9BAB8FEB2951-->
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--61E8F84D26B046AEB1BA9BAB8FEB2951--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--61E8F84D26B046AEB1BA9BAB8FEB2951--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--61E8F84D26B046AEB1BA9BAB8FEB2951-->
<VALUE><![CDATA[NotExistTaxRateForTaxCategory]]></VALUE>
+<!--61E8F84D26B046AEB1BA9BAB8FEB2951--> <MSGTEXT><![CDATA[Does not exist any
tax rate in the tax category '%s' for product/GLItem '%s']]></MSGTEXT>
+<!--61E8F84D26B046AEB1BA9BAB8FEB2951--> <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--61E8F84D26B046AEB1BA9BAB8FEB2951-->
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--61E8F84D26B046AEB1BA9BAB8FEB2951--></AD_MESSAGE>
+
<!--631B7EBFDD604B18B92CCF2F855602FE--><AD_MESSAGE>
<!--631B7EBFDD604B18B92CCF2F855602FE-->
<AD_MESSAGE_ID><![CDATA[631B7EBFDD604B18B92CCF2F855602FE]]></AD_MESSAGE_ID>
<!--631B7EBFDD604B18B92CCF2F855602FE-->
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
@@ -19224,6 +19235,17 @@
<!--C0E57F087EBD4FB596DB9B6CCB2DA124-->
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
<!--C0E57F087EBD4FB596DB9B6CCB2DA124--></AD_MESSAGE>
+<!--C112334AFC4844F68BCACBA8D1D4FEF3--><AD_MESSAGE>
+<!--C112334AFC4844F68BCACBA8D1D4FEF3-->
<AD_MESSAGE_ID><![CDATA[C112334AFC4844F68BCACBA8D1D4FEF3]]></AD_MESSAGE_ID>
+<!--C112334AFC4844F68BCACBA8D1D4FEF3-->
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
+<!--C112334AFC4844F68BCACBA8D1D4FEF3--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
+<!--C112334AFC4844F68BCACBA8D1D4FEF3--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
+<!--C112334AFC4844F68BCACBA8D1D4FEF3-->
<VALUE><![CDATA[NotExistTaxRateForTaxZone]]></VALUE>
+<!--C112334AFC4844F68BCACBA8D1D4FEF3--> <MSGTEXT><![CDATA[Does not exist any
tax rate defined for product/GLItem '%s' in tax category '%s' and tax zone
'%s']]></MSGTEXT>
+<!--C112334AFC4844F68BCACBA8D1D4FEF3--> <MSGTYPE><![CDATA[E]]></MSGTYPE>
+<!--C112334AFC4844F68BCACBA8D1D4FEF3-->
<AD_MODULE_ID><![CDATA[0]]></AD_MODULE_ID>
+<!--C112334AFC4844F68BCACBA8D1D4FEF3--></AD_MESSAGE>
+
<!--C17765EDD3844A0393433448B4F7E799--><AD_MESSAGE>
<!--C17765EDD3844A0393433448B4F7E799-->
<AD_MESSAGE_ID><![CDATA[C17765EDD3844A0393433448B4F7E799]]></AD_MESSAGE_ID>
<!--C17765EDD3844A0393433448B4F7E799-->
<AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
diff -r 57b7ee4c01b3 -r 475e5dd573e7
src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java
--- a/src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java Tue May
29 13:51:51 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CopyFromInvoice.java Tue May
29 18:41:57 2012 +0200
@@ -22,19 +22,28 @@
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.sql.Connection;
+import java.util.List;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.hibernate.criterion.Restrictions;
+import org.openbravo.base.exception.OBException;
import org.openbravo.base.secureApp.HttpSecureAppServlet;
import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.service.OBCriteria;
+import org.openbravo.dal.service.OBDal;
import org.openbravo.erpCommon.businessUtility.Tax;
import org.openbravo.erpCommon.utility.DateTimeData;
import org.openbravo.erpCommon.utility.OBError;
import org.openbravo.erpCommon.utility.SequenceIdData;
import org.openbravo.erpCommon.utility.Utility;
+import org.openbravo.model.common.businesspartner.Location;
+import org.openbravo.model.common.plm.Product;
+import org.openbravo.model.financialmgmt.gl.GLItem;
+import org.openbravo.model.financialmgmt.tax.TaxRate;
import org.openbravo.xmlEngine.XmlDocument;
public class CopyFromInvoice extends HttpSecureAppServlet {
@@ -167,6 +176,54 @@
priceactual = data[i].priceactual;
linenetamt = data[i].linenetamt;
}
+
+ // Checking, why is not possible to get a tax
+ BigDecimal linenetamtBD = new BigDecimal(linenetamt);
+ if ("".equals(strCTaxID)
+ &&
!linenetamtBD.equals(BigDecimal.ZERO.setScale(linenetamtBD.scale()))) {
+ if (!"".equals(data[i].accountId)) {
+ GLItem glItem = OBDal.getInstance().get(GLItem.class,
data[i].accountId);
+
+ OBCriteria<TaxRate> obcriteria =
OBDal.getInstance().createCriteria(TaxRate.class);
+ obcriteria.add(Restrictions.eq(TaxRate.PROPERTY_TAXCATEGORY,
+ glItem.getTaxCategory()));
+ obcriteria.add(Restrictions.eq(TaxRate.PROPERTY_ACTIVE,
Boolean.TRUE));
+ List<TaxRate> taxRates = obcriteria.list();
+ if (taxRates.size() == 0) {
+ throw new OBException(String.format(
+ Utility.messageBD(this, "NotExistTaxRateForTaxCategory",
vars.getLanguage()),
+ glItem.getTaxCategory().getIdentifier(),
glItem.getIdentifier()));
+ } else {
+ Location location = OBDal.getInstance().get(Location.class,
+ dataInvoice[0].cBpartnerLocationId);
+ throw new OBException(String.format(
+ Utility.messageBD(this, "NotExistTaxRateForTaxZone",
vars.getLanguage()),
+ glItem.getIdentifier(),
glItem.getTaxCategory().getIdentifier(),
+ location.getIdentifier()));
+ }
+ } else if (!"".equals(data[i].productId)) {
+ Product product = OBDal.getInstance().get(Product.class,
data[i].productId);
+
+ OBCriteria<TaxRate> obcriteria =
OBDal.getInstance().createCriteria(TaxRate.class);
+ obcriteria.add(Restrictions.eq(TaxRate.PROPERTY_TAXCATEGORY,
+ product.getTaxCategory()));
+ obcriteria.add(Restrictions.eq(TaxRate.PROPERTY_ACTIVE,
Boolean.TRUE));
+ List<TaxRate> taxRates = obcriteria.list();
+ if (taxRates.size() == 0) {
+ throw new OBException(String.format(
+ Utility.messageBD(this, "NotExistTaxRateForTaxCategory",
vars.getLanguage()),
+ product.getTaxCategory().getIdentifier(),
product.getIdentifier()));
+ } else {
+ Location location = OBDal.getInstance().get(Location.class,
+ dataInvoice[0].cBpartnerLocationId);
+ throw new OBException(String.format(
+ Utility.messageBD(this, "NotExistTaxRateForTaxZone",
vars.getLanguage()),
+ product.getIdentifier(),
product.getTaxCategory().getIdentifier(),
+ location.getIdentifier()));
+ }
+ }
+ }
+
CopyFromInvoiceData.insert(conn, this, strSequence, strKey,
dataInvoice[0].adClientId,
dataInvoice[0].adOrgId, vars.getUser(), pricelist,
priceactual, pricelimit,
linenetamt, strCTaxID, data[i].cInvoicelineId);
@@ -181,6 +238,16 @@
}
}
releaseCommitConnection(conn);
+ } catch (OBException obe) {
+ try {
+ releaseRollbackConnection(conn);
+ } catch (Exception ignored) {
+ }
+ myError = new OBError();
+ myError.setType("Error");
+ myError.setTitle(Utility.messageBD(this, "Error", vars.getLanguage()));
+ myError.setMessage(obe.getMessage());
+ return myError;
} catch (Exception e) {
try {
releaseRollbackConnection(conn);
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits