Merge remote-tracking branch 'origin/new/bug_7310'
[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 use C4::Context;
11
12 my %fields = (
13         ok            => 0,
14         patron        => undef,
15         item          => undef,
16         desensitize   => 0,
17         alert         => '',
18         transaction_id=> undef,
19         sip_fee_type  => '01', # Other/Unknown
20         fee_amount    => undef,
21         sip_currency  => 'USD', # FIXME: why hardcoded?
22         screen_msg    => '',
23         print_line    => '',
24 );
25
26 our $AUTOLOAD;
27
28 sub new {
29         my $class = shift;
30         my $self = {
31                 _permitted => \%fields,
32                 %fields,
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;
60 __END__
61