<!DOCTYPE openRPTDef>
<report>
 <title>Vendor Information</title>
 <name>VendorInformation</name>
 <description></description>
 <grid>
  <snap/>
  <show/>
  <x>0.05</x>
  <y>0.05</y>
 </grid>
 <size>Letter</size>
 <portrait/>
 <topmargin>50</topmargin>
 <bottommargin>50</bottommargin>
 <rightmargin>50</rightmargin>
 <leftmargin>50</leftmargin>
 <querysource>
  <name>head</name>
  <sql>SELECT vend_name,      vend_vendtype_id, vend_terms_id,
       vend_shipvia,   vend_active,      vend_cntct1_id,
       vend_cntct2_id, crmacct_id, vend_number,
       MIN(pohead_orderdate) AS minpodate, 
       MAX(pohead_orderdate) AS maxpodate, 
       formatMoney(SUM(currToBase(pohead_curr_id,
       (poitem_qty_ordered - poitem_qty_received) * poitem_unitprice,
                              CURRENT_DATE))) AS backlog ,
       c1.cntct_first_name || ' ' || c1.cntct_last_name AS contact1_name,
       c1.cntct_phone AS contact1_phone, c1.cntct_phone2 AS contact1_phone, 
       formataddr(a1.addr_id) AS contact1_address,
       c1.cntct_fax as contact1_fax, c1.cntct_email AS contct1_email,
       c2.cntct_first_name || ' ' || c2.cntct_last_name AS contact2_name,
       c2.cntct_phone AS contact2_phone, c2.cntct_phone2 AS contact2_phone, 
       c2.cntct_fax as contact2_fax, c2.cntct_email AS contct2_email,
       formataddr(a2.addr_id) AS contact2_address,
       vend_comments
  FROM vendinfo
    LEFT OUTER JOIN cntct c1 ON (vend_cntct1_id = c1.cntct_id)
    LEFT OUTER JOIN addr  a1 ON (c1.cntct_addr_id = a1.addr_id)
    LEFT OUTER JOIN cntct c2 ON (vend_cntct2_id = c2.cntct_id)
    LEFT OUTER JOIN addr  a2 ON (c2.cntct_addr_id = a2.addr_id)
    LEFT OUTER JOIN pohead ON (pohead_vend_id=vend_id)
    LEFT OUTER JOIN poitem ON (poitem_pohead_id=pohead_id
                               AND poitem_status='O')
    JOIN crmacct ON (crmacct_vend_id=vend_id)
    WHERE (vend_id=&lt;? value("vend_id") ?>) 
    GROUP BY vend_name, vend_vendtype_id, vend_terms_id,
       vend_shipvia,   vend_active,vend_cntct1_id,
       vend_cntct2_id, crmacct_id,
       c1.cntct_first_name, c1.cntct_last_name,
       c1.cntct_phone, c1.cntct_phone2, 
       a1.addr_id,c1.cntct_fax, c1.cntct_email,
       c2.cntct_first_name,c2.cntct_last_name ,
       c2.cntct_phone, c2.cntct_phone2, 
       c2.cntct_fax, c2.cntct_email,a2.addr_id,
       vend_comments, vend_number;</sql>
 </querysource>
 <querysource>
  <name>lypurch</name>
  <sql>SELECT formatMoney(SUM(currToBase(vohead_curr_id,
                                        vohead_amount,
                                        vohead_gldistdate))) AS purchases 
                           FROM vohead 
                           WHERE (vohead_posted
                             AND (vohead_gldistdate 
                                  BETWEEN (DATE_TRUNC('year', CURRENT_DATE) - INTERVAL '1 year')
                                      AND (DATE_TRUNC('year', CURRENT_DATE) - INTERVAL '1 day'))
                             AND (vohead_vend_id=&lt;? value("vend_id") ?>));</sql>
 </querysource>
 <querysource>
  <name>ytdpurch</name>
  <sql>SELECT formatMoney(SUM(currToBase(vohead_curr_id,
                                        vohead_amount,
                                        vohead_gldistdate))) AS purchases 
                           FROM vohead 
                           WHERE (vohead_posted
                             AND (vohead_gldistdate 
                                  BETWEEN (DATE_TRUNC('year', CURRENT_DATE))
                                      AND (CURRENT_DATE - INTERVAL '1 day'))
                             AND (vohead_vend_id=&lt;? value("vend_id") ?>));</sql>
 </querysource>
 <querysource>
  <name>backlog</name>
  <sql>SELECT formatMoney( COALESCE( SUM( (noNeg(coitem_qtyord - coitem_qtyshipped + coitem_qtyreturned) * coitem_qty_invuomratio) * (coitem_price / coitem_price_invuomratio) ), 0 ) ) AS backlog FROM cohead, coitem, itemsite, item WHERE ( (coitem_cohead_id=cohead_id) AND (coitem_itemsite_id=itemsite_id) AND (itemsite_item_id=item_id) AND (coitem_status='O') AND (cohead_cust_id=&lt;? value("cust_id") ?>) );</sql>
 </querysource>
 <querysource>
  <name>OpenBalance</name>
  <sql>SELECT formatMoney(COALESCE(SUM((apopen_amount-apopen_paid) / apopen_curr_rate * 
                      CASE WHEN (apopen_doctype IN ('D','V')) THEN 1 
                      ELSE -1 END), 0.0)) AS balance 
                    FROM apopen 
                    WHERE ((apopen_open)
                       AND (apopen_vend_id=&lt;? value("vend_id") ?>));
</sql>
 </querysource>
 <querysource>
  <name>podate</name>
  <sql>SELECT formatDate(MIN(pohead_orderdate)) AS firstpodate, formatDate(MAX(pohead_orderdate)) AS lastpodate
FROM pohead
WHERE (pohead_vend_id=&lt;? value("vend_id") ?>)</sql>
 </querysource>
 <rpthead>
  <height>392</height>
  <label>
   <rect>
    <x>385</x>
    <y>260</y>
    <width>85</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>FAX:</string>
  </label>
  <text>
   <rect>
    <x>105</x>
    <y>368</y>
    <width>575</width>
    <height>15</height>
   </rect>
   <bottompad>0</bottompad>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <top/>
   <data>
    <query>head</query>
    <column>vend_comments</column>
   </data>
  </text>
  <field>
   <rect>
    <x>134</x>
    <y>305</y>
    <width>100</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>podate</query>
    <column>firstpodate</column>
   </data>
  </field>
  <line>
   <xstart>370</xstart>
   <ystart>160</ystart>
   <xend>370</xend>
   <yend>295</yend>
   <weight>0</weight>
  </line>
  <line>
   <xstart>5</xstart>
   <ystart>155</ystart>
   <xend>360</xend>
   <yend>155</yend>
   <weight>0</weight>
  </line>
  <label>
   <rect>
    <x>375</x>
    <y>10</y>
    <width>350</width>
    <height>38</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>18</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Vendor Information</string>
  </label>
  <field>
   <rect>
    <x>99.8</x>
    <y>229</y>
    <width>260</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>contact1_name</column>
   </data>
  </field>
  <field>
   <rect>
    <x>100</x>
    <y>260</y>
    <width>260</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>contact1_fax</column>
   </data>
  </field>
  <label>
   <rect>
    <x>270</x>
    <y>305</y>
    <width>120</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Last Year Purchases:</string>
  </label>
  <field>
   <rect>
    <x>474</x>
    <y>229</y>
    <width>260</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>contact2_name</column>
   </data>
  </field>
  <label>
   <rect>
    <x>15</x>
    <y>75</y>
    <width>80</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Name:</string>
  </label>
  <label>
   <rect>
    <x>5</x>
    <y>325</y>
    <width>115</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Last Purchase Date:</string>
  </label>
  <line>
   <xstart>5</xstart>
   <ystart>295</ystart>
   <xend>740</xend>
   <yend>295</yend>
   <weight>2</weight>
  </line>
  <label>
   <rect>
    <x>10</x>
    <y>260</y>
    <width>85</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>FAX:</string>
  </label>
  <label>
   <rect>
    <x>385</x>
    <y>229</y>
    <width>85</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Contact Name:</string>
  </label>
  <field>
   <rect>
    <x>400</x>
    <y>305</y>
    <width>145</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <data>
    <query>lypurch</query>
    <column>purchases</column>
   </data>
  </field>
  <field>
   <rect>
    <x>475</x>
    <y>275</y>
    <width>260</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>contact2_email</column>
   </data>
  </field>
  <field>
   <rect>
    <x>100</x>
    <y>275</y>
    <width>260</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>contact1_email</column>
   </data>
  </field>
  <field>
   <rect>
    <x>475</x>
    <y>260</y>
    <width>260</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>contact2_fax</column>
   </data>
  </field>
  <label>
   <rect>
    <x>10</x>
    <y>245</y>
    <width>85</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Phone:</string>
  </label>
  <field>
   <rect>
    <x>100</x>
    <y>75</y>
    <width>295</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>vend_name</column>
   </data>
  </field>
  <label>
   <rect>
    <x>290</x>
    <y>325</y>
    <width>100</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>YTD Purchases:</string>
  </label>
  <field>
   <rect>
    <x>400</x>
    <y>325</y>
    <width>145</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <data>
    <query>ytdpurch</query>
    <column>purchases</column>
   </data>
  </field>
  <label>
   <rect>
    <x>1.60714</x>
    <y>345.214</y>
    <width>118.393</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Backlog:</string>
  </label>
  <label>
   <rect>
    <x>385</x>
    <y>275</y>
    <width>85</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Email:</string>
  </label>
  <field>
   <rect>
    <x>475</x>
    <y>245</y>
    <width>260</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>contact2_phone</column>
   </data>
  </field>
  <label>
   <rect>
    <x>385</x>
    <y>140</y>
    <width>135</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Contact 2</string>
  </label>
  <line>
   <xstart>380</xstart>
   <ystart>155</ystart>
   <xend>735</xend>
   <yend>155</yend>
   <weight>0</weight>
  </line>
  <label>
   <rect>
    <x>10</x>
    <y>229</y>
    <width>85</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Contact Name:</string>
  </label>
  <label>
   <rect>
    <x>385</x>
    <y>245</y>
    <width>85</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Phone:</string>
  </label>
  <label>
   <rect>
    <x>10</x>
    <y>140</y>
    <width>170</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Contact 1</string>
  </label>
  <field>
   <rect>
    <x>130</x>
    <y>344.893</y>
    <width>103</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>backlog</column>
   </data>
  </field>
  <field>
   <rect>
    <x>100</x>
    <y>245</y>
    <width>260</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>contact1_phone</column>
   </data>
  </field>
  <field>
   <rect>
    <x>130</x>
    <y>325</y>
    <width>105</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>podate</query>
    <column>lastpodate</column>
   </data>
  </field>
  <field>
   <rect>
    <x>410</x>
    <y>345</y>
    <width>134.643</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <data>
    <query>OpenBalance</query>
    <column>balance</column>
   </data>
  </field>
  <label>
   <rect>
    <x>5</x>
    <y>365</y>
    <width>95</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Notes:</string>
  </label>
  <label>
   <rect>
    <x>15</x>
    <y>95</y>
    <width>80</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Number:</string>
  </label>
  <field>
   <rect>
    <x>100</x>
    <y>95</y>
    <width>200</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>vend_number</column>
   </data>
  </field>
  <label>
   <rect>
    <x>10</x>
    <y>275</y>
    <width>85</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Email:</string>
  </label>
  <label>
   <rect>
    <x>286</x>
    <y>345</y>
    <width>104</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Open Balance:</string>
  </label>
  <label>
   <rect>
    <x>5</x>
    <y>305</y>
    <width>115</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>First Purchase Date:</string>
  </label>
  <text>
   <rect>
    <x>21</x>
    <y>163</y>
    <width>341</width>
    <height>12</height>
   </rect>
   <bottompad>0</bottompad>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <top/>
   <data>
    <query>head</query>
    <column>contact1_address</column>
   </data>
  </text>
  <text>
   <rect>
    <x>399</x>
    <y>164</y>
    <width>333</width>
    <height>12</height>
   </rect>
   <bottompad>0</bottompad>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <top/>
   <data>
    <query>head</query>
    <column>contact2_address</column>
   </data>
  </text>
 </rpthead>
 <pgfoot>
  <height>18</height>
  <field>
   <rect>
    <x>95</x>
    <y>0</y>
    <width>100</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>Context Query</query>
    <column>report_date</column>
   </data>
  </field>
  <label>
   <rect>
    <x>615</x>
    <y>0</y>
    <width>85</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Page:</string>
  </label>
  <label>
   <rect>
    <x>5</x>
    <y>0</y>
    <width>85</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Report Date:</string>
  </label>
  <field>
   <rect>
    <x>705</x>
    <y>0</y>
    <width>40</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>Context Query</query>
    <column>page_number</column>
   </data>
  </field>
 </pgfoot>
</report>
