<!DOCTYPE openRPTDef>
<report>
 <title>Invoice Information</title>
 <name>InvoiceInformation</name>
 <description></description>
 <watermark>
  <data>
   <query>Parameter Query</query>
   <column>watermark</column>
  </data>
  <opacity>25</opacity>
 </watermark>
 <size>Letter</size>
 <portrait/>
 <topmargin>50</topmargin>
 <bottommargin>50</bottommargin>
 <rightmargin>50</rightmargin>
 <leftmargin>50</leftmargin>
 <querysource>
  <name>GroupHead</name>
  <sql>SELECT invchead_id, invchead_ponumber,
       formatDate(invchead_shipdate) AS f_shipdate,
       formatDate(invchead_invcdate) AS f_invcdate,
       formatMoney(invoiceTotal(invchead_id)) AS f_amount,
       invchead_billto_name, invchead_billto_address1,
       invchead_billto_address2, invchead_billto_address3,
       ( invchead_billto_city || ' ' || invchead_billto_state || ', '
         || invchead_billto_zipcode ) AS billtocitystatezip,
       invchead_shipto_name, invchead_shipto_address1,
       invchead_shipto_address2, invchead_shipto_address3,
       ( invchead_shipto_city || ' ' || invchead_shipto_state || ', '
         || invchead_shipto_zipcode ) AS shiptocitystatezip,
       invchead_notes, invchead_invcnumber
FROM invchead LEFT OUTER JOIN (invcitem LEFT OUTER JOIN item ON (invcitem_item_id=item_id) ) ON (invcitem_invchead_id=invchead_id)
WHERE (invchead_id=&lt;? value("invchead_id") ?>)
GROUP BY invchead_id, invchead_ponumber,
         invchead_shipdate, invchead_invcdate,
         invchead_misc_amount, invchead_freight,
         invchead_billto_name, invchead_billto_address1,
         invchead_billto_address2, invchead_billto_address3,
         invchead_billto_city, invchead_billto_state, invchead_billto_zipcode,
         invchead_shipto_name, invchead_shipto_address1,
         invchead_shipto_address2, invchead_shipto_address3,
         invchead_shipto_city, invchead_shipto_state, invchead_shipto_zipcode,
         invchead_notes, invchead_invcnumber;</sql>
 </querysource>
 <querysource>
  <name>CustInfo</name>
  <sql>SELECT cust_id,
       cust_number,
       cust_name,
       addr_line1 AS cust_address1,
       addr_line2 AS cust_address2,
       addr_line3 AS cust_address3,
       addr_city || ' ' || addr_state || ', ' || addr_postalcode AS custcitystatezip
FROM invchead, custinfo
LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)
LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)
WHERE ( (invchead_id=&lt;? value("invchead_id") ?>)
 AND (invchead_cust_id=cust_id) );</sql>
 </querysource>
 <querysource>
  <name>Details</name>
  <sql>SELECT 1 as grpnum,
       arapply_id,
       CASE WHEN (arapply_source_doctype = 'C') THEN text('C/M')
            WHEN (arapply_fundstype='C') THEN text('Check')
            WHEN (arapply_fundstype='T') THEN text('Certified Check')
            WHEN (arapply_fundstype='M') THEN text('Master Card')
            WHEN (arapply_fundstype='V') THEN text('Visa')
            WHEN (arapply_fundstype='A') THEN text('American Express')
            WHEN (arapply_fundstype='D') THEN text('Discover Card')
            WHEN (arapply_fundstype='R') THEN text('Other Credit Card')
            WHEN (arapply_fundstype='K') THEN text('Cash')
            WHEN (arapply_fundstype='W') THEN text('Wire Transfer')
            WHEN (arapply_fundstype='O') THEN text('Other')
       END AS documenttype,
       CASE WHEN (arapply_source_doctype = 'C') THEN arapply_source_docnumber
            WHEN (arapply_source_doctype = 'R') THEN arapply_source_docnumber
            WHEN (arapply_source_doctype = 'K') THEN arapply_refnumber
            ELSE text('Error')
       END AS docnumber,
       formatDate(arapply_postdate) AS f_postdate,
       formatMoney(arapply_applied) AS f_amount
  FROM arapply, invchead
 WHERE ( (arapply_target_doctype='I')
   AND (arapply_target_docnumber=invchead_invcnumber)
   AND (invchead_id=&lt;? value("invchead_id") ?>) )
ORDER BY arapply_postdate;</sql>
 </querysource>
 <pghead>
  <firstpage/>
  <height>389</height>
  <field>
   <rect>
    <x>590</x>
    <y>80</y>
    <width>125</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>f_invcdate</column>
   </data>
  </field>
  <field>
   <rect>
    <x>155</x>
    <y>140</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>CustInfo</query>
    <column>cust_address2</column>
   </data>
  </field>
  <label>
   <rect>
    <x>0</x>
    <y>50</y>
    <width>150</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Cust. P/O Number:</string>
  </label>
  <field>
   <rect>
    <x>155</x>
    <y>80</y>
    <width>125</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>CustInfo</query>
    <column>cust_number</column>
   </data>
  </field>
  <field>
   <rect>
    <x>25</x>
    <y>280</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>invchead_billto_address2</column>
   </data>
  </field>
  <field>
   <rect>
    <x>155</x>
    <y>120</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>CustInfo</query>
    <column>cust_address1</column>
   </data>
  </field>
  <field>
   <rect>
    <x>590</x>
    <y>125</y>
    <width>125</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>f_amount</column>
   </data>
  </field>
  <field>
   <rect>
    <x>25</x>
    <y>240</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>invchead_billto_name</column>
   </data>
  </field>
  <field>
   <rect>
    <x>155</x>
    <y>25</y>
    <width>125</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>invchead_invcnumber</column>
   </data>
  </field>
  <field>
   <rect>
    <x>155</x>
    <y>160</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>CustInfo</query>
    <column>cust_address3</column>
   </data>
  </field>
  <field>
   <rect>
    <x>155</x>
    <y>100</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>CustInfo</query>
    <column>cust_name</column>
   </data>
  </field>
  <label>
   <rect>
    <x>360</x>
    <y>225</y>
    <width>50</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Ship To:</string>
  </label>
  <label>
   <rect>
    <x>457</x>
    <y>125</y>
    <width>125</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Invoice Amount:</string>
  </label>
  <field>
   <rect>
    <x>155</x>
    <y>180</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>CustInfo</query>
    <column>custcitystatezip</column>
   </data>
  </field>
  <label>
   <rect>
    <x>5</x>
    <y>350</y>
    <width>50</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Notes:</string>
  </label>
  <field>
   <rect>
    <x>25</x>
    <y>320</y>
    <width>325</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>billtocitystatezip</column>
   </data>
  </field>
  <label>
   <rect>
    <x>5</x>
    <y>225</y>
    <width>50</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Bill To:</string>
  </label>
  <label>
   <rect>
    <x>457</x>
    <y>100</y>
    <width>125</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Ship Date:</string>
  </label>
  <field>
   <rect>
    <x>385</x>
    <y>320</y>
    <width>325</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>shiptocitystatezip</column>
   </data>
  </field>
  <label>
   <rect>
    <x>0</x>
    <y>80</y>
    <width>150</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Customer #:</string>
  </label>
  <field>
   <rect>
    <x>385</x>
    <y>300</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>invchead_shipto_address3</column>
   </data>
  </field>
  <label>
   <rect>
    <x>0</x>
    <y>25</y>
    <width>150</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Invoice #:</string>
  </label>
  <field>
   <rect>
    <x>385</x>
    <y>280</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>invchead_shipto_address2</column>
   </data>
  </field>
  <field>
   <rect>
    <x>155</x>
    <y>50</y>
    <width>125</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>invchead_ponumber</column>
   </data>
  </field>
  <label>
   <rect>
    <x>457</x>
    <y>80</y>
    <width>125</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Invoice Date:</string>
  </label>
  <field>
   <rect>
    <x>385</x>
    <y>240</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>invchead_shipto_name</column>
   </data>
  </field>
  <text>
   <rect>
    <x>20</x>
    <y>365</y>
    <width>690</width>
    <height>20</height>
   </rect>
   <bottompad>0</bottompad>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <top/>
   <data>
    <query>GroupHead</query>
    <column>invchead_notes</column>
   </data>
  </text>
  <field>
   <rect>
    <x>25</x>
    <y>300</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>invchead_billto_address3</column>
   </data>
  </field>
  <field>
   <rect>
    <x>385</x>
    <y>260</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>invchead_shipto_address1</column>
   </data>
  </field>
  <label>
   <rect>
    <x>340</x>
    <y>10</y>
    <width>400</width>
    <height>40</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>20</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Invoice Information</string>
  </label>
  <field>
   <rect>
    <x>25</x>
    <y>260</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>invchead_billto_address1</column>
   </data>
  </field>
  <field>
   <rect>
    <x>590</x>
    <y>100</y>
    <width>125</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>GroupHead</query>
    <column>f_shipdate</column>
   </data>
  </field>
 </pghead>
 <section>
  <name>details</name>
  <group>
   <name>header</name>
   <column>grpnum</column>
   <head>
    <height>47</height>
    <label>
     <rect>
      <x>540</x>
      <y>25</y>
      <width>100</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>normal</weight>
     </font>
     <hcenter/>
     <vcenter/>
     <string>Apply Date</string>
    </label>
    <label>
     <rect>
      <x>5</x>
      <y>25</y>
      <width>100</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>normal</weight>
     </font>
     <left/>
     <vcenter/>
     <string>Type</string>
    </label>
    <label>
     <rect>
      <x>110</x>
      <y>25</y>
      <width>150</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>normal</weight>
     </font>
     <left/>
     <vcenter/>
     <string>Doc./Ref. Number</string>
    </label>
    <line>
     <xstart>5</xstart>
     <ystart>40</ystart>
     <xend>745</xend>
     <yend>40</yend>
     <weight>2</weight>
    </line>
    <label>
     <rect>
      <x>5</x>
      <y>5</y>
      <width>100</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>normal</weight>
     </font>
     <left/>
     <vcenter/>
     <string>Applications:</string>
    </label>
    <label>
     <rect>
      <x>645</x>
      <y>25</y>
      <width>100</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>normal</weight>
     </font>
     <hcenter/>
     <vcenter/>
     <string>Amount</string>
    </label>
   </head>
  </group>
  <detail>
   <key>
    <query>Details</query>
   </key>
   <height>17</height>
   <field>
    <rect>
     <x>645</x>
     <y>0</y>
     <width>100</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>Details</query>
     <column>f_amount</column>
    </data>
   </field>
   <field>
    <rect>
     <x>110</x>
     <y>0</y>
     <width>425</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>Details</query>
     <column>docnumber</column>
    </data>
   </field>
   <field>
    <rect>
     <x>5</x>
     <y>0</y>
     <width>100</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>Details</query>
     <column>documenttype</column>
    </data>
   </field>
   <field>
    <rect>
     <x>540</x>
     <y>0</y>
     <width>100</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>normal</weight>
    </font>
    <hcenter/>
    <vcenter/>
    <data>
     <query>Details</query>
     <column>f_postdate</column>
    </data>
   </field>
  </detail>
 </section>
 <pgfoot>
  <height>17</height>
  <label>
   <rect>
    <x>0</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>
  <field>
   <rect>
    <x>90</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>
 </pgfoot>
</report>
