added method to put into and remove from collections ..
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 29 Jun 2006 20:54:06 +0000 (20:54 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 29 Jun 2006 20:54:06 +0000 (20:54 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@4853 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Collections.pm

index 3921fd9..0aa9db4 100644 (file)
@@ -7,6 +7,7 @@ use OpenSRF::Application;
 use base 'OpenSRF::Application';
 my $U = "OpenILS::Application::AppUtils";
 use OpenILS::Utils::CStoreEditor qw/:funcs/;
+use OpenILS::Utils::Fieldmapper;
 use OpenILS::Event;
 
 
@@ -72,11 +73,86 @@ sub users_with_activity {
        return $U->storagereq(
                'open-ils.storage.money.collections.users_with_activity.atomic', 
                $start_date, $end_date, $location);
+}
+
+
+
+__PACKAGE__->register_method(
+       method          => 'put_into_collections',
+       api_name                => 'open-ils.collections.put_into_collections',
+       signature       => q/
+               Returns the users that are currently in collections and
+               had activity during the provided interval.  Dates are inclusive.
+               @param start_date The beginning of the activity interval
+               @param end_date The end of the activity interval
+               @param location The location at which the fines were created
+       /
+);
+
+sub put_into_collections {
+       my( $self, $conn, $auth, $user_id, $location ) = @_;
+
+       return OpenILS::Event->new('BAD_PARAMS') 
+               unless ($auth and $user_id and $location);
+
+       my $e = new_editor(authtoken => $auth, xact =>1);
+       return $e->event unless $e->checkauth;
+
+       my $org = $e->search_actor_org_unit({shortname => $location})
+               or return $e->event; $org = $org->[0];
+       return $e->event unless $e->allowed('money.collections_tracker.create', $org->id);
+
+       my $tracker = Fieldmapper::money::collections_tracker->new;
+
+       $tracker->usr($user_id);
+       $tracker->collector($e->requestor->id);
+       $tracker->location($org->id);
+       $tracker->enter_time('now');
 
+       $e->create_money_collections_tracker($tracker) 
+               or return $e->event;
+
+       $e->commit;
+       return OpenILS::Event->new('SUCCESS');
 }
 
 
 
 
+__PACKAGE__->register_method(
+       method          => 'remove_from_collections',
+       api_name                => 'open-ils.collections.remove_from_collections',
+       signature       => q/
+               Returns the users that are currently in collections and
+               had activity during the provided interval.  Dates are inclusive.
+               @param start_date The beginning of the activity interval
+               @param end_date The end of the activity interval
+               @param location The location at which the fines were created
+       /
+);
+
+sub remove_from_collections {
+       my( $self, $conn, $auth, $user_id, $location ) = @_;
+
+       return OpenILS::Event->new('BAD_PARAMS') 
+               unless ($auth and $user_id and $location);
+
+       my $e = new_editor(authtoken => $auth, xact=>1);
+       return $e->event unless $e->checkauth;
+
+       my $org = $e->search_actor_org_unit({shortname => $location})
+               or return $e->event; $org = $org->[0];
+       return $e->event unless $e->allowed('money.collections_tracker.delete', $org->id);
+
+       my $tracker = $e->search_money_collections_tracker(
+               { usr => $user_id, location => $org->id })
+               or return $e->event;
+
+       $e->delete_money_collections_tracker($tracker->[0])
+               or return $e->event;
+
+       $e->commit;
+       return OpenILS::Event->new('SUCCESS');
+}
 
 1;