Bug 5605 [ENH] SIP: Add Support for the Fee Paid Message
authorColin Campbell <colin.campbell@ptfs-europe.com>
Sun, 9 Jan 2011 23:53:05 +0000 (23:53 +0000)
committerChris Cormack <chrisc@catalyst.net.nz>
Tue, 6 Sep 2011 20:56:15 +0000 (08:56 +1200)
Allow fee paid to be supported for those machines which handle it

Development Sponsered by Halton Borough Council

Signed-off-by: Ian Walls <ian.walls@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
C4/SIP/ILS.pm
C4/SIP/ILS/Transaction/FeePayment.pm
C4/SIP/Sip/MsgType.pm

index 9e20845..7dc29a7 100644 (file)
@@ -32,7 +32,7 @@ my %supports = (
     "login"                 => 1,
     "patron information"    => 1,
     "end patron session"    => 1,
-    "fee paid"              => 0,
+    "fee paid"              => 1,
     "item information"      => 1,
     "item status update"    => 0,
     "patron enable"         => 1,
@@ -214,14 +214,18 @@ sub pay_fee {
     my ($self, $patron_id, $patron_pwd, $fee_amt, $fee_type,
        $pay_type, $fee_id, $trans_id, $currency) = @_;
     my $trans;
-    my $patron;
 
-#    $trans = new ILS::Transaction::FeePayment;
+    $trans = ILS::Transaction::FeePayment->new();
 
-    $patron = new ILS::Patron $patron_id;
 
     $trans->transaction_id($trans_id);
-    $trans->patron($patron);
+    my $patron;
+    $trans->patron($patron = ILS::Patron->new($patron_id));
+    if (!$patron) {
+        $trans->screen_msg('Invalid patron barcode.');
+        return $trans;
+    }
+    $trans->pay($patron->{borrowernumber},$fee_amt);
     $trans->ok(1);
 
     return $trans;
index 8a156b7..3026296 100644 (file)
@@ -3,16 +3,56 @@ package ILS::Transaction::FeePayment;
 use warnings;
 use strict;
 
+# Copyright 2011 PTFS-Europe Ltd.
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use C4::Accounts qw(recordpayment);
+use ILS;
+use base qw(ILS::Transaction);
+
 use vars qw($VERSION @ISA $debug);
 
-BEGIN {
-       $VERSION = 1.00;
-       @ISA = qw(ILS::Transaction);
-       $debug = 0;
+our $debug   = 0;
+our $VERSION = 1.00;
+
+my %fields = ();
+
+sub new {
+    my $class = shift;
+    my $self  = $class->SUPER::new();
+
+    foreach ( keys %fields ) {
+        $self->{_permitted}->{$_} = $fields{$_};    # overlaying _permitted
+    }
+
+    @{$self}{ keys %fields } = values %fields;    # copying defaults into object
+    return bless $self, $class;
 }
 
-use ILS;
-use ILS::Transaction;
+sub pay {
+    my $self           = shift;
+    my $borrowernumber = shift;
+    my $amt            = shift;
+    warn("RECORD:$borrowernumber::$amt");
+    recordpayment( $borrowernumber, $amt );
+}
+
+#sub DESTROY {
+#}
 
 1;
 __END__
index d76503d..6a11d0e 100644 (file)
@@ -176,13 +176,13 @@ my %handlers = (
                    handler => \&handle_fee_paid,
                    protocol => {
                        2 => {
-                           template => "A18A2A3",
-                           template_len => 0,
+                           template => "A18A2A2A3",
+                           template_len => 25,
                            fields => [(FID_FEE_AMT), (FID_INST_ID),
                                       (FID_PATRON_ID), (FID_TERMINAL_PWD),
                                       (FID_PATRON_PWD), (FID_FEE_ID),
-                                      (FID_TRANSACTION_ID)],
-                       }
+                       (FID_TRANSACTION_ID)],
+               }
                    }
                },
                (ITEM_INFORMATION) => {