[open-ils-commits] r15209 - in trunk/Open-ILS/src/perlmods/OpenILS/Application: . Circ (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Dec 21 11:46:40 EST 2009


Author: erickson
Date: 2009-12-21 11:46:37 -0500 (Mon, 21 Dec 2009)
New Revision: 15209

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm
   trunk/Open-ILS/src/perlmods/OpenILS/Application/CreditCard.pm
Log:
move the credit card payable balance summary into the the public circ service

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm	2009-12-21 16:33:23 UTC (rev 15208)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Money.pm	2009-12-21 16:46:37 UTC (rev 15209)
@@ -750,4 +750,83 @@
     return $data;
 }
 
+
+__PACKAGE__->register_method(
+    method    => 'retrieve_credit_payable_balance',
+    api_name  => 'open-ils.circ.credit.payable_balance.retrieve',
+    authoritative => 1,
+    signature => {
+        desc   => q/Returns the total amount the patron can pay via credit card/,
+        params => [
+            { desc => 'Authentication token', type => 'string' },
+            { desc => 'User id', type => 'number' }
+        ],
+        return => { desc => 'The ID of the new provider' }
+    }
+);
+
+sub retrieve_credit_payable_balance {
+    my ( $self, $conn, $auth, $user_id ) = @_;
+    my $e = new_editor(authtoken => $auth);
+    return $e->event unless $e->checkauth;
+
+    my $user = $e->retrieve_actor_user($user_id) 
+        or return $e->event;
+
+    if($e->requestor->id != $user_id) {
+        return $e->event unless $e->allowed('VIEW_USER_TRANSACTIONS', $user->home_ou)
+    }
+
+    my $circ_orgs = $e->json_query({
+        "select" => {circ => ["circ_lib"]},
+        from     => "circ",
+        "where"  => {usr => $user_id, xact_finish => undef},
+        distinct => 1
+    });
+
+    my $groc_orgs = $e->json_query({
+        "select" => {mg => ["billing_location"]},
+        from     => "mg",
+        "where"  => {usr => $user_id, xact_finish => undef},
+        distinct => 1
+    });
+
+    my %hash;
+    for my $org ( @$circ_orgs, @$groc_orgs ) {
+        my $o = $org->{billing_location};
+        $o = $org->{circ_lib} unless $o;
+        next if $hash{$o};    # was $hash{$org}, but that doesn't make sense.  $org is a hashref and $o gets added in the next line.
+        $hash{$o} = $U->ou_ancestor_setting_value($o, 'credit.payments.allow', $e);
+    }
+
+    my @credit_orgs = map { $hash{$_} ? ($_) : () } keys %hash;
+    $logger->debug("credit: relevant orgs that allow credit payments => @credit_orgs");
+
+    my $xact_summaries =
+      OpenILS::Application::AppUtils->simplereq('open-ils.actor',
+        'open-ils.actor.user.transactions.have_charge', $auth, $user_id);
+
+    my $sum = 0.0;
+
+    for my $xact (@$xact_summaries) {
+
+        # make two lists and grab them in batch XXX
+        if ( $xact->xact_type eq 'circulation' ) {
+            my $circ = $e->retrieve_action_circulation($xact->id) or return $e->event;
+            next unless grep { $_ == $circ->circ_lib } @credit_orgs;
+
+        } elsif ($xact->xact_type eq 'grocery') {
+            my $bill = $e->retrieve_money_grocery($xact->id) or return $e->event;
+            next unless grep { $_ == $bill->billing_location } @credit_orgs;
+        } elsif ($xact->xact_type eq 'reservation') {
+            my $bill = $e->retrieve_booking_reservation($xact->id) or return $e->event;
+            next unless grep { $_ == $bill->pickup_lib } @credit_orgs;
+        }
+        $sum += $xact->balance_owed();
+    }
+
+    return $sum;
+}
+
+
 1;

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/CreditCard.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/CreditCard.pm	2009-12-21 16:33:23 UTC (rev 15208)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/CreditCard.pm	2009-12-21 16:46:37 UTC (rev 15209)
@@ -296,80 +296,4 @@
 }
 
 
-__PACKAGE__->register_method(
-    method    => 'retrieve_payable_balance',
-    api_name  => 'open-ils.credit.payable_balance.retrieve',
-    signature => {
-        desc   => q/Returns the total amount of the patron can pay via credit card/,
-        params => [
-            { desc => 'Authentication token', type => 'string' },
-            { desc => 'User id', type => 'number' }
-        ],
-        return => { desc => 'The ID of the new provider' }
-    }
-);
-
-sub retrieve_payable_balance {
-    my ( $self, $conn, $auth, $user_id ) = @_;
-    my $e = new_editor(authtoken => $auth);
-    return $e->event unless $e->checkauth;
-
-    my $user = $e->retrieve_actor_user($user_id) 
-        or return $e->event;
-
-    if($e->requestor->id != $user_id) {
-        return $e->event unless $e->allowed('VIEW_USER_TRANSACTIONS', $user->home_ou)
-    }
-
-    my $circ_orgs = $e->json_query({
-        "select" => {circ => ["circ_lib"]},
-        from     => "circ",
-        "where"  => {usr => $user_id, xact_finish => undef},
-        distinct => 1
-    });
-
-    my $groc_orgs = $e->json_query({
-        "select" => {mg => ["billing_location"]},
-        from     => "mg",
-        "where"  => {usr => $user_id, xact_finish => undef},
-        distinct => 1
-    });
-
-    my %hash;
-    for my $org ( @$circ_orgs, @$groc_orgs ) {
-        my $o = $org->{billing_location};
-        $o = $org->{circ_lib} unless $o;
-        next if $hash{$o};    # was $hash{$org}, but that doesn't make sense.  $org is a hashref and $o gets added in the next line.
-        $hash{$o} = $U->ou_ancestor_setting_value($o, CREDIT_NS . '.payments.allow', $e);
-    }
-
-    my @credit_orgs = map { $hash{$_} ? ($_) : () } keys %hash;
-    $logger->debug("credit: relevant orgs that allow credit payments => @credit_orgs");
-
-    my $xact_summaries =
-      OpenILS::Application::AppUtils->simplereq('open-ils.actor',
-        'open-ils.actor.user.transactions.have_charge', $auth, $user_id);
-
-    my $sum = 0.0;
-
-    for my $xact (@$xact_summaries) {
-
-        # make two lists and grab them in batch XXX
-        if ( $xact->xact_type eq 'circulation' ) {
-            my $circ = $e->retrieve_action_circulation($xact->id) or return $e->event;
-            next unless grep { $_ == $circ->circ_lib } @credit_orgs;
-
-        } elsif ($xact->xact_type eq 'grocery') {
-            my $bill = $e->retrieve_money_grocery($xact->id) or return $e->event;
-            next unless grep { $_ == $bill->billing_location } @credit_orgs;
-        } elsif ($xact->xact_type eq 'reservation') {
-            my $bill = $e->retrieve_booking_reservation($xact->id) or return $e->event;
-            next unless grep { $_ == $bill->pickup_lib } @credit_orgs;
-        }
-        $sum += $xact->balance_owed();
-    }
-
-    return $sum;
-}
-
 1;



More information about the open-ils-commits mailing list