details:   https://code.openbravo.com/erp/devel/pi/rev/73454ec69b17
changeset: 35455:73454ec69b17
user:      Mark <markmm82 <at> gmail.com>
date:      Wed Jan 30 20:00:19 2019 -0300
summary:   Fixes issue 40044: Negative quantity in Create lines from Receipt in 
Purchase
Invoice window if the order was previously invoiced and received.

To calculate the pending to invoice movement quantity was needed to subtract the
sum of the already invoiced quantity instead of the matched quantity as it is 
the
total of the received quantity.

diffstat:

 src/org/openbravo/common/datasource/InOutLinePEHQLTransformer.java |  9 
+++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (47 lines):

diff -r 5318eb8145c5 -r 73454ec69b17 
src/org/openbravo/common/datasource/InOutLinePEHQLTransformer.java
--- a/src/org/openbravo/common/datasource/InOutLinePEHQLTransformer.java        
Fri Feb 15 09:11:12 2019 +0100
+++ b/src/org/openbravo/common/datasource/InOutLinePEHQLTransformer.java        
Wed Jan 30 20:00:19 2019 -0300
@@ -11,7 +11,7 @@
  * under the License.
  * The Original Code is Openbravo ERP.
  * The Initial Developer of the Original Code is Openbravo SLU
- * All portions are Copyright (C) 2018 Openbravo SLU
+ * All portions are Copyright (C) 2018-2019 Openbravo SLU
  * All Rights Reserved.
  * Contributor(s):  ______________________________________.
  *************************************************************************
@@ -80,6 +80,7 @@
       fromClause.append(" left join il.invoice i");
     } else {
       fromClause.append(" left join e.procurementReceiptInvoiceMatchList mi");
+      fromClause.append(" left join mi.invoiceLine mil");
     }
 
     return fromClause.toString();
@@ -142,7 +143,7 @@
       groupByClause.append("  OR (e.explode='Y')");
     } else {
       groupByClause.append(
-          " HAVING ((e.movementQuantity-SUM(COALESCE(mi.quantity,0))) <> 0 OR 
(e.explode='Y'))");
+          " HAVING ((e.movementQuantity-SUM(COALESCE(mil.invoicedQuantity,0))) 
<> 0 OR (e.explode='Y'))");
     }
     return groupByClause.toString();
   }
@@ -153,7 +154,7 @@
       movementQuantityHql.append(
           " (e.movementQuantity - sum(COALESCE(CASE WHEN i.documentStatus = 
'CO' THEN il.invoicedQuantity ELSE 0 END, 0)))");
     } else {
-      movementQuantityHql.append(" (e.movementQuantity - 
COALESCE(SUM(mi.quantity), 0))");
+      movementQuantityHql.append(" (e.movementQuantity - 
COALESCE(SUM(mil.invoicedQuantity), 0))");
     }
     return movementQuantityHql.toString();
   }
@@ -179,7 +180,7 @@
 
     } else {
       orderQuantityHql.append(
-          " e.orderQuantity * ((e.movementQuantity - coalesce(mi.quantity,0)) 
/ (case when e.movementQuantity <> 0 then e.movementQuantity else null end))");
+          " e.orderQuantity * ((e.movementQuantity - 
coalesce(mil.invoicedQuantity,0)) / (case when e.movementQuantity <> 0 then 
e.movementQuantity else null end))");
     }
     return orderQuantityHql.toString();
   }


_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to