|
Lines 97-115
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 ); |
|
|
| 106 |
|
105 |
|
| 107 |
t::lib::Mocks::mock_preference('HoldFeeMode', 'not_always'); |
106 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); |
| 108 |
my $fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
107 |
my $fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
|
|
108 |
is( $fee, 0, 'HoldFeeMode=not_always, Patron 2 should not be charged' ); |
| 109 |
|
| 110 |
my $res1 = addreserve( $patron1->borrowernumber ); |
| 111 |
|
| 112 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'issued_or_reserved' ); |
| 113 |
$fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
| 114 |
is( int($fee), 2, 'HoldFeeMode=issued_or_reserved, Patron 2 should be charged' ); |
| 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' ); |
| 112 |
|
121 |
|
|
|
122 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); |
| 113 |
# If we delete the reserve, there should be no charge |
123 |
# If we delete the reserve, there should be no charge |
| 114 |
$dbh->do( "DELETE FROM reserves WHERE borrowernumber = ?", undef, ( $patron1->borrowernumber) ); |
124 |
$dbh->do( "DELETE FROM reserves WHERE borrowernumber = ?", undef, ( $patron1->borrowernumber) ); |
| 115 |
$fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
125 |
$fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
|
Lines 156-162
subtest 'Integration with AddReserve' => sub {
Link Here
|
| 156 |
}; |
166 |
}; |
| 157 |
|
167 |
|
| 158 |
subtest 'Items are issued' => sub { |
168 |
subtest 'Items are issued' => sub { |
| 159 |
plan tests => 4; |
169 |
plan tests => 7; |
| 160 |
|
170 |
|
| 161 |
$dbh->do( "DELETE FROM issues WHERE itemnumber=?", undef, $item1->itemnumber); |
171 |
$dbh->do( "DELETE FROM issues WHERE itemnumber=?", undef, $item1->itemnumber); |
| 162 |
$dbh->do( "DELETE FROM issues WHERE itemnumber=?", undef, $item2->itemnumber); |
172 |
$dbh->do( "DELETE FROM issues WHERE itemnumber=?", undef, $item2->itemnumber); |
|
Lines 168-178
subtest 'Integration with AddReserve' => sub {
Link Here
|
| 168 |
addreserve( $patron1->borrowernumber ); |
178 |
addreserve( $patron1->borrowernumber ); |
| 169 |
is( acctlines( $patron1->borrowernumber ), 0, 'not_always - Patron should not be charged if items are not all checked out' ); |
179 |
is( acctlines( $patron1->borrowernumber ), 0, 'not_always - Patron should not be charged if items are not all checked out' ); |
| 170 |
|
180 |
|
| 171 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
181 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'issued_or_reserved' ); |
|
|
182 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 183 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 184 |
addreserve( $patron3->borrowernumber ); |
| 185 |
addreserve( $patron1->borrowernumber ); |
| 186 |
is( |
| 187 |
acctlines( $patron1->borrowernumber ), 1, |
| 188 |
'issued_or_reserved - Patron should be charged if all the items are not checked out because 1 hold is placed' |
| 189 |
); |
| 190 |
|
| 191 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); |
| 192 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 172 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
193 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 173 |
addreserve( $patron3->borrowernumber ); |
194 |
addreserve( $patron3->borrowernumber ); |
| 174 |
addreserve( $patron1->borrowernumber ); |
195 |
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' ); |
196 |
is( |
|
|
197 |
acctlines( $patron1->borrowernumber ), 0, |
| 198 |
'not_always - Patron should not be charged if all the items are not checked out, even if 1 hold is already placed' |
| 199 |
); |
| 176 |
|
200 |
|
| 177 |
C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ); |
201 |
C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ); |
| 178 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
202 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
|
Lines 180-190
subtest 'Integration with AddReserve' => sub {
Link Here
|
| 180 |
addreserve( $patron1->borrowernumber ); |
204 |
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' ); |
205 |
is( acctlines( $patron1->borrowernumber ), 0, 'not_always - Patron should not be charged if all items are checked out but no holds are placed' ); |
| 182 |
|
206 |
|
|
|
207 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'issued_or_reserved' ); |
| 208 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 209 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 210 |
addreserve( $patron1->borrowernumber ); |
| 211 |
is( |
| 212 |
acctlines( $patron1->borrowernumber ), 1, |
| 213 |
'issued_or_reserved - Patron should be charged if all items are checked out but no holds are placed' |
| 214 |
); |
| 215 |
|
| 216 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); |
| 183 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
217 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 184 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
218 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 185 |
addreserve( $patron3->borrowernumber ); |
219 |
addreserve( $patron3->borrowernumber ); |
| 186 |
addreserve( $patron1->borrowernumber ); |
220 |
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' ); |
221 |
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' ); |
|
|
222 |
|
| 223 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'issued_or_reserved' ); |
| 224 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 225 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 226 |
addreserve( $patron3->borrowernumber ); |
| 227 |
addreserve( $patron1->borrowernumber ); |
| 228 |
is( |
| 229 |
acctlines( $patron1->borrowernumber ), 1, |
| 230 |
'issued_or_reserved - Patron should be charged if all items are checked out and at least 1 hold is already placed' |
| 231 |
); |
| 188 |
}; |
232 |
}; |
| 189 |
}; |
233 |
}; |
| 190 |
|
234 |
|
| 191 |
- |
|
|