Author: sichen
Date: Thu Oct 11 12:40:59 2007
New Revision: 583931

URL: http://svn.apache.org/viewvc?rev=583931&view=rev
Log:
Before creating purchase invoices from purchase shipments, make sure that the 
items received were for an internal organization

Modified:
    
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java

Modified: 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java?rev=583931&r1=583930&r2=583931&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
 (original)
+++ 
ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/invoice/InvoiceServices.java
 Thu Oct 11 12:40:59 2007
@@ -1111,6 +1111,18 @@
         try {
             if (purchaseShipmentFound) {
                 items = delegator.findByCondition("ShipmentReceipt", 
shipmentIdsCond, null, UtilMisc.toList("shipmentId"));
+                // filter out items which have been received but are not 
actually owned by an internal organization, so they should not be on a purchase 
invoice
+                if (items != null) {
+                    Iterator itemsIter = items.iterator();
+                    while (itemsIter.hasNext()) {
+                        GenericValue item = (GenericValue) itemsIter.next();
+                        GenericValue inventoryItem = 
item.getRelatedOne("InventoryItem");
+                        GenericValue ownerPartyRole = 
delegator.findByPrimaryKeyCache("PartyRole", UtilMisc.toMap("partyId", 
inventoryItem.getString("ownerPartyId"), "roleTypeId", "INTERNAL_ORGANIZATIO"));
+                        if (UtilValidate.isEmpty(ownerPartyRole)) {
+                            items.remove(item);
+                        }
+                    }
+                }
             } else if (dropShipmentFound) {
 
                 List shipments = delegator.findByCondition("Shipment", 
shipmentIdsCond, null, null);


Reply via email to