From: Greg Pazo Date: Fri, 11 Apr 2014 19:03:10 +0000 (-0400) Subject: Issue #22634:include credit memos X-Git-Tag: v4.4.1~20^2 X-Git-Url: http://git.roojs.org/?a=commitdiff_plain;h=b6b4b2f275bef6d8f8d630ff9ab38ef80f3dfef0;p=xtuple Issue #22634:include credit memos --- diff --git a/foundation-database/public/tables/metasql/summarizedSalesHistory-detail.mql b/foundation-database/public/tables/metasql/summarizedSalesHistory-detail.mql index 4cc1e3bfa..4fc320160 100644 --- a/foundation-database/public/tables/metasql/summarizedSalesHistory-detail.mql +++ b/foundation-database/public/tables/metasql/summarizedSalesHistory-detail.mql @@ -1,6 +1,6 @@ -- Group: summarizedSalesHistory -- Name: detail --- Notes: +-- Notes: -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple. -- See www.xtuple.com/CPAL for the full text of the software license. @@ -9,75 +9,76 @@ SELECT 1 AS dummy, - || E'\n' || + || E'\n' || AS groupsLit, - substring( from 1 for 15) + substring( from 1 for 15) - || E'\n' || + || E'\n' || AS groups, - substring( from 1 for 30) + substring( from 1 for 30) - || E'\n' || + || E'\n' || AS groupsDescrip, -- End of columns for printed report cust_number, cohist_cust_id AS cust_number_xtidrole, cust_name, - + - custtype_code, cust_custtype_id AS custtype_code_xtidrole, - + custtype_code, cust_custtype_id AS custtype_code_xtidrole, + - item_number, item_id AS item_number_xtidrole, itemdescription, - + item_number, item_id AS item_number_xtidrole, itemdescription, + - salesrep_number, cohist_salesrep_id AS salesrep_number_xtidrole, salesrep_name, - + salesrep_number, cohist_salesrep_id AS salesrep_number_xtidrole, salesrep_name, + shipzone_name, shipzone_id AS shipzone_name_xtidrole, - + warehous_code, itemsite_warehous_id AS warehous_code_xtidrole, - + currAbbr, - MIN(custunitprice) AS minprice, MAX(custunitprice) AS maxprice, + MIN(custunitprice) AS minprice, MAX(custunitprice) AS maxprice, AVG(custunitprice) AS avgprice, - SUM(custextprice) AS totalsales, - CASE WHEN (SUM(cohist_qtyshipped) = 0) THEN 0 - ELSE SUM(custextprice) / SUM(cohist_qtyshipped) + SUM(custextprice) AS totalsales, + CASE WHEN (SUM(cohist_qtyshipped) = 0) THEN 0 + ELSE SUM(custextprice) / SUM(cohist_qtyshipped) END AS wtavgprice, - currConcat(baseCurrId()) AS currAbbr, - MIN(baseunitprice) AS minprice, MAX(baseunitprice) AS maxprice, - AVG(baseunitprice) AS avgprice, - SUM(baseextprice) AS totalsales, - CASE WHEN (SUM(cohist_qtyshipped) = 0) THEN 0 - ELSE SUM(baseextprice) / SUM(cohist_qtyshipped) + currConcat(baseCurrId()) AS currAbbr, + MIN(baseunitprice) AS minprice, MAX(baseunitprice) AS maxprice, + AVG(baseunitprice) AS avgprice, + SUM(baseextprice) AS totalsales, + CASE WHEN (SUM(cohist_qtyshipped) = 0) THEN 0 + ELSE SUM(baseextprice) / SUM(cohist_qtyshipped) END AS wtavgprice, - SUM(cohist_qtyshipped) AS totalunits, - MIN(cohist_invcdate) AS firstdate, - MAX(cohist_invcdate) AS lastdate, - SUM(cohist_qtyshipped) AS qtyshipped, - 'salesprice' AS minprice_xtnumericrole, - 'salesprice' AS maxprice_xtnumericrole, - 'salesprice' AS avgprice_xtnumericrole, - 'salesprice' AS wtavgprice_xtnumericrole, - 'qty' AS qtyshipped_xtnumericrole, + SUM(cohist_qtyshipped) AS totalunits, + MIN(cohist_invcdate) AS firstdate, + MAX(cohist_invcdate) AS lastdate, + SUM(cohist_qtyshipped) AS qtyshipped, + 'salesprice' AS minprice_xtnumericrole, + 'salesprice' AS maxprice_xtnumericrole, + 'salesprice' AS avgprice_xtnumericrole, + 'salesprice' AS wtavgprice_xtnumericrole, + 'qty' AS qtyshipped_xtnumericrole, 'curr' AS extprice_xtnumericrole, - 'qty' AS totalunits_xtnumericrole, - 'curr' AS totalsales_xtnumericrole, - 'qty' AS totalunits_xtnumericrole, - 'curr' AS totalsales_xtnumericrole, - 0 AS totalunits_xttotalrole, - 0 AS totalsales_xttotalrole -FROM saleshistory -WHERE (cohist_doctype NOT IN ('C') + 'qty' AS totalunits_xtnumericrole, + 'curr' AS totalsales_xtnumericrole, + 'qty' AS totalunits_xtnumericrole, + 'curr' AS totalsales_xtnumericrole, + 0 AS totalunits_xttotalrole, + 0 AS totalsales_xttotalrole +FROM saleshistory +WHERE ((COALESCE(cohist_misc_type, '') <> 'F') + AND (COALESCE(cohist_misc_type, '') <> 'T') AND (cohist_invcdate >= ) @@ -119,7 +120,7 @@ WHERE (cohist_doctype NOT IN ('C') - AND (prodcat_code ~ ) + AND (prodcat_code ~ ) @@ -128,7 +129,7 @@ WHERE (cohist_doctype NOT IN ('C') AND (custtype_code ~ ) - + AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id @@ -152,9 +153,9 @@ WHERE (cohist_doctype NOT IN ('C') - AND (currAbbr ~ ) + AND (currAbbr ~ ) -) +) GROUP BY dummy , cohist_salesrep_id, salesrep_number, salesrep_name @@ -196,4 +197,4 @@ GROUP BY dummy , warehous_code -; +; \ No newline at end of file