Lp 1835577: Add more missing auto_renewal fields
authorJason Stephenson <jason@sigio.com>
Tue, 10 Sep 2019 15:27:07 +0000 (11:27 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 1 Oct 2019 21:17:54 +0000 (17:17 -0400)
Add missing auto_renewal and auto_renewal_remaining fields to the
following additional IDL classes:

* aacs
* aoc
* circbyyr
* robcirc

Add database updates to add auto_renewal fields to the following
views:

* action.billable_circulations
* action.open_circulation
* reporter.circ_type
* reporter.overdue_circs

Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/reporter-schema.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.auto_renewal_view_updates.sql [new file with mode: 0644]

index e41ce8b..bb01086 100644 (file)
@@ -4759,6 +4759,8 @@ SELECT  usr,
                        <field reporter:label="Archived Copy Stat-Cat Entries" name="aaasc_entries" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Linked Active Circulation" name="active_circ" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Linked Aged Circulation" name="aged_circ" oils_persist:virtual="true" reporter:datatype="link"/>
+                       <field reporter:label="Auto Renewal" name="auto_renewal" reporter:datatype="bool"/>
+                       <field reporter:label="Remaining Auto Renewals" name="auto_renewal_remaining" reporter:datatype="int" />
                </fields>
                <links>
                        <link field="billable_transaction" reltype="might_have" key="id" map="" class="mbt"/>
@@ -7390,6 +7392,8 @@ SELECT  usr,
                        <field name="xact_finish" reporter:datatype="timestamp" />
                        <field name="xact_start" reporter:datatype="timestamp" />
                        <field name="circulation" oils_persist:virtual="true" reporter:datatype="link"/>
+                       <field name="auto_renewal" reporter:datatype="bool"/>
+                       <field name="auto_renewal_remaining" reporter:datatype="int" />
                </fields>
                <links>
                        <link field="circulation" reltype="might_have" key="id" map="" class="circ"/>
@@ -12342,7 +12346,7 @@ SELECT  usr,
                        cp.id as copy,
                        COUNT(circ.id),
                        EXTRACT(YEAR FROM circ.xact_start) AS year,
-                       (phone_renewal OR desk_renewal OR opac_renewal) as is_renewal
+                       (phone_renewal OR desk_renewal OR opac_renewal OR auto_renewal) as is_renewal
                FROM
                        asset.copy cp
                                JOIN action.circulation circ ON (cp.id = circ.target_copy)
@@ -12352,7 +12356,7 @@ SELECT  usr,
                        cp.id as copy,
                        COUNT(circ.id),
                        EXTRACT(YEAR FROM circ.xact_start) AS year,
-                       (phone_renewal OR desk_renewal OR opac_renewal) as is_renewal
+                       (phone_renewal OR desk_renewal OR opac_renewal OR auto_renewal) as is_renewal
                FROM
                        asset.copy cp
                                JOIN action.aged_circulation circ ON (cp.id = circ.target_copy)
@@ -12416,6 +12420,8 @@ SELECT  usr,
                        <field reporter:label="Circulation Type" name="circ_type" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Billing Totals" name="billing_total" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Payment Totals" name="payment_total" oils_persist:virtual="true" reporter:datatype="link"/>
+                       <field reporter:label="Auto Renewal" name="auto_renewal" reporter:datatype="bool"/>
+                       <field reporter:label="Remaining Auto Renewals" name="auto_renewal_remaining" reporter:datatype="int" />
                </fields>
                <links>
                        <link field="billable_transaction" reltype="might_have" key="id" map="" class="mbt"/>
index 52f2f39..4ed0047 100644 (file)
@@ -245,7 +245,7 @@ SELECT      u.id,
 
 CREATE OR REPLACE VIEW reporter.circ_type AS
 SELECT id,
-       CASE WHEN opac_renewal OR phone_renewal OR desk_renewal
+       CASE WHEN opac_renewal OR phone_renewal OR desk_renewal OR auto_renewal
                THEN 'RENEWAL'
                ELSE 'CHECKOUT'
        END AS "type"
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.auto_renewal_view_updates.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.auto_renewal_view_updates.sql
new file mode 100644 (file)
index 0000000..9365993
--- /dev/null
@@ -0,0 +1,31 @@
+BEGIN;
+
+--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE VIEW action.open_circulation AS
+       SELECT  *
+         FROM  action.circulation
+         WHERE checkin_time IS NULL
+         ORDER BY due_date;
+
+CREATE OR REPLACE VIEW action.billable_circulations AS
+       SELECT  *
+         FROM  action.circulation
+         WHERE xact_finish IS NULL;
+
+CREATE OR REPLACE VIEW reporter.overdue_circs AS
+SELECT  *
+  FROM  "action".circulation
+  WHERE checkin_time is null
+        AND (stop_fines NOT IN ('LOST','CLAIMSRETURNED') OR stop_fines IS NULL)
+        AND due_date < now();
+
+CREATE OR REPLACE VIEW reporter.circ_type AS
+SELECT id,
+       CASE WHEN opac_renewal OR phone_renewal OR desk_renewal OR auto_renewal
+               THEN 'RENEWAL'
+               ELSE 'CHECKOUT'
+       END AS "type"
+  FROM action.circulation;
+
+COMMIT;