<!DOCTYPE openRPTDef>
<report>
 <title>Financial Report Month and Prior Month</title>
 <name>FinancialReportMonthPriorMonth</name>
 <description></description>
 <parameter default="" active="false" listtype="dynamic" type="integer" name="flcol_id">
  <description>Financial Report Column Layout</description>
  <query>SELECT flcol_id, flhead_name || ' - ' || flcol_name FROM flcol, flhead WHERE ((flcol_flhead_id=flhead_id) AND (flhead_active))</query>
 </parameter>
 <parameter default="" active="false" listtype="dynamic" type="integer" name="period_id">
  <description>Accounting Period Reference</description>
  <query>SELECT period_id, 
  CASE
    WHEN period_name &lt;> '' THEN period_name 
    ELSE (formatdate(period_start) || '-' || formatdate(period_end)) 
  END 
FROM period 
ORDER BY period_end DESC</query>
 </parameter>
 <size>Letter</size>
 <portrait/>
 <topmargin>50</topmargin>
 <bottommargin>50</bottommargin>
 <rightmargin>50</rightmargin>
 <leftmargin>50</leftmargin>
 <querysource>
  <name>head</name>
  <sql>SELECT 
    &lt;? value("project") ?> AS project,
    (SELECT prj_name FROM prj WHERE prj_id=&lt;? value("prj_id") ?>) AS prj_name,
    flstmthead_username,
    flstmthead_flhead_name || ' - ' || flstmthead_flcol_name AS f_name,
    flstmthead_typedescrip1,
    flstmthead_typedescrip2,
    flstmthead_typedescrip2 || ' Diff.' AS f_diff,
    flstmthead_typedescrip2 || ' % Diff.' AS f_diffprcnt,
    flstmthead_month,
    flstmthead_qtr,
    flstmthead_year,
    flstmthead_prmonth,
    flstmthead_prqtr,
    flstmthead_pryear
FROM getflstmthead(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>)</sql>
 </querysource>
 <querysource>
  <name>detail</name>
  <sql>SELECT 
    flstmtitem_flhead_id,
    flstmtitem_period_id,
    flstmtitem_username,
    flstmtitem_order,
    flstmtitem_level,
    flstmtitem_subgrp,
    flstmtitem_type,
    flstmtitem_type_id,
    flstmtitem_parent_id,
    flstmtitem_accnt_id,
    flstmtitem_name,
    formatMoney(flstmtitem_month) AS flstmtitem_month,
    formatMoney(flstmtitem_monthdb) AS flstmtitem_monthdb,
    formatMoney(flstmtitem_monthcr) AS flstmtitem_monthcr,
    formatPrcnt(flstmtitem_monthprcnt) AS flstmtitem_monthprcnt,
    formatMoney(flstmtitem_monthbudget) AS flstmtitem_monthbudget,
    formatPrcnt(flstmtitem_monthbudgetprcnt) AS flstmtitem_monthbudgetprcnt,
    formatMoney(flstmtitem_monthbudgetdiff) AS flstmtitem_monthbudgetdiff,
    formatPrcnt(flstmtitem_monthbudgetdiffprcnt) AS flstmtitem_monthbudgetdiffprcnt,
    formatMoney(flstmtitem_qtr) AS flstmtitem_qtr,
    formatMoney(flstmtitem_qtrdb) AS flstmtitem_qtrdb,
    formatMoney(flstmtitem_qtrcr) AS flstmtitem_qtrcr,
    formatPrcnt(flstmtitem_qtrprcnt) AS flstmtitem_qtrprcnt,
    formatMoney(flstmtitem_qtrbudget) AS flstmtitem_qtrbudget,
    formatPrcnt(flstmtitem_qtrbudgetprcnt) AS flstmtitem_qtrbudgetprcnt,
    formatMoney(flstmtitem_qtrbudgetdiff) AS flstmtitem_qtrbudgetdiff,
    formatPrcnt(flstmtitem_qtrbudgetdiffprcnt) AS flstmtitem_qtrbudgetdiffprcnt,
    formatMoney(flstmtitem_year) AS flstmtitem_year,
    formatMoney(flstmtitem_yeardb) AS flstmtitem_yeardb,
    formatMoney(flstmtitem_yearcr) AS flstmtitem_yearcr,
    formatPrcnt(flstmtitem_yearprcnt) AS flstmtitem_yearprcnt,
    formatMoney(flstmtitem_yearbudget) AS flstmtitem_yearbudget,
    formatPrcnt(flstmtitem_yearbudgetprcnt) AS flstmtitem_yearbudgetprcnt,
    formatMoney(flstmtitem_yearbudgetdiff) AS flstmtitem_yearbudgetdiff,
    formatPrcnt(flstmtitem_yearbudgetdiffprcnt) AS flstmtitem_yearbudgetdiffprcnt,
    formatMoney(flstmtitem_prmonth) AS flstmtitem_prmonth,
    formatPrcnt(flstmtitem_prmonthprcnt) AS flstmtitem_prmonthprcnt,
    formatMoney(flstmtitem_prmonthdiff) AS flstmtitem_prmonthdiff,
    formatPrcnt(flstmtitem_prmonthdiffprcnt) AS flstmtitem_prmonthdiffprcnt,
    formatMoney(flstmtitem_prqtr) AS flstmtitem_prqtr,
    formatPrcnt(flstmtitem_prqtrprcnt) AS flstmtitem_prqtrprcnt,
    formatMoney(flstmtitem_prqtrdiff) AS flstmtitem_prqtrdiff,
    formatPrcnt(flstmtitem_prqtrdiffprcnt) AS flstmtitem_prqtrdiffprcnt,
    formatMoney(flstmtitem_pryear) AS flstmtitem_pryear,
    formatPrcnt(flstmtitem_pryearprcnt) AS flstmtitem_pryearprcnt,
    formatMoney(flstmtitem_pryeardiff) AS flstmtitem_pryeardiff,
    formatPrcnt(flstmtitem_pryeardiffprcnt) AS flstmtitem_pryeardiffprcnt
FROM financialreport(&lt;? value("flcol_id") ?>,&lt;? value("period_id") ?>,
&lt;? if exists("shownumbers") ?>
  true
&lt;? else ?>
  false
&lt;? endif ?>
,True,&lt;? value("prj_id") ?>)
&lt;? if not exists("showzeros") ?>
  WHERE ((flstmtitem_month &lt;> 0) OR (flstmtitem_prmonth &lt;> 0) OR (flstmtitem_type &lt;> 'I'))
&lt;? endif ?>
;</sql>
 </querysource>
 <querysource>
  <name>notes</name>
  <sql>SELECT * FROM (
SELECT 1 AS seq, flhead_notes AS notes
FROM flhead
 JOIN flcol ON (flhead_id=flcol_flhead_id)
WHERE ((flcol_id=&lt;? value("flcol_id") ?>)
  AND (length(flhead_notes) > 0))
UNION ALL
SELECT 2 AS seq, flnotes_notes AS notes
FROM flnotes
  JOIN flcol ON (flcol_flhead_id=flnotes_flhead_id)
WHERE ((flcol_id=&lt;? value("flcol_id") ?>)
  AND (flnotes_period_id=&lt;? value("period_id") ?>)
  AND (length(flnotes_notes) > 0))) data
ORDER BY seq;
</sql>
 </querysource>
 <rpthead>
  <height>170</height>
  <line>
   <xstart>2.82315</xstart>
   <ystart>160.942</ystart>
   <xend>760</xend>
   <yend>160.942</yend>
   <weight>2</weight>
  </line>
  <field>
   <rect>
    <x>100</x>
    <y>80</y>
    <width>459</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>f_name</column>
   </data>
  </field>
  <field>
   <rect>
    <x>500</x>
    <y>130</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>flstmthead_prmonth</column>
   </data>
  </field>
  <field>
   <rect>
    <x>380</x>
    <y>130</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>flstmthead_month</column>
   </data>
  </field>
  <field>
   <rect>
    <x>580</x>
    <y>130</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>flstmthead_prmonth</column>
   </data>
  </field>
  <label>
   <rect>
    <x>1</x>
    <y>130</y>
    <width>55</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Name</string>
  </label>
  <field>
   <rect>
    <x>100</x>
    <y>100</y>
    <width>459</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>flstmthead_typedescrip1</column>
   </data>
  </field>
  <field>
   <rect>
    <x>380</x>
    <y>145</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>flstmthead_typedescrip2</column>
   </data>
  </field>
  <label>
   <rect>
    <x>345</x>
    <y>10</y>
    <width>380</width>
    <height>37</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>18</size>
    <weight>bold</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Financial Report</string>
  </label>
  <field>
   <rect>
    <x>660</x>
    <y>145</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>f_diffprcnt</column>
   </data>
  </field>
  <field>
   <rect>
    <x>660</x>
    <y>130</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>flstmthead_prmonth</column>
   </data>
  </field>
  <field>
   <rect>
    <x>500</x>
    <y>145</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>flstmthead_typedescrip2</column>
   </data>
  </field>
  <label>
   <rect>
    <x>15</x>
    <y>80</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>15</x>
    <y>100</y>
    <width>80</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <string>Type:</string>
  </label>
  <field>
   <rect>
    <x>580</x>
    <y>145</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>f_diff</column>
   </data>
  </field>
  <field>
   <rect>
    <x>99</x>
    <y>59.6</y>
    <width>459</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>bold</weight>
   </font>
   <left/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>prj_name</column>
   </data>
  </field>
  <field>
   <rect>
    <x>15</x>
    <y>59.5</y>
    <width>80</width>
    <height>20</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>10</size>
    <weight>normal</weight>
   </font>
   <right/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>project</column>
   </data>
  </field>
 </rpthead>
 <pghead>
  <firstpage/>
  <height>7</height>
 </pghead>
 <pghead>
  <height>40</height>
  <field>
   <rect>
    <x>660</x>
    <y>0</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>flstmthead_prmonth</column>
   </data>
  </field>
  <field>
   <rect>
    <x>500</x>
    <y>0</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>flstmthead_prmonth</column>
   </data>
  </field>
  <field>
   <rect>
    <x>500</x>
    <y>15</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>flstmthead_typedescrip2</column>
   </data>
  </field>
  <field>
   <rect>
    <x>580</x>
    <y>0</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>flstmthead_prmonth</column>
   </data>
  </field>
  <label>
   <rect>
    <x>1</x>
    <y>0</y>
    <width>55</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <string>Name</string>
  </label>
  <field>
   <rect>
    <x>380</x>
    <y>0</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>flstmthead_month</column>
   </data>
  </field>
  <field>
   <rect>
    <x>380</x>
    <y>15</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>flstmthead_typedescrip2</column>
   </data>
  </field>
  <field>
   <rect>
    <x>660</x>
    <y>15</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>f_diffprcnt</column>
   </data>
  </field>
  <field>
   <rect>
    <x>580</x>
    <y>15</y>
    <width>75</width>
    <height>15</height>
   </rect>
   <font>
    <face>Arial</face>
    <size>8</size>
    <weight>normal</weight>
   </font>
   <hcenter/>
   <vcenter/>
   <data>
    <query>head</query>
    <column>f_diff</column>
   </data>
  </field>
  <line>
   <xstart>0.0790882</xstart>
   <ystart>31.4959</ystart>
   <xend>747.149</xend>
   <yend>31.4959</yend>
   <weight>2</weight>
  </line>
 </pghead>
 <section>
  <name>detail</name>
  <group>
   <name>subgrp</name>
   <column>flstmtitem_subgrp</column>
   <foot>
    <height>7</height>
    <line>
     <xstart>380</xstart>
     <ystart>1</ystart>
     <xend>740</xend>
     <yend>1</yend>
     <weight>0</weight>
    </line>
   </foot>
  </group>
  <detail>
   <key>
    <query>detail</query>
   </key>
   <height>22</height>
   <field>
    <rect>
     <x>500</x>
     <y>0</y>
     <width>75</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>flstmtitem_prmonth</column>
    </data>
   </field>
   <field>
    <rect>
     <x>25</x>
     <y>0</y>
     <width>345</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <left/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>flstmtitem_name</column>
    </data>
   </field>
   <field>
    <rect>
     <x>380</x>
     <y>0</y>
     <width>75</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>flstmtitem_month</column>
    </data>
   </field>
   <field>
    <rect>
     <x>660</x>
     <y>0</y>
     <width>75</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>flstmtitem_prmonthdiffprcnt</column>
    </data>
   </field>
   <field>
    <rect>
     <x>580</x>
     <y>0</y>
     <width>75</width>
     <height>15</height>
    </rect>
    <font>
     <face>Arial</face>
     <size>8</size>
     <weight>bold</weight>
    </font>
    <right/>
    <vcenter/>
    <data>
     <query>detail</query>
     <column>flstmtitem_prmonthdiff</column>
    </data>
   </field>
  </detail>
 </section>
 <section>
  <name>notes</name>
  <detail>
   <key>
    <query>notes</query>
   </key>
   <height>24</height>
   <text>
    <rect>
     <x>25</x>
     <y>9</y>
     <width>700</width>
     <height>15</height>
    </rect>
    <bottompad>0</bottompad>
    <font>
     <face>Arial</face>
     <size>9</size>
     <weight>normal</weight>
    </font>
    <left/>
    <top/>
    <data>
     <query>notes</query>
     <column>notes</column>
    </data>
   </text>
  </detail>
 </section>
 <pgfoot>
  <height>25</height>
  <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>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>
  <field>
   <rect>
    <x>695</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>550</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>
 <rptfoot>
  <height>10</height>
 </rptfoot>
</report>
