<!DOCTYPE openRPTDef>
<report>
 <title>Summarized G/L Transactions</title>
 <name>SummarizedGLTransactions</name>
 <description></description>
 <size>Letter</size>
 <portrait/>
 <topmargin>50</topmargin>
 <bottommargin>50</bottommargin>
 <rightmargin>50</rightmargin>
 <leftmargin>50</leftmargin>
 <querysource>
  <name>head</name>
  <sql>SELECT formatDate(&lt;? value("startDate") ?>, 'Earliest') AS startdate,
       formatDate(&lt;? value("endDate") ?>, 'Latest') AS enddate,
       &lt;? if exists("source") ?>
         text(&lt;? value("source") ?>)
       &lt;? else ?>
         text('All Sources')
       &lt;? endif  ?>
       AS source,
       &lt;? if exists("showUsernames") ?>
         text('Username')
       &lt;? else ?>
         text('')
       &lt;? endif ?>
       AS f_username;</sql>
 </querysource>
 <querysource>
  <name>detail</name>
  <sql>SELECT data.accnt_id AS accnt_id,
-- account information
       formatGLAccount(data.accnt_id) AS account,
       accnt_descrip,
       f_debit,
       f_credit,
-- transactionn details
       formatDate(gltrans_date) AS transdate,
       gltrans_source,
       gltrans_doctype,
       gltrans_docnumber,
       gltrans_notes,
       f_debitdetail,
       f_creditdetail,
       &lt;? if exists("showUsernames") ?>
         gltrans_username
       &lt;? else ?>
         text('')
       &lt;? endif ?>
       AS f_username
  FROM ( SELECT accnt_id,
                accnt_number,
                accnt_profit,
                accnt_sub,
                accnt_descrip,
                formatMoney( SUM( CASE WHEN (gltrans_amount &lt; 0) THEN (gltrans_amount * -1)
                                       ELSE 0
                                  END ) ) AS f_debit,
                formatMoney( SUM( CASE WHEN (gltrans_amount > 0) THEN gltrans_amount
                                       ELSE 0
                                  END ) ) AS f_credit
           FROM gltrans, accnt
          WHERE ( (gltrans_accnt_id=accnt_id)
            AND (NOT gltrans_deleted)
            AND (gltrans_date BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)
         &lt;? if exists("source") ?>
            AND (gltrans_source=&lt;? value("source") ?>)
         &lt;? endif ?>
         &lt;? if exists("unpostedTransactions") ?>
            AND (NOT gltrans_posted)
         &lt;? elseif exists("postedTransactions") ?>
            AND (gltrans_posted)
         &lt;? endif ?>
         )
         GROUP BY accnt_id, accnt_number, accnt_profit, accnt_sub, accnt_descrip
       ) AS data LEFT OUTER JOIN
       ( SELECT accnt_id,
                gltrans_date,
                gltrans_created,
                gltrans_source,
                gltrans_doctype,
                gltrans_docnumber,
                gltrans_notes,
                gltrans_username,
                CASE WHEN (gltrans_amount &lt; 0) THEN formatMoney(gltrans_amount * -1)
                     ELSE ''
                END AS f_debitdetail,
                CASE WHEN (gltrans_amount > 0) THEN formatMoney(gltrans_amount)
                     ELSE ''
                END AS f_creditdetail
           FROM gltrans, accnt
          WHERE ((gltrans_accnt_id=accnt_id)
            AND (NOT gltrans_deleted)
            AND (gltrans_date BETWEEN &lt;? value("startDate") ?> AND &lt;? value("endDate") ?>)
         &lt;? if exists("source") ?>
            AND (gltrans_source=&lt;? value("source") ?>)
         &lt;? endif ?>
         &lt;? if exists("unpostedTransactions") ?>
            AND (NOT gltrans_posted)
         &lt;? elseif exists("postedTransactions") ?>
            AND (gltrans_posted)
         &lt;? endif ?>
                )
       ) AS data2 ON (data.accnt_id=data2.accnt_id)
ORDER BY accnt_number, accnt_profit, accnt_sub, gltrans_date DESC, gltrans_created;</sql>
 </querysource>
 <rpthead>
  <height>201</height>
  <label>
   <rect>
    <x>375</x>
    <y>185</y>
    <width>50</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Doc. Type</string>
  </label>
  <line>
   <xstart>5</xstart>
   <ystart>200</ystart>
   <xend>745</xend>
   <yend>200</yend>
   <weight>2</weight>
  </line>
  <field>
   <rect>
    <x>545</x>
    <y>90</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>enddate</column>
   </data>
  </field>
  <label>
   <rect>
    <x>120</x>
    <y>185</y>
    <width>125</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Decription/Notes</string>
  </label>
  <field>
   <rect>
    <x>140</x>
    <y>70</y>
    <width>290</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>source</column>
   </data>
  </field>
  <label>
   <rect>
    <x>409</x>
    <y>70</y>
    <width>130</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Start Date:</string>
  </label>
  <field>
   <rect>
    <x>665</x>
    <y>185</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>f_username</column>
   </data>
  </field>
  <label>
   <rect>
    <x>330</x>
    <y>185</y>
    <width>36</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Source</string>
  </label>
  <label>
   <rect>
    <x>595</x>
    <y>185</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Credit</string>
  </label>
  <label>
   <rect>
    <x>409</x>
    <y>90</y>
    <width>130</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>End Date:</string>
  </label>
  <label>
   <rect>
    <x>260</x>
    <y>10</y>
    <width>465</width>
    <height>38</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>18</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Summarized G/L Transactions</string>
  </label>
  <field>
   <rect>
    <x>545</x>
    <y>70</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>startdate</column>
   </data>
  </field>
  <label>
   <rect>
    <x>10</x>
    <y>185</y>
    <width>125</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Account/Date</string>
  </label>
  <label>
   <rect>
    <x>509</x>
    <y>185</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Debit</string>
  </label>
  <label>
   <rect>
    <x>5</x>
    <y>70</y>
    <width>130</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Source:</string>
  </label>
  <label>
   <rect>
    <x>434</x>
    <y>185</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Doc. #</string>
  </label>
 </rpthead>
 <pghead>
  <firstpage/>
  <height>17</height>
 </pghead>
 <pghead>
  <height>28</height>
  <label>
   <rect>
    <x>434</x>
    <y>5</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Doc. #</string>
  </label>
  <label>
   <rect>
    <x>120</x>
    <y>5</y>
    <width>125</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Decription/Notes</string>
  </label>
  <label>
   <rect>
    <x>10</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>Account/Date</string>
  </label>
  <label>
   <rect>
    <x>595</x>
    <y>5</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Credit</string>
  </label>
  <label>
   <rect>
    <x>375</x>
    <y>5</y>
    <width>50</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Doc. Type</string>
  </label>
  <line>
   <xstart>5</xstart>
   <ystart>20</ystart>
   <xend>745</xend>
   <yend>20</yend>
   <weight>2</weight>
  </line>
  <field>
   <rect>
    <x>665</x>
    <y>5</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>f_username</column>
   </data>
  </field>
  <label>
   <rect>
    <x>509</x>
    <y>5</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Debit</string>
  </label>
  <label>
   <rect>
    <x>330</x>
    <y>5</y>
    <width>60</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Source</string>
  </label>
 </pghead>
 <section>
  <name>detail</name>
  <group>
   <name>detail</name>
   <column>accnt_id</column>
   <head>
    <height>23</height>
    <field>
     <rect>
      <x>10</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>detail</query>
      <column>account</column>
     </data>
    </field>
    <field>
     <rect>
      <x>595</x>
      <y>0</y>
      <width>80</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>bold</weight>
     </font>
     <right/>
     <vcenter/>
     <data>
      <query>detail</query>
      <column>f_credit</column>
     </data>
    </field>
    <field>
     <rect>
      <x>120</x>
      <y>0</y>
      <width>305</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>bold</weight>
     </font>
     <left/>
     <vcenter/>
     <data>
      <query>detail</query>
      <column>accnt_descrip</column>
     </data>
    </field>
    <field>
     <rect>
      <x>509</x>
      <y>0</y>
      <width>80</width>
      <height>15</height>
     </rect>
     <font>
      <face>Arial</face>
      <size>8</size>
      <weight>bold</weight>
     </font>
     <right/>
     <vcenter/>
     <data>
      <query>detail</query>
      <column>f_debit</column>
     </data>
    </field>
   </head>
   <foot>
    <height>14</height>
    <line>
     <xstart>112</xstart>
     <ystart>5</ystart>
     <xend>744</xend>
     <yend>5</yend>
     <weight>0</weight>
    </line>
   </foot>
  </group>
  <detail>
   <key>
    <query>detail</query>
   </key>
   <height>24</height>
   <field>
    <rect>
     <x>10</x>
     <y>0</y>
     <width>100</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <top/>
    <data>
     <query>detail</query>
     <column>transdate</column>
    </data>
   </field>
   <field>
    <rect>
     <x>375</x>
     <y>0</y>
     <width>50</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <top/>
    <data>
     <query>detail</query>
     <column>gltrans_doctype</column>
    </data>
   </field>
   <field>
    <rect>
     <x>595</x>
     <y>0</y>
     <width>80</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <top/>
    <data>
     <query>detail</query>
     <column>f_creditdetail</column>
    </data>
   </field>
   <field>
    <rect>
     <x>330</x>
     <y>0</y>
     <width>36</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <top/>
    <data>
     <query>detail</query>
     <column>gltrans_source</column>
    </data>
   </field>
   <field>
    <rect>
     <x>434</x>
     <y>0</y>
     <width>80</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <top/>
    <data>
     <query>detail</query>
     <column>gltrans_docnumber</column>
    </data>
   </field>
   <text>
    <rect>
     <x>120</x>
     <y>0</y>
     <width>200</width>
     <height>15</height>
    </rect>
    <bottompad>5</bottompad>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <top/>
    <data>
     <query>detail</query>
     <column>gltrans_notes</column>
    </data>
   </text>
   <field>
    <rect>
     <x>665</x>
     <y>0</y>
     <width>80</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <top/>
    <data>
     <query>detail</query>
     <column>f_username</column>
    </data>
   </field>
   <field>
    <rect>
     <x>509</x>
     <y>0</y>
     <width>80</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <top/>
    <data>
     <query>detail</query>
     <column>f_debitdetail</column>
    </data>
   </field>
  </detail>
 </section>
 <pgfoot>
  <height>26</height>
  <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>
  <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>
  <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>
 </pgfoot>
</report>
