added some money methods
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 17 Nov 2005 23:18:08 +0000 (23:18 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 17 Nov 2005 23:18:08 +0000 (23:18 +0000)
fixed some typos/bugs
made some updates to work with new storage methods

git-svn-id: svn://svn.open-ils.org/ILS/trunk@2062 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/extras/fieldmapper.pl
Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm
Open-ILS/src/perlmods/OpenILS/Application/Circ/Rules.pm
Open-ILS/src/perlmods/OpenILS/Application/Search.pm

index 066e4bf..f885be1 100755 (executable)
@@ -12,7 +12,7 @@ if(!$web) { $web = ""; }
 # List of classes needed by the opac
 my @web_hints = qw/asv asva asvr asvq 
                circ acp acpl acn ccs ahn aua ac 
-               actscecm crcd crmf crrf mus mbts aoc aus/;
+               actscecm crcd crmf crrf mbts aoc aus mous/;
 
 my @web_core = qw/ aou au perm_ex ex aout mvr ccs ahr /;
 
index 55b5807..87479db 100644 (file)
@@ -383,9 +383,11 @@ sub _update_patron {
        my( $session, $patron, $user_obj) = @_;
 
 
-       if($apputils->check_user_perms(
-                               $user_obj->id, $user_obj->home_ou, "UPDATE_USER")) {
-               return OpenILS::Perm->new("UPDATE_USER");
+       if($patron->id ne $user_obj->id) {
+               if($apputils->check_user_perms(
+                                       $user_obj->id, $user_obj->home_ou, "UPDATE_USER")) {
+                       return OpenILS::Perm->new("UPDATE_USER");
+               }
        }
 
        warn "updating patron " . Dumper($patron) . "\n";
@@ -1056,7 +1058,7 @@ __PACKAGE__->register_method(
        notes           => <<"  NOTES");
        Returns a short summary of the users total open fines, excluding voided fines
        Params are login_session, user_id
-       Returns a 'mus' object.
+       Returns a 'mous' object.
        NOTES
 
 sub user_fines_summary {
@@ -1071,7 +1073,7 @@ sub user_fines_summary {
 
        return $apputils->simple_scalar_request( 
                "open-ils.storage",
-               "open-ils.storage.direct.money.user_summary.search.usr",
+               "open-ils.storage.direct.money.open_user_summary.search.usr",
                $user_id );
 
 }
@@ -1161,21 +1163,21 @@ sub user_transactions {
 
                $trans = $apputils->simple_scalar_request( 
                        "open-ils.storage",
-                       "open-ils.storage.direct.money.billable_transaction_summary.search_where.atomic",
+                       "open-ils.storage.direct.money.open_billable_transaction_summary.search_where.atomic",
                        { usr => $user_id, total_owed => { ">" => 0 }, @xact });
 
        } elsif($api =~ /have_balance/) {
 
                $trans =  $apputils->simple_scalar_request( 
                        "open-ils.storage",
-                       "open-ils.storage.direct.money.billable_transaction_summary.search_where.atomic",
+                       "open-ils.storage.direct.money.open_billable_transaction_summary.search_where.atomic",
                        { usr => $user_id, balance_owed => { ">" => 0 }, @xact });
 
        } else {
 
                $trans =  $apputils->simple_scalar_request( 
                        "open-ils.storage",
-                       "open-ils.storage.direct.money.billable_transaction_summary.search_where.atomic",
+                       "open-ils.storage.direct.money.open_billable_transaction_summary.search_where.atomic",
                        { usr => $user_id, @xact });
        }
 
index 55d1af8..2bb25cb 100644 (file)
@@ -46,7 +46,7 @@ sub checkouts_by_user {
 
        my $circs = $session->request(
                "open-ils.storage.direct.action.open_circulation.search.atomic", 
-               { usr => $user_id, stop_fines => undef } );
+               { usr => $user_id } );
        $circs = $circs->gather(1);
 
        my @results;
index d4c6b20..616c3f2 100644 (file)
@@ -68,7 +68,7 @@ sub make_payments {
                my $transid = $pay->[0];
                my $amount = $pay->[1];
                my $trans = $session->request(
-                       "open-ils.storage.direct.money.billable_transaction_summary.retrieve", 
+                       "open-ils.storage.direct.money.open_billable_transaction_summary.retrieve", 
                        $transid )->gather(1);
 
                return OpenILS::EX->new("NO_TRANSACTION_FOUND")->ex unless $trans; 
@@ -138,6 +138,93 @@ sub _update_patron_credit {
 
 
 
+__PACKAGE__->register_method(
+       method  => "create_bill",
+       api_name        => "open-ils.circ.money.grocery.create",
+       notes           => <<"  NOTE");
+       Creates a new grocery transaction using the transaction object provided
+       PARAMS: (login_session, money.grocery (mg) object)
+       NOTE
+
+sub create_grocery_bill {
+       my( $self, $client, $login, $transaction ) = @_;
+
+       my $staff = $apputils->check_user_session($login);
+       if($apputils->check_user_perms($staff->id, 
+                       $transaction->billing_location, "CREATE_TRANSACTION")) {
+               return OpenILS::Perm->new("CREATE_TRANSACTION");
+       }
+
+       my $session = $apputils->start_db_session;
+       my $transid = $session->request(
+               'open-ils.storage.direct.money.grocery.create', $transaction)->gather(1);
+
+       if(!$transid) {
+               throw OpenSRF::EX ("Error creating new money.grocery");
+       }
+
+       warn "created new grocery transaction $transid\n";
+       
+       $apputils->commit_db_session($session);
+
+       return $transid;
+}
+
+__PACKAGE__->register_method(
+       method  => "billing_items",
+       api_name        => "open-ils.circ.money.billing.retrieve.all",
+       notes           =><<"   NOTE");
+       Returns a list of billing items for the given transaction.
+       PARAMS( login, transaction_id )
+       NOTE
+
+sub billing_items {
+       my( $self, $client, $login, $transid ) = @_;
+
+       my $staff = $apputils->check_user_session($login);
+       if($apputils->check_user_perms($staff->id, 
+                       $staff->home_ou, "VIEW_TRANSACTION")) {
+               return OpenILS::Perm->new("VIEW_TRANSACTION");
+       }
+
+       return $apputils->simple_scalar_request(
+               'open-ils.storage',
+               'open-ils.storage.direct.money.billing.search.xact.atomic', $transid )
+}
+
+
+__PACKAGE__->register_method(
+       method  => "billing_items_create",
+       api_name        => "open-ils.circ.money.billing.create",
+       notes           =><<"   NOTE");
+       Creates a new billing line item
+       PARAMS( login, bill_object (mb) )
+       NOTE
+
+sub billing_items_create {
+       my( $self, $client, $login, $billing ) = @_;
+
+       my $staff = $apputils->check_user_session($login);
+       if($apputils->check_user_perms($staff->id, 
+                       $staff->home_ou, "CREATE_BILL")) {
+               return OpenILS::Perm->new("CREATE_BILL");
+       }
+
+       my $session = $apputils->start_db_session;
+
+       my $id = $session->request(
+               'open-ils.storage.direct.money.billing.create', $billing )->gather(1);
+
+       if(!$id) {
+               throw OpenSRF::EX ("Error creating new bill");
+       }
+
+       return $id;
+}
+
+
+
+
 
 1;
 
index 986077c..4c693c7 100644 (file)
@@ -784,7 +784,7 @@ sub transit_receive {
                                        if($circ) {
 
                                                my $transaction = $session->request(
-                                                       "open-ils.storage.direct.money.billable_transaction_summary.retrieve", $circ->id)->gather(1);
+                                                       "open-ils.storage.direct.money.open_billable_transaction_summary.retrieve", $circ->id)->gather(1);
 
                                                $circ->xact_finish("now") if($transaction->balance_owed <= 0);
 
@@ -926,7 +926,7 @@ sub checkin {
                        } else {
        
                                $transaction = $session->request(
-                                       "open-ils.storage.direct.money.billable_transaction_summary.retrieve", $circ->id)->gather(1);
+                                       "open-ils.storage.direct.money.open_billable_transaction_summary.retrieve", $circ->id)->gather(1);
                
                                warn "Checking in circ ". $circ->id . "\n";
                        
@@ -934,6 +934,9 @@ sub checkin {
                                $circ->stop_fines("RENEW") if($isrenewal);
                                $circ->stop_fines("LOST") if($iamlost);
                                $circ->xact_finish("now") if($transaction->balance_owed <= 0 and !$iamlost);
+                               $circ->stop_fines_time('now');
+                               $circ->checkin_time('now');
+                               $circ->checkin_staff($user->id);
 
                                if($backdate) { 
                                        $circ->xact_finish($backdate); 
index 0ae8c48..1d2dc50 100644 (file)
@@ -14,6 +14,7 @@ use OpenILS::Application::Search::Biblio;
 use OpenILS::Application::Search::Authority;
 use OpenILS::Application::Search::Actor;
 use OpenILS::Application::Search::Z3950;
+use OpenILS::Application::Search::AddedContent;
 
 use OpenILS::Application::AppUtils;
 
@@ -27,6 +28,7 @@ use Text::Aspell; # spell checking...
 
 sub initialize {
        OpenILS::Application::Search::Z3950->initialize();
+       OpenILS::Application::Search::AddedContent->initialize();
 }
 
 sub filter_search {