1 -- Group: briefEarnedCommission
3 -- Notes: used by dspBriefEarnedCommissions
4 -- Copyright (c) 1999-2014 by OpenMFG LLC, d/b/a xTuple.
5 -- See www.xtuple.com/CPAL for the full text of the software license.
7 SELECT cohist_salesrep_id, salesrep_number, salesrep_name, cust_number, cust_name,
8 cohist_ordernumber, cohist_invcnumber, cohist_invcdate, currAbbr,
9 SUM(extprice) AS sumextprice,
10 SUM(cohist_commission) AS sumcommission,
11 SUM(baseextprice) AS sumbaseextprice,
12 SUM(basecommission) AS sumbasecommission,
13 'curr' AS sumextprice_xtnumericrole,
14 'curr' AS sumcommission_xtnumericrole,
15 'curr' AS sumbaseextprice_xtnumericrole,
16 'curr' AS sumbasecommission_xtnumericrole,
17 0 AS sumbaseextprice_xttotalrole,
18 0 AS sumbasecommission_xttotalrole
19 <? if exists("includeMisc") ?>
24 WHERE ((cohist_commission <> 0)
25 AND(cohist_invcdate BETWEEN <? value("startDate") ?> AND <? value("endDate") ?>)
26 <? if exists("includeMisc") ?>
27 AND (COALESCE(cohist_misc_type, '') <> 'T')
28 AND (COALESCE(cohist_misc_type, '') <> 'F')
30 <? if exists("salesrep_id") ?>
31 AND (cohist_salesrep_id=<? value("salesrep_id") ?>)
34 GROUP BY cohist_salesrep_id, salesrep_number, salesrep_name, cust_number, cust_name,
35 cohist_ordernumber, cohist_invcnumber, cohist_invcdate, currAbbr
36 ORDER BY salesrep_number, cust_number, cohist_invcdate;