details:   https://code.openbravo.com/erp/devel/pi/rev/7536e04c7099
changeset: 20434:7536e04c7099
user:      Sandra Huguet <sandra.huguet <at> openbravo.com>
date:      Mon May 20 13:12:23 2013 +0200
summary:   Fixed issue 22620 Match invoice posting fail with service product

diffstat:

 src/org/openbravo/erpCommon/ad_forms/DocMatchInv.java |  18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diffs (53 lines):

diff -r 1f3407c46d14 -r 7536e04c7099 
src/org/openbravo/erpCommon/ad_forms/DocMatchInv.java
--- a/src/org/openbravo/erpCommon/ad_forms/DocMatchInv.java     Tue May 21 
16:47:06 2013 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/DocMatchInv.java     Mon May 20 
13:12:23 2013 +0200
@@ -20,6 +20,7 @@
 import java.math.RoundingMode;
 import java.sql.Connection;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Map;
 
 import javax.servlet.ServletException;
@@ -31,6 +32,7 @@
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.data.FieldProvider;
 import org.openbravo.database.ConnectionProvider;
+import org.openbravo.erpCommon.utility.OBDateUtils;
 import org.openbravo.erpCommon.utility.SequenceIdData;
 import org.openbravo.financial.FinancialUtils;
 import org.openbravo.model.ad.system.Client;
@@ -240,6 +242,17 @@
       // If the Product is not checked as book using PO Price, the Cost of the
       // Transaction will be used to create the FactAcct Line
       MaterialTransaction transaction = getTransaction(Record_ID);
+      if (transaction == null) {
+        Map<String, String> parameters = new HashMap<String, String>();
+        parameters.put("Product", inOutLine.getProduct().getIdentifier());
+        parameters.put(
+            "Date",
+            
(OBDateUtils.formatDate(OBDal.getInstance().get(ReceiptInvoiceMatch.class, 
Record_ID)
+                .getTransactionDate())).toString());
+        setMessageResult(conn, STATUS_InvalidCost, "error", parameters);
+        throw new IllegalStateException();
+
+      }
       if (!CostingStatus.getInstance().isMigrated()) {
         costCurrency = OBDal.getInstance().get(Client.class, 
AD_Client_ID).getCurrency();
       } else if (transaction != null && transaction.getCurrency() != null) {
@@ -468,10 +481,15 @@
   private MaterialTransaction getTransaction(String matchInvId) {
     OBContext.setAdminMode(false);
     MaterialTransaction transaction;
+    if (OBDal.getInstance().get(ReceiptInvoiceMatch.class, 
matchInvId).getGoodsShipmentLine()
+        .getMaterialMgmtMaterialTransactionList().size() == 0) {
+      return null;
+    }
     try {
       transaction = OBDal.getInstance().get(ReceiptInvoiceMatch.class, 
matchInvId)
           
.getGoodsShipmentLine().getMaterialMgmtMaterialTransactionList().get(0);
     } finally {
+
       OBContext.restorePreviousMode();
     }
     return transaction;

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to