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',
116 maxonsiteissueqty
=> 4,
118 lengthunit
=> 'Null',
120 norenewalbefore
=> 6,
124 chargeperiod_charge_at
=> 0,
125 rentaldiscount
=> '2.000000',
126 reservesallowed
=> 0,
127 hardduedate
=> '2013-01-01',
128 branchcode
=> $samplebranch1->{branchcode
},
130 hardduedatecompare
=> 5,
131 overduefinescap
=> '0.000000',
132 renewalsallowed
=> 0,
135 categorycode
=> $samplecat->{categorycode
},
136 maxsuspensiondays
=> 0,
138 opacitemholds
=> 'N',
140 my $sampleissuingrule2 = {
141 branchcode
=> $samplebranch2->{branchcode
},
142 categorycode
=> $samplecat->{categorycode
},
145 maxonsiteissueqty
=> 1,
146 renewalsallowed
=> 'Null',
148 norenewalbefore
=> 7,
150 reservesallowed
=> 'Null',
152 lengthunit
=> 'Null',
154 hardduedatecompare
=> 'Null',
157 firstremind
=> 'Null',
158 chargeperiod
=> 'Null',
159 chargeperiod_charge_at
=> 0,
160 rentaldiscount
=> 2.00,
161 overduefinescap
=> 'Null',
162 accountsent
=> 'Null',
163 reservecharge
=> 'Null',
164 chargename
=> 'Null',
165 restrictedtype
=> 'Null',
166 maxsuspensiondays
=> 0,
168 opacitemholds
=> 'Y',
170 my $sampleissuingrule3 = {
171 branchcode
=> $samplebranch1->{branchcode
},
172 categorycode
=> $samplecat->{categorycode
},
175 maxonsiteissueqty
=> 2,
176 renewalsallowed
=> 'Null',
178 norenewalbefore
=> 8,
180 reservesallowed
=> 'Null',
182 lengthunit
=> 'Null',
184 hardduedatecompare
=> 'Null',
187 firstremind
=> 'Null',
188 chargeperiod
=> 'Null',
189 chargeperiod_charge_at
=> 0,
190 rentaldiscount
=> 3.00,
191 overduefinescap
=> 'Null',
192 accountsent
=> 'Null',
193 reservecharge
=> 'Null',
194 chargename
=> 'Null',
195 restrictedtype
=> 'Null',
196 maxsuspensiondays
=> 0,
198 opacitemholds
=> 'F',
201 $query = 'INSERT INTO issuingrules (
220 chargeperiod_charge_at,
228 ) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
229 my $sth = $dbh->prepare($query);
231 $sampleissuingrule1->{branchcode
},
232 $sampleissuingrule1->{categorycode
},
233 $sampleissuingrule1->{itemtype
},
234 $sampleissuingrule1->{maxissueqty
},
235 $sampleissuingrule1->{maxonsiteissueqty
},
236 $sampleissuingrule1->{renewalsallowed
},
237 $sampleissuingrule1->{renewalperiod
},
238 $sampleissuingrule1->{norenewalbefore
},
239 $sampleissuingrule1->{auto_renew
},
240 $sampleissuingrule1->{reservesallowed
},
241 $sampleissuingrule1->{issuelength
},
242 $sampleissuingrule1->{lengthunit
},
243 $sampleissuingrule1->{hardduedate
},
244 $sampleissuingrule1->{hardduedatecompare
},
245 $sampleissuingrule1->{fine
},
246 $sampleissuingrule1->{finedays
},
247 $sampleissuingrule1->{firstremind
},
248 $sampleissuingrule1->{chargeperiod
},
249 $sampleissuingrule1->{chargeperiod_charge_at
},
250 $sampleissuingrule1->{rentaldiscount
},
251 $sampleissuingrule1->{overduefinescap
},
252 $sampleissuingrule1->{accountsent
},
253 $sampleissuingrule1->{reservecharge
},
254 $sampleissuingrule1->{chargename
},
255 $sampleissuingrule1->{restrictedtype
},
256 $sampleissuingrule1->{maxsuspensiondays
},
259 $sampleissuingrule2->{branchcode
},
260 $sampleissuingrule2->{categorycode
},
261 $sampleissuingrule2->{itemtype
},
262 $sampleissuingrule2->{maxissueqty
},
263 $sampleissuingrule2->{maxonsiteissueqty
},
264 $sampleissuingrule2->{renewalsallowed
},
265 $sampleissuingrule2->{renewalperiod
},
266 $sampleissuingrule2->{norenewalbefore
},
267 $sampleissuingrule2->{auto_renew
},
268 $sampleissuingrule2->{reservesallowed
},
269 $sampleissuingrule2->{issuelength
},
270 $sampleissuingrule2->{lengthunit
},
271 $sampleissuingrule2->{hardduedate
},
272 $sampleissuingrule2->{hardduedatecompare
},
273 $sampleissuingrule2->{fine
},
274 $sampleissuingrule2->{finedays
},
275 $sampleissuingrule2->{firstremind
},
276 $sampleissuingrule2->{chargeperiod
},
277 $sampleissuingrule2->{chargeperiod_charge_at
},
278 $sampleissuingrule2->{rentaldiscount
},
279 $sampleissuingrule2->{overduefinescap
},
280 $sampleissuingrule2->{accountsent
},
281 $sampleissuingrule2->{reservecharge
},
282 $sampleissuingrule2->{chargename
},
283 $sampleissuingrule2->{restrictedtype
},
284 $sampleissuingrule2->{maxsuspensiondays
},
287 $sampleissuingrule3->{branchcode
},
288 $sampleissuingrule3->{categorycode
},
289 $sampleissuingrule3->{itemtype
},
290 $sampleissuingrule3->{maxissueqty
},
291 $sampleissuingrule3->{maxonsiteissueqty
},
292 $sampleissuingrule3->{renewalsallowed
},
293 $sampleissuingrule3->{renewalperiod
},
294 $sampleissuingrule3->{norenewalbefore
},
295 $sampleissuingrule3->{auto_renew
},
296 $sampleissuingrule3->{reservesallowed
},
297 $sampleissuingrule3->{issuelength
},
298 $sampleissuingrule3->{lengthunit
},
299 $sampleissuingrule3->{hardduedate
},
300 $sampleissuingrule3->{hardduedatecompare
},
301 $sampleissuingrule3->{fine
},
302 $sampleissuingrule3->{finedays
},
303 $sampleissuingrule3->{firstremind
},
304 $sampleissuingrule3->{chargeperiod
},
305 $sampleissuingrule3->{chargeperiod_charge_at
},
306 $sampleissuingrule3->{rentaldiscount
},
307 $sampleissuingrule3->{overduefinescap
},
308 $sampleissuingrule3->{accountsent
},
309 $sampleissuingrule3->{reservecharge
},
310 $sampleissuingrule3->{chargename
},
311 $sampleissuingrule3->{restrictedtype
},
312 $sampleissuingrule3->{maxsuspensiondays
},
317 $samplecat->{categorycode
},
318 'Book', $samplebranch1->{branchcode
}
321 "GetIssuingCharge returns issuingrule1's informations"
326 C4
::Circulation
::GetLoanLength
(
327 $samplecat->{categorycode
},
328 'BOOK', $samplebranch1->{branchcode
}
330 { issuelength
=> 5, lengthunit
=> 'Null', renewalperiod
=> 5 },
334 C4
::Circulation
::GetLoanLength
(),
338 lengthunit
=> 'days',
340 "Without parameters, GetLoanLength returns hardcoded values"
343 C4
::Circulation
::GetLoanLength
( -1, -1 ),
347 lengthunit
=> 'days',
349 "With wrong parameters, GetLoanLength returns hardcoded values"
352 C4
::Circulation
::GetLoanLength
( $samplecat->{categorycode
} ),
356 lengthunit
=> 'days',
358 "With only one parameter, GetLoanLength returns hardcoded values"
359 ); #NOTE : is that really what is expected?
361 C4
::Circulation
::GetLoanLength
( $samplecat->{categorycode
}, 'BOOK' ),
365 lengthunit
=> 'days',
367 "With only one parameter, GetLoanLength returns hardcoded values"
368 ); #NOTE : is that really what is expected?
371 my @hardduedate = C4
::Circulation
::GetHardDueDate
( $samplecat->{categorycode
},
372 'BOOK', $samplebranch1->{branchcode
} );
376 dt_from_string
( $sampleissuingrule1->{hardduedate
}, 'iso' ),
377 $sampleissuingrule1->{hardduedatecompare
}
379 "GetHardDueDate returns the duedate and the duedatecompare"