<!DOCTYPE openRPTDef>
<report>
 <title>Statement</title>
 <name>Statement</name>
 <description>"As of" date included</description>
 <grid>
  <snap/>
  <show/>
  <x>0.05</x>
  <y>0.05</y>
 </grid>
 <size>Letter</size>
 <portrait/>
 <topmargin>100</topmargin>
 <bottommargin>100</bottommargin>
 <rightmargin>100</rightmargin>
 <leftmargin>100</leftmargin>
 <querysource>
  <name>detail</name>
  <sql>SELECT CASE WHEN (araging_doctype = 'I') THEN &lt;? value("invoice") ?>
            WHEN (araging_doctype = 'D') THEN &lt;? value("debit") ?>
            WHEN (araging_doctype = 'C') THEN &lt;? value("credit") ?>
            WHEN (araging_doctype = 'R') THEN &lt;? value("deposit") ?>
            ELSE 'Misc.'
       END AS doctype,
       araging_docnumber AS f_docnumber,
       formatDate(CAST(araging_docdate AS DATE)) AS f_docdate,
       CASE WHEN (araging_doctype IN ('I','C','D')) THEN formatDate(araging_duedate)
            ELSE ''
       END AS f_duedate,
       formatMoney(araging_aropen_amount) AS f_amount,
       formatMoney(araging_aropen_amount - araging_total_val) AS f_applied,
       formatMoney(araging_total_val) AS f_balance
FROM araging(&lt;? value("asofdate") ?>, true, false)
WHERE ((araging_cust_id = &lt;? value("cust_id") ?>)
   AND (abs(araging_aropen_amount) > 0)
      )
ORDER BY araging_duedate;</sql>
 </querysource>
 <querysource>
  <name>head</name>
  <sql>SELECT cust_name, addr_line1 AS cust_address1, addr_line2 AS cust_address2, addr_line3 AS cust_address3,
       (addr_city || '  ' || addr_state || '  ' || addr_postalcode) AS citystatezip,
       formatDate(COALESCE(&lt;? value("asofdate") ?>, current_date)) AS asofdate
FROM custinfo
LEFT OUTER JOIN cntct ON (cust_cntct_id=cntct_id)
LEFT OUTER JOIN addr ON (cntct_addr_id=addr_id)
WHERE (cust_id = &lt;? value("cust_id") ?>);</sql>
 </querysource>
 <querysource>
  <name>Currency</name>
  <sql>SELECT currconcat(cust_curr_id) AS currAbbr
  FROM custinfo
 WHERE (cust_id=&lt;? value("cust_id") ?>)
</sql>
 </querysource>
 <querysource>
  <name>foot</name>
  <sql>SELECT formatMoney(SUM(araging_cur_val)) AS f_current,
       formatMoney(SUM(araging_thirty_val)) AS f_thirty,
       formatMoney(SUM(araging_sixty_val)) AS f_sixty,
       formatMoney(SUM(araging_ninety_val)) AS f_ninety,
       formatMoney(SUM(araging_plus_val)) AS f_plus,
       formatMoney(SUM(araging_total_val)) AS f_total
FROM araging(&lt;? value("asofdate") ?>, true, false)
WHERE ((abs(araging_aropen_amount) > 0)
   AND (araging_cust_id = &lt;? value("cust_id") ?>));</sql>
 </querysource>
 <pghead>
  <height>277</height>
  <line>
   <xstart>475</xstart>
   <ystart>245</ystart>
   <xend>475</xend>
   <yend>270</yend>
   <weight>0</weight>
  </line>
  <field>
   <rect>
    <x>25</x>
    <y>190</y>
    <width>300</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>citystatezip</column>
   </data>
  </field>
  <label>
   <rect>
    <x>545</x>
    <y>250</y>
    <width>95</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Balance Due</string>
  </label>
  <label>
   <rect>
    <x>14.2513</x>
    <y>250</y>
    <width>86.4477</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Document Type</string>
  </label>
  <line>
   <xstart>10</xstart>
   <ystart>245</ystart>
   <xend>10</xend>
   <yend>270</yend>
   <weight>0</weight>
  </line>
  <label>
   <rect>
    <x>430</x>
    <y>15</y>
    <width>175</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>14</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Statement</string>
  </label>
  <label>
   <rect>
    <x>215</x>
    <y>250</y>
    <width>90</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Document Date</string>
  </label>
  <line>
   <xstart>445</xstart>
   <ystart>40</ystart>
   <xend>445</xend>
   <yend>75</yend>
   <weight>0</weight>
  </line>
  <label>
   <rect>
    <x>315</x>
    <y>250</y>
    <width>75</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Due Date</string>
  </label>
  <line>
   <xstart>395</xstart>
   <ystart>245</ystart>
   <xend>395</xend>
   <yend>270</yend>
   <weight>0</weight>
  </line>
  <line>
   <xstart>445</xstart>
   <ystart>75</ystart>
   <xend>585</xend>
   <yend>75</yend>
   <weight>0</weight>
  </line>
  <line>
   <xstart>310</xstart>
   <ystart>245</ystart>
   <xend>310</xend>
   <yend>270</yend>
   <weight>0</weight>
  </line>
  <line>
   <xstart>123.972</xstart>
   <ystart>244.219</ystart>
   <xend>123.972</xend>
   <yend>269.461</yend>
   <weight>0</weight>
  </line>
  <label>
   <rect>
    <x>130</x>
    <y>250</y>
    <width>80</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Document No.</string>
  </label>
  <field>
   <rect>
    <x>25</x>
    <y>150</y>
    <width>300</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>cust_address1</column>
   </data>
  </field>
  <field>
   <rect>
    <x>25</x>
    <y>165</y>
    <width>300</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>cust_address2</column>
   </data>
  </field>
  <label>
   <rect>
    <x>442</x>
    <y>40</y>
    <width>140</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>6</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>STATEMENT DATE</string>
  </label>
  <line>
   <xstart>10</xstart>
   <ystart>244.541</ystart>
   <xend>640</xend>
   <yend>244.541</yend>
   <weight>0</weight>
  </line>
  <field>
   <rect>
    <x>25</x>
    <y>135</y>
    <width>300</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>cust_name</column>
   </data>
  </field>
  <line>
   <xstart>210</xstart>
   <ystart>245.459</ystart>
   <xend>210</xend>
   <yend>270.459</yend>
   <weight>0</weight>
  </line>
  <field>
   <rect>
    <x>475</x>
    <y>60</y>
    <width>90</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>12</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>Context Query</query>
    <column>report_date</column>
   </data>
  </field>
  <line>
   <xstart>640</xstart>
   <ystart>245</ystart>
   <xend>640</xend>
   <yend>270</yend>
   <weight>0</weight>
  </line>
  <field>
   <rect>
    <x>25</x>
    <y>180</y>
    <width>300</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>cust_address3</column>
   </data>
  </field>
  <label>
   <rect>
    <x>407</x>
    <y>250</y>
    <width>60</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Amount</string>
  </label>
  <line>
   <xstart>545</xstart>
   <ystart>245</ystart>
   <xend>545</xend>
   <yend>270</yend>
   <weight>0</weight>
  </line>
  <label>
   <rect>
    <x>480</x>
    <y>250</y>
    <width>60</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Applied</string>
  </label>
  <line>
   <xstart>585</xstart>
   <ystart>40</ystart>
   <xend>585</xend>
   <yend>75</yend>
   <weight>0</weight>
  </line>
  <line>
   <xstart>445</xstart>
   <ystart>40</ystart>
   <xend>585</xend>
   <yend>40</yend>
   <weight>0</weight>
  </line>
  <line>
   <xstart>10</xstart>
   <ystart>270</ystart>
   <xend>640</xend>
   <yend>270</yend>
   <weight>0</weight>
  </line>
  <line>
   <xstart>445</xstart>
   <ystart>55</ystart>
   <xend>585</xend>
   <yend>55</yend>
   <weight>0</weight>
  </line>
  <label>
   <rect>
    <x>25</x>
    <y>50</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <string>As Of Date:</string>
  </label>
  <field>
   <rect>
    <x>105</x>
    <y>50</y>
    <width>100</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>asofdate</column>
   </data>
  </field>
 </pghead>
 <section>
  <name>detail</name>
  <group>
   <name>unnamed</name>
   <column></column>
  </group>
  <detail>
   <key>
    <query>detail</query>
   </key>
   <height>16</height>
   <field>
    <rect>
     <x>20</x>
     <y>0</y>
     <width>100</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>12</size>
     <weight>normal</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>doctype</column>
    </data>
   </field>
   <field>
    <rect>
     <x>395</x>
     <y>0</y>
     <width>80</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>11</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_amount</column>
    </data>
   </field>
   <field>
    <rect>
     <x>130</x>
     <y>0</y>
     <width>75</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>11</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_docnumber</column>
    </data>
   </field>
   <field>
    <rect>
     <x>480</x>
     <y>0</y>
     <width>75</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>11</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_applied</column>
    </data>
   </field>
   <field>
    <rect>
     <x>315</x>
     <y>0</y>
     <width>75</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>11</size>
     <weight>normal</weight>
    </font>
    <hcenter/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_duedate</column>
    </data>
   </field>
   <field>
    <rect>
     <x>215</x>
     <y>0</y>
     <width>90</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>11</size>
     <weight>normal</weight>
    </font>
    <hcenter/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_docdate</column>
    </data>
   </field>
   <field>
    <rect>
     <x>560</x>
     <y>0</y>
     <width>80</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>11</size>
     <weight>normal</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_balance</column>
    </data>
   </field>
  </detail>
 </section>
 <pgfoot>
  <lastpage/>
  <height>111</height>
  <line>
   <xstart>190</xstart>
   <ystart>5</ystart>
   <xend>190</xend>
   <yend>35</yend>
   <weight>0</weight>
  </line>
  <line>
   <xstart>10</xstart>
   <ystart>5</ystart>
   <xend>10</xend>
   <yend>35</yend>
   <weight>0</weight>
  </line>
  <label>
   <rect>
    <x>285</x>
    <y>5</y>
    <width>80</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>6</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>61 to 90 Days</string>
  </label>
  <line>
   <xstart>100</xstart>
   <ystart>5</ystart>
   <xend>100</xend>
   <yend>35</yend>
   <weight>0</weight>
  </line>
  <line>
   <xstart>365</xstart>
   <ystart>5</ystart>
   <xend>365</xend>
   <yend>35</yend>
   <weight>0</weight>
  </line>
  <label>
   <rect>
    <x>195</x>
    <y>5</y>
    <width>85</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>6</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>31 to 60 Days</string>
  </label>
  <label>
   <rect>
    <x>15</x>
    <y>5</y>
    <width>85</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>6</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Current</string>
  </label>
  <field>
   <rect>
    <x>190</x>
    <y>15</y>
    <width>85</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>11</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <data>
    <query>foot</query>
    <column>f_sixty</column>
   </data>
  </field>
  <field>
   <rect>
    <x>365</x>
    <y>15</y>
    <width>85</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>11</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <data>
    <query>foot</query>
    <column>f_plus</column>
   </data>
  </field>
  <field>
   <rect>
    <x>100</x>
    <y>15</y>
    <width>85</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>11</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <data>
    <query>foot</query>
    <column>f_thirty</column>
   </data>
  </field>
  <line>
   <xstart>10</xstart>
   <ystart>35</ystart>
   <xend>640</xend>
   <yend>35</yend>
   <weight>0</weight>
  </line>
  <field>
   <rect>
    <x>10</x>
    <y>15</y>
    <width>85</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>11</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <data>
    <query>foot</query>
    <column>f_current</column>
   </data>
  </field>
  <line>
   <xstart>640</xstart>
   <ystart>5</ystart>
   <xend>640</xend>
   <yend>35</yend>
   <weight>0</weight>
  </line>
  <label>
   <rect>
    <x>20</x>
    <y>45</y>
    <width>75</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Currency:</string>
  </label>
  <label>
   <rect>
    <x>455</x>
    <y>10</y>
    <width>75</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Total Due</string>
  </label>
  <line>
   <xstart>280</xstart>
   <ystart>5</ystart>
   <xend>280</xend>
   <yend>35</yend>
   <weight>0</weight>
  </line>
  <label>
   <rect>
    <x>370</x>
    <y>5</y>
    <width>85</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>6</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Over 90</string>
  </label>
  <label>
   <rect>
    <x>102</x>
    <y>5</y>
    <width>85</width>
    <height>17</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>6</size>
    <weight>bold</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>1 to 30 Days</string>
  </label>
  <field>
   <rect>
    <x>280</x>
    <y>15</y>
    <width>80</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>11</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <data>
    <query>foot</query>
    <column>f_ninety</column>
   </data>
  </field>
  <line>
   <xstart>455</xstart>
   <ystart>5</ystart>
   <xend>455</xend>
   <yend>35</yend>
   <weight>0</weight>
  </line>
  <field>
   <rect>
    <x>100</x>
    <y>45</y>
    <width>67</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>11</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>Currency</query>
    <column>currAbbr</column>
   </data>
  </field>
  <line>
   <xstart>10</xstart>
   <ystart>5</ystart>
   <xend>640</xend>
   <yend>5</yend>
   <weight>0</weight>
  </line>
  <field>
   <rect>
    <x>544</x>
    <y>15</y>
    <width>85</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>11</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <data>
    <query>foot</query>
    <column>f_total</column>
   </data>
  </field>
 </pgfoot>
</report>
