|
Lines 22-28
use C4::SIP::ILS::Transaction::Hold;
Link Here
|
| 22 |
use C4::SIP::ILS::Transaction::Checkout; |
22 |
use C4::SIP::ILS::Transaction::Checkout; |
| 23 |
use C4::SIP::ILS::Transaction::Checkin; |
23 |
use C4::SIP::ILS::Transaction::Checkin; |
| 24 |
|
24 |
|
| 25 |
use C4::Reserves qw( AddReserve ModReserve ModReserveAffect ); |
25 |
use C4::Reserves qw( AddReserve ModReserve ModReserveAffect ); |
|
|
26 |
use C4::Circulation qw( AddReturn ); |
| 26 |
use Koha::CirculationRules; |
27 |
use Koha::CirculationRules; |
| 27 |
use Koha::Item::Transfer; |
28 |
use Koha::Item::Transfer; |
| 28 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
29 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
|
Lines 1138-1144
subtest do_checkout_with_noblock => sub {
Link Here
|
| 1138 |
}; |
1139 |
}; |
| 1139 |
|
1140 |
|
| 1140 |
subtest do_checkout_with_holds => sub { |
1141 |
subtest do_checkout_with_holds => sub { |
| 1141 |
plan tests => 7; |
1142 |
plan tests => 10; |
| 1142 |
|
1143 |
|
| 1143 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
1144 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
| 1144 |
my $patron = $builder->build_object( |
1145 |
my $patron = $builder->build_object( |
|
Lines 1186-1215
subtest do_checkout_with_holds => sub {
Link Here
|
| 1186 |
$sip_item, "Item assigned to transaction" |
1187 |
$sip_item, "Item assigned to transaction" |
| 1187 |
); |
1188 |
); |
| 1188 |
|
1189 |
|
| 1189 |
# Test attached holds |
1190 |
t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '' ); |
|
|
1191 |
|
| 1192 |
# Test attached holds with no hold statuses allowed to check out |
| 1190 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve ); # Mark waiting (W) |
1193 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve ); # Mark waiting (W) |
| 1191 |
my $hold = Koha::Holds->find($reserve); |
1194 |
my $hold = Koha::Holds->find($reserve); |
| 1192 |
$co_transaction->do_checkout(); |
1195 |
$co_transaction->do_checkout(); |
| 1193 |
is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (W)' ); |
1196 |
is( |
|
|
1197 |
$patron->checkouts->count, 0, |
| 1198 |
'Checkout was not done due to attached hold (W) and AllowItemsOnHoldCheckoutSIP' |
| 1199 |
); |
| 1194 |
|
1200 |
|
| 1195 |
$hold->set_transfer; |
1201 |
$hold->set_transfer; |
| 1196 |
$co_transaction->do_checkout(); |
1202 |
$co_transaction->do_checkout(); |
| 1197 |
is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (T)' ); |
1203 |
is( |
|
|
1204 |
$patron->checkouts->count, 0, |
| 1205 |
'Checkout was not done due to attached hold (T) and AllowItemsOnHoldCheckoutSIP' |
| 1206 |
); |
| 1198 |
|
1207 |
|
| 1199 |
$hold->set_processing; |
1208 |
$hold->set_processing; |
| 1200 |
$co_transaction->do_checkout(); |
1209 |
$co_transaction->do_checkout(); |
| 1201 |
is( $patron->checkouts->count, 0, 'Checkout was not done due to attached hold (P)' ); |
1210 |
is( |
|
|
1211 |
$patron->checkouts->count, 0, |
| 1212 |
'Checkout was not done due to attached hold (P) and AllowItemsOnHoldCheckoutSIP' |
| 1213 |
); |
| 1202 |
|
1214 |
|
| 1203 |
# Test non-attached holds |
1215 |
# Test non-attached holds |
| 1204 |
$hold->set_waiting(); |
|
|
| 1205 |
$hold->revert_found(); |
1216 |
$hold->revert_found(); |
| 1206 |
t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '0' ); |
1217 |
|
| 1207 |
$co_transaction->do_checkout(); |
1218 |
$co_transaction->do_checkout(); |
| 1208 |
is( $patron->checkouts->count, 0, 'Checkout refused due to hold and AllowItemsOnHoldCheckoutSIP' ); |
1219 |
is( |
|
|
1220 |
$patron->checkouts->count, 0, |
| 1221 |
'Checkout with non-attached hold refused due to hold and AllowItemsOnHoldCheckoutSIP' |
| 1222 |
); |
| 1223 |
|
| 1224 |
t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', 'pending,processing,transferred,waiting' ); |
| 1209 |
|
1225 |
|
| 1210 |
t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckoutSIP', '1' ); |
|
|
| 1211 |
$co_transaction->do_checkout(); |
1226 |
$co_transaction->do_checkout(); |
| 1212 |
is( $patron->checkouts->count, 1, 'Checkout allowed due to hold and AllowItemsOnHoldCheckoutSIP' ); |
1227 |
is( |
|
|
1228 |
$patron->checkouts->count, 1, |
| 1229 |
'Checkout with non-attached hold allowed due to hold and AllowItemsOnHoldCheckoutSIP' |
| 1230 |
); |
| 1231 |
|
| 1232 |
# Test attached holds with all hold statuses allowed to check out |
| 1233 |
AddReturn( $item->barcode, $library->branchcode ); |
| 1234 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 0, $reserve ); # Mark waiting (W) |
| 1235 |
$co_transaction->do_checkout(); |
| 1236 |
is( $patron->checkouts->count, 1, 'Checkout allowed with attached hold (W) due to AllowItemsOnHoldCheckoutSIP' ); |
| 1237 |
|
| 1238 |
AddReturn( $item->barcode, $library->branchcode ); |
| 1239 |
$hold->set_transfer; |
| 1240 |
$co_transaction->do_checkout(); |
| 1241 |
is( $patron->checkouts->count, 1, 'Checkout allowed with attached hold (T) due to AllowItemsOnHoldCheckoutSIP' ); |
| 1242 |
|
| 1243 |
AddReturn( $item->barcode, $library->branchcode ); |
| 1244 |
$hold->set_processing; |
| 1245 |
$co_transaction->do_checkout(); |
| 1246 |
is( $patron->checkouts->count, 1, 'Checkout allowed with attached hold (P) due to AllowItemsOnHoldCheckoutSIP' ); |
| 1213 |
}; |
1247 |
}; |
| 1214 |
|
1248 |
|
| 1215 |
subtest checkin_lost => sub { |
1249 |
subtest checkin_lost => sub { |
| 1216 |
- |
|
|