<!DOCTYPE openRPTDef>
<report>
 <title>Unposted Returns For Purchase Order</title>
 <name>UnpostedReturnsForPO</name>
 <description></description>
 <size>Letter</size>
 <portrait/>
 <topmargin>100</topmargin>
 <bottommargin>100</bottommargin>
 <rightmargin>50</rightmargin>
 <leftmargin>50</leftmargin>
 <querysource>
  <name>address</name>
  <sql>select formatAddr(&lt;? value("addr_id") ?>) AS f_addr;</sql>
 </querysource>
 <querysource>
  <name>detail</name>
  <sql>SELECT poitem_linenumber,
       COALESCE(item_number, 'Non-Inventory') AS item_number,
       COALESCE(uom_name, 'N/A') AS uom_name,
       poitem_vend_item_number, poitem_vend_uom,
       formatQty(poitem_qty_ordered)  AS f_poitem_qty_ordered,
       formatQty(poitem_qty_received) AS f_poitem_qty_received,
       formatQty(poitem_qty_returned) AS f_poitem_qty_returned,
       formatQty(SUM(COALESCE(poreject_qty, 0))) AS f_poreject_qty,
       rjctcode_code
FROM poreject LEFT OUTER JOIN rjctcode ON (poreject_rjctcode_id=rjctcode_id),
     poitem LEFT OUTER JOIN
     ( itemsite JOIN item
       ON (itemsite_item_id=item_id) JOIN uom ON (item_inv_uom_id=uom_id)
     ) ON (poitem_itemsite_id=itemsite_id)
WHERE ((poreject_poitem_id=poitem_id)
  AND  (NOT poreject_posted)
  AND  (poitem_pohead_id=&lt;? value("pohead_id") ?>))
GROUP BY
        poitem_linenumber,
        item_number,
        uom_name,
        poitem_vend_item_number,
        poitem_vend_uom,
        poitem_qty_ordered,
        poitem_qty_received,
        poitem_qty_returned,
        rjctcode_code
ORDER BY poitem_linenumber;</sql>
 </querysource>
 <querysource>
  <name>pohead</name>
  <sql>SELECT *
FROM pohead, vendinfo
WHERE ((pohead_vend_id=vend_id)
  AND  (pohead_id=&lt;? value("pohead_id") ?>));</sql>
 </querysource>
 <querysource>
  <name>logo</name>
  <sql>SELECT image_data 
FROM image 
WHERE ((image_name='logo'));</sql>
 </querysource>
 <rpthead>
  <height>127</height>
  <label>
   <rect>
    <x>290</x>
    <y>10</y>
    <width>450</width>
    <height>40</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>18</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Purchase Order Returns</string>
  </label>
  <image>
   <rect>
    <x>5</x>
    <y>5</y>
    <width>155</width>
    <height>95</height>
   </rect>
   <mode>stretch</mode>
   <data>
    <query>logo</query>
    <column>image_data</column>
   </data>
  </image>
  <line>
   <xstart>0</xstart>
   <ystart>113</ystart>
   <xend>740</xend>
   <yend>113</yend>
   <weight>2</weight>
  </line>
 </rpthead>
 <section>
  <name>Address</name>
  <detail>
   <key>
    <query>address</query>
   </key>
   <height>23</height>
   <label>
    <rect>
     <x>0</x>
     <y>0</y>
     <width>50</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>To:</string>
   </label>
   <text>
    <rect>
     <x>60</x>
     <y>0</y>
     <width>500</width>
     <height>18</height>
    </rect>
    <bottompad>11</bottompad>
    <font>
     <face>Arial</face>
     <size>10</size>
     <weight>bold</weight>
    </font>
    <left/>
    <top/>
    <data>
     <query>address</query>
     <column>f_addr</column>
    </data>
   </text>
  </detail>
 </section>
 <section>
  <name>POHead</name>
  <detail>
   <key>
    <query>pohead</query>
   </key>
   <height>107</height>
   <label>
    <rect>
     <x>1</x>
     <y>80</y>
     <width>35</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <vcenter/>
    <string>Line #</string>
   </label>
   <label>
    <rect>
     <x>200</x>
     <y>80</y>
     <width>100</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <vcenter/>
    <string>Vendor Item Number</string>
   </label>
   <label>
    <rect>
     <x>150</x>
     <y>80</y>
     <width>40</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <hcenter/>
    <vcenter/>
    <string>UOM</string>
   </label>
   <field>
    <rect>
     <x>100</x>
     <y>41</y>
     <width>100</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>pohead</query>
     <column>vend_number</column>
    </data>
   </field>
   <label>
    <rect>
     <x>310</x>
     <y>80</y>
     <width>40</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <hcenter/>
    <vcenter/>
    <string>UOM</string>
   </label>
   <label>
    <rect>
     <x>40</x>
     <y>80</y>
     <width>100</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <vcenter/>
    <string>Item Number</string>
   </label>
   <label>
    <rect>
     <x>340</x>
     <y>80</y>
     <width>100</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>Qty Received</string>
   </label>
   <field>
    <rect>
     <x>100</x>
     <y>30</y>
     <width>100</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>pohead</query>
     <column>pohead_number</column>
    </data>
   </field>
   <line>
    <xstart>0</xstart>
    <ystart>95</ystart>
    <xend>740</xend>
    <yend>95</yend>
    <weight>0</weight>
   </line>
   <label>
    <rect>
     <x>0</x>
     <y>30</y>
     <width>100</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <vcenter/>
    <string>Purchase Order #:</string>
   </label>
   <label>
    <rect>
     <x>0</x>
     <y>41</y>
     <width>100</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <vcenter/>
    <string>Vendor:</string>
   </label>
   <label>
    <rect>
     <x>565</x>
     <y>80</y>
     <width>85</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>Qty To Return</string>
   </label>
   <label>
    <rect>
     <x>450</x>
     <y>80</y>
     <width>100</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <string>Previously Returned</string>
   </label>
  </detail>
 </section>
 <section>
  <name>detail</name>
  <detail>
   <key>
    <query>detail</query>
   </key>
   <height>42</height>
   <field>
    <rect>
     <x>355</x>
     <y>0</y>
     <width>85</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_poitem_qty_received</column>
    </data>
   </field>
   <field>
    <rect>
     <x>200</x>
     <y>0</y>
     <width>100</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>poitem_vend_item_number</column>
    </data>
   </field>
   <field>
    <rect>
     <x>570</x>
     <y>0</y>
     <width>85</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_poreject_qty</column>
    </data>
   </field>
   <text>
    <rect>
     <x>45</x>
     <y>15</y>
     <width>645</width>
     <height>11</height>
    </rect>
    <bottompad>1</bottompad>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>rjctcode_code</column>
    </data>
   </text>
   <field>
    <rect>
     <x>310</x>
     <y>0</y>
     <width>40</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <hcenter/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>poitem_vend_uom</column>
    </data>
   </field>
   <field>
    <rect>
     <x>1</x>
     <y>0</y>
     <width>35</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>poitem_linenumber</column>
    </data>
   </field>
   <field>
    <rect>
     <x>459</x>
     <y>0</y>
     <width>90</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_poitem_qty_returned</column>
    </data>
   </field>
   <label>
    <rect>
     <x>1</x>
     <y>15</y>
     <width>60</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <vcenter/>
    <string>Reason</string>
   </label>
   <field>
    <rect>
     <x>150</x>
     <y>0</y>
     <width>40</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <hcenter/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>uom_name</column>
    </data>
   </field>
   <field>
    <rect>
     <x>40</x>
     <y>0</y>
     <width>100</width>
     <height>11</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>item_number</column>
    </data>
   </field>
  </detail>
 </section>
 <pgfoot>
  <height>23</height>
  <label>
   <rect>
    <x>615</x>
    <y>0</y>
    <width>85</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Page:</string>
  </label>
  <label>
   <rect>
    <x>0</x>
    <y>0</y>
    <width>85</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Report Date:</string>
  </label>
  <field>
   <rect>
    <x>90</x>
    <y>0</y>
    <width>100</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>Context Query</query>
    <column>report_date</column>
   </data>
  </field>
  <field>
   <rect>
    <x>700</x>
    <y>0</y>
    <width>40</width>
    <height>11</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>Context Query</query>
    <column>page_number</column>
   </data>
  </field>
 </pgfoot>
</report>
