src/org/openbravo/erpCommon/ad_reports/ReportTaxInvoiceSale.jrxml
changeset 1271 762533f2593a
parent 1102 d24a59b98fbb
child 1727 cc39bbf87d15
--- a/src/org/openbravo/erpCommon/ad_reports/ReportTaxInvoiceSale.jrxml	Wed Jun 18 15:06:07 2008 +0000
+++ b/src/org/openbravo/erpCommon/ad_reports/ReportTaxInvoiceSale.jrxml	Wed Jun 18 15:34:13 2008 +0000
@@ -148,13 +148,15 @@
 	<parameter name="NUMBERFORMAT" isForPrompting="false" class="java.text.DecimalFormat"/>
 	<parameter name="LOCALE" isForPrompting="false" class="java.util.Locale"/>
 	<queryString><![CDATA[SELECT C_INVOICE.ISSOTRX AS SALES, 'Y' AS NATIONAL, C_INVOICE.DOCUMENTNO AS DOCUMENTNO, C_INVOICE.DATEINVOICED, C_BPARTNER.NAME AS BPARTNER, LTRIM(RTRIM(C_TAX.NAME, ' '), ' ') AS TAXNAME, 
-      SUM(C_INVOICETAX.TAXBASEAMT) AS TAXBASEAMT, SUM(C_INVOICETAX.TAXAMT) AS TAXAMT, '' AS ADTREEID
-      FROM C_TAX, C_INVOICETAX, C_INVOICE, C_BPARTNER_LOCATION, C_LOCATION, C_BPARTNER
+      SUM(CASE WHEN DOCBASETYPE IN ('ARC','APC') THEN -1 * C_INVOICETAX.TAXBASEAMT ELSE C_INVOICETAX.TAXBASEAMT END) AS TAXBASEAMT, 
+      SUM(CASE WHEN DOCBASETYPE IN ('ARC','APC') THEN -1 * C_INVOICETAX.TAXAMT ELSE C_INVOICETAX.TAXAMT END) AS TAXAMT, '' AS ADTREEID
+      FROM C_TAX, C_INVOICETAX, C_INVOICE, C_BPARTNER_LOCATION, C_LOCATION, C_BPARTNER, C_DOCTYPE
       WHERE C_TAX.C_TAX_ID=C_INVOICETAX.C_TAX_ID
       AND C_INVOICETAX.C_INVOICE_ID=C_INVOICE.C_INVOICE_ID
       AND C_INVOICE.C_BPARTNER_LOCATION_ID = C_BPARTNER_LOCATION.C_BPARTNER_LOCATION_ID
       AND C_BPARTNER_LOCATION.C_LOCATION_ID = C_LOCATION.C_LOCATION_ID
       AND C_INVOICE.C_BPARTNER_ID = C_BPARTNER.C_BPARTNER_ID
+      AND C_INVOICE.C_DOCTYPE_ID = C_DOCTYPE.C_DOCTYPE_ID
       AND C_INVOICE.PROCESSED = 'Y'
       AND C_INVOICE.ISACTIVE = 'Y'
       AND C_INVOICE.ISSOTRX = 'Y'