|
Lines 115-135
my $item2 = $builder->build_sample_item(
Link Here
|
| 115 |
); |
115 |
); |
| 116 |
|
116 |
|
| 117 |
subtest 'GetReserveFee' => sub { |
117 |
subtest 'GetReserveFee' => sub { |
| 118 |
plan tests => 6; |
118 |
plan tests => 8; |
| 119 |
|
119 |
|
| 120 |
C4::Circulation::AddIssue( $patron1, $item1->barcode, '2015-12-31', 0, undef, 0, {} ) |
120 |
C4::Circulation::AddIssue( $patron1, $item1->barcode, '2015-12-31', 0, undef, 0, {} ) |
| 121 |
; # the date does not really matter |
121 |
; # the date does not really matter |
| 122 |
C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ) |
122 |
C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ) |
| 123 |
; # the date does not really matter |
123 |
; # the date does not really matter |
| 124 |
my $acc2 = acctlines( $patron2->borrowernumber ); |
124 |
my $acc2 = acctlines( $patron2->borrowernumber ); |
| 125 |
my $res1 = addreserve( $patron1->borrowernumber ); |
|
|
| 126 |
|
125 |
|
| 127 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); |
126 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); |
| 128 |
my $fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
127 |
my $fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
|
|
128 |
is( $fee, 0, 'HoldFeeMode=not_always, Patron 2 should not be charged' ); |
| 129 |
|
| 130 |
my $res1 = addreserve( $patron1->borrowernumber ); |
| 131 |
|
| 132 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'issued_or_reserved' ); |
| 133 |
$fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
| 134 |
is( int($fee), 2, 'HoldFeeMode=issued_or_reserved, Patron 2 should be charged' ); |
| 135 |
C4::Circulation::AddIssue( $patron3, $item2->barcode, '2015-12-31', 0, undef, 0, {} ) |
| 136 |
; # the date does not really matter |
| 137 |
$fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
| 129 |
is( $fee > 0, 1, 'Patron 2 should be charged cf GetReserveFee' ); |
138 |
is( $fee > 0, 1, 'Patron 2 should be charged cf GetReserveFee' ); |
| 130 |
C4::Reserves::ChargeReserveFee( $patron2->borrowernumber, $fee, $biblio->title ); |
139 |
C4::Reserves::ChargeReserveFee( $patron2->borrowernumber, $fee, $biblio->title ); |
| 131 |
is( acctlines( $patron2->borrowernumber ), $acc2 + 1, 'Patron 2 has been charged by ChargeReserveFee' ); |
140 |
is( acctlines( $patron2->borrowernumber ), $acc2 + 1, 'Patron 2 has been charged by ChargeReserveFee' ); |
| 132 |
|
141 |
|
|
|
142 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); |
| 133 |
# If we delete the reserve, there should be no charge |
143 |
# If we delete the reserve, there should be no charge |
| 134 |
$dbh->do( "DELETE FROM reserves WHERE borrowernumber = ?", undef, ( $patron1->borrowernumber ) ); |
144 |
$dbh->do( "DELETE FROM reserves WHERE borrowernumber = ?", undef, ( $patron1->borrowernumber ) ); |
| 135 |
$fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
145 |
$fee = C4::Reserves::GetReserveFee( $patron2->borrowernumber, $biblio->biblionumber ); |
|
Lines 179-185
subtest 'Integration with AddReserve' => sub {
Link Here
|
| 179 |
}; |
189 |
}; |
| 180 |
|
190 |
|
| 181 |
subtest 'Items are issued' => sub { |
191 |
subtest 'Items are issued' => sub { |
| 182 |
plan tests => 4; |
192 |
plan tests => 7; |
| 183 |
|
193 |
|
| 184 |
$dbh->do( "DELETE FROM issues WHERE itemnumber=?", undef, $item1->itemnumber ); |
194 |
$dbh->do( "DELETE FROM issues WHERE itemnumber=?", undef, $item1->itemnumber ); |
| 185 |
$dbh->do( "DELETE FROM issues WHERE itemnumber=?", undef, $item2->itemnumber ); |
195 |
$dbh->do( "DELETE FROM issues WHERE itemnumber=?", undef, $item2->itemnumber ); |
|
Lines 194-199
subtest 'Integration with AddReserve' => sub {
Link Here
|
| 194 |
'not_always - Patron should not be charged if items are not all checked out' |
204 |
'not_always - Patron should not be charged if items are not all checked out' |
| 195 |
); |
205 |
); |
| 196 |
|
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( $patron3->borrowernumber ); |
| 211 |
addreserve( $patron1->borrowernumber ); |
| 212 |
is( |
| 213 |
acctlines( $patron1->borrowernumber ), 1, |
| 214 |
'issued_or_reserved - Patron should be charged if all the items are not checked out because 1 hold is placed' |
| 215 |
); |
| 216 |
|
| 217 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); |
| 197 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
218 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 198 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
219 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 199 |
addreserve( $patron3->borrowernumber ); |
220 |
addreserve( $patron3->borrowernumber ); |
|
Lines 212-217
subtest 'Integration with AddReserve' => sub {
Link Here
|
| 212 |
'not_always - Patron should not be charged if all items are checked out but no holds are placed' |
233 |
'not_always - Patron should not be charged if all items are checked out but no holds are placed' |
| 213 |
); |
234 |
); |
| 214 |
|
235 |
|
|
|
236 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'issued_or_reserved' ); |
| 237 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 238 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 239 |
addreserve( $patron1->borrowernumber ); |
| 240 |
is( |
| 241 |
acctlines( $patron1->borrowernumber ), 1, |
| 242 |
'issued_or_reserved - Patron should be charged if all items are checked out but no holds are placed' |
| 243 |
); |
| 244 |
|
| 245 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'not_always' ); |
| 215 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
246 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 216 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
247 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 217 |
addreserve( $patron3->borrowernumber ); |
248 |
addreserve( $patron3->borrowernumber ); |
|
Lines 219-224
subtest 'Integration with AddReserve' => sub {
Link Here
|
| 219 |
is( |
250 |
is( |
| 220 |
acctlines( $patron1->borrowernumber ), 1, |
251 |
acctlines( $patron1->borrowernumber ), 1, |
| 221 |
'not_always - Patron should only be charged if all items are checked out and at least 1 hold is already placed' |
252 |
'not_always - Patron should only be charged if all items are checked out and at least 1 hold is already placed' |
|
|
253 |
|
| 254 |
t::lib::Mocks::mock_preference( 'HoldFeeMode', 'issued_or_reserved' ); |
| 255 |
$dbh->do( "DELETE FROM reserves WHERE biblionumber=?", undef, $biblio->biblionumber ); |
| 256 |
$dbh->do( "DELETE FROM accountlines WHERE borrowernumber=?", undef, $patron1->borrowernumber ); |
| 257 |
addreserve( $patron3->borrowernumber ); |
| 258 |
addreserve( $patron1->borrowernumber ); |
| 259 |
is( |
| 260 |
acctlines( $patron1->borrowernumber ), 1, |
| 261 |
'issued_or_reserved - Patron should be charged if all items are checked out and at least 1 hold is already placed' |
| 222 |
); |
262 |
); |
| 223 |
}; |
263 |
}; |
| 224 |
}; |
264 |
}; |
| 225 |
- |
|
|