From aea6d7d365fbe058e8d151a5832841060d6168c4 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 28 May 2014 16:11:59 -0400 Subject: [PATCH] bill history transactions Signed-off-by: Bill Erickson --- Open-ILS/examples/fm_IDL.xml | 18 +++- .../templates/staff/circ/patron/t_bill_history.tt2 | 84 +++++++++++++++++ .../templates/staff/circ/patron/t_xact_details.tt2 | 8 +- Open-ILS/src/templates/staff/css/style.css.tt2 | 3 + Open-ILS/src/templates/staff/share/t_autogrid.tt2 | 2 +- .../web/js/ui/default/staff/circ/patron/app.js | 6 ++ .../web/js/ui/default/staff/circ/patron/bills.js | 103 +++++++++++++++++---- Open-ILS/web/js/ui/default/staff/services/pcrud.js | 6 +- Open-ILS/web/js/ui/default/staff/services/ui.js | 26 ++++++ 9 files changed, 229 insertions(+), 27 deletions(-) create mode 100644 Open-ILS/src/templates/staff/circ/patron/t_bill_history.tt2 diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 43558dd645..eceafd0870 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -1968,7 +1968,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + @@ -1988,6 +1988,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + + @@ -6139,7 +6146,7 @@ SELECT usr, - + @@ -6164,6 +6171,13 @@ SELECT usr, + + + + + + + diff --git a/Open-ILS/src/templates/staff/circ/patron/t_bill_history.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_bill_history.tt2 new file mode 100644 index 0000000000..1f2c75a074 --- /dev/null +++ b/Open-ILS/src/templates/staff/circ/patron/t_bill_history.tt2 @@ -0,0 +1,84 @@ +

[% l('Bill History') %]

+ + +
+
+ +
+
+
[% l('Selected Billed:') %]
+
{{selected_billed | currency}}
+
[% l('Selected Paid:') %]
+
{{selected_paid | currency}}
+
+
[% l('Start Date:') %]
+
+
[% l('End Date:') %]
+
+
+
+ + + + + + + + + + + + + + + + + {{item.title}} + + + + + + + {{item.copy_barcode}} + + + + + + + + + + + + + +
+ +
+
+ diff --git a/Open-ILS/src/templates/staff/circ/patron/t_xact_details.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_xact_details.tt2 index a676a38e13..0e5807e392 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_xact_details.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_xact_details.tt2 @@ -4,7 +4,7 @@
[% l('Billing Location') %]
{{xact.billing_location().shortname()}}
[% l('Total Billed') %]
-
{{xact.total_owed() | currency}}
+
{{xact.summary().total_owed() | currency}}
[% l('Title') %]
{{title}} @@ -13,9 +13,9 @@
[% l('Type') %]
-
{{xact.xact_type()}}
+
{{xact.summary().xact_type()}}
[% l('Total Paid') %]
-
{{xact.total_paid() | currency}}
+
{{xact.summary().total_paid() | currency}}
[% l('Checked Out') %]
{{xact.circulation().xact_start() | date:'short'}}
@@ -23,7 +23,7 @@
[% l('Start') %]
{{xact.xact_start() | date:'short'}}
[% l('Total Billed') %]
-
{{xact.balance_owed() | currency}}
+
{{xact.summary().balance_owed() | currency}}
[% l('Due Date') %]
{{xact.circulation().due_date() | date:'short'}}
diff --git a/Open-ILS/src/templates/staff/css/style.css.tt2 b/Open-ILS/src/templates/staff/css/style.css.tt2 index 8b51943b93..c30215b1f8 100644 --- a/Open-ILS/src/templates/staff/css/style.css.tt2 +++ b/Open-ILS/src/templates/staff/css/style.css.tt2 @@ -351,6 +351,9 @@ table.list tr.selected td { .flex-row { display: flex; } +.flex-row.padded div { + padding: 5px; +} .flex-cell { flex: 1; padding: 4px; /* bootstrap default is much bigger */ diff --git a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 index 883d3dd336..27f01c88fa 100644 --- a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 @@ -195,7 +195,7 @@
diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index 462d22d02a..5d59b3e76d 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -103,6 +103,12 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap', resolve : resolver }); + $routeProvider.when('/circ/patron/:id/bill_history/:history_tab', { + templateUrl: './circ/patron/t_bill_history', + controller: 'BillHistoryCtrl', + resolve : resolver + }); + $routeProvider.when('/circ/patron/:id/messages', { templateUrl: './circ/patron/t_messages', controller: 'PatronMessagesCtrl', diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js b/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js index 6e23b44796..a360c6cc5e 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/bills.js @@ -111,21 +111,33 @@ function($q , egCore , patronSvc) { }); } + service.xactFlesh = { + flesh : 5, + flesh_fields : { + mbt : ['summary','circulation','grocery','reservation'], + circ : ['target_copy'], + acp : ['call_number','location','status','age_protect'], + acn : ['record'], + bre : ['simple_record'] + }, + select : { bre : ['id'] } // avoid MARC + } + service.fetchXact = function(id) { - return egCore.pcrud.retrieve('mobts', id, - { flesh : 5, - flesh_fields : { - mobts : ['circulation','grocery'], - circ : ['target_copy'], - acp : ['call_number','location','status','age_protect'], - acn : ['record'], - bre : ['simple_record'] - }, - select : { bre : ['id'] } // avoid MARC - }, - {authoritative : true} + return egCore.pcrud.retrieve( + 'mbt', id, service.xactFlesh, {authoritative : true} ).then(function(xact) { - xact.billing_location(egCore.org.get(xact.billing_location())); + + /* mobts has location, but mbts does not + * only the xact detail page shows it now, so maybe move + * this into the template... + * + var loc; + if (xact.circulation()) loc = xact.circulation().circ_lib(); + if (xact.reservation()) loc = xact.reservation().pickup_lib(); + if (xact.grocery()) loc = xact.grocery().billing_location(); + xact.billing_location(egCore.org.get(loc)); + */ return xact; }); } @@ -335,6 +347,11 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location, billSvc.fetchSummary().then(function(s) {$scope.summary = s}); }) } + + $scope.showHistory = function() { + $location.path('/circ/patron/' + + patronSvc.current.id() + '/bill_history/transactions'); + } // For now, only adds billing to first selected item. // Could do batches later if needed @@ -378,16 +395,12 @@ function($scope , $q , $routeParams , egCore , egConfirmDialog , $location, ); } - $scope.showHistory = function() { - // go to bills/history - } - $scope.selectRefunds = function() { - // select grid items where refunds are due + // TODO: select grid items where refunds are due } $scope.printBills = function() { - // print selected bills using the bills print template + // TODO: print selected bills using the bills print template } $scope.applyPayment = function() { @@ -592,3 +605,55 @@ function($scope, $q , $routeParams , egCore , egGridDataProvider , patronSvc , }]) +.controller('BillHistoryCtrl', + ['$scope','$q','$routeParams','egCore','patronSvc','billSvc','egPromptDialog','$location', +function($scope, $q , $routeParams , egCore , patronSvc , billSvc , egPromptDialog , $location) { + + $scope.initTab('bills', $routeParams.id); + billSvc.userId = $routeParams.id; + $scope.bill_tab = $routeParams.history_tab; + $scope.selected_billed = 0; + $scope.selected_paid = 0; + + var start = new Date(); // now - 1 year + start.setFullYear(start.getFullYear() - 1), + $scope.dates = { + xact_start : start, + xact_finish : new Date() + } + + $scope.xactQuery = function() { + // strip the time for our search purposes + var start = $scope.dates.xact_start.toISOString().replace(/T.*/,''); + var end = $scope.dates.xact_finish.toISOString().replace(/T.*/,''); + var today = new Date().toISOString().replace(/T.*/,''); + + // open-ils.actor.user.transactions.history.have_bill_or_payment + var query = { + '-or' : [ + {'summary.balance_owed' : {'<>' : 0}}, + {'summary.last_payment_ts' : {'<>' : null}} + ], + xact_start : {'>=' : start}, + usr : billSvc.userId + } + + // end date of today implies that xacts with a null xact_finish + // are also acceptable + if (end < today) query.xact_finish = {'<=' : end}; + + return query; + } + + $scope.showFullDetails = function(all) { + if (all[0]) + $location.path('/circ/patron/' + + patronSvc.current.id() + '/bill/' + all[0].id); + } + $scope.activateBill = function(xact) { + $scope.showFullDetails([xact]); + } + +}]) + + diff --git a/Open-ILS/web/js/ui/default/staff/services/pcrud.js b/Open-ILS/web/js/ui/default/staff/services/pcrud.js index 54c91c3b5e..5c4ec2f076 100644 --- a/Open-ILS/web/js/ui/default/staff/services/pcrud.js +++ b/Open-ILS/web/js/ui/default/staff/services/pcrud.js @@ -208,8 +208,12 @@ angular.module('egCoreMod') oncomplete : function() { deferred.resolve(lastResp); }, + onmethoderror : function(e) { + self.err(method + " failed " + e + "\n" + js2JSON(params)); + deferred.reject(e); + }, onerror : function(e) { - self.err(method + " failed " + e); + self.err(method + " failed " + e + "\n" + js2JSON(params)); deferred.reject(e); } }).send(); diff --git a/Open-ILS/web/js/ui/default/staff/services/ui.js b/Open-ILS/web/js/ui/default/staff/services/ui.js index 6aec308d30..9ee72c7f6d 100644 --- a/Open-ILS/web/js/ui/default/staff/services/ui.js +++ b/Open-ILS/web/js/ui/default/staff/services/ui.js @@ -248,3 +248,29 @@ function($modal, $interpolate) { } }) + +/* +http://stackoverflow.com/questions/18061757/angular-js-and-html5-date-input-value-how-to-get-firefox-to-show-a-readable-d + +This directive allows us to use html5 input type="date" (for Chrome) and +gracefully fall back to a regular ISO text input for Firefox. +It also allows us to abstract away some browser finickiness. +*/ +.directive( + 'egDateInput', + function(dateFilter) { + return { + require: 'ngModel', + template: '', + replace: true, + link: function(scope, elm, attrs, ngModelCtrl) { + ngModelCtrl.$formatters.unshift(function (modelValue) { + return dateFilter(modelValue, 'yyyy-MM-dd'); + }); + + ngModelCtrl.$parsers.unshift(function(viewValue) { + return new Date(viewValue); + }); + }, + }; +}) -- 2.11.0