File Coverage

blib/lib/Biblio/ILL/ISO/CostInfoType.pm
Criterion Covered Total %
statement 27 47 57.4
branch 5 26 19.2
condition 1 9 11.1
subroutine 6 8 75.0
pod 3 3 100.0
total 42 93 45.1


line stmt bran cond sub pod time code
1             package Biblio::ILL::ISO::CostInfoType;
2              
3             =head1 NAME
4              
5             Biblio::ILL::ISO::CostInfoType
6              
7             =cut
8              
9 4     4   643 use Biblio::ILL::ISO::ILLASNtype;
  4         9  
  4         111  
10 4     4   24 use Biblio::ILL::ISO::AccountNumber;
  4         8  
  4         81  
11 4     4   24 use Biblio::ILL::ISO::Amount;
  4         6  
  4         88  
12              
13 4     4   21 use Carp;
  4         8  
  4         439  
14              
15             =head1 VERSION
16              
17             Version 0.01
18              
19             =cut
20              
21             our $VERSION = '0.01';
22             #---------------------------------------------------------------------------
23             # Mods
24             # 0.01 - 2003.07.15 - original version
25             #---------------------------------------------------------------------------
26              
27             =head1 DESCRIPTION
28              
29             Biblio::ILL::ISO::CostInfoType is a derivation of Biblio::ILL::ISO::ILLASNtype.
30              
31             =head1 USES
32              
33             Biblio::ILL::ISO::AccountNumber
34             Biblio::ILL::ISO::Amount
35              
36             =head1 USED IN
37              
38             Biblio::ILL::ISO::Request
39              
40             =cut
41              
42 4     4   2871 BEGIN{@ISA = qw ( Biblio::ILL::ISO::ILLASNtype );} # inherit from ILLASNtype
43              
44             =head1 FROM THE ASN DEFINITION
45            
46             Cost-Info-Type ::= SEQUENCE {
47             account-number [0] Account-Number OPTIONAL,
48             maximum-cost [1] IMPLICIT Amount OPTIONAL,
49             reciprocal-agreement [2] IMPLICIT BOOLEAN, -- DEFAULT FALSE,
50             will-pay-fee [3] IMPLICIT BOOLEAN, -- DEFAULT FALSE,
51             payment-provided [4] IMPLICIT BOOLEAN -- DEFAULT FALSE
52             }
53              
54             =cut
55              
56             =head1 METHODS
57              
58             =cut
59              
60             #---------------------------------------------------------------
61             #
62             #---------------------------------------------------------------
63             =head1
64              
65             =head2 from_asn($href)
66              
67             Given a properly formatted hash, builds the object.
68              
69             =cut
70             sub from_asn {
71 0     0 1 0 my $self = shift;
72 0         0 my $href = shift;
73              
74 0         0 foreach my $k (keys %$href) {
75             #print ref($self) . "...$k\n";
76              
77 0 0 0     0 if ($k =~ /^account-number$/) {
    0 0        
    0          
78 0         0 $self->{$k} = new Biblio::ILL::ISO::AccountNumber();
79 0         0 $self->{$k}->from_asn($href->{$k});
80              
81             } elsif ($k =~ /^maximum-cost$/) {
82 0         0 $self->{$k} = new Biblio::ILL::ISO::Amount();
83 0         0 $self->{$k}->from_asn($href->{$k});
84              
85             } elsif (($k =~ /^reciprocal-agreement$/)
86             || ($k =~ /^will-pay-fee$/)
87             || ($k =~ /^payment-provided$/)
88             ) {
89 0         0 $self->{$k} = $href->{$k};
90            
91             } else {
92 0         0 croak "invalid " . ref($self) . " element: [$k]";
93             }
94              
95             }
96 0         0 return $self;
97             }
98              
99              
100             #---------------------------------------------------------------
101             #
102             #---------------------------------------------------------------
103             =head1
104              
105             =head2 new( $reciprocal_agreement, $will_pay_fee, $payment_provided [, $account] [, $maxcost])
106              
107             Creates a new CostInfoType object.
108             Expects a reciprocal-agreement flag (0/1),
109             a will-pay-fee flag (0/1),
110             a payment-provided flag (0/1),
111             (optionally) an account-number (Biblio::ILL:ISO::AccountNumber), and
112             (optionally) a maximum-cost (Biblio::ILL::ISO::Amount).
113              
114             =cut
115             sub new {
116 2     2 1 27 my $class = shift;
117 2         4 my $self = {};
118              
119 2         6 $self->{"reciprocal-agreement"} = 0;
120 2         6 $self->{"will-pay-fee"} = 0;
121 2         5 $self->{"payment-provided"} = 0;
122              
123 2 50       8 if (@_) {
124 2         7 my ($reciprocal, $will_pay, $payment_provided,
125             $account, $maxcost) = @_;
126            
127 2 50       8 $self->{"reciprocal-agreement"} = $reciprocal if ($reciprocal);
128 2 50       16 $self->{"will-pay-fee"} = $will_pay if ($will_pay);
129 2 50       21 $self->{"payment-provided"} = $payment_provided if ($payment_provided);;
130 2 50       34 $self->{"account-number"} = new Biblio::ILL::ISO::AccountNumber($account) if ($account);
131 2         16 $self->{"maximum-cost"} = new Biblio::ILL::ISO::Amount($maxcost);
132             }
133              
134 2   33     29 bless($self, ref($class) || $class);
135 2         7 return ($self);
136             }
137              
138              
139             #---------------------------------------------------------------
140             #
141             #---------------------------------------------------------------
142             =head1
143              
144             =head2 set( $reciprocal_agreement [, [$will_pay_fee] [, [$payment_provided] [, [$account] [, $maxcost]]]] )
145              
146             Sets the object's reciprocal-agreement flag (0/1),
147             (optionally) will-pay-fee flag (0/1),
148             (optionally) payment-provided flag (0/1),
149             (optionally) account-number (Biblio::ILL:ISO::AccountNumber), and
150             (optionally) maximum-cost (Biblio::ILL::ISO::Amount).
151              
152             =cut
153             sub set {
154 0     0 1   my $self = shift;
155 0           my ($reciprocal, $will_pay, $payment_provided, $account, $maxcost) = @_;
156              
157 0 0         croak "missing reciprocal-agreement" unless $reciprocal;
158              
159 0           $self->{"reciprocal-agreement"} = $reciprocal;
160 0 0         $self->{"will-pay-fee"} = $will_pay if ($will_pay);
161 0 0         $self->{"payment-provided"} = $payment_provided if ($payment_provided);
162 0 0         $self->{"account-number"} = new Biblio::ILL::ISO::AccountNumber($account) if ($account);
163 0 0         $self->{"maximum-cost"} = new Biblio::ILL::ISO::Amount($maxcost) if ($maxcost);
164              
165 0           return;
166             }
167              
168             =head1 SEE ALSO
169              
170             See the README for system design notes.
171             See the parent class(es) for other available methods.
172              
173             For more information on Interlibrary Loan standards (ISO 10160/10161),
174             a good place to start is:
175              
176             http://www.nlc-bnc.ca/iso/ill/main.htm
177              
178             =cut
179              
180             =head1 AUTHOR
181              
182             David Christensen,
183              
184             =cut
185              
186              
187             =head1 COPYRIGHT AND LICENSE
188              
189             Copyright 2003 by David Christensen
190              
191             This library is free software; you can redistribute it and/or modify it
192             under the same terms as Perl itself.
193              
194             =cut
195              
196             1;