9 use Test::More tests => 9;
12 use_ok('C4::Circulation');
24 my $dbh = C4::Context->dbh;
25 $dbh->{RaiseError} = 1;
26 $dbh->{AutoCommit} = 0;
28 $dbh->do(q|DELETE FROM issues|);
29 $dbh->do(q|DELETE FROM items|);
30 $dbh->do(q|DELETE FROM borrowers|);
31 $dbh->do(q|DELETE FROM branches|);
32 $dbh->do(q|DELETE FROM categories|);
33 $dbh->do(q|DELETE FROM issuingrules|);
37 #Add branch and category
41 branchname => 'Sample Branch',
42 branchaddress1 => 'sample adr1',
43 branchaddress2 => 'sample adr2',
44 branchaddress3 => 'sample adr3',
45 branchzip => 'sample zip',
46 branchcity => 'sample city',
47 branchstate => 'sample state',
48 branchcountry => 'sample country',
49 branchphone => 'sample phone',
50 branchfax => 'sample fax',
51 branchemail => 'sample email',
52 branchurl => 'sample url',
53 branchip => 'sample ip',
54 branchprinter => undef,
55 opac_info => 'sample opac',
60 branchname => 'Sample Branch2',
61 branchaddress1 => 'sample adr1_2',
62 branchaddress2 => 'sample adr2_2',
63 branchaddress3 => 'sample adr3_2',
64 branchzip => 'sample zip2',
65 branchcity => 'sample city2',
66 branchstate => 'sample state2',
67 branchcountry => 'sample country2',
68 branchphone => 'sample phone2',
69 branchfax => 'sample fax2',
70 branchemail => 'sample email2',
71 branchurl => 'sample url2',
72 branchip => 'sample ip2',
73 branchprinter => undef,
74 opac_info => 'sample opac2',
76 ModBranch($samplebranch1);
77 ModBranch($samplebranch2);
80 categorycode => 'CAT1',
81 description => 'Description1',
82 enrolmentperiod => 'Null',
83 enrolmentperioddate => 'Null',
84 dateofbirthrequired => 'Null',
87 enrolmentfee => 'Null',
88 overduenoticerequired => 'Null',
92 category_type => 'Null'
95 "INSERT INTO categories (categorycode,description,enrolmentperiod,enrolmentperioddate,dateofbirthrequired ,finetype,bulk,enrolmentfee,overduenoticerequired,issuelimit ,reservefee ,hidelostitems ,category_type) VALUES( ?,?,?,?,?,?,?,?,?,?,?,?,?)";
98 $samplecat->{categorycode}, $samplecat->{description},
99 $samplecat->{enrolmentperiod}, $samplecat->{enrolmentperioddate},
100 $samplecat->{dateofbirthrequired}, $samplecat->{finetype},
101 $samplecat->{bulk}, $samplecat->{enrolmentfee},
102 $samplecat->{overduenoticerequired}, $samplecat->{issuelimit},
103 $samplecat->{reservefee}, $samplecat->{hidelostitems},
104 $samplecat->{category_type}
110 my $sampleissuingrule1 = {
111 reservecharge => '0.000000',
112 chargename => 'Null',
117 lengthunit => 'Null',
121 rentaldiscount => '2.000000',
122 reservesallowed => 0,
123 hardduedate => '2013-01-01',
124 branchcode => $samplebranch1->{branchcode},
126 hardduedatecompare => 5,
127 overduefinescap => '0.000000',
128 renewalsallowed => 0,
131 categorycode => $samplecat->{categorycode}
133 my $sampleissuingrule2 = {
134 branchcode => $samplebranch2->{branchcode},
135 categorycode => $samplecat->{categorycode},
138 renewalsallowed => 'Null',
140 reservesallowed => 'Null',
142 lengthunit => 'Null',
144 hardduedatecompare => 'Null',
147 firstremind => 'Null',
148 chargeperiod => 'Null',
149 rentaldiscount => 2.00,
150 overduefinescap => 'Null',
151 accountsent => 'Null',
152 reservecharge => 'Null',
153 chargename => 'Null',
154 restrictedtype => 'Null'
156 my $sampleissuingrule3 = {
157 branchcode => $samplebranch1->{branchcode},
158 categorycode => $samplecat->{categorycode},
161 renewalsallowed => 'Null',
163 reservesallowed => 'Null',
165 lengthunit => 'Null',
167 hardduedatecompare => 'Null',
170 firstremind => 'Null',
171 chargeperiod => 'Null',
172 rentaldiscount => 3.00,
173 overduefinescap => 'Null',
174 accountsent => 'Null',
175 reservecharge => 'Null',
176 chargename => 'Null',
177 restrictedtype => 'Null'
179 $query = 'INSERT INTO issuingrules (
201 ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
202 my $sth = $dbh->prepare($query);
204 $sampleissuingrule1->{branchcode},
205 $sampleissuingrule1->{categorycode},
206 $sampleissuingrule1->{itemtype},
207 $sampleissuingrule1->{maxissueqty},
208 $sampleissuingrule1->{renewalsallowed},
209 $sampleissuingrule1->{renewalperiod},
210 $sampleissuingrule1->{reservesallowed},
211 $sampleissuingrule1->{issuelength},
212 $sampleissuingrule1->{lengthunit},
213 $sampleissuingrule1->{hardduedate},
214 $sampleissuingrule1->{hardduedatecompare},
215 $sampleissuingrule1->{fine},
216 $sampleissuingrule1->{finedays},
217 $sampleissuingrule1->{firstremind},
218 $sampleissuingrule1->{chargeperiod},
219 $sampleissuingrule1->{rentaldiscount},
220 $sampleissuingrule1->{overduefinescap},
221 $sampleissuingrule1->{accountsent},
222 $sampleissuingrule1->{reservecharge},
223 $sampleissuingrule1->{chargename},
224 $sampleissuingrule1->{restrictedtype}
227 $sampleissuingrule2->{branchcode},
228 $sampleissuingrule2->{categorycode},
229 $sampleissuingrule2->{itemtype},
230 $sampleissuingrule2->{maxissueqty},
231 $sampleissuingrule2->{renewalsallowed},
232 $sampleissuingrule2->{renewalperiod},
233 $sampleissuingrule2->{reservesallowed},
234 $sampleissuingrule2->{issuelength},
235 $sampleissuingrule2->{lengthunit},
236 $sampleissuingrule2->{hardduedate},
237 $sampleissuingrule2->{hardduedatecompare},
238 $sampleissuingrule2->{fine},
239 $sampleissuingrule2->{finedays},
240 $sampleissuingrule2->{firstremind},
241 $sampleissuingrule2->{chargeperiod},
242 $sampleissuingrule2->{rentaldiscount},
243 $sampleissuingrule2->{overduefinescap},
244 $sampleissuingrule2->{accountsent},
245 $sampleissuingrule2->{reservecharge},
246 $sampleissuingrule2->{chargename},
247 $sampleissuingrule2->{restrictedtype}
250 $sampleissuingrule3->{branchcode},
251 $sampleissuingrule3->{categorycode},
252 $sampleissuingrule3->{itemtype},
253 $sampleissuingrule3->{maxissueqty},
254 $sampleissuingrule3->{renewalsallowed},
255 $sampleissuingrule3->{renewalperiod},
256 $sampleissuingrule3->{reservesallowed},
257 $sampleissuingrule3->{issuelength},
258 $sampleissuingrule3->{lengthunit},
259 $sampleissuingrule3->{hardduedate},
260 $sampleissuingrule3->{hardduedatecompare},
261 $sampleissuingrule3->{fine},
262 $sampleissuingrule3->{finedays},
263 $sampleissuingrule3->{firstremind},
264 $sampleissuingrule3->{chargeperiod},
265 $sampleissuingrule3->{rentaldiscount},
266 $sampleissuingrule3->{overduefinescap},
267 $sampleissuingrule3->{accountsent},
268 $sampleissuingrule3->{reservecharge},
269 $sampleissuingrule3->{chargename},
270 $sampleissuingrule3->{restrictedtype}
275 $samplecat->{categorycode},
276 'Book', $samplebranch1->{branchcode}
279 "GetIssuingCharge returns issuingrule1's informations"
284 C4::Circulation::GetLoanLength(
285 $samplecat->{categorycode},
286 'BOOK', $samplebranch1->{branchcode}
288 { issuelength => 5, lengthunit => 'Null', renewalperiod => 5 },
292 C4::Circulation::GetLoanLength(),
296 lengthunit => 'days',
298 "Without parameters, GetLoanLength returns hardcoded values"
301 C4::Circulation::GetLoanLength( -1, -1 ),
305 lengthunit => 'days',
307 "With wrong parameters, GetLoanLength returns hardcoded values"
310 C4::Circulation::GetLoanLength( $samplecat->{categorycode} ),
314 lengthunit => 'days',
316 "With only one parameter, GetLoanLength returns hardcoded values"
317 ); #NOTE : is that really what is expected?
319 C4::Circulation::GetLoanLength( $samplecat->{categorycode}, 'BOOK' ),
323 lengthunit => 'days',
325 "With only one parameter, GetLoanLength returns hardcoded values"
326 ); #NOTE : is that really what is expected?
329 my @hardduedate = C4::Circulation::GetHardDueDate( $samplecat->{categorycode},
330 'BOOK', $samplebranch1->{branchcode} );
334 dt_from_string( $sampleissuingrule1->{hardduedate}, 'iso' ),
335 $sampleissuingrule1->{hardduedatecompare}
337 "GetHardDueDate returns the duedate and the duedatecompare"