details:   https://code.openbravo.com/erp/devel/pi/rev/9626592579b5
changeset: 17982:9626592579b5
user:      Pandeeswari Ramakrishnan <pandeeswari.ramakrishnan <at> 
openbravo.com>
date:      Tue Sep 18 17:41:08 2012 +0200
summary:   Fixes Issue 21459:Invoice for Orders from different Legal Entity is 
possible

diffstat:

 src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java |  39 +++++++-----
 src/org/openbravo/erpCommon/utility/Utility.java            |   3 +-
 2 files changed, 25 insertions(+), 17 deletions(-)

diffs (131 lines):

diff -r d9a38ada2c86 -r 9626592579b5 
src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java
--- a/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java       Wed Sep 
19 16:17:34 2012 +0200
+++ b/src/org/openbravo/erpCommon/ad_actionButton/CreateFrom.java       Tue Sep 
18 17:41:08 2012 +0200
@@ -22,6 +22,7 @@
 import java.io.PrintWriter;
 import java.math.BigDecimal;
 import java.sql.Connection;
+import java.util.ArrayList;
 import java.util.StringTokenizer;
 
 import javax.servlet.ServletConfig;
@@ -32,6 +33,7 @@
 import org.openbravo.base.filter.IsIDFilter;
 import org.openbravo.base.secureApp.HttpSecureAppServlet;
 import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.dal.core.OBContext;
 import org.openbravo.dal.service.OBDal;
 import org.openbravo.database.SessionInfo;
 import org.openbravo.erpCommon.businessUtility.Tax;
@@ -42,7 +44,9 @@
 import org.openbravo.erpCommon.utility.SequenceIdData;
 import org.openbravo.erpCommon.utility.Utility;
 import org.openbravo.financial.FinancialUtils;
+import org.openbravo.model.common.enterprise.Organization;
 import org.openbravo.model.common.invoice.Invoice;
+import org.openbravo.model.materialmgmt.transaction.ShipmentInOut;
 import org.openbravo.model.pricing.pricelist.PriceList;
 import org.openbravo.utils.Replace;
 import org.openbravo.xmlEngine.XmlDocument;
@@ -543,28 +547,27 @@
       xmlDocument.setData("reportShipmentReciept", "liststructure", new 
CreateFromInvoiceData[0]);
       xmlDocument.setData("reportPurchaseOrder", "liststructure", new 
CreateFromInvoiceData[0]);
     } else {
+      ArrayList<String> organizationList = new 
ArrayList<String>(OBContext.getOBContext()
+          
.getOrganizationStructureProvider().getNaturalTree(invoice.getOrganization().getId()));
+      String narturalOrgTreeList = Utility.arrayListToString(organizationList, 
true);
       if (isSOTrx.equals("Y")) {
         xmlDocument.setData("reportShipmentReciept", "liststructure", 
CreateFromInvoiceData
             .selectFromShipmentSOTrxCombo(this, vars.getLanguage(),
-                Utility.getContext(this, vars, "#User_Client", strWindowId),
-                Utility.getContext(this, vars, "#User_Org", strWindowId), 
strBPartner,
-                strIsTaxIncluded));
+                Utility.getContext(this, vars, "#User_Client", strWindowId), 
narturalOrgTreeList, 
+                strBPartner, strIsTaxIncluded));
         xmlDocument.setData("reportPurchaseOrder", "liststructure", 
CreateFromInvoiceData
             .selectFromPOSOTrxCombo(this, vars.getLanguage(),
-                Utility.getContext(this, vars, "#User_Client", strWindowId),
-                Utility.getContext(this, vars, "#User_Org", strWindowId), 
strBPartner,
-                strIsTaxIncluded));
+                Utility.getContext(this, vars, "#User_Client", strWindowId), 
narturalOrgTreeList,
+                strBPartner, strIsTaxIncluded));
       } else {
         xmlDocument.setData("reportShipmentReciept", "liststructure", 
CreateFromInvoiceData
             .selectFromShipmentCombo(this, vars.getLanguage(),
-                Utility.getContext(this, vars, "#User_Client", strWindowId),
-                Utility.getContext(this, vars, "#User_Org", strWindowId), 
strBPartner,
-                strIsTaxIncluded));
+                Utility.getContext(this, vars, "#User_Client", strWindowId), 
narturalOrgTreeList, 
+                strBPartner, strIsTaxIncluded));
         xmlDocument.setData("reportPurchaseOrder", "liststructure", 
CreateFromInvoiceData
             .selectFromPOCombo(this, vars.getLanguage(),
-                Utility.getContext(this, vars, "#User_Client", strWindowId),
-                Utility.getContext(this, vars, "#User_Org", strWindowId), 
strBPartner,
-                strIsTaxIncluded));
+                Utility.getContext(this, vars, "#User_Client", strWindowId), 
narturalOrgTreeList,
+                strBPartner, strIsTaxIncluded));
       }
     }
     {
@@ -593,6 +596,7 @@
     XmlDocument xmlDocument;
     String strPO = vars.getStringParameter("inpPurchaseOrder");
     String strInvoice = vars.getStringParameter("inpInvoice");
+    ShipmentInOut shipment = OBDal.getInstance().get(ShipmentInOut.class, 
strKey);
     final String strLocator = vars.getStringParameter("inpmLocatorId");
     final String isSOTrx = Utility.getContext(this, vars, "isSOTrx", 
strWindowId);
     if (vars.commandIn("FIND_PO"))
@@ -685,32 +689,35 @@
       xmlDocument.setData("reportInvoice", "liststructure", new 
CreateFromShipmentData[0]);
       xmlDocument.setData("reportPurchaseOrder", "liststructure", new 
CreateFromShipmentData[0]);
     } else {
+      ArrayList<String> organizationList = new 
ArrayList<String>(OBContext.getOBContext()
+          
.getOrganizationStructureProvider().getNaturalTree(shipment.getOrganization().getId()));
+      String narturalOrgTreeList = Utility.arrayListToString(organizationList, 
true);
       if (isSOTrx.equals("Y")) {
         xmlDocument.setData(
             "reportInvoice",
             "liststructure",
             CreateFromShipmentData.selectFromInvoiceTrxCombo(this, 
vars.getLanguage(),
                 Utility.getContext(this, vars, "#User_Client", strWindowId),
-                Utility.getContext(this, vars, "#User_Org", strWindowId), 
strBPartner));
+                narturalOrgTreeList, strBPartner));
         xmlDocument.setData(
             "reportPurchaseOrder",
             "liststructure",
             CreateFromShipmentData.selectFromPOSOTrxCombo(this, 
vars.getLanguage(),
                 Utility.getContext(this, vars, "#User_Client", strWindowId),
-                Utility.getContext(this, vars, "#User_Org", strWindowId), 
strBPartner));
+                narturalOrgTreeList, strBPartner));
       } else {
         xmlDocument.setData(
             "reportInvoice",
             "liststructure",
             CreateFromShipmentData.selectFromInvoiceCombo(this, 
vars.getLanguage(),
                 Utility.getContext(this, vars, "#User_Client", strWindowId),
-                Utility.getContext(this, vars, "#User_Org", strWindowId), 
strBPartner));
+                narturalOrgTreeList, strBPartner));
         xmlDocument.setData(
             "reportPurchaseOrder",
             "liststructure",
             CreateFromShipmentData.selectFromPOCombo(this, vars.getLanguage(),
                 Utility.getContext(this, vars, "#User_Client", strWindowId),
-                Utility.getContext(this, vars, "#User_Org", strWindowId), 
strBPartner));
+                narturalOrgTreeList, strBPartner));
       }
     }
 
diff -r d9a38ada2c86 -r 9626592579b5 
src/org/openbravo/erpCommon/utility/Utility.java
--- a/src/org/openbravo/erpCommon/utility/Utility.java  Wed Sep 19 16:17:34 
2012 +0200
+++ b/src/org/openbravo/erpCommon/utility/Utility.java  Tue Sep 18 17:41:08 
2012 +0200
@@ -1608,8 +1608,9 @@
   public static String arrayListToString(ArrayList<String> list, boolean 
addQuotes) {
     String rt = "";
     for (int i = 0; i < list.size(); i++) {
-      rt += rt.equals("") ? "" : ", " + (addQuotes ? "'" : "") + list.get(i)
+      String aux = (rt.equals("") ? "" : ", ") + (addQuotes ? "'" : "") + 
list.get(i)
           + (addQuotes ? "'" : "");
+      rt = rt + aux;
     }
     return rt;
   }

------------------------------------------------------------------------------
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

Reply via email to