tweaked some utility methods
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 13 Feb 2006 21:38:33 +0000 (21:38 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 13 Feb 2006 21:38:33 +0000 (21:38 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3047 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/AppUtils.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm

index 512f803..e61a132 100644 (file)
@@ -861,7 +861,15 @@ sub update_copy {
        return undef;
 }
 
-
+sub fetch_billable_xact {
+       my( $self, $id ) = @_;
+       my($xact, $evt);
+       $logger->debug("Fetching billable transaction %id");
+       $xact = $self->storagereq(
+               'open-ils.storage.direct.money.billable_transaction.retrieve', $id );
+       $evt = OpenILS::Event->new('TRANSACTION_NOT_FOUND') unless $xact;
+       return ($xact, $evt);
+}
 
 
 
index 1deaec2..74c64af 100644 (file)
@@ -19,6 +19,7 @@ use base qw/OpenSRF::Application/;
 use strict; use warnings;
 use OpenILS::Application::AppUtils;
 my $apputils = "OpenILS::Application::AppUtils";
+my $U = "OpenILS::Application::AppUtils";
 
 use OpenSRF::EX qw(:try);
 use OpenILS::Perm;
@@ -222,19 +223,20 @@ __PACKAGE__->register_method(
 sub billing_items {
        my( $self, $client, $login, $transid ) = @_;
 
-       my( $staff, $evt ) = $apputils->checksesperm($login, 'VIEW_TRANSACTION');
+       my( $trans, $evt ) = $U->fetch_billable_xact($transid);
        return $evt if $evt;
 
-# we need to grab the transaction by id and check the billing location
-# to determin the permissibility XXX
-
-#      $evt = $apputils->check_perms($staff->id, 
-#              $transaction->billing_location, 'VIEW_TRANSACTION' );
-#      return $evt if $evt;
+       my $staff;
+       ($staff, $evt ) = $apputils->checkses($login);
+       return $evt if $evt;
 
+       if($staff->id ne $trans->usr) {
+               $evt = $U->check_perms($staff->id, $staff->home_ou, 'VIEW_TRANSACTION');
+               return $evt if $evt;
+       }
+       
        return $apputils->simplereq( 'open-ils.storage',
                'open-ils.storage.direct.money.billing.search.xact.atomic', $transid )
-
 }