money.billing pcrud; use for history grid
authorBill Erickson <berick@esilibrary.com>
Mon, 2 Jun 2014 15:39:28 +0000 (11:39 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 2 Jun 2014 15:39:28 +0000 (11:39 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/templates/staff/circ/patron/t_xact_details.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js

index 006a26c..7a5a756 100644 (file)
@@ -7015,7 +7015,7 @@ SELECT  usr,
             </actions>
         </permacrud>
        </class>
-       <class id="mb" controller="open-ils.cstore" oils_obj:fieldmapper="money::billing" oils_persist:tablename="money.billing" reporter:label="Billing Line Item">
+       <class id="mb" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="money::billing" oils_persist:tablename="money.billing" reporter:label="Billing Line Item">
                <fields oils_persist:primary="id" oils_persist:sequence="money.billing_id_seq">
                        <field reporter:label="Amount" name="amount" reporter:datatype="money" />
                        <field reporter:label="Billing Timestamp" name="billing_ts" reporter:datatype="timestamp"/>
@@ -7033,6 +7033,13 @@ SELECT  usr,
                        <link field="voider" reltype="has_a" key="id" map="" class="au"/>
                        <link field="btype" reltype="has_a" key="id" map="" class="cbt"/>
                </links>
+        <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+                <retrieve permission="VIEW_USER_TRANSACTIONS">
+                    <context link="xact" jump="usr" field="home_ou"/>
+                </retrieve>
+                       </actions>
+               </permacrud>
        </class>
        <class id="pugm" controller="open-ils.cstore" oils_obj:fieldmapper="permission::usr_grp_map" oils_persist:tablename="permission.usr_grp_map" reporter:label="User Group Map">
                <fields oils_persist:primary="id" oils_persist:sequence="permission.usr_grp_map_id_seq">
index 0e5807e..1345562 100644 (file)
   main-label="[% l('Bills') %]"
   idl-class="mb"
   id-field="id"
+  query="billQuery"
+  sort="billSort"
+  revision="billRevision"
   auto-fields="true"
-  page-size="10"
-  items-provider="billGridProvider">
+  page-size="10">
 
   <eg-grid-action 
     label="[% l('Void Billings') %]" handler="voidBillings"></eg-grid-action>
 
 </eg-grid>
 
-<!-- TODO: this grid may contain objects of different types.. apply manual columns, see xul -->
+<!-- TODO: this grid may contain objects (payments) of different types.. 
+    apply manual columns, see xul -->
+<!-- NOTE: sorting disabled since payments are fetched via non-sortable API -->
 <br/>
 <eg-grid
   main-label="[% l('Payments') %]"
+  features="-sort,-multisort"
   idl-class="mp"
   id-field="id"
   auto-fields="true"
index 17ef6df..218b9b5 100644 (file)
@@ -151,10 +151,14 @@ function($q , egCore , patronSvc) {
     }
 
     service.fetchBills = function(xact_id) {
-        return egCore.net.request(
-            'open-ils.circ',
-            'open-ils.circ.money.billing.retrieve.all.authoritative',
-            egCore.auth.token(), xact_id
+        var bills = [];
+        return egCore.pcrud.search('mb',
+            {xact : xact_id}, null,
+            {authoritative : true}
+        ).then(
+            function() {return bills},
+            null,
+            function(bill) {bills.push(bill); return bill}
         );
     }
 
@@ -577,13 +581,9 @@ function($scope,  $q , $routeParams , egCore , egGridDataProvider , patronSvc ,
     var bills = [];
     var payments = [];
 
-    // --- bills grid
-    var billProvider = egGridDataProvider.instance();
-    billProvider.get = function(offset, count) {
-        return billProvider.arrayNotifier(bills, offset, count);
-    }
-    billProvider.itemFieldValue = billProvider.nestedItemFieldValue;
-    $scope.billGridProvider = billProvider;
+    $scope.billQuery = function() {return {xact : xact_id}};
+    $scope.billSort = ['billing_ts'];
+    $scope.billRevision = 0;
 
     // --- payments grid
     var paymentProvider = egGridDataProvider.instance();
@@ -597,7 +597,7 @@ function($scope,  $q , $routeParams , egCore , egGridDataProvider , patronSvc ,
     $scope.voidBillings = function(bill_list) {
         var bill_ids = [];
         angular.forEach(bill_list, function(b) {
-            if (b.voided() != 't') bill_ids.push(b.id());
+            if (b.voided != 't') bill_ids.push(b.id);
         });
 
         if (bill_ids.length == 0) {
@@ -614,11 +614,8 @@ function($scope,  $q , $routeParams , egCore , egGridDataProvider , patronSvc ,
             billSvc.fetchXact(xact_id).then(function(xact) {
                 $scope.xact = xact
             });
-        
-            billSvc.fetchBills(xact_id).then(function(bs) {
-                bills = bs; 
-                billProvider.increment();
-            });
+
+            $scope.billRevision++;
         });
     }
 
@@ -645,10 +642,7 @@ function($scope,  $q , $routeParams , egCore , egGridDataProvider , patronSvc ,
                             });
 
                         } else {
-                            billSvc.fetchBills(xact_id).then(function(bs) {
-                                bills = bs; 
-                                billProvider.increment();
-                            });
+                            $scope.billRevision++;
                         }
                     });
                 }
@@ -682,11 +676,6 @@ function($scope,  $q , $routeParams , egCore , egGridDataProvider , patronSvc ,
         }
     });
 
-    billSvc.fetchBills(xact_id).then(function(bs) {
-        bills = bs; 
-        billProvider.increment();
-    });
-
     billSvc.fetchPayments(xact_id).then(function(ps) {
         payments = ps;
         paymentProvider.increment();