ACQ "Fund Summary" combined IDL reporter view
authorBill Erickson <berick@esilibrary.com>
Mon, 23 Jul 2012 22:51:45 +0000 (18:51 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 24 Jul 2012 15:44:16 +0000 (11:44 -0400)
IDL view which produces summary information for funds for reporting.
The resulting "table" looks like a fund w/ four additional fields:
allocated_total, spent_total, encumbrance_total, and combined_balance.

The view is marked as reporter:core="true" so it will be visible in the
main reporter sources.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/examples/fm_IDL.xml

index 780751f..a3cda7c 100644 (file)
@@ -7361,7 +7361,51 @@ SELECT  usr,
             </actions>
         </permacrud>
     </class>
-
+    <class id="acqfsum" controller="open-ils.cstore open-ils.pcrud open-ils.reporter-store" oils_obj:fieldmapper="acq::fund_summary" reporter:label="Fund Summary" reporter:core="true" oils_persist:readonly="true">
+        <oils_persist:source_definition><![CDATA[
+            SELECT
+                acqf.*,
+                COALESCE(acqfat.amount, 0.00) AS allocated_total,
+                COALESCE(acqfst.amount, 0.00) AS spent_total,
+                COALESCE(acqfet.amount, 0.00) AS encumbrance_total,
+                COALESCE(acqfcb.amount, 0.00) AS combined_balance
+            FROM
+                acq.fund acqf
+                LEFT JOIN acq.fund_allocation_total acqfat ON (acqfat.fund = acqf.id)
+                LEFT JOIN acq.fund_spent_total acqfst ON (acqfst.fund = acqf.id)
+                LEFT JOIN acq.fund_encumbrance_total acqfet ON (acqfet.fund = acqf.id)
+                LEFT JOIN acq.fund_combined_balance acqfcb ON (acqfcb.fund = acqf.id)
+        ]]></oils_persist:source_definition>
+        <fields oils_persist:primary="id" oils_persist:sequence="acq.fund_id_seq">
+            <field reporter:label="Fund ID" name="id" reporter:datatype="id" reporter:selector='code'/>
+            <field reporter:label="Org Unit" name="org" reporter:datatype="org_unit" />
+            <field reporter:label="Name" name="name" reporter:datatype="text" />
+            <field reporter:label="Year" name="year" reporter:datatype="int" />
+            <field reporter:label="Currency Type" name="currency_type" reporter:datatype="link" />
+            <field reporter:label="Code" name="code" reporter:datatype="text" />
+            <field reporter:label="Rollover" name="rollover" reporter:datatype="bool" />
+            <field reporter:label="Propagate" name="propagate" reporter:datatype="bool" />
+            <field reporter:label="Active" name="active" reporter:datatype="bool" />
+            <field reporter:label="Balance Warning Percent" name="balance_warning_percent" reporter:datatype="int" />
+            <field reporter:label="Balance Stop Percent" name="balance_stop_percent" reporter:datatype="int" />
+
+            <!-- non fund-native fields -->
+            <field reporter:label="Total Allocated" name="allocated_total" reporter:datatype="money"/>
+            <field reporter:label="Total Spent" name="spent_total" reporter:datatype="money"/>
+            <field reporter:label="Total Encumbered" name="encumbrance_total" reporter:datatype="money"/>
+            <field reporter:label="Remaining Balance" name="combined_balance" reporter:datatype="money"/>
+        </fields>
+        <links>
+            <link field="id" reltype="has_a" key="id" map="" class="acqf"/>
+            <link field="org" reltype="has_a" key="id" map="" class="aou"/>
+            <link field="currency_type" reltype="has_a" key="code" map="" class="acqct"/>
+        </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <retrieve permission="ADMIN_ACQ_FUND VIEW_FUND MANAGE_FUND" context_field="org"/>
+            </actions>
+        </permacrud>
+       </class>
        <class id="acqfa" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="acq::fund_allocation" oils_persist:tablename="acq.fund_allocation" reporter:label="Fund Allocation">
                <fields oils_persist:primary="id" oils_persist:sequence="acq.fund_allocation_id_seq">
                        <field reporter:label="Allocation ID" name="id" reporter:datatype="id" />