From: Michael Peters Date: Tue, 18 Oct 2011 19:44:19 +0000 (-0400) Subject: Create a user_payment_detail method in OpenILS::Application::Actor X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fmrpeters-isl%2Factor_user_payment_details;p=working%2FEvergreen.git Create a user_payment_detail method in OpenILS::Application::Actor In relation to LP#812382, I've created a new API, open-ils.actor.user.payments.detailed, which allows you to pull in information regarding the location (workstation name) and accepting user (username) for a particular user's payment history. This is the beginnings of a customization which allows for additional detail when attempting to audit payment histories via the staff client. Additional work is still needed to "link up" this API in the staff client, however, this takes care of the backend Perl. Signed-off-by: Michael Peters --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index ad6fabc176..d2adc425e8 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -3620,6 +3620,74 @@ sub user_payments { } +__PACKAGE__->register_method ( + method => 'user_payment_detail', + api_name => 'open-ils.actor.user.payments.detailed', + stream => 1, + signature => q/ + Returns all payments for a given user. Default order is newest payments first. + @param auth Authentication token + @param user_id The user ID + @param filters An optional hash of filters, including limit, offset, and order_by definitions + / +); + +sub user_payment_detail { + my($self, $conn, $auth, $user_id, $filters) = @_; + $filters ||= {}; + + my $e = new_editor(authtoken => $auth); + return $e->die_event unless $e->checkauth; + + my $user = $e->retrieve_actor_user($user_id) or return $e->event; + return $e->event unless + $e->requestor->id == $user_id or + $e->allowed('VIEW_USER_TRANSACTIONS', $user->home_ou); + + # Find detailed information about all payments for user $user_id + my $query = { + select => {mdp => ['id']}, + from => 'mdp', + where => { + xact => { + in => { + select => {mbt => ['id']}, + from => 'mbt', + where => {usr => $user_id} + } + } + }, + order_by => [{ # by default, order newest payments first + class => 'mp', + field => 'payment_ts', + direction => 'desc' + }] + }; + + my $payment_ids = $e->json_query($query); + for my $pid (@$payment_ids) { + my $pay = $e->retrieve_money_desk_payment([ + $pid->{id}, + { flesh => 6, + flesh_fields => { + mdp => ['xact'], + mdp => ['accepting_usr'] + } + } + ]); + + my $resp = { + mdp => $pay, + }; + + $pay->accepting_usr($pay->accepting_usr->id); # de-flesh accepting_usr to usrname + $conn->respond($resp); + } + + + return undef; +} + __PACKAGE__->register_method ( method => 'negative_balance_users', diff --git a/Open-ILS/xul/staff_client/chrome/content/main/constants.js b/Open-ILS/xul/staff_client/chrome/content/main/constants.js index 31142e744c..a33b3d4ac7 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -278,6 +278,7 @@ var api = { 'FM_MP_RETRIEVE_VIA_MBTS_ID' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.retrieve.all' }, 'FM_MP_RETRIEVE_VIA_MBTS_ID.authoritative' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.retrieve.all.authoritative' }, 'FM_MP_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.payments.retrieve' }, + 'FM_MDP_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.payments.detailed' }, 'FM_MP_NOTE_EDIT' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment.note.edit' }, 'FM_MG_CREATE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.grocery.create' }, 'FM_MG_RETRIEVE' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.grocery.retrieve' },