From 6c0962f06b35d897fc0e1f2276182feeb3124c6f Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Sun, 9 Jan 2011 23:53:05 +0000 Subject: [PATCH] Bug 5605 [ENH] SIP: Add Support for the Fee Paid Message Allow fee paid to be supported for those machines which handle it Development Sponsered by Halton Borough Council Signed-off-by: Ian Walls Signed-off-by: Chris Cormack --- C4/SIP/ILS.pm | 14 +++++--- C4/SIP/ILS/Transaction/FeePayment.pm | 52 ++++++++++++++++++++++++---- C4/SIP/Sip/MsgType.pm | 8 ++--- 3 files changed, 59 insertions(+), 15 deletions(-) diff --git a/C4/SIP/ILS.pm b/C4/SIP/ILS.pm index 9e2084594e..7dc29a7511 100644 --- a/C4/SIP/ILS.pm +++ b/C4/SIP/ILS.pm @@ -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; diff --git a/C4/SIP/ILS/Transaction/FeePayment.pm b/C4/SIP/ILS/Transaction/FeePayment.pm index 8a156b74c8..3026296629 100644 --- a/C4/SIP/ILS/Transaction/FeePayment.pm +++ b/C4/SIP/ILS/Transaction/FeePayment.pm @@ -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__ diff --git a/C4/SIP/Sip/MsgType.pm b/C4/SIP/Sip/MsgType.pm index d76503d8b0..6a11d0e58d 100644 --- a/C4/SIP/Sip/MsgType.pm +++ b/C4/SIP/Sip/MsgType.pm @@ -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) => { -- 2.39.5