minor billing / print template repairs
authorBill Erickson <berick@esilibrary.com>
Thu, 5 Jun 2014 14:24:37 +0000 (10:24 -0400)
committerBill Erickson <berick@esilibrary.com>
Thu, 5 Jun 2014 14:24:37 +0000 (10:24 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/admin/workstation/t_print_templates.tt2
Open-ILS/src/templates/staff/circ/patron/t_bill_patron_dialog.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/bills.js
Open-ILS/web/js/ui/default/staff/services/grid.js

index 71cd5b3..29d8531 100644 (file)
@@ -19,7 +19,6 @@
   </div>
   <div class="col-md-7">
     <div class="pull-right">
-      <button class="btn btn-default" ng-click="update_preview()">[% l('Preview') %]</button>
       <button class="btn btn-default" ng-click="save_locally()">[% l('Save Locally') %]</button>
     </div>
   </div>
index 4f84971..2170d32 100644 (file)
@@ -59,7 +59,8 @@
           [% l('Billing Type:') %]
         </label>
         <div class="col-md-8">
-          <select ng-model="billArgs.billingType" class="form-control">
+          <select ng-model="billArgs.billingType" class="form-control"
+            ng-change="updateDefaultPrice()">
             <option ng-repeat="type in billingTypes" value="{{type.id()}}">
               {{type.name()}}
             </option>
index 5f2a445..94ead2a 100644 (file)
@@ -408,10 +408,10 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
         // page data not yet refreshed, capture data from current scope
         var print_data = {
             payment_note : note,
-            previous_balance : $scope.summary.balance_owed,
-            payment_total : $scope.payment_amount,
+            previous_balance : Number($scope.summary.balance_owed()),
+            payment_total : Number($scope.payment_amount),
             payment_applied : $scope.pending_payment(),
-            amount_voided : $scope.session_voided,
+            amount_voided : Number($scope.session_voided),
             change_given : $scope.pending_change(),
             payments : payment_blobs,
             current_location : egCore.idl.toHash(
@@ -447,8 +447,8 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
         return $modal.open({
             templateUrl: './circ/patron/t_bill_patron_dialog',
             controller: 
-                       ['$scope','$modalInstance','billingTypes',
-                function($scope , $modalInstance , billingTypes) {
+                       ['$scope','$modalInstance','$timeout','billingTypes',
+                function($scope , $modalInstance , $timeout , billingTypes) {
                 $scope.focus = true;
                 $scope.xact = xact;
                 $scope.patron = patronSvc.current;
@@ -459,6 +459,12 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
                 }
                 $scope.ok = function(args) { $modalInstance.close(args) }
                 $scope.cancel = function () { $modalInstance.dismiss() }
+                $scope.updateDefaultPrice = function() {
+                    var type = billingTypes.filter(function(t) {
+                        return t.id() == $scope.billArgs.billingType })[0];
+                    if (type.default_price() && !$scope.billArgs.amount) 
+                        $scope.billArgs.amount = Number(type.default_price());
+                }
             }],
             resolve : {
                 // if we don't already have them, fetch the billing types
@@ -501,8 +507,10 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
             $scope.gridControls.selectItems([]);
         }
     });
+
     $scope.gridControls.allItemsRetrieved = function() {
         if (selectOnLoad) {
+            selectOnLoad = false; // only for initial controller load.
             // select all non-refund items
             $scope.gridControls.selectItems( 
                 $scope.gridControls.allItems()
@@ -561,8 +569,10 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location,
                 var bill_ids = [];
                 var cents = 0;
                 angular.forEach(bills, function(b) {
-                    cents += b.amount() * 100;
-                    bill_ids.push(b.id())
+                    if (b.voided() != 't') {
+                        cents += b.amount() * 100;
+                        bill_ids.push(b.id())
+                    }
                 });
 
                 $scope.session_voided = 
@@ -670,10 +680,7 @@ function($scope,  $q , $routeParams , egCore , egGridDataProvider , patronSvc ,
     }
 
     // batch-edit billing and payment notes, depending on 'type'
-    function editNotes(selected, type) {
-        var notes = selected.map(function(b){ return b.note() }).join(',');
-        var ids = selected.map(function(b){ return b.id() });
-
+    function editNotes(ids, notes, type) {
         // show the note edit prompt
         egPromptDialog.open(
             egCore.strings.EDIT_BILL_PAY_NOTE, notes, {
@@ -701,11 +708,16 @@ function($scope,  $q , $routeParams , egCore , egGridDataProvider , patronSvc ,
     }
 
     $scope.editBillNotes = function(selected) {
-        editNotes(selected, 'bill');
+        // bill data is flattened
+        var notes = selected.map(function(b){ return b.note }).join(',');
+        var ids = selected.map(function(b){ return b.id });
+        editNotes(ids, notes, 'bill');
     }
 
     $scope.editPaymentNotes = function(selected) {
-        editNotes(selected, 'payment');
+        var notes = selected.map(function(b){ return b.note() }).join(',');
+        var ids = selected.map(function(b){ return b.id() });
+        editNotes(ids, notes, 'payment');
     }
 
     // -- retrieve our data
index 57af67e..e7101c2 100644 (file)
@@ -1295,7 +1295,6 @@ angular.module('egGridMod',
                         return $q.when();
 
                     var query = provider.query();
-                    console.log(JSON.stringify(query));
                     if (!query || angular.equals(query, {})) 
                         return $q.when();