Fixes Issue 39386: Goods Shipment IsCompletelyInvoiced
authorAtul Gaware <atul.gaware@openbravo.com>
Thu, 04 Oct 2018 01:14:57 +0530
changeset 35324 f56c59c75e26
parent 35323 7f68f19b9b80
child 35325 90c48060859c
Fixes Issue 39386: Goods Shipment IsCompletelyInvoiced
flag is not properly updated when voiding Sales Invoice

IsCompletelyInvoiced flag is set to No for the shipments
that have shipment line linked with the invoice lines of
the invoice that is being voided.
src-db/database/model/functions/C_INVOICE_POST.xml
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Wed Jan 16 13:32:57 2019 +0100
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Thu Oct 04 01:14:57 2018 +0530
@@ -792,6 +792,14 @@
             Processed='Y',
             Updated=now()
         WHERE C_Invoice_ID=v_Record_ID;
+        -- Update M_Inout isCompletelyInvoiced flag as No when voiding the invoice.
+        UPDATE M_InOut
+        SET iscompletelyinvoiced = 'N'
+        WHERE iscompletelyinvoiced = 'Y'
+          AND EXISTS (SELECT 1 FROM M_INOUTLINE l
+                      LEFT JOIN c_invoiceline il ON l.m_inoutline_id = il.m_inoutline_id
+                      WHERE il.c_invoice_id = v_Record_ID
+                        AND l.M_InOut_ID = M_InOut.M_InOut_ID);
         -- Update reversal invoice dates
         IF (v_voiddate_inv IS NOT NULL) THEN
           UPDATE C_INVOICE SET DateInvoiced = v_voiddate_inv WHERE C_Invoice_ID=v_RInvoice_ID;