Add SIP2 chargeable loan support.
authorJason Stephenson <jstephenson@mvlc.org>
Thu, 30 Jun 2011 17:43:24 +0000 (13:43 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 26 Aug 2011 19:15:12 +0000 (15:15 -0400)
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Bill Erickson <berick@esilibrary.com>

Open-ILS/src/perlmods/lib/OpenILS/SIP.pm
Open-ILS/src/perlmods/lib/OpenILS/SIP/Item.pm
Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction.pm
Open-ILS/src/perlmods/lib/OpenILS/SIP/Transaction/Checkout.pm

index 729fc5c..acfa572 100644 (file)
@@ -297,16 +297,18 @@ sub offline_ok {
 
 
 ##
-## Checkout(patron_id, item_id, sc_renew):
+## Checkout(patron_id, item_id, sc_renew, fee_ack):
 ##    patron_id & item_id are the identifiers send by the terminal
 ##    sc_renew is the renewal policy configured on the terminal
 ## returns a status opject that can be queried for the various bits
 ## of information that the protocol (SIP or NCIP) needs to generate
 ## the response.
+##    fee_ack is the fee_acknowledged field (BO) sent from the sc
+## when doing chargeable loans.
 ##
 
 sub checkout {
-       my ($self, $patron_id, $item_id, $sc_renew) = @_;
+       my ($self, $patron_id, $item_id, $sc_renew, $fee_ack) = @_;
        $sc_renew = 0;
 
        $self->verify_session;
@@ -347,6 +349,21 @@ sub checkout {
                $xact->ok(0);
        } 
 
+        # Check for fee and $fee_ack. If there is a fee, and $fee_ack
+        # is 'Y', we proceed, otherwise we reject the checkout.
+        if ($item->fee > 0.0) {
+            $xact->fee_amount($item->fee);
+            $xact->sip_fee_type($item->sip_fee_type);
+            $xact->sip_currency($item->fee_currency);
+            if ($fee_ack && $fee_ack eq 'Y') {
+                $xact->fee_ack(1);
+            } else {
+                $xact->screen_msg('Fee required');
+                $xact->ok(0);
+                return $xact;
+            }
+        }
+
        $xact->do_checkout($sc_renew);
        $xact->desensitize(!$item->magnetic);
 
index 91302a1..35d9ee4 100644 (file)
@@ -364,12 +364,15 @@ sub sip_security_marker {
 }
 
 sub sip_fee_type {
-    return '01';    # FIXME? 01-09 enumerated in spec.  We just use O1-other/unknown.
+    my $self = shift;
+    # Return '06' for rental unless the fee is a deposit, or there is
+    # no fee. In the latter cases, return '01'.
+    return ($self->{copy}->deposit_amount > 0.0 && $self->{copy}->deposit =~ /^f/i) ? '06' : '01';
 }
 
-sub fee {           # TODO
+sub fee {
     my $self = shift;
-    return 0;
+    return $self->{copy}->deposit_amount;
 }
 
 
index a4813cb..5ef185d 100644 (file)
@@ -26,6 +26,7 @@ my %fields = (
       print_line    => '',
       editor        => undef,
       authtoken     => '',
+      fee_ack       => 0,
 );
 
 our $AUTOLOAD;
index bb751b2..bcfdc3b 100644 (file)
@@ -102,6 +102,9 @@ sub do_checkout {
                     if ($override_events{$txt} && $method !~ /override$/) {
                         # Found an event we've been configured to override.
                         $override = 1;
+                    } elsif ($txt =~ /ITEM_(?:DEPOSIT|RENTAL)_FEE_REQUIRED/ && $self->fee_ack) {
+                        # Patron acknowledged the fee.
+                        $override = 1;
                     } elsif ( $txt eq 'OPEN_CIRCULATION_EXISTS' ) {
                         $self->screen_msg(OILS_SIP_MSG_CIRC_EXISTS);
                         return 0;