|
Lines 97-111
my $item2 = $builder->build_sample_item(
Link Here
|
| 97 |
); |
97 |
); |
| 98 |
|
98 |
|
| 99 |
subtest 'GetReserveFee' => sub { |
99 |
subtest 'GetReserveFee' => sub { |
| 100 |
plan tests => 6; |
100 |
plan tests => 8; |
| 101 |
|
101 |
|
| 102 |
C4::Circulation::AddIssue( $patron1, $item1->barcode, '2015-12-31', 0, undef, 0, {} ); # the date does not really matter |
102 |
C4::Circulation::AddIssue( $patron1, $item1->barcode, '2015-12-31', 0, undef, 0, {} ); # the date does not really matter |
| 103 |
C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ); # the date does not really matter |
103 |
C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ); # the date does not really matter |
| 104 |
my $acc2 = acctlines( $patron2->borrowernumber ); |
104 |
my $acc2 = acctlines( $patron2->borrowernumber ); |
| 105 |
my $res1 = addreserve( $patron1->borrowernumber ); |
105 |
my $res1 = addreserve( $patron1->borrowernumber ); |
| 106 |
|
106 |
|
| 107 |
t::lib::Mocks::mock_preference('HoldFeeMode', 'not_always'); |
107 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'issued_or_reserved' ); |
| 108 |
my $fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
108 |
my $fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
|
|
109 |
is( int($fee), 2, 'HoldFeeMode=issued_or_reserved, Patron 2 should be charged' ); |
| 110 |
|
| 111 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); |
| 112 |
$fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
| 113 |
is( $fee, 0, 'HoldFeeMode=not_always, Patron 2 should not be charged' ); |
| 114 |
|
| 115 |
C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ) |
| 116 |
; # the date does not really matter |
| 117 |
$fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
| 109 |
is( $fee > 0, 1, 'Patron 2 should be charged cf GetReserveFee' ); |
118 |
is( $fee > 0, 1, 'Patron 2 should be charged cf GetReserveFee' ); |
| 110 |
C4::Reserves::ChargeReserveFee( $patron2->borrowernumber, $fee, $biblio->title ); |
119 |
C4::Reserves::ChargeReserveFee( $patron2->borrowernumber, $fee, $biblio->title ); |
| 111 |
is( acctlines( $patron2->borrowernumber ), $acc2 + 1, 'Patron 2 has been charged by ChargeReserveFee' ); |
120 |
is( acctlines( $patron2->borrowernumber ), $acc2 + 1, 'Patron 2 has been charged by ChargeReserveFee' ); |
|
Lines 156-162
subtest 'Integration with AddReserve' => sub {
Link Here
|
| 156 |
}; |
165 |
}; |
| 157 |
|
166 |
|
| 158 |
subtest 'Items are issued' => sub { |
167 |
subtest 'Items are issued' => sub { |
| 159 |
plan tests => 4; |
168 |
plan tests => 7; |
| 160 |
|
169 |
|
| 161 |
$dbh->do( "DELETE FROM issues WHERE itemnumber=?", undef, $item1->itemnumber); |
170 |
$dbh->do( "DELETE FROM issues WHERE itemnumber=?", undef, $item1->itemnumber); |
| 162 |
$dbh->do( "DELETE FROM issues WHERE itemnumber=?", undef, $item2->itemnumber); |
171 |
$dbh->do( "DELETE FROM issues WHERE itemnumber=?", undef, $item2->itemnumber); |
|
Lines 168-178
subtest 'Integration with AddReserve' => sub {
Link Here
|
| 168 |
addreserve( $patron1->borrowernumber ); |
177 |
addreserve( $patron1->borrowernumber ); |
| 169 |
is( acctlines( $patron1->borrowernumber ), 0, 'not_always - Patron should not be charged if items are not all checked out' ); |
178 |
is( acctlines( $patron1->borrowernumber ), 0, 'not_always - Patron should not be charged if items are not all checked out' ); |
| 170 |
|
179 |
|
| 171 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
180 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'issued_or_reserved' ); |
|
|
181 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 182 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 183 |
addreserve( $patron3->borrowernumber ); |
| 184 |
addreserve( $patron1->borrowernumber ); |
| 185 |
is( |
| 186 |
acctlines( $patron1->borrowernumber ), 1, |
| 187 |
'issued_or_reserved - Patron should be charged if all the items are not checked out because 1 hold is placed' |
| 188 |
); |
| 189 |
|
| 190 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); |
| 191 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 172 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
192 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 173 |
addreserve( $patron3->borrowernumber ); |
193 |
addreserve( $patron3->borrowernumber ); |
| 174 |
addreserve( $patron1->borrowernumber ); |
194 |
addreserve( $patron1->borrowernumber ); |
| 175 |
is( acctlines( $patron1->borrowernumber ), 0, 'not_always - Patron should not be charged if all the items are not checked out, even if 1 hold is already placed' ); |
195 |
is( |
|
|
196 |
acctlines( $patron1->borrowernumber ), 0, |
| 197 |
'not_always - Patron should not be charged if all the items are not checked out, even if 1 hold is already placed' |
| 198 |
); |
| 176 |
|
199 |
|
| 177 |
C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ); |
200 |
C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ); |
| 178 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
201 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
|
Lines 180-190
subtest 'Integration with AddReserve' => sub {
Link Here
|
| 180 |
addreserve( $patron1->borrowernumber ); |
203 |
addreserve( $patron1->borrowernumber ); |
| 181 |
is( acctlines( $patron1->borrowernumber ), 0, 'not_always - Patron should not be charged if all items are checked out but no holds are placed' ); |
204 |
is( acctlines( $patron1->borrowernumber ), 0, 'not_always - Patron should not be charged if all items are checked out but no holds are placed' ); |
| 182 |
|
205 |
|
|
|
206 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'issued_or_reserved' ); |
| 207 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 208 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 209 |
addreserve( $patron1->borrowernumber ); |
| 210 |
is( |
| 211 |
acctlines( $patron1->borrowernumber ), 1, |
| 212 |
'issued_or_reserved - Patron should be charged if all items are checked out but no holds are placed' |
| 213 |
); |
| 214 |
|
| 215 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); |
| 183 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
216 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 184 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
217 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 185 |
addreserve( $patron3->borrowernumber ); |
218 |
addreserve( $patron3->borrowernumber ); |
| 186 |
addreserve( $patron1->borrowernumber ); |
219 |
addreserve( $patron1->borrowernumber ); |
| 187 |
is( acctlines( $patron1->borrowernumber ), 1, 'not_always - Patron should only be charged if all items are checked out and at least 1 hold is already placed' ); |
220 |
is( acctlines( $patron1->borrowernumber ), 1, 'not_always - Patron should only be charged if all items are checked out and at least 1 hold is already placed' ); |
|
|
221 |
|
| 222 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'issued_or_reserved' ); |
| 223 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 224 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 225 |
addreserve( $patron3->borrowernumber ); |
| 226 |
addreserve( $patron1->borrowernumber ); |
| 227 |
is( |
| 228 |
acctlines( $patron1->borrowernumber ), 1, |
| 229 |
'issued_or_reserved - Patron should be charged if all items are checked out and at least 1 hold is already placed' |
| 230 |
); |
| 188 |
}; |
231 |
}; |
| 189 |
}; |
232 |
}; |
| 190 |
|
233 |
|
| 191 |
- |
|
|