3 <title>Sales History</title>
4 <name>SalesHistory</name>
5 <description></description>
14 <topmargin>50</topmargin>
15 <bottommargin>50</bottommargin>
16 <rightmargin>50</rightmargin>
17 <leftmargin>50</leftmargin>
20 <sql>SELECT cohist_ordernumber AS sonumber,
21 cohist_invcnumber AS invnumber,
22 formatDate(cohist_orderdate) AS orddate,
23 formatDate(cohist_invcdate, 'Return') AS invcdate,
24 item_number, item_descrip1, item_descrip2,
25 formatQty(cohist_qtyshipped) AS shipped,
26 <? if exists("showPrices") ?>
27 formatPrice(currtobase(cohist_curr_id,cohist_unitprice,cohist_invcdate)) AS unitprice,
28 formatMoney(round(cohist_qtyshipped * currtobase(cohist_curr_id,cohist_unitprice,cohist_invcdate),2)) AS f_total,
33 round(cohist_qtyshipped * currtobase(cohist_curr_id,cohist_unitprice,cohist_invcdate),2) AS total
34 FROM cohist JOIN custinfo ON (cust_id=cohist_cust_id)
35 JOIN salesrep ON (salesrep_id=cohist_salesrep_id)
36 <? if exists("includeMisc") ?>
37 LEFT OUTER JOIN itemsite ON (itemsite_id=cohist_itemsite_id)
38 LEFT OUTER JOIN site() ON (warehous_id=itemsite_warehous_id)
39 LEFT OUTER JOIN item ON (item_id=itemsite_item_id)
41 JOIN itemsite ON (itemsite_id=cohist_itemsite_id)
42 JOIN site() ON (warehous_id=itemsite_warehous_id)
43 JOIN item ON (item_id=itemsite_item_id)
45 <? if exists("cohead_id") ?>
46 JOIN cohead ON (cohead_number=cohist_ordernumber)
49 <? if exists("includeMisc") ?>
50 AND (COALESCE(cohist_misc_type, '') <> 'F')
51 AND (COALESCE(cohist_misc_type, '') <> 'T')
53 <? if exists("startDate") ?>
54 AND (cohist_invcdate >= <? value("startDate") ?>)
56 <? if exists("endDate") ?>
57 AND (cohist_invcdate <= <? value("endDate") ?>)
59 <? if exists("shipStartDate") ?>
60 AND (cohist_shipdate >= <? value("shipStartDate") ?>)
62 <? if exists("shipEndDate") ?>
63 AND (cohist_shipdate <= <? value("shipEndDate") ?>)
65 <? if exists("salesrep_id") ?>
66 AND (cohist_salesrep_id=<? value("salesrep_id") ?>)
68 <? if exists("shipto_id") ?>
69 AND (cohist_shipto_id=<? value("shipto_id") ?>)
71 <? if exists("billToName") ?>
72 AND (UPPER(cohist_billtoname) ~ UPPER(<? value("billToName") ?>))
74 <? if exists("cust_id") ?>
75 AND (cohist_cust_id=<? value("cust_id") ?>)
77 <? if exists("custtype_id") ?>
78 AND (cust_custtype_id=<? value("custtype_id") ?>)
79 <? elseif exists("custtype_pattern") ?>
80 AND (cust_custtype_id IN (SELECT DISTINCT custtype_id
82 WHERE (custtype_code ~ <? value("custtype_pattern") ?>)))
84 <? if exists("by_custgrp" ?>
85 AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id
88 <? if exists("custgrp_id") ?>
89 AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id
91 WHERE (custgrpitem_custgrp_id=<? value("custgrp_id") ?>)))
93 <? if exists("custgrp_pattern") ?>
94 AND (cust_id IN (SELECT DISTINCT custgrpitem_cust_id
95 FROM custgrp, custgrpitem
96 WHERE ( (custgrpitem_custgrp_id=custgrp_id)
97 AND (custgrp_name ~ <? value("custgrp_pattern") ?>) )) )
100 <? if exists("item_id") ?>
101 AND (itemsite_item_id=<? value("item_id") ?>)
103 <? if exists("prodcat_id") ?>
104 AND (item_prodcat_id=<? value("prodcat_id") ?>)
106 <? if exists("prodcat_pattern") ?>
107 AND (item_prodcat_id IN (SELECT DISTINCT prodcat_id
109 WHERE (prodcat_code ~ <? value("prodcat_pattern") ?>)))
112 <? if exists("warehous_id") ?>
113 AND (itemsite_warehous_id=<? value("warehous_id") ?>)
115 <? if exists("shipzone_id") ?>
116 AND (cohist_shipzone_id=<? value("shipzone_id") ?>)
118 <? if exists("saletype_id") ?>
119 AND (cohist_saletype_id=<? value("saletype_id") ?>)
121 <? if exists("cohead_id") ?>
122 AND (cohead_id=<? value("cohead_id") ?>)
125 ORDER BY cohist_invcdate, item_number</sql>
129 <sql>SELECT <? if exists("showPrices") ?>
130 text('Unit Price') AS lbl_unitprice,
131 text('Total') AS lbl_total
133 text('') AS lbl_unitprice,
134 text('') AS lbl_total
135 <? endif ?>;</sql>
149 <weight>bold</weight>
153 <string>Sales History</string>
165 <weight>normal</weight>
171 <column>lbl_total</column>
184 <weight>normal</weight>
188 <string>Doc. #</string>
200 <weight>normal</weight>
204 <string>Ord. Date</string>
216 <weight>normal</weight>
220 <string>Description</string>
232 <weight>normal</weight>
236 <string>Item Number</string>
248 <weight>normal</weight>
252 <string>Shipped</string>
264 <weight>normal</weight>
268 <string>Invoice #</string>
287 <weight>normal</weight>
293 <column>lbl_unitprice</column>
306 <weight>normal</weight>
310 <string>Invc. Date</string>
319 <bottompad>12</bottompad>
323 <weight>bold</weight>
328 <query>Parameter Query</query>
329 <column>filter</column>
349 <weight>normal</weight>
353 <string>Invc. Date</string>
365 <weight>normal</weight>
369 <string>Invoice #</string>
381 <weight>normal</weight>
385 <string>Doc. #</string>
397 <weight>normal</weight>
401 <string>Shipped</string>
413 <weight>normal</weight>
419 <column>lbl_total</column>
432 <weight>normal</weight>
436 <string>Item Number</string>
455 <weight>normal</weight>
459 <string>Description</string>
471 <weight>normal</weight>
477 <column>lbl_unitprice</column>
490 <weight>normal</weight>
494 <string>Ord. Date</string>
501 <query>detail</query>
514 <weight>bold</weight>
519 <query>detail</query>
520 <column>item_descrip1</column>
533 <weight>bold</weight>
538 <query>detail</query>
539 <column>sonumber</column>
552 <weight>bold</weight>
557 <query>detail</query>
558 <column>item_descrip2</column>
571 <weight>bold</weight>
576 <query>detail</query>
577 <column>unitprice</column>
590 <weight>bold</weight>
595 <query>detail</query>
596 <column>orddate</column>
609 <weight>bold</weight>
614 <query>detail</query>
615 <column>shipped</column>
635 <weight>bold</weight>
640 <query>detail</query>
641 <column>invcdate</column>
654 <weight>bold</weight>
659 <query>detail</query>
660 <column>item_number</column>
673 <weight>bold</weight>
678 <query>detail</query>
679 <column>f_total</column>
692 <weight>bold</weight>
697 <query>detail</query>
698 <column>invnumber</column>
707 <query>showPrices</query>
720 <weight>bold</weight>
725 <query>detail</query>
726 <column>total</column>
728 <format builtin="true">money</format>
741 <weight>normal</weight>
745 <string>Total Sales:</string>
761 <weight>normal</weight>
765 <string>Report Date:</string>
777 <weight>bold</weight>
782 <query>Context Query</query>
783 <column>page_number</column>
796 <weight>normal</weight>
800 <string>Page:</string>
812 <weight>bold</weight>
817 <query>Context Query</query>
818 <column>report_date</column>