From ba4d29327f98365f3f63c4d1f78a3eaa88e78677 Mon Sep 17 00:00:00 2001 From: erickson Date: Fri, 4 Feb 2011 00:14:26 +0000 Subject: [PATCH] ported open-ils.actor.user.transaction.[fleshed.]retrieve to CStoreEditor both for cleanup and to take advantage of .authoritative. Use authoritative version in staff client git-svn-id: svn://svn.open-ils.org/ILS/trunk@19379 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/lib/OpenILS/Application/Actor.pm | 80 +++++++++------------- .../staff_client/chrome/content/main/constants.js | 2 +- 2 files changed, 35 insertions(+), 47 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index fa75db451..6b3e7be6c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -1749,6 +1749,7 @@ __PACKAGE__->register_method( method => "user_transaction_retrieve", api_name => "open-ils.actor.user.transaction.fleshed.retrieve", argc => 1, + authoritative => 1, notes => "Returns a fleshed transaction record" ); @@ -1756,68 +1757,55 @@ __PACKAGE__->register_method( method => "user_transaction_retrieve", api_name => "open-ils.actor.user.transaction.retrieve", argc => 1, + authoritative => 1, notes => "Returns a transaction record" ); sub user_transaction_retrieve { - my( $self, $client, $login_session, $bill_id ) = @_; - - # I think I'm deprecated... make sure. phasefx says, "No, I'll use you :) - - my $trans = $apputils->simple_scalar_request( - "open-ils.cstore", - "open-ils.cstore.direct.money.billable_transaction_summary.retrieve", - $bill_id - ); + my($self, $client, $auth, $bill_id) = @_; - my( $user_obj, $target, $evt ) = $apputils->checkses_requestor( - $login_session, $trans->usr, 'VIEW_USER_TRANSACTIONS' ); - return $evt if $evt; - - my $api = $self->api_name(); - if($api !~ /fleshed/o) { return $trans; } + my $e = new_editor(authtoken => $auth); + return $e->event unless $e->checkauth; - if( $trans->xact_type ne 'circulation' ) { - $logger->debug("Returning non-circ transaction"); - return {transaction => $trans}; - } + my $trans = $e->retrieve_money_billable_transaction_summary( + [$bill_id, {flesh => 1, flesh_fields => {mbts => ['usr']}}]) or return $e->event; - my $circ = $apputils->simple_scalar_request( - "open-ils.cstore", - "open-ils.cstore.direct.action.circulation.retrieve", - $trans->id ); + return $e->event unless $e->allowed('VIEW_USER_TRANSACTIONS', $trans->usr->home_ou); - return {transaction => $trans} unless $circ; - $logger->debug("Found the circ transaction"); + $trans->usr($trans->usr->id); # de-flesh for backwards compat - my $title = $apputils->simple_scalar_request( - "open-ils.storage", - "open-ils.storage.fleshed.biblio.record_entry.retrieve_by_copy", - $circ->target_copy ); + return $trans unless $self->api_name =~ /flesh/; + return {transaction => $trans} if $trans->xact_type ne 'circulation'; - return {transaction => $trans, circ => $circ } unless $title; - $logger->debug("Found the circ title"); + my $circ = $e->retrieve_action_circulation([ + $trans->id, { + flesh => 3, + flesh_fields => { + circ => ['target_copy'], + acp => ['call_number'], + acn => ['record'] + } + } + ]); my $mods; - my $copy = $apputils->simple_scalar_request( - "open-ils.cstore", - "open-ils.cstore.direct.asset.copy.retrieve", - $circ->target_copy ); + my $copy = $circ->target_copy; + + if($circ->target_copy->call_number->id == OILS_PRECAT_CALL_NUMBER) { + $mods = new Fieldmapper::metabib::virtual_record; + $mods->doc_id(OILS_PRECAT_RECORD); + $mods->title($copy->dummy_title); + $mods->author($copy->dummy_author); - try { + } else { my $u = OpenILS::Utils::ModsParser->new(); - $u->start_mods_batch($title->marc()); + $u->start_mods_batch($circ->target_copy->call_number->record->marc); $mods = $u->finish_mods_batch(); - } otherwise { - if ($title->id == OILS_PRECAT_RECORD) { - $mods = new Fieldmapper::metabib::virtual_record; - $mods->doc_id(OILS_PRECAT_RECORD); - $mods->title($copy->dummy_title); - $mods->author($copy->dummy_author); - } - }; + } - $logger->debug("MODSized the circ title"); + # more de-fleshiing + $circ->target_copy($circ->target_copy->id); + $copy->call_number($copy->call_number->id); return {transaction => $trans, circ => $circ, record => $mods, copy => $copy }; } 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 00521de0c..d7fa588e9 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/constants.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/constants.js @@ -63,7 +63,7 @@ var api = { 'BILL_PAY' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.money.payment' }, 'BLOB_AU_PARTS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.retrieve.parts', 'cacheable' : true, 'ttl' : 120000 }, 'BLOB_MARC_CALLNUMBERS_RETRIEVE' : { 'app' : 'open-ils.cat', 'method' : 'open-ils.cat.biblio.record.marc_cn.retrieve', 'secure' : false }, - 'BLOB_MBTS_DETAILS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transaction.fleshed.retrieve', 'secure' : false }, + 'BLOB_MBTS_DETAILS_RETRIEVE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transaction.fleshed.retrieve.authoritative', 'secure' : false }, 'BLOB_MOBTS_CIRC_MVR_HAVING_BALANCE' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.have_balance.fleshed' }, 'BLOB_MOBTS_CIRC_MVR_OPEN' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.transactions.fleshed' }, 'BLOB_BALANCE_OWED_VIA_USERGROUP' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.usergroup.members.balance_owed.authoritative' }, -- 2.11.0