adding openncip / opensip SIP2 service
[koha.git] / C4 / SIP / ILS / Transaction.pm
1 #
2 # Transaction: Superclass of all the transactional status objects
3 #
4
5 package ILS::Transaction;
6
7 use Carp;
8 use strict;
9 use warnings;
10
11 my %fields = (
12               ok            => 0,
13               patron        => undef,
14               item          => undef,
15               desensitize   => 0,
16               alert         => '',
17               transation_id => undef,
18               sip_fee_type  => '01', # Other/Unknown
19               fee_amount    => undef,
20               sip_currency  => 'CAD',
21               screen_msg    => '',
22               print_line    => '',
23               );
24
25 our $AUTOLOAD;
26
27 sub new {
28     my $class = shift;
29     my $self = {
30         _permitted => \%fields,
31         %fields,
32     };
33
34     return bless $self, $class;
35 }
36
37 sub DESTROY {
38     # be cool
39 }
40
41 sub AUTOLOAD {
42     my $self = shift;
43     my $class = ref($self) or croak "$self is not an object";
44     my $name = $AUTOLOAD;
45
46     $name =~ s/.*://;
47
48     unless (exists $self->{_permitted}->{$name}) {
49         croak "Can't access '$name' field of class '$class'";
50     }
51
52     if (@_) {
53         return $self->{$name} = shift;
54     } else {
55         return $self->{$name};
56     }
57 }
58
59 1;