Fixes issue 12793: Sales invoices of a business partner with a withholding associated creates payments with incorrect amount
authorSivaraman Rajagopal <sivaraman.rajagopal@openbravo.com>
Wed, 07 Jul 2010 16:58:42 +0530
changeset 7819 110640fbe62b
parent 7818 fc5a6575baf5
child 7820 683e3aa728a6
Fixes issue 12793: Sales invoices of a business partner with a withholding associated creates payments with incorrect amount

C_INVOICE_POST is responsible to complete both purchase and sales invoices. There, It just subtracts the withholding from the net amount without checking the document type if corresponding Business Partner is associated with any Withholding.
As a fix, an IF clause has been added to take Withholding into account only if document type is ''PURCHASE\" otherwise 0 amount will be subtracted.
src-db/database/model/functions/C_INVOICE_POST.xml
--- a/src-db/database/model/functions/C_INVOICE_POST.xml	Wed Jul 07 11:50:31 2010 +0200
+++ b/src-db/database/model/functions/C_INVOICE_POST.xml	Wed Jul 07 16:58:42 2010 +0530
@@ -1178,7 +1178,11 @@
       FROM C_INVOICETAX
       WHERE C_Invoice_ID = v_Record_ID
         AND Recalculate = 'N';
-      SELECT c_getwithholding(v_record_id) INTO withholdamount FROM dual;
+      IF (v_IsSOTrx = 'N') THEN
+        SELECT c_getwithholding(v_record_id) INTO withholdamount FROM dual;
+      ELSE
+        withholdamount:=0;
+      END IF;
 
       v_GrandTotal:=C_Currency_Round(v_GrandTotal+v_TaxNoRecalculable, v_Currency_ID, NULL) ;
       SELECT COALESCE(SUM(TAXAMT), 0) INTO v_GrandTotal