Add SIP2 chargeable loan support. collab/jason@mvlc.org/SIP2_chargeable_loans_rel_2_1
authorJason Stephenson <jstephenson@mvlc.org>
Thu, 30 Jun 2011 17:43:24 +0000 (13:43 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Wed, 6 Jul 2011 14:03:18 +0000 (10:03 -0400)
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
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 fe312ff..250792e 100644 (file)
@@ -296,16 +296,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;
@@ -346,6 +348,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 7eb815c..2fedbc7 100644 (file)
@@ -363,12 +363,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 eeb9faf..38bbd3f 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;