fleshing workstation on payment objects and returning specific objects
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 15 Aug 2006 19:02:52 +0000 (19:02 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 15 Aug 2006 19:02:52 +0000 (19:02 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5522 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index 4e3d760..395d809 100644 (file)
@@ -26,7 +26,8 @@ use OpenILS::Perm;
 use Data::Dumper;
 use OpenILS::Event;
 use OpenSRF::Utils::Logger qw/:logger/;
-use OpenILS::Utils::Editor qw/:funcs/;
+#use OpenILS::Utils::Editor qw/:funcs/;
+use OpenILS::Utils::CStoreEditor qw/:funcs/;
 
 __PACKAGE__->register_method(
        method  => "make_payments",
@@ -208,7 +209,7 @@ sub _update_patron_credit {
 
 __PACKAGE__->register_method(
        method  => "retrieve_payments",
-       api_name        => "open-ils.circ.money.payment.retrieve.all",
+       api_name        => "open-ils.circ.money.payment.retrieve.all_",
        notes           => "Returns a list of payments attached to a given transaction"
        );
        
@@ -222,12 +223,43 @@ sub retrieve_payments {
        # XXX the logic here is wrong.. we need to check the owner of the transaction
        # to make sure the requestor has access
 
+       # XXX grab the view, for each object in the view, grab the real object
+
        return $apputils->simplereq(
                'open-ils.cstore',
                'open-ils.cstore.direct.money.payment.search.atomic', { xact => $transid } );
 }
 
 
+__PACKAGE__->register_method(
+       method  => "retrieve_payments2",
+       api_name        => "open-ils.circ.money.payment.retrieve.all",
+       notes           => "Returns a list of payments attached to a given transaction"
+       );
+       
+sub retrieve_payments2 {
+       my( $self, $client, $login, $transid ) = @_;
+
+       my $e = new_editor(authtoken=>$login);
+       return $e->event unless $e->checkauth;
+       return $e->event unless $e->allowed('VIEW_TRANSACTION');
+
+       my @payments;
+       my $pmnts = $e->search_money_payment({ xact => $transid });
+       for( @$pmnts ) {
+               my $type = $_->payment_type;
+               my $meth = "retrieve_money_$type";
+               my $p = $e->$meth($_->id) or return $e->event;
+               try {
+                       $p->cash_drawer($e->retrieve_actor_workstation($p->cash_drawer));
+               } catch Error with {};
+               push( @payments, $p );
+       }
+
+       return \@payments;
+}
+
+
 
 __PACKAGE__->register_method(
        method  => "create_grocery_bill",
@@ -346,7 +378,8 @@ __PACKAGE__->register_method(
 sub void_bill {
        my( $s, $c, $authtoken, $billid ) = @_;
 
-       my $e = OpenILS::Utils::Editor->new( authtoken => $authtoken );
+       #my $e = OpenILS::Utils::Editor->new( authtoken => $authtoken );
+       my $e = new_editor( authtoken => $authtoken );
        return $e->event unless $e->checkauth;
        return $e->event unless $e->allowed('VOID_BILLING');