Bug 14949: Remove C4::Dates from admin/smart-rules.pl and admin/categorie.pl
[koha.git] / C4 / SIP / ILS / Transaction.pm
1 #
2 # Transaction: Superclass of all the transactional status objects
3 #
4
5 package C4::SIP::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     fee_ack       => 'N',
25 );
26
27 our $AUTOLOAD;
28
29 sub new {
30         my $class = shift;
31         my $self = {
32                 _permitted => \%fields,
33                 %fields,
34         };
35         return bless $self, $class;
36 }
37
38 sub DESTROY {
39     # be cool
40 }
41
42 sub AUTOLOAD {
43     my $self = shift;
44     my $class = ref($self) or croak "$self is not an object";
45     my $name = $AUTOLOAD;
46
47     $name =~ s/.*://;
48
49     unless (exists $self->{_permitted}->{$name}) {
50                 croak "Can't access '$name' field of class '$class'";
51     }
52
53         if (@_) {
54                 return $self->{$name} = shift;
55         } else {
56                 return $self->{$name};
57         }
58 }
59
60 1;
61 __END__
62