svn commit: r1772346 - /ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1772346 - /ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java

Deepak Dixit-5
Author: deepak
Date: Fri Dec  2 14:01:57 2016
New Revision: 1772346

URL: http://svn.apache.org/viewvc?rev=1772346&view=rev
Log:
Fixed: Added missing code to get the ItemIssuance in setInvoicesToReadyFromShipment service. This bug was introduced at r#1628288 while delegator to EntityQuery convertion. Also added complete code to check null shipment on setInvoicesToReadyFromShipment, code was incompletely implemented.

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

Modified: ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java?rev=1772346&r1=1772345&r2=1772346&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java (original)
+++ ofbiz/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/invoice/InvoiceServices.java Fri Dec  2 14:01:57 2016
@@ -1205,19 +1205,24 @@ public class InvoiceServices {
         // 2. For every order check the invoice
         // 2.a If the invoice is in In-Process status, then move its status to ready and capture the payment.
         // 2.b If the invoice is in status other then IN-Process, skip this. These would be already paid and captured.
-
+        GenericValue shipment = null;
         try {
-            EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne();
+            shipment = EntityQuery.use(delegator).from("Shipment").where("shipmentId", shipmentId).queryOne();
         } catch (GenericEntityException e) {
             Debug.logError(e, "Trouble getting Shipment entity for shipment " + shipmentId, module);
             return ServiceUtil.returnError(UtilProperties.getMessage(resource,
                     "AccountingTroubleGettingShipmentEntity",
                     UtilMisc.toMap("shipmentId", shipmentId), locale));
         }
+        if (shipment == null) {
+            Debug.logError(UtilProperties.getMessage(resource, "AccountingShipmentNotFound", locale), module);
+            return ServiceUtil.returnError(UtilProperties.getMessage(resource, "AccountingShipmentNotFound", locale));
+        }
+
         List<GenericValue> itemIssuances = new LinkedList<GenericValue>();
         try {
             itemIssuances = EntityQuery.use(delegator).select("orderId", "shipmentId")
-                    .from("ItemIssuance").orderBy("orderId").distinct().queryList();
+                    .from("ItemIssuance").where("shipmentId", shipmentId).orderBy("orderId").distinct().queryList();
         } catch (GenericEntityException e) {
             Debug.logError(e, "Problem getting issued items from shipments", module);
             return ServiceUtil.returnError(UtilProperties.getMessage(resource,