related to issue 39415 prepaymentamt is wrong calculated
authorSandra Huguet <sandra.huguet@openbravo.com>
Mon, 12 Nov 2018 13:00:12 +0100
changeset 34961 03d8fd2a8cca
parent 34960 649b56723e39
child 34962 6323b569fcbb
related to issue 39415 prepaymentamt is wrong calculated
prepayment amout is wrong calculated when two order lines
are added in to the invoice.
src-db/database/model/functions/C_INVOICE_POST.xml
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Wed Nov 07 07:45:34 2018 +0530
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Mon Nov 12 13:00:12 2018 +0100
@@ -1767,8 +1767,8 @@
     UPDATE C_Invoice i
     SET prepaymentamt = (
       SELECT COALESCE(SUM(fps.paidamt), 0)
-      FROM FIN_Payment_Schedule fps
-      WHERE fps.C_Order_ID = i.C_Order_ID
+      FROM FIN_Payment_Schedule fps 
+      WHERE EXISTS ( select 1  from c_invoiceline il , c_orderline ol where il.c_invoice_id=v_Record_ID and il.c_orderline_id=ol.c_orderline_id and fps.C_Order_ID =ol.c_order_id)  
     )
     WHERE i.C_Invoice_ID = v_Record_ID;
   END IF;--FINISH_PROCESS