<!DOCTYPE openRPTDef>
<report>
 <title>Journals</title>
 <name>Journals</name>
 <description></description>
 <grid>
  <snap/>
  <show/>
  <x>0.05</x>
  <y>0.05</y>
 </grid>
 <size>Letter</size>
 <landscape/>
 <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("accnt_id") ?>
         ( SELECT (accnt_number || '-' || accnt_descrip)
             FROM accnt
            WHERE (accnt_id=&lt;? value("accnt_id") ?>) )
       &lt;? else ?>
         text('All Accounts')
       &lt;? endif ?>
       AS accnt,
       &lt;? if exists("showUsernames") ?>
         text('Username')
       &lt;? else ?>
         text('')
       &lt;? endif ?>
       AS f_username</sql>
 </querysource>
 <querysource>
  <name>detail</name>
  <sql>SELECT sltrans_id,
       sltrans_created, formatDate(sltrans_date) AS transdate,
       sltrans_source, sltrans_doctype, sltrans_docnumber, invhist_docnumber,
       firstLine(sltrans_notes) AS transnotes,
       (formatGLAccount(accnt_id) || ' - ' || accnt_descrip) AS account,
-- Debits:
       CASE WHEN (sltrans_amount &lt; 0) THEN formatMoney(ABS(sltrans_amount))
            ELSE ''
       END AS f_debit,       
       CASE WHEN (sltrans_amount &lt; 0) THEN ABS(sltrans_amount)
            ELSE 0
       END AS debit_amt, 
--Credits:
       CASE WHEN (sltrans_amount > 0) THEN formatMoney(sltrans_amount)
            ELSE ''
       END AS f_credit,
       CASE WHEN (sltrans_amount > 0) THEN sltrans_amount
            ELSE 0
       END AS credit_amt,
--Balance:
       sltrans_amount * -1 as balance_amt,
--
       sltrans_amount,
       CASE WHEN accnt_type IN ('A','E') THEN 
         sltrans_amount * -1
       ELSE sltrans_amount END AS running,
       formatBoolYN(sltrans_posted) AS f_posted,
       sltrans_username AS f_username,
       sltrans_sequence
FROM sltrans
  JOIN accnt ON (sltrans_accnt_id=accnt_id) 
     LEFT OUTER JOIN invhist ON (sltrans_misc_id=invhist_id
                            AND sltrans_docnumber='Misc.') 
&lt;? if exists("company_id") ?>
     JOIN company ON (accnt_company=company_number) 
&lt;? endif ?>
&lt;? if exists("prfcntr_id") ?>
     JOIN prftcntr ON (accnt_profit=prftcntr_number) 
&lt;? endif ?>
&lt;? if exists("subaccnt_id") ?>
     JOIN subaccnt ON (accnt_sub=subaccnt_number) 
&lt;? endif ?>
&lt;? if exists("subType") ?>
     JOIN subaccnttype ON (subaccnttype_code=accnt_subaccnttype_code) 
&lt;? endif ?>
WHERE (
&lt;? if exists("startDate") ?>
  &lt;? if exists("endDate") ?>
       (sltrans_date BETWEEN &lt;? value("startDate") ?>
                         AND &lt;? value("endDate") ?>)
  &lt;? else ?>
       (sltrans_date BETWEEN &lt;? value("startDate") ?>
                         AND endoftime())
  &lt;? endif ?>
&lt;? else ?>
  &lt;? if exists("endDate") ?>
       (sltrans_date BETWEEN startoftime()
                         AND &lt;? value("endDate") ?>)
  &lt;? else ?>
       (sltrans_date BETWEEN startoftime()
                         AND endoftime())
  &lt;? endif ?>
&lt;? endif ?>
&lt;? if exists("company_id") ?>
   AND (company_id=&lt;? value("company_id") ?>)
&lt;? endif ?>
&lt;? if exists("prfcntr_id") ?>
   AND (prftcntr_id=&lt;? value("prfcntr_id") ?>)
&lt;? endif ?>
&lt;? if exists("accnt_number") ?>
   AND (accnt_number=&lt;? value("accnt_number") ?>)
&lt;? endif ?>
&lt;? if exists("subaccnt_id") ?>
   AND (subaccnt_id=&lt;? value("subaccnt_id") ?>)
&lt;? endif ?>
&lt;? if exists("subType") ?>
   AND (subaccnttype_id=&lt;? value("subType") ?>)
&lt;? endif ?>
&lt;? if exists("accntType") ?>
   AND (accnt_type= &lt;? value("accntType") ?>)
&lt;? endif ?>
&lt;? if exists("accnt_id") ?>
   AND (sltrans_accnt_id=&lt;? value("accnt_id") ?>)
&lt;? endif ?>
&lt;? if exists("docnum") ?>
   AND (sltrans_docnumber = case when &lt;? value("docnum") ?> = '' then 
 sltrans_docnumber else 
&lt;? value("docnum") ?> end ) 
&lt;? endif ?>
&lt;? if exists("source") ?>
   AND (sltrans_source=&lt;? value("source") ?>)
&lt;? endif ?>
&lt;? if exists("source_pattern") ?>
   AND (sltrans_source ~* &lt;? value("source_pattern") ?>)
&lt;? endif ?>
&lt;? if exists("journalnumber") ?>
   AND (sltrans_gltrans_journalnumber=&lt;? value("journalnumber") ?>)
&lt;? endif ?>
&lt;? if exists("posted") ?>
   AND (sltrans_posted=&lt;? value("posted") ?>)
&lt;? endif ?>
       )
ORDER BY sltrans_created,
        sltrans_sequence, sltrans_amount;</sql>
 </querysource>
 <rpthead>
  <height>205</height>
  <label>
   <rect>
    <x>240</x>
    <y>170</y>
    <width>105</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Account</string>
  </label>
  <label>
   <rect>
    <x>240</x>
    <y>185</y>
    <width>105</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Reference</string>
  </label>
  <label>
   <rect>
    <x>125</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>
  <label>
   <rect>
    <x>0</x>
    <y>185</y>
    <width>40</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Date</string>
  </label>
  <label>
   <rect>
    <x>180</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. #</string>
  </label>
  <label>
   <rect>
    <x>65</x>
    <y>185</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>
  <line>
   <xstart>0</xstart>
   <ystart>200</ystart>
   <xend>1000</xend>
   <yend>200</yend>
   <weight>2</weight>
  </line>
  <label>
   <rect>
    <x>535</x>
    <y>5</y>
    <width>465</width>
    <height>38</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>18</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Journals</string>
  </label>
  <label>
   <rect>
    <x>787.345</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>676.25</x>
    <y>185.891</y>
    <width>85</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>960</x>
    <y>185</y>
    <width>40</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Posted</string>
  </label>
  <label>
   <rect>
    <x>875</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>Username</string>
  </label>
  <text>
   <rect>
    <x>10</x>
    <y>40</y>
    <width>725</width>
    <height>15</height>
   </rect>
   <bottompad>12</bottompad>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <top/>
   <data>
    <query>Parameter Query</query>
    <column>filter</column>
   </data>
  </text>
 </rpthead>
 <pghead>
  <firstpage/>
  <height>5</height>
 </pghead>
 <pghead>
  <height>45</height>
  <label>
   <rect>
    <x>240</x>
    <y>10</y>
    <width>105</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Account</string>
  </label>
  <label>
   <rect>
    <x>125</x>
    <y>25</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>
  <label>
   <rect>
    <x>65</x>
    <y>25</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>
  <line>
   <xstart>0</xstart>
   <ystart>40</ystart>
   <xend>1000</xend>
   <yend>40</yend>
   <weight>2</weight>
  </line>
  <label>
   <rect>
    <x>785.815</x>
    <y>25.8923</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>0</x>
    <y>25</y>
    <width>40</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Date</string>
  </label>
  <label>
   <rect>
    <x>180</x>
    <y>25</y>
    <width>50</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Doc. #</string>
  </label>
  <label>
   <rect>
    <x>674.738</x>
    <y>25.8923</y>
    <width>85</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>240</x>
    <y>25</y>
    <width>105</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Reference</string>
  </label>
  <label>
   <rect>
    <x>960.892</x>
    <y>25</y>
    <width>40</width>
    <height>16.7846</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Posted</string>
  </label>
  <label>
   <rect>
    <x>869.692</x>
    <y>25.923</y>
    <width>80</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Username</string>
  </label>
 </pghead>
 <section>
  <name>detail</name>
  <detail>
   <key>
    <query>detail</query>
   </key>
   <height>31</height>
   <field>
    <rect>
     <x>882.19</x>
     <y>-0.890523</y>
     <width>50</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_username</column>
    </data>
   </field>
   <field>
    <rect>
     <x>790.907</x>
     <y>-0.890523</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>240</x>
     <y>15</y>
     <width>265</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>transnotes</column>
    </data>
   </field>
   <field>
    <rect>
     <x>954.846</x>
     <y>-0.891</y>
     <width>42.1539</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <hcenter/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>f_posted</column>
    </data>
   </field>
   <field>
    <rect>
     <x>12500</x>
     <y>0</y>
     <width>80</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>gltrans_doctype</column>
    </data>
   </field>
   <field>
    <rect>
     <x>125</x>
     <y>0</y>
     <width>50</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>sltrans_doctype</column>
    </data>
   </field>
   <field>
    <rect>
     <x>0</x>
     <y>0</y>
     <width>60</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>transdate</column>
    </data>
   </field>
   <field>
    <rect>
     <x>180</x>
     <y>15</y>
     <width>50</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>invhist_docnumber</column>
    </data>
   </field>
   <field>
    <rect>
     <x>180</x>
     <y>0</y>
     <width>50</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>sltrans_docnumber</column>
    </data>
   </field>
   <field>
    <rect>
     <x>681.65</x>
     <y>-0.890523</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>
   <field>
    <rect>
     <x>240</x>
     <y>0</y>
     <width>270</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>65</x>
     <y>0</y>
     <width>60</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>sltrans_source</column>
    </data>
   </field>
  </detail>
 </section>
 <pgfoot>
  <lastpage/>
  <height>75</height>
  <field>
   <rect>
    <x>765.907</x>
    <y>8.08006</y>
    <width>105</width>
    <height>14</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <right/>
   <top/>
   <data>
    <query>detail</query>
    <column>credit_amt</column>
   </data>
   <format builtin="true">money</format>
   <tracktotal/>
  </field>
  <line>
   <xstart>632.141</xstart>
   <ystart>5.07044</ystart>
   <xend>1000</xend>
   <yend>5</yend>
   <weight>2</weight>
  </line>
  <field>
   <rect>
    <x>960</x>
    <y>60</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>60</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>598.701</x>
    <y>8.21895</y>
    <width>55</width>
    <height>14</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <right/>
   <top/>
   <string>Total:</string>
  </label>
  <field>
   <rect>
    <x>656.65</x>
    <y>8.08006</y>
    <width>105</width>
    <height>14</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>bold</weight>
   </font>
   <right/>
   <top/>
   <data>
    <query>detail</query>
    <column>debit_amt</column>
   </data>
   <format builtin="true">money</format>
   <tracktotal/>
  </field>
  <label>
   <rect>
    <x>0</x>
    <y>60</y>
    <width>85</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <left/>
   <vcenter/>
   <string>Report Date:</string>
  </label>
  <label>
   <rect>
    <x>868</x>
    <y>60</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>
 <pgfoot>
  <height>15</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>868</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>960</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>
   <left/>
   <vcenter/>
   <string>Report Date:</string>
  </label>
 </pgfoot>
</report>
