Merge pull request #1 from shackbarth/keith1
[xtuple] / foundation-database / public / tables / report / InventoryAvailability.xml
1 <!DOCTYPE openRPTDef>
2 <report>
3  <title>Inventory Availability</title>
4  <name>InventoryAvailability</name>
5  <description></description>
6  <grid>
7   <snap/>
8   <show/>
9   <x>0.05</x>
10   <y>0.05</y>
11  </grid>
12  <size>Letter</size>
13  <portrait/>
14  <topmargin>50</topmargin>
15  <bottommargin>50</bottommargin>
16  <rightmargin>50</rightmargin>
17  <leftmargin>50</leftmargin>
18  <querysource>
19   <name>head</name>
20   <sql>SELECT &lt;? if exists("byDays") ?>
21          (text('Look ahead ') || text(&lt;? value("byDays") ?>) || text(' days'))
22        &lt;? elseif exists("byDate") ?>
23          (text('Cutoff date ') || formatDate(&lt;? value("byDate") ?>))
24        &lt;? elseif exists("byDates") ?>
25          (text('Dates from ') || formatDate(&lt;? value("startDate") ?>) || text(' to ') || formatDate(&lt;? value("endDate") ?>))
26        &lt;? else ?>
27          text('Item Site Lead Time')
28        &lt;? endif ?>
29        AS ltcriteria;</sql>
30  </querysource>
31  <querysource>
32   <name>detail</name>
33   <sql>SELECT item_number, item_descrip1, item_descrip2,
34        warehous_code, itemsite_leadtime,
35        formatQty(qtyonhand) AS f_qtyonhand,
36        formatQty(noNeg(qtyonhand - allocated)) AS f_unallocated,
37        formatQty(noNeg(allocated)) AS f_allocated,
38        formatQty(ordered) AS f_ordered,
39        formatQty(requests) AS f_requests,
40        formatQty(reorderlevel) AS f_reorderlevel,
41        (qtyonhand - allocated + ordered) AS available,
42        formatQty(qtyonhand - allocated + ordered) AS f_available
43   FROM (SELECT 
44            &lt;? if reExists("[vV]end") ?>
45              DISTINCT
46            &lt;? endif ?>
47              itemsite_id,
48              CASE WHEN (item_type IN ('P', 'O')) THEN 1
49                   WHEN (item_type IN ('M')) THEN 2
50                   ELSE 0
51              END AS altId,
52              item_number, item_descrip1, item_descrip2, item_inv_uom_id,
53              warehous_id, warehous_code, itemsite_leadtime,
54              qtyAvailable(itemsite_id) AS qtyonhand,
55              CASE WHEN itemsite_useparams THEN itemsite_reorderlevel
56                   ELSE 0.0
57              END AS reorderlevel,
58              CASE WHEN itemsite_useparams THEN itemsite_ordertoqty
59                   ELSE 0.0
60              END AS outlevel,
61              &lt;? if exists("byVend") ?>
62                vend_number,
63              &lt;? else ?>
64                NULL AS vend_number,
65              &lt;? endif ?>
66              &lt;? if exists("byLeadTime") ?>
67                qtyAllocated(itemsite_id, itemsite_leadtime) AS allocated,
68                qtyOrdered(itemsite_id,   itemsite_leadtime) AS ordered, 
69                qtypr(itemsite_id,   itemsite_leadtime) AS requests
70              &lt;? elseif exists("byDays") ?>
71                qtyAllocated(itemsite_id, CAST(&lt;? value("byDays") ?> AS INTEGER)) AS allocated,
72                qtyOrdered(itemsite_id,   CAST(&lt;? value("byDays") ?> AS INTEGER)) AS ordered,
73                qtypr(itemsite_id,   CAST(&lt;? value("byDays") ?> AS INTEGER)) AS requests  
74              &lt;? elseif exists("byDate") ?>
75                qtyAllocated(itemsite_id, (&lt;? value("byDate") ?> - CURRENT_DATE)) AS allocated,
76                qtyOrdered(itemsite_id,   (&lt;? value("byDate") ?> - CURRENT_DATE)) AS ordered,
77                qtypr(itemsite_id,   (&lt;? value("byDate") ?> - CURRENT_DATE)) AS requests 
78              &lt;? elseif exists("byDates") ?>
79                qtyAllocated(itemsite_id, &lt;? value("startDate") ?>, &lt;? value("endDate") ?>) AS allocated,
80                qtyOrdered(itemsite_id,   &lt;? value("startDate") ?>, &lt;? value("endDate") ?>) AS ordered,
81                qtypr(itemsite_id,   &lt;? value("startDate") ?>, &lt;? value("endDate") ?>) AS requests
82              &lt;? endif ?>
83       FROM item, itemsite, whsinfo
84            &lt;? if reExists("[vV]end") ?>
85              , vendinfo JOIN itemsrc ON (itemsrc_vend_id=vend_id)
86            &lt;? endif ?>
87       WHERE ( (itemsite_active)
88           AND (itemsite_item_id=item_id)
89           AND (itemsite_warehous_id=warehous_id)
90           &lt;? if exists("warehous_id") ?>
91             AND (warehous_id=&lt;? value("warehous_id") ?>)
92           &lt;? endif ?>
93           &lt;? if exists("item_id") ?>
94             AND (item_id=&lt;? value("item_id") ?>)
95           &lt;? elseif exists("classcode_id") ?>
96             AND (item_classcode_id=&lt;? value("classcode_id") ?>)
97           &lt;? elseif exists("classcode_pattern") ?>
98             AND (item_classcode_id IN (SELECT classcode_id
99                                        FROM classcode
100                                        WHERE (classcode_code ~ &lt;? value("classcode_pattern") ?>)))
101           &lt;? elseif exists("plancode_id") ?>
102             AND (itemsite_plancode_id=&lt;? value("plancode_id") ?>)
103           &lt;? elseif exists("plancode_pattern") ?>
104             AND (itemsite_plancode_id IN (SELECT plancode_id
105                                           FROM plancode
106                                           WHERE (plancode_code ~ &lt;? value("plancode_pattern") ?>)))
107           &lt;? elseif exists("itemgrp_id") ?>
108             AND (item_id IN (SELECT itemgrpitem_item_id
109                              FROM itemgrpitem
110                              WHERE (itemgrpitem_itemgrp_id=&lt;? value("itemgrp_id") ?>)))
111           &lt;? elseif exists("itemgrp_pattern") ?>
112             AND (item_id IN (SELECT itemgrpitem_item_id
113                              FROM itemgrpitem, itemgrp
114                              WHERE ( (itemgrpitem_itemgrp_id=itemgrp_id)
115                                     AND (itemgrp_name ~ &lt;? value("itemgrp_pattern") ?>) ) ))
116           &lt;? elseif exists("itemgrp") ?>
117             AND (item_id IN (SELECT DISTINCT itemgrpitem_item_id FROM itemgrpitem))
118           &lt;? endif ?>
119           &lt;? if reExists("[vV]end") ?>
120             AND (itemsrc_item_id=item_id)
121           &lt;? endif ?>
122           &lt;? if exists("vend_id") ?>
123             AND (vend_id=&lt;? value("vend_id") ?>)
124           &lt;? elseif exists("vendtype_id") ?>
125             AND (vend_vendtype_id=&lt;? value("vendtype_id") ?>)
126           &lt;? elseif exists("vendtype_pattern") ?>
127             AND (vend_vendtype_id IN (SELECT vendtype_id
128                                       FROM vendtype
129                                       WHERE (vendtype_code ~ &lt;? value("vendtype_pattern") ?>)))
130           &lt;? endif ?>
131       ) ) AS data
132 &lt;? if exists("showReorder") ?>
133  WHERE ( ((qtyonhand - allocated + ordered) &lt;= reorderlevel)
134   &lt;? if exists("ignoreReorderAtZero") ?>
135    AND (NOT ( ((qtyonhand - allocated + ordered) = 0) AND (reorderlevel = 0)) )
136   &lt;? endif ?>
137   )
138 &lt;? elseif exists("showShortages") ?>
139  WHERE ((qtyonhand - allocated + ordered) &lt; 0)
140 &lt;? endif ?>
141 ORDER BY item_number, warehous_code DESC;</sql>
142  </querysource>
143  <rpthead>
144   <height>221</height>
145   <label>
146    <rect>
147     <x>434</x>
148     <y>200</y>
149     <width>100</width>
150     <height>15</height>
151    </rect>
152    <font>
153     <face>Arial</face>
154     <size>8</size>
155     <weight>normal</weight>
156    </font>
157    <hcenter/>
158    <vcenter/>
159    <string>Unallocated</string>
160   </label>
161   <label>
162    <rect>
163     <x>10</x>
164     <y>178</y>
165     <width>35</width>
166     <height>15</height>
167    </rect>
168    <font>
169     <face>Arial</face>
170     <size>8</size>
171     <weight>normal</weight>
172    </font>
173    <hcenter/>
174    <vcenter/>
175    <string>Site</string>
176   </label>
177   <label>
178    <rect>
179     <x>540</x>
180     <y>200</y>
181     <width>100</width>
182     <height>15</height>
183    </rect>
184    <font>
185     <face>Arial</face>
186     <size>8</size>
187     <weight>normal</weight>
188    </font>
189    <hcenter/>
190    <vcenter/>
191    <string>Reorder Level</string>
192   </label>
193   <label>
194    <rect>
195     <x>275</x>
196     <y>10</y>
197     <width>450</width>
198     <height>38</height>
199    </rect>
200    <font>
201     <face>Arial</face>
202     <size>18</size>
203     <weight>bold</weight>
204    </font>
205    <right/>
206    <vcenter/>
207    <string>Inventory Availability</string>
208   </label>
209   <label>
210    <rect>
211     <x>0</x>
212     <y>43</y>
213     <width>130</width>
214     <height>20</height>
215    </rect>
216    <font>
217     <face>Arial</face>
218     <size>10</size>
219     <weight>normal</weight>
220    </font>
221    <right/>
222    <vcenter/>
223    <string>Availability as of: </string>
224   </label>
225   <line>
226    <xstart>5</xstart>
227    <ystart>215</ystart>
228    <xend>745</xend>
229    <yend>215</yend>
230    <weight>2</weight>
231   </line>
232   <label>
233    <rect>
234     <x>65</x>
235     <y>178</y>
236     <width>106</width>
237     <height>15</height>
238    </rect>
239    <font>
240     <face>Arial</face>
241     <size>8</size>
242     <weight>normal</weight>
243    </font>
244    <left/>
245    <vcenter/>
246    <string>Item Number</string>
247   </label>
248   <label>
249    <rect>
250     <x>10</x>
251     <y>200</y>
252     <width>35</width>
253     <height>15</height>
254    </rect>
255    <font>
256     <face>Arial</face>
257     <size>8</size>
258     <weight>normal</weight>
259    </font>
260    <hcenter/>
261    <vcenter/>
262    <string>LT</string>
263   </label>
264   <label>
265    <rect>
266     <x>330</x>
267     <y>178</y>
268     <width>100</width>
269     <height>15</height>
270    </rect>
271    <font>
272     <face>Arial</face>
273     <size>8</size>
274     <weight>normal</weight>
275    </font>
276    <hcenter/>
277    <vcenter/>
278    <string>QOH</string>
279   </label>
280   <label>
281    <rect>
282     <x>431</x>
283     <y>178</y>
284     <width>100</width>
285     <height>15</height>
286    </rect>
287    <font>
288     <face>Arial</face>
289     <size>8</size>
290     <weight>normal</weight>
291    </font>
292    <hcenter/>
293    <vcenter/>
294    <string>Allocated</string>
295   </label>
296   <label>
297    <rect>
298     <x>65</x>
299     <y>200</y>
300     <width>106</width>
301     <height>15</height>
302    </rect>
303    <font>
304     <face>Arial</face>
305     <size>8</size>
306     <weight>normal</weight>
307    </font>
308    <left/>
309    <vcenter/>
310    <string>Description</string>
311   </label>
312   <label>
313    <rect>
314     <x>540</x>
315     <y>178</y>
316     <width>100</width>
317     <height>15</height>
318    </rect>
319    <font>
320     <face>Arial</face>
321     <size>8</size>
322     <weight>normal</weight>
323    </font>
324    <hcenter/>
325    <vcenter/>
326    <string>On Order</string>
327   </label>
328   <label>
329    <rect>
330     <x>645</x>
331     <y>178</y>
332     <width>100</width>
333     <height>15</height>
334    </rect>
335    <font>
336     <face>Arial</face>
337     <size>8</size>
338     <weight>normal</weight>
339    </font>
340    <hcenter/>
341    <vcenter/>
342    <string>Available</string>
343   </label>
344   <field>
345    <rect>
346     <x>140</x>
347     <y>43</y>
348     <width>280</width>
349     <height>20</height>
350    </rect>
351    <font>
352     <face>Arial</face>
353     <size>10</size>
354     <weight>bold</weight>
355    </font>
356    <left/>
357    <vcenter/>
358    <data>
359     <query>head</query>
360     <column>ltcriteria</column>
361    </data>
362   </field>
363   <label>
364    <rect>
365     <x>540</x>
366     <y>189</y>
367     <width>100</width>
368     <height>15</height>
369    </rect>
370    <font>
371     <face>Arial</face>
372     <size>8</size>
373     <weight>normal</weight>
374    </font>
375    <hcenter/>
376    <vcenter/>
377    <string>PO Requests</string>
378   </label>
379   <text>
380    <rect>
381     <x>10</x>
382     <y>63</y>
383     <width>725</width>
384     <height>15</height>
385    </rect>
386    <bottompad>12</bottompad>
387    <font>
388     <face>Arial</face>
389     <size>10</size>
390     <weight>bold</weight>
391    </font>
392    <left/>
393    <top/>
394    <data>
395     <query>Parameter Query</query>
396     <column>filter</column>
397    </data>
398   </text>
399  </rpthead>
400  <pghead>
401   <firstpage/>
402   <height>6</height>
403  </pghead>
404  <pghead>
405   <height>36</height>
406   <label>
407    <rect>
408     <x>434</x>
409     <y>15</y>
410     <width>100</width>
411     <height>15</height>
412    </rect>
413    <font>
414     <face>Arial</face>
415     <size>8</size>
416     <weight>normal</weight>
417    </font>
418    <hcenter/>
419    <vcenter/>
420    <string>Unallocated</string>
421   </label>
422   <label>
423    <rect>
424     <x>65</x>
425     <y>15</y>
426     <width>106</width>
427     <height>15</height>
428    </rect>
429    <font>
430     <face>Arial</face>
431     <size>8</size>
432     <weight>normal</weight>
433    </font>
434    <left/>
435    <vcenter/>
436    <string>Description</string>
437   </label>
438   <label>
439    <rect>
440     <x>10</x>
441     <y>15</y>
442     <width>35</width>
443     <height>15</height>
444    </rect>
445    <font>
446     <face>Arial</face>
447     <size>8</size>
448     <weight>normal</weight>
449    </font>
450    <hcenter/>
451    <vcenter/>
452    <string>LT</string>
453   </label>
454   <label>
455    <rect>
456     <x>540</x>
457     <y>15</y>
458     <width>100</width>
459     <height>15</height>
460    </rect>
461    <font>
462     <face>Arial</face>
463     <size>8</size>
464     <weight>normal</weight>
465    </font>
466    <hcenter/>
467    <vcenter/>
468    <string>Reorder Level</string>
469   </label>
470   <label>
471    <rect>
472     <x>65</x>
473     <y>0</y>
474     <width>106</width>
475     <height>15</height>
476    </rect>
477    <font>
478     <face>Arial</face>
479     <size>8</size>
480     <weight>normal</weight>
481    </font>
482    <left/>
483    <vcenter/>
484    <string>Item Number</string>
485   </label>
486   <label>
487    <rect>
488     <x>645</x>
489     <y>0</y>
490     <width>100</width>
491     <height>15</height>
492    </rect>
493    <font>
494     <face>Arial</face>
495     <size>8</size>
496     <weight>normal</weight>
497    </font>
498    <hcenter/>
499    <vcenter/>
500    <string>Available</string>
501   </label>
502   <label>
503    <rect>
504     <x>330</x>
505     <y>0</y>
506     <width>100</width>
507     <height>15</height>
508    </rect>
509    <font>
510     <face>Arial</face>
511     <size>8</size>
512     <weight>normal</weight>
513    </font>
514    <hcenter/>
515    <vcenter/>
516    <string>QOH</string>
517   </label>
518   <label>
519    <rect>
520     <x>434</x>
521     <y>0</y>
522     <width>100</width>
523     <height>15</height>
524    </rect>
525    <font>
526     <face>Arial</face>
527     <size>8</size>
528     <weight>normal</weight>
529    </font>
530    <hcenter/>
531    <vcenter/>
532    <string>Allocated</string>
533   </label>
534   <line>
535    <xstart>5</xstart>
536    <ystart>30</ystart>
537    <xend>745</xend>
538    <yend>30</yend>
539    <weight>2</weight>
540   </line>
541   <label>
542    <rect>
543     <x>10</x>
544     <y>0</y>
545     <width>35</width>
546     <height>15</height>
547    </rect>
548    <font>
549     <face>Arial</face>
550     <size>8</size>
551     <weight>normal</weight>
552    </font>
553    <hcenter/>
554    <vcenter/>
555    <string>Site</string>
556   </label>
557   <label>
558    <rect>
559     <x>540</x>
560     <y>0</y>
561     <width>100</width>
562     <height>15</height>
563    </rect>
564    <font>
565     <face>Arial</face>
566     <size>8</size>
567     <weight>normal</weight>
568    </font>
569    <hcenter/>
570    <vcenter/>
571    <string>On Order</string>
572   </label>
573  </pghead>
574  <section>
575   <name>detail</name>
576   <detail>
577    <key>
578     <query>detail</query>
579    </key>
580    <height>56</height>
581    <field>
582     <rect>
583      <x>330</x>
584      <y>0</y>
585      <width>100</width>
586      <height>15</height>
587     </rect>
588     <font>
589      <face>Arial</face>
590      <size>8</size>
591      <weight>bold</weight>
592     </font>
593     <hcenter/>
594     <vcenter/>
595     <data>
596      <query>detail</query>
597      <column>f_qtyonhand</column>
598     </data>
599    </field>
600    <field>
601     <rect>
602      <x>645</x>
603      <y>0</y>
604      <width>100</width>
605      <height>15</height>
606     </rect>
607     <font>
608      <face>Arial</face>
609      <size>8</size>
610      <weight>bold</weight>
611     </font>
612     <hcenter/>
613     <vcenter/>
614     <data>
615      <query>detail</query>
616      <column>f_available</column>
617     </data>
618    </field>
619    <field>
620     <rect>
621      <x>65</x>
622      <y>0</y>
623      <width>250</width>
624      <height>15</height>
625     </rect>
626     <font>
627      <face>Arial</face>
628      <size>8</size>
629      <weight>bold</weight>
630     </font>
631     <left/>
632     <vcenter/>
633     <data>
634      <query>detail</query>
635      <column>item_number</column>
636     </data>
637    </field>
638    <field>
639     <rect>
640      <x>434</x>
641      <y>0</y>
642      <width>100</width>
643      <height>15</height>
644     </rect>
645     <font>
646      <face>Arial</face>
647      <size>8</size>
648      <weight>bold</weight>
649     </font>
650     <hcenter/>
651     <vcenter/>
652     <data>
653      <query>detail</query>
654      <column>f_allocated</column>
655     </data>
656    </field>
657    <field>
658     <rect>
659      <x>10</x>
660      <y>15</y>
661      <width>35</width>
662      <height>15</height>
663     </rect>
664     <font>
665      <face>Arial</face>
666      <size>8</size>
667      <weight>bold</weight>
668     </font>
669     <hcenter/>
670     <vcenter/>
671     <data>
672      <query>detail</query>
673      <column>itemsite_leadtime</column>
674     </data>
675    </field>
676    <field>
677     <rect>
678      <x>540</x>
679      <y>0</y>
680      <width>100</width>
681      <height>15</height>
682     </rect>
683     <font>
684      <face>Arial</face>
685      <size>8</size>
686      <weight>bold</weight>
687     </font>
688     <hcenter/>
689     <vcenter/>
690     <data>
691      <query>detail</query>
692      <column>f_ordered</column>
693     </data>
694    </field>
695    <line>
696     <xstart>5</xstart>
697     <ystart>50</ystart>
698     <xend>745</xend>
699     <yend>50</yend>
700     <weight>0</weight>
701    </line>
702    <field>
703     <rect>
704      <x>65</x>
705      <y>15</y>
706      <width>250</width>
707      <height>15</height>
708     </rect>
709     <font>
710      <face>Arial</face>
711      <size>8</size>
712      <weight>bold</weight>
713     </font>
714     <left/>
715     <vcenter/>
716     <data>
717      <query>detail</query>
718      <column>item_descrip1</column>
719     </data>
720    </field>
721    <field>
722     <rect>
723      <x>10</x>
724      <y>0</y>
725      <width>35</width>
726      <height>15</height>
727     </rect>
728     <font>
729      <face>Arial</face>
730      <size>8</size>
731      <weight>bold</weight>
732     </font>
733     <hcenter/>
734     <vcenter/>
735     <data>
736      <query>detail</query>
737      <column>warehous_code</column>
738     </data>
739    </field>
740    <field>
741     <rect>
742      <x>65</x>
743      <y>30</y>
744      <width>250</width>
745      <height>15</height>
746     </rect>
747     <font>
748      <face>Arial</face>
749      <size>8</size>
750      <weight>bold</weight>
751     </font>
752     <left/>
753     <vcenter/>
754     <data>
755      <query>detail</query>
756      <column>item_descrip2</column>
757     </data>
758    </field>
759    <field>
760     <rect>
761      <x>434</x>
762      <y>30</y>
763      <width>100</width>
764      <height>16</height>
765     </rect>
766     <font>
767      <face>Arial</face>
768      <size>8</size>
769      <weight>bold</weight>
770     </font>
771     <hcenter/>
772     <vcenter/>
773     <data>
774      <query>detail</query>
775      <column>f_unallocated</column>
776     </data>
777    </field>
778    <field>
779     <rect>
780      <x>540</x>
781      <y>31</y>
782      <width>100</width>
783      <height>12</height>
784     </rect>
785     <font>
786      <face>Arial</face>
787      <size>8</size>
788      <weight>bold</weight>
789     </font>
790     <hcenter/>
791     <vcenter/>
792     <data>
793      <query>detail</query>
794      <column>f_reorderlevel</column>
795     </data>
796    </field>
797    <field>
798     <rect>
799      <x>540</x>
800      <y>14</y>
801      <width>100</width>
802      <height>15</height>
803     </rect>
804     <font>
805      <face>Arial</face>
806      <size>8</size>
807      <weight>bold</weight>
808     </font>
809     <hcenter/>
810     <vcenter/>
811     <data>
812      <query>detail</query>
813      <column>f_requests</column>
814     </data>
815    </field>
816   </detail>
817  </section>
818  <pgfoot>
819   <height>16</height>
820   <field>
821    <rect>
822     <x>90</x>
823     <y>0</y>
824     <width>100</width>
825     <height>15</height>
826    </rect>
827    <font>
828     <face>Arial</face>
829     <size>8</size>
830     <weight>bold</weight>
831    </font>
832    <left/>
833    <vcenter/>
834    <data>
835     <query>Context Query</query>
836     <column>report_date</column>
837    </data>
838   </field>
839   <label>
840    <rect>
841     <x>615</x>
842     <y>0</y>
843     <width>85</width>
844     <height>15</height>
845    </rect>
846    <font>
847     <face>Arial</face>
848     <size>8</size>
849     <weight>normal</weight>
850    </font>
851    <right/>
852    <vcenter/>
853    <string>Page:</string>
854   </label>
855   <field>
856    <rect>
857     <x>705</x>
858     <y>0</y>
859     <width>40</width>
860     <height>15</height>
861    </rect>
862    <font>
863     <face>Arial</face>
864     <size>8</size>
865     <weight>bold</weight>
866    </font>
867    <left/>
868    <vcenter/>
869    <data>
870     <query>Context Query</query>
871     <column>page_number</column>
872    </data>
873   </field>
874   <label>
875    <rect>
876     <x>0</x>
877     <y>0</y>
878     <width>85</width>
879     <height>15</height>
880    </rect>
881    <font>
882     <face>Arial</face>
883     <size>8</size>
884     <weight>normal</weight>
885    </font>
886    <right/>
887    <vcenter/>
888    <string>Report Date:</string>
889   </label>
890  </pgfoot>
891 </report>