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