}
+__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',
'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' },