LP#1772955: Only include xacts with balance in summary
authorMike Rylander <mrylander@gmail.com>
Thu, 30 Jul 2020 15:48:46 +0000 (11:48 -0400)
committerJason Boyer <JBoyer@EquinoxInitiative.org>
Mon, 15 Feb 2021 21:05:32 +0000 (16:05 -0500)
This commit adds a new view and IDL definition that shows the total
owed/paid/balance for transactions that have a balance other than 0.
This new view is used in the patron summary bar, and access is provided
wherever the all-open-transactions version is available in case we want
to move to the new one elsewhere.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Ruth Frasur <rfrasur@library.in.gov>
Signed-off-by: Jason Boyer <JBoyer@EquinoxInitiative.org>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/Utils/Configure.pm
Open-ILS/src/sql/Pg/500.view.cross-schema.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.open_with_balance_usr_summary.sql [new file with mode: 0644]
Open-ILS/web/js/dojo/fieldmapper/Fieldmapper.js
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js

index a312c10..b00330c 100644 (file)
@@ -3411,6 +3411,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
             </actions>
         </permacrud>
        </class>
+       <class id="mowbus" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="money::open_with_balance_user_summary" oils_persist:tablename="money.open_with_balance_usr_summary" reporter:label="Open User Summary for transactions with balances">
+               <fields oils_persist:primary="usr" oils_persist:sequence="">
+                       <field name="balance_owed" reporter:datatype="money" />
+                       <field name="total_owed" reporter:datatype="money" />
+                       <field name="total_paid" reporter:datatype="money" />
+                       <field name="usr" reporter:datatype="link"/>
+               </fields>
+               <links>
+                       <link field="usr" reltype="has_a" key="id" map="" class="au"/>
+        </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <retrieve permission="VIEW_USER">
+                    <context link="usr" field="home_ou"/>
+                </retrieve>
+            </actions>
+        </permacrud>
+       </class>
        <class id="mct" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="money::collections_tracker" oils_persist:tablename="money.collections_tracker" reporter:label="Collections Tracker">
                <fields oils_persist:primary="id" oils_persist:sequence="money.collections_tracker_id_seq">
                        <field name="collector" />
index 351a129..2b1f24f 100644 (file)
@@ -25,7 +25,7 @@ sub fieldmapper {
         asv asva asvr asvq 
         circ ccs ahn bre mrd
         crcd crmf crrf mbts aoc aus 
-        mous mobts mb ancc cnct cnal
+        mous mowbus mobts mb ancc cnct cnal
         /;
 
     my @reports = qw/ perm_ex ex ao aou aout /;
index 2dd3592..158e151 100644 (file)
@@ -39,6 +39,16 @@ CREATE OR REPLACE VIEW money.open_usr_summary AS
     WHERE xact_finish IS NULL
     GROUP BY usr;
 
+CREATE OR REPLACE VIEW money.open_with_balance_usr_summary AS
+    SELECT
+        usr,
+        sum(total_paid) AS total_paid,
+        sum(total_owed) AS total_owed,
+        sum(balance_owed) AS balance_owed
+    FROM money.materialized_billable_xact_summary
+    WHERE xact_finish IS NULL AND balance_owed <> 0.0
+    GROUP BY usr;
+
 CREATE OR REPLACE VIEW money.open_usr_circulation_summary AS
     SELECT 
         usr,
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.open_with_balance_usr_summary.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.open_with_balance_usr_summary.sql
new file mode 100644 (file)
index 0000000..48ef598
--- /dev/null
@@ -0,0 +1,15 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+CREATE OR REPLACE VIEW money.open_with_balance_usr_summary AS
+    SELECT
+        usr,
+        sum(total_paid) AS total_paid,
+        sum(total_owed) AS total_owed,
+        sum(balance_owed) AS balance_owed
+    FROM money.materialized_billable_xact_summary
+    WHERE xact_finish IS NULL AND balance_owed <> 0.0
+    GROUP BY usr;
+
+COMMIT;
index 3ef0ad9..9e9f4b5 100644 (file)
@@ -356,6 +356,7 @@ if(!dojo._hasResource["fieldmapper.Fieldmapper"]){
         fieldmapper.cblvl.Identifier = 'code';
         fieldmapper.clfm.Identifier = 'code';
         fieldmapper.mous.Identifier = 'usr';
+        fieldmapper.mowbus.Identifier = 'usr';
         fieldmapper.moucs.Identifier = 'usr';
         fieldmapper.mucs.Identifier = 'usr';
         fieldmapper.mus.Identifier = 'usr';
index f9a6d66..011e553 100644 (file)
@@ -24,7 +24,7 @@ function($q , egCore , egWorkLog , patronSvc) {
     // user billing summary
     service.fetchSummary = function() {
         return egCore.pcrud.retrieve(
-            'mous', service.userId, {}, {authoritative : true})
+            'mowbus', service.userId, {}, {authoritative : true})
         .then(function(summary) {return service.summary = summary})
     }