Lines 63-70
subtest 'Basic object tests' => sub {
Link Here
|
63 |
); |
63 |
); |
64 |
|
64 |
|
65 |
# Relationship to rota |
65 |
# Relationship to rota |
66 |
isa_ok( $sritem->itemnumber, 'Koha::Item', "Fetched related item." ); |
66 |
isa_ok( $sritem->item, 'Koha::Item', "Fetched related item." ); |
67 |
is( $sritem->itemnumber->itemnumber, $itm->itemnumber, "Related rota OK." ); |
67 |
is( $sritem->item->itemnumber, $itm->itemnumber, "Related rota OK." ); |
68 |
|
68 |
|
69 |
# Relationship to stage |
69 |
# Relationship to stage |
70 |
isa_ok( $sritem->stage, 'Koha::StockRotationStage', "Fetched related stage." ); |
70 |
isa_ok( $sritem->stage, 'Koha::StockRotationStage', "Fetched related stage." ); |
Lines 89-96
subtest 'Tests for needs_repatriating' => sub {
Link Here
|
89 |
} |
89 |
} |
90 |
); |
90 |
); |
91 |
my $dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id}); |
91 |
my $dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id}); |
92 |
$dbitem->itemnumber->homebranch($dbitem->stage->branchcode_id); |
92 |
$dbitem->item->homebranch($dbitem->stage->branchcode_id); |
93 |
$dbitem->itemnumber->holdingbranch($dbitem->stage->branchcode_id); |
93 |
$dbitem->item->holdingbranch($dbitem->stage->branchcode_id); |
94 |
$dbitem->stage->position(1); |
94 |
$dbitem->stage->position(1); |
95 |
|
95 |
|
96 |
my $dbrota = $dbitem->stage->rota; |
96 |
my $dbrota = $dbitem->stage->rota; |
Lines 109-115
subtest 'Tests for needs_repatriating' => sub {
Link Here
|
109 |
); |
109 |
); |
110 |
|
110 |
|
111 |
my $branch = $builder->build({ source => 'Branch' }); |
111 |
my $branch = $builder->build({ source => 'Branch' }); |
112 |
$dbitem->itemnumber->holdingbranch($branch->{branchcode}); |
112 |
$dbitem->item->holdingbranch($branch->{branchcode}); |
113 |
|
113 |
|
114 |
# - homebranch != holdingbranch [1] |
114 |
# - homebranch != holdingbranch [1] |
115 |
is( |
115 |
is( |
Lines 118-125
subtest 'Tests for needs_repatriating' => sub {
Link Here
|
118 |
); |
118 |
); |
119 |
|
119 |
|
120 |
# Set to incorrect homebranch. |
120 |
# Set to incorrect homebranch. |
121 |
$dbitem->itemnumber->holdingbranch($dbitem->stage->branchcode_id); |
121 |
$dbitem->item->holdingbranch($dbitem->stage->branchcode_id); |
122 |
$dbitem->itemnumber->homebranch($branch->{branchcode}); |
122 |
$dbitem->item->homebranch($branch->{branchcode}); |
123 |
# - homebranch != stockrotationstage.branch & not in transit [1] |
123 |
# - homebranch != stockrotationstage.branch & not in transit [1] |
124 |
is( |
124 |
is( |
125 |
$dbitem->needs_repatriating, 1, |
125 |
$dbitem->needs_repatriating, 1, |
Lines 149-171
subtest "Tests for repatriate." => sub {
Link Here
|
149 |
} |
149 |
} |
150 |
} |
150 |
} |
151 |
); |
151 |
); |
152 |
my $item_id = $sritem_1->itemnumber->itemnumber; |
152 |
my $item_id = $sritem_1->item->itemnumber; |
153 |
my $srstage_1 = $sritem_1->stage; |
153 |
my $srstage_1 = $sritem_1->stage; |
154 |
$sritem_1->discard_changes; |
154 |
$sritem_1->discard_changes; |
155 |
$sritem_1->stage->position(1); |
155 |
$sritem_1->stage->position(1); |
156 |
$sritem_1->stage->duration(50); |
156 |
$sritem_1->stage->duration(50); |
157 |
my $branch = $builder->build({ source => 'Branch' }); |
157 |
my $branch = $builder->build({ source => 'Branch' }); |
158 |
$sritem_1->itemnumber->holdingbranch($branch->{branchcode}); |
158 |
$sritem_1->item->holdingbranch($branch->{branchcode}); |
159 |
|
159 |
|
160 |
# Test a straight up repatriate |
160 |
# Test a straight up repatriate |
161 |
ok($sritem_1->repatriate, "Repatriation done."); |
161 |
ok($sritem_1->repatriate, "Repatriation done."); |
162 |
my $intransfer = $sritem_1->itemnumber->get_transfer; |
162 |
my $intransfer = $sritem_1->item->get_transfer; |
163 |
is($intransfer->frombranch, $branch->{branchcode}, "Origin correct."); |
163 |
is($intransfer->frombranch, $branch->{branchcode}, "Origin correct."); |
164 |
is($intransfer->tobranch, $sritem_1->stage->branchcode_id, "Target Correct."); |
164 |
is($intransfer->tobranch, $sritem_1->stage->branchcode_id, "Target Correct."); |
165 |
|
165 |
|
166 |
# Reset |
166 |
# Reset |
167 |
$intransfer->datearrived(dt_from_string())->store; |
167 |
$intransfer->datearrived(dt_from_string())->store; |
168 |
$sritem_1->itemnumber->holdingbranch($branch->{branchcode}); |
168 |
$sritem_1->item->holdingbranch($branch->{branchcode}); |
169 |
|
169 |
|
170 |
# Setup a conflicting manual transfer |
170 |
# Setup a conflicting manual transfer |
171 |
my $item = Koha::Items->find($item_id); |
171 |
my $item = Koha::Items->find($item_id); |
Lines 179-185
subtest "Tests for repatriate." => sub {
Link Here
|
179 |
|
179 |
|
180 |
# Reset |
180 |
# Reset |
181 |
$intransfer->datearrived(dt_from_string())->store; |
181 |
$intransfer->datearrived(dt_from_string())->store; |
182 |
$sritem_1->itemnumber->holdingbranch($branch->{branchcode}); |
182 |
$sritem_1->item->holdingbranch($branch->{branchcode}); |
183 |
|
183 |
|
184 |
# Confirm that stockrotation ignores transfer limits |
184 |
# Confirm that stockrotation ignores transfer limits |
185 |
t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1); |
185 |
t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1); |
Lines 188-200
subtest "Tests for repatriate." => sub {
Link Here
|
188 |
{ |
188 |
{ |
189 |
fromBranch => $branch->{branchcode}, |
189 |
fromBranch => $branch->{branchcode}, |
190 |
toBranch => $srstage_1->branchcode_id, |
190 |
toBranch => $srstage_1->branchcode_id, |
191 |
itemtype => $sritem_1->itemnumber->effective_itemtype, |
191 |
itemtype => $sritem_1->item->effective_itemtype, |
192 |
} |
192 |
} |
193 |
)->store; |
193 |
)->store; |
194 |
|
194 |
|
195 |
# Stockrotation should overrule transfer limits |
195 |
# Stockrotation should overrule transfer limits |
196 |
ok($sritem_1->repatriate, "Repatriation done regardless of transfer limits."); |
196 |
ok($sritem_1->repatriate, "Repatriation done regardless of transfer limits."); |
197 |
$intransfer = $sritem_1->itemnumber->get_transfer; |
197 |
$intransfer = $sritem_1->item->get_transfer; |
198 |
is($intransfer->frombranch, $branch->{branchcode}, "Origin correct."); |
198 |
is($intransfer->frombranch, $branch->{branchcode}, "Origin correct."); |
199 |
is($intransfer->tobranch, $sritem_1->stage->branchcode_id, "Target Correct."); |
199 |
is($intransfer->tobranch, $sritem_1->stage->branchcode_id, "Target Correct."); |
200 |
|
200 |
|
Lines 229-236
subtest "Tests for needs_advancing." => sub {
Link Here
|
229 |
} |
229 |
} |
230 |
); |
230 |
); |
231 |
$dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id}); |
231 |
$dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id}); |
232 |
$dbitem->itemnumber->homebranch($dbitem->stage->branchcode_id); |
232 |
$dbitem->item->homebranch($dbitem->stage->branchcode_id); |
233 |
$dbitem->itemnumber->holdingbranch($dbitem->stage->branchcode_id); |
233 |
$dbitem->item->holdingbranch($dbitem->stage->branchcode_id); |
234 |
$dbitem->stage->position(1); |
234 |
$dbitem->stage->position(1); |
235 |
$dbitem->stage->duration(50); |
235 |
$dbitem->stage->duration(50); |
236 |
|
236 |
|
Lines 267-273
subtest "Tests for needs_advancing." => sub {
Link Here
|
267 |
)->store; |
267 |
)->store; |
268 |
is($dbitem->needs_advancing, 1, "Ready to be advanced."); |
268 |
is($dbitem->needs_advancing, 1, "Ready to be advanced."); |
269 |
$dbtransfer->delete; |
269 |
$dbtransfer->delete; |
270 |
warning_is {$dbitem->needs_advancing} "We have no historical branch transfer for itemnumber " . $dbitem->itemnumber->itemnumber . "; This should not have happened!", "Missing transfer is warned."; |
270 |
warning_is {$dbitem->needs_advancing} "We have no historical branch transfer for itemnumber " . $dbitem->item->itemnumber . "; This should not have happened!", "Missing transfer is warned."; |
271 |
|
271 |
|
272 |
$schema->storage->txn_rollback; |
272 |
$schema->storage->txn_rollback; |
273 |
}; |
273 |
}; |
Lines 286-298
subtest "Tests for advance." => sub {
Link Here
|
286 |
} |
286 |
} |
287 |
); |
287 |
); |
288 |
$sritem_1->discard_changes; |
288 |
$sritem_1->discard_changes; |
289 |
$sritem_1->itemnumber->holdingbranch($sritem_1->stage->branchcode_id); |
289 |
$sritem_1->item->holdingbranch($sritem_1->stage->branchcode_id); |
290 |
my $item_id = $sritem_1->itemnumber->itemnumber; |
290 |
my $item_id = $sritem_1->item->itemnumber; |
291 |
my $srstage_1 = $sritem_1->stage; |
291 |
my $srstage_1 = $sritem_1->stage; |
292 |
$srstage_1->position(1)->duration(50)->store; # Configure stage. |
292 |
$srstage_1->position(1)->duration(50)->store; # Configure stage. |
293 |
# Configure item |
293 |
# Configure item |
294 |
$sritem_1->itemnumber->holdingbranch($srstage_1->branchcode_id)->store; |
294 |
$sritem_1->item->holdingbranch($srstage_1->branchcode_id)->store; |
295 |
$sritem_1->itemnumber->homebranch($srstage_1->branchcode_id)->store; |
295 |
$sritem_1->item->homebranch($srstage_1->branchcode_id)->store; |
296 |
# Sanity check |
296 |
# Sanity check |
297 |
is($sritem_1->stage->stage_id, $srstage_1->stage_id, "Stage sanity check."); |
297 |
is($sritem_1->stage->stage_id, $srstage_1->stage_id, "Stage sanity check."); |
298 |
|
298 |
|
Lines 333-350
subtest "Tests for advance." => sub {
Link Here
|
333 |
## Test results |
333 |
## Test results |
334 |
is($sritem_1->stage->stage_id, $srstage_2->stage_id, "Stage updated."); |
334 |
is($sritem_1->stage->stage_id, $srstage_2->stage_id, "Stage updated."); |
335 |
is( |
335 |
is( |
336 |
$sritem_1->itemnumber->homebranch, |
336 |
$sritem_1->item->homebranch, |
337 |
$srstage_2->branchcode_id, |
337 |
$srstage_2->branchcode_id, |
338 |
"Item homebranch updated" |
338 |
"Item homebranch updated" |
339 |
); |
339 |
); |
340 |
my $transfer_request = $sritem_1->itemnumber->get_transfer; |
340 |
my $transfer_request = $sritem_1->item->get_transfer; |
341 |
is($transfer_request->frombranch, $srstage_1->branchcode_id, "Origin correct."); |
341 |
is($transfer_request->frombranch, $srstage_1->branchcode_id, "Origin correct."); |
342 |
is($transfer_request->tobranch, $srstage_2->branchcode_id, "Target Correct."); |
342 |
is($transfer_request->tobranch, $srstage_2->branchcode_id, "Target Correct."); |
343 |
is($transfer_request->datesent, undef, "Transfer requested, but not sent."); |
343 |
is($transfer_request->datesent, undef, "Transfer requested, but not sent."); |
344 |
|
344 |
|
345 |
# Arrive at new branch |
345 |
# Arrive at new branch |
346 |
$transfer_request->datearrived(dt_from_string())->store; |
346 |
$transfer_request->datearrived(dt_from_string())->store; |
347 |
$sritem_1->itemnumber->holdingbranch($srstage_2->branchcode_id)->store; |
347 |
$sritem_1->item->holdingbranch($srstage_2->branchcode_id)->store; |
348 |
|
348 |
|
349 |
# Test a cyclical advance |
349 |
# Test a cyclical advance |
350 |
ok($sritem_1->advance, "Cyclical advancement done."); |
350 |
ok($sritem_1->advance, "Cyclical advancement done."); |
Lines 353-369
subtest "Tests for advance." => sub {
Link Here
|
353 |
## Test results |
353 |
## Test results |
354 |
is($sritem_1->stage->stage_id, $srstage_1->stage_id, "Stage updated."); |
354 |
is($sritem_1->stage->stage_id, $srstage_1->stage_id, "Stage updated."); |
355 |
is( |
355 |
is( |
356 |
$sritem_1->itemnumber->homebranch, |
356 |
$sritem_1->item->homebranch, |
357 |
$srstage_1->branchcode_id, |
357 |
$srstage_1->branchcode_id, |
358 |
"Item homebranch updated" |
358 |
"Item homebranch updated" |
359 |
); |
359 |
); |
360 |
$transfer_request = $sritem_1->itemnumber->get_transfer; |
360 |
$transfer_request = $sritem_1->item->get_transfer; |
361 |
is($transfer_request->frombranch, $srstage_2->branchcode_id, "Origin correct."); |
361 |
is($transfer_request->frombranch, $srstage_2->branchcode_id, "Origin correct."); |
362 |
is($transfer_request->tobranch, $srstage_1->branchcode_id, "Target correct."); |
362 |
is($transfer_request->tobranch, $srstage_1->branchcode_id, "Target correct."); |
363 |
|
363 |
|
364 |
# Arrive at new branch |
364 |
# Arrive at new branch |
365 |
$transfer_request->datearrived(dt_from_string())->store; |
365 |
$transfer_request->datearrived(dt_from_string())->store; |
366 |
$sritem_1->itemnumber->holdingbranch($srstage_1->branchcode_id)->store; |
366 |
$sritem_1->item->holdingbranch($srstage_1->branchcode_id)->store; |
367 |
|
367 |
|
368 |
# Confirm that stockrotation ignores transfer limits |
368 |
# Confirm that stockrotation ignores transfer limits |
369 |
t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1); |
369 |
t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1); |
Lines 372-378
subtest "Tests for advance." => sub {
Link Here
|
372 |
{ |
372 |
{ |
373 |
fromBranch => $srstage_1->branchcode_id, |
373 |
fromBranch => $srstage_1->branchcode_id, |
374 |
toBranch => $srstage_2->branchcode_id, |
374 |
toBranch => $srstage_2->branchcode_id, |
375 |
itemtype => $sritem_1->itemnumber->effective_itemtype, |
375 |
itemtype => $sritem_1->item->effective_itemtype, |
376 |
} |
376 |
} |
377 |
)->store; |
377 |
)->store; |
378 |
|
378 |
|
Lines 382-398
subtest "Tests for advance." => sub {
Link Here
|
382 |
## Test results |
382 |
## Test results |
383 |
is($sritem_1->stage->stage_id, $srstage_2->stage_id, "Stage updated ignoring transfer limits."); |
383 |
is($sritem_1->stage->stage_id, $srstage_2->stage_id, "Stage updated ignoring transfer limits."); |
384 |
is( |
384 |
is( |
385 |
$sritem_1->itemnumber->homebranch, |
385 |
$sritem_1->item->homebranch, |
386 |
$srstage_2->branchcode_id, |
386 |
$srstage_2->branchcode_id, |
387 |
"Item homebranch updated ignoring transfer limits" |
387 |
"Item homebranch updated ignoring transfer limits" |
388 |
); |
388 |
); |
389 |
$transfer_request = $sritem_1->itemnumber->get_transfer; |
389 |
$transfer_request = $sritem_1->item->get_transfer; |
390 |
is($transfer_request->frombranch, $srstage_1->branchcode_id, "Origin correct ignoring transfer limits."); |
390 |
is($transfer_request->frombranch, $srstage_1->branchcode_id, "Origin correct ignoring transfer limits."); |
391 |
is($transfer_request->tobranch, $srstage_2->branchcode_id, "Target correct ignoring transfer limits."); |
391 |
is($transfer_request->tobranch, $srstage_2->branchcode_id, "Target correct ignoring transfer limits."); |
392 |
|
392 |
|
393 |
# Arrive at new branch |
393 |
# Arrive at new branch |
394 |
$transfer_request->datearrived(dt_from_string())->store; |
394 |
$transfer_request->datearrived(dt_from_string())->store; |
395 |
$sritem_1->itemnumber->holdingbranch($srstage_2->branchcode_id)->store; |
395 |
$sritem_1->item->holdingbranch($srstage_2->branchcode_id)->store; |
396 |
|
396 |
|
397 |
# Setup a conflicting manual transfer |
397 |
# Setup a conflicting manual transfer |
398 |
my $item = Koha::Items->find($item_id); |
398 |
my $item = Koha::Items->find($item_id); |
Lines 413-426
subtest "Tests for advance." => sub {
Link Here
|
413 |
isnt($transfer_request->datecancelled, undef, "Conflicting manual transfer was cancelled"); |
413 |
isnt($transfer_request->datecancelled, undef, "Conflicting manual transfer was cancelled"); |
414 |
|
414 |
|
415 |
# StockRotationAdvance transfer added |
415 |
# StockRotationAdvance transfer added |
416 |
$transfer_request = $sritem_1->itemnumber->get_transfer; |
416 |
$transfer_request = $sritem_1->item->get_transfer; |
417 |
is($transfer_request->reason, 'StockrotationAdvance', "StockrotationAdvance transfer added"); |
417 |
is($transfer_request->reason, 'StockrotationAdvance', "StockrotationAdvance transfer added"); |
418 |
is($transfer_request->frombranch, $srstage_2->branchcode_id, "Origin correct."); |
418 |
is($transfer_request->frombranch, $srstage_2->branchcode_id, "Origin correct."); |
419 |
is($transfer_request->tobranch, $srstage_1->branchcode_id, "Target correct."); |
419 |
is($transfer_request->tobranch, $srstage_1->branchcode_id, "Target correct."); |
420 |
|
420 |
|
421 |
# Arrive at new branch |
421 |
# Arrive at new branch |
422 |
$transfer_request->datearrived(dt_from_string())->store; |
422 |
$transfer_request->datearrived(dt_from_string())->store; |
423 |
$sritem_1->itemnumber->holdingbranch($srstage_1->branchcode_id)->store; |
423 |
$sritem_1->item->holdingbranch($srstage_1->branchcode_id)->store; |
424 |
|
424 |
|
425 |
# Setup a conflicting reserve transfer |
425 |
# Setup a conflicting reserve transfer |
426 |
$item->request_transfer({ to => $srstage_2->branchcode, reason => "Reserve" }); |
426 |
$item->request_transfer({ to => $srstage_2->branchcode, reason => "Reserve" }); |
Lines 442-448
subtest "Tests for advance." => sub {
Link Here
|
442 |
# StockRotationAdvance transfer added |
442 |
# StockRotationAdvance transfer added |
443 |
my $transfer_requests = Koha::Item::Transfers->search( |
443 |
my $transfer_requests = Koha::Item::Transfers->search( |
444 |
{ |
444 |
{ |
445 |
itemnumber => $sritem_1->itemnumber->itemnumber, |
445 |
itemnumber => $sritem_1->item->itemnumber, |
446 |
datearrived => undef, |
446 |
datearrived => undef, |
447 |
datecancelled => undef |
447 |
datecancelled => undef |
448 |
} |
448 |
} |
Lines 451-467
subtest "Tests for advance." => sub {
Link Here
|
451 |
|
451 |
|
452 |
# Arrive at new branch |
452 |
# Arrive at new branch |
453 |
$transfer_request->datearrived(dt_from_string())->store; |
453 |
$transfer_request->datearrived(dt_from_string())->store; |
454 |
$sritem_1->itemnumber->holdingbranch($srstage_2->branchcode_id)->store; |
454 |
$sritem_1->item->holdingbranch($srstage_2->branchcode_id)->store; |
455 |
|
455 |
|
456 |
# StockRotationAdvance transfer added |
456 |
# StockRotationAdvance transfer added |
457 |
$transfer_request = $sritem_1->itemnumber->get_transfer; |
457 |
$transfer_request = $sritem_1->item->get_transfer; |
458 |
is($transfer_request->reason, 'StockrotationAdvance', "StockrotationAdvance transfer remains after reserve is met"); |
458 |
is($transfer_request->reason, 'StockrotationAdvance', "StockrotationAdvance transfer remains after reserve is met"); |
459 |
is($transfer_request->frombranch, $srstage_1->branchcode_id, "Origin correct."); |
459 |
is($transfer_request->frombranch, $srstage_1->branchcode_id, "Origin correct."); |
460 |
is($transfer_request->tobranch, $srstage_2->branchcode_id, "Target correct."); |
460 |
is($transfer_request->tobranch, $srstage_2->branchcode_id, "Target correct."); |
461 |
|
461 |
|
462 |
# Arrive at new branch |
462 |
# Arrive at new branch |
463 |
$transfer_request->datearrived(dt_from_string())->store; |
463 |
$transfer_request->datearrived(dt_from_string())->store; |
464 |
$sritem_1->itemnumber->holdingbranch($srstage_2->branchcode_id)->store; |
464 |
$sritem_1->item->holdingbranch($srstage_2->branchcode_id)->store; |
465 |
|
465 |
|
466 |
$srstage_1->rota->cyclical(0)->store; # Set Rota to non-cyclical. |
466 |
$srstage_1->rota->cyclical(0)->store; # Set Rota to non-cyclical. |
467 |
|
467 |
|
Lines 478-484
subtest "Tests for advance." => sub {
Link Here
|
478 |
|
478 |
|
479 |
# Arrive at new branch |
479 |
# Arrive at new branch |
480 |
$transfer_request->datearrived(dt_from_string())->store; |
480 |
$transfer_request->datearrived(dt_from_string())->store; |
481 |
$sritem_1->itemnumber->holdingbranch($srstage_3->branchcode_id)->store; |
481 |
$sritem_1->item->holdingbranch($srstage_3->branchcode_id)->store; |
482 |
|
482 |
|
483 |
# Advance again, Remove from rota. |
483 |
# Advance again, Remove from rota. |
484 |
ok($sritem_1->advance, "Non-cyclical advance."); |
484 |
ok($sritem_1->advance, "Non-cyclical advance."); |
Lines 519-526
subtest "Tests for investigate (singular)." => sub {
Link Here
|
519 |
} |
519 |
} |
520 |
); |
520 |
); |
521 |
$dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id}); |
521 |
$dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id}); |
522 |
$dbitem->itemnumber->homebranch($dbitem->stage->branchcode_id)->store; |
522 |
$dbitem->item->homebranch($dbitem->stage->branchcode_id)->store; |
523 |
$dbitem->itemnumber->holdingbranch($dbitem->stage->branchcode_id)->store; |
523 |
$dbitem->item->holdingbranch($dbitem->stage->branchcode_id)->store; |
524 |
is($dbitem->investigate->{reason}, 'initiation', "fresh item at stagebranch initiates."); |
524 |
is($dbitem->investigate->{reason}, 'initiation', "fresh item at stagebranch initiates."); |
525 |
|
525 |
|
526 |
# Test item not at stagebranch with branchtransfer history ['repatriation'] |
526 |
# Test item not at stagebranch with branchtransfer history ['repatriation'] |
Lines 536-543
subtest "Tests for investigate (singular)." => sub {
Link Here
|
536 |
$dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id}); |
536 |
$dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id}); |
537 |
my $dbtransfer = Koha::Item::Transfer->new({ |
537 |
my $dbtransfer = Koha::Item::Transfer->new({ |
538 |
'itemnumber' => $dbitem->itemnumber_id, |
538 |
'itemnumber' => $dbitem->itemnumber_id, |
539 |
'frombranch' => $dbitem->itemnumber->homebranch, |
539 |
'frombranch' => $dbitem->item->homebranch, |
540 |
'tobranch' => $dbitem->itemnumber->homebranch, |
540 |
'tobranch' => $dbitem->item->homebranch, |
541 |
'datesent' => dt_from_string(), |
541 |
'datesent' => dt_from_string(), |
542 |
'datearrived' => dt_from_string(), |
542 |
'datearrived' => dt_from_string(), |
543 |
'reason' => "StockrotationAdvance", |
543 |
'reason' => "StockrotationAdvance", |
Lines 557-570
subtest "Tests for investigate (singular)." => sub {
Link Here
|
557 |
$dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id}); |
557 |
$dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id}); |
558 |
$dbtransfer = Koha::Item::Transfer->new({ |
558 |
$dbtransfer = Koha::Item::Transfer->new({ |
559 |
'itemnumber' => $dbitem->itemnumber_id, |
559 |
'itemnumber' => $dbitem->itemnumber_id, |
560 |
'frombranch' => $dbitem->itemnumber->homebranch, |
560 |
'frombranch' => $dbitem->item->homebranch, |
561 |
'tobranch' => $dbitem->stage->branchcode_id, |
561 |
'tobranch' => $dbitem->stage->branchcode_id, |
562 |
'datesent' => dt_from_string(), |
562 |
'datesent' => dt_from_string(), |
563 |
'datearrived' => dt_from_string(), |
563 |
'datearrived' => dt_from_string(), |
564 |
'reason' => "StockrotationAdvance", |
564 |
'reason' => "StockrotationAdvance", |
565 |
})->store; |
565 |
})->store; |
566 |
$dbitem->itemnumber->homebranch($dbitem->stage->branchcode_id)->store; |
566 |
$dbitem->item->homebranch($dbitem->stage->branchcode_id)->store; |
567 |
$dbitem->itemnumber->holdingbranch($dbitem->stage->branchcode_id)->store; |
567 |
$dbitem->item->holdingbranch($dbitem->stage->branchcode_id)->store; |
568 |
is($dbitem->investigate->{reason}, 'not-ready', "older item at stagebranch not-ready."); |
568 |
is($dbitem->investigate->{reason}, 'not-ready', "older item at stagebranch not-ready."); |
569 |
|
569 |
|
570 |
# Test item due for advancement ['advancement'] |
570 |
# Test item due for advancement ['advancement'] |
Lines 584-597
subtest "Tests for investigate (singular)." => sub {
Link Here
|
584 |
my $arrived_duration = DateTime::Duration->new( days => 52); |
584 |
my $arrived_duration = DateTime::Duration->new( days => 52); |
585 |
$dbtransfer = Koha::Item::Transfer->new({ |
585 |
$dbtransfer = Koha::Item::Transfer->new({ |
586 |
'itemnumber' => $dbitem->itemnumber_id, |
586 |
'itemnumber' => $dbitem->itemnumber_id, |
587 |
'frombranch' => $dbitem->itemnumber->homebranch, |
587 |
'frombranch' => $dbitem->item->homebranch, |
588 |
'tobranch' => $dbitem->stage->branchcode_id, |
588 |
'tobranch' => $dbitem->stage->branchcode_id, |
589 |
'datesent' => dt_from_string() - $sent_duration, |
589 |
'datesent' => dt_from_string() - $sent_duration, |
590 |
'datearrived' => dt_from_string() - $arrived_duration, |
590 |
'datearrived' => dt_from_string() - $arrived_duration, |
591 |
'reason' => "StockrotationAdvance", |
591 |
'reason' => "StockrotationAdvance", |
592 |
})->store; |
592 |
})->store; |
593 |
$dbitem->itemnumber->homebranch($dbitem->stage->branchcode_id)->store; |
593 |
$dbitem->item->homebranch($dbitem->stage->branchcode_id)->store; |
594 |
$dbitem->itemnumber->holdingbranch($dbitem->stage->branchcode_id)->store; |
594 |
$dbitem->item->holdingbranch($dbitem->stage->branchcode_id)->store; |
595 |
is($dbitem->investigate->{reason}, 'advancement', |
595 |
is($dbitem->investigate->{reason}, 'advancement', |
596 |
"Item ready for advancement."); |
596 |
"Item ready for advancement."); |
597 |
|
597 |
|
Lines 612-625
subtest "Tests for investigate (singular)." => sub {
Link Here
|
612 |
$arrived_duration = DateTime::Duration->new( days => 52); |
612 |
$arrived_duration = DateTime::Duration->new( days => 52); |
613 |
$dbtransfer = Koha::Item::Transfer->new({ |
613 |
$dbtransfer = Koha::Item::Transfer->new({ |
614 |
'itemnumber' => $dbitem->itemnumber_id, |
614 |
'itemnumber' => $dbitem->itemnumber_id, |
615 |
'frombranch' => $dbitem->itemnumber->homebranch, |
615 |
'frombranch' => $dbitem->item->homebranch, |
616 |
'tobranch' => $dbitem->stage->branchcode_id, |
616 |
'tobranch' => $dbitem->stage->branchcode_id, |
617 |
'datesent' => dt_from_string() - $sent_duration, |
617 |
'datesent' => dt_from_string() - $sent_duration, |
618 |
'datearrived' => dt_from_string() - $arrived_duration, |
618 |
'datearrived' => dt_from_string() - $arrived_duration, |
619 |
'reason' => "StockrotationAdvance", |
619 |
'reason' => "StockrotationAdvance", |
620 |
})->store; |
620 |
})->store; |
621 |
$dbitem->itemnumber->homebranch($dbitem->stage->branchcode_id)->store; |
621 |
$dbitem->item->homebranch($dbitem->stage->branchcode_id)->store; |
622 |
$dbitem->itemnumber->holdingbranch($dbitem->stage->branchcode_id)->store; |
622 |
$dbitem->item->holdingbranch($dbitem->stage->branchcode_id)->store; |
623 |
is($dbitem->investigate->{reason}, 'in-demand', |
623 |
is($dbitem->investigate->{reason}, 'in-demand', |
624 |
"Item advances, but in-demand."); |
624 |
"Item advances, but in-demand."); |
625 |
|
625 |
|
Lines 640-646
subtest "Tests for investigate (singular)." => sub {
Link Here
|
640 |
$arrived_duration = DateTime::Duration->new( days => 52); |
640 |
$arrived_duration = DateTime::Duration->new( days => 52); |
641 |
$dbtransfer = Koha::Item::Transfer->new({ |
641 |
$dbtransfer = Koha::Item::Transfer->new({ |
642 |
'itemnumber' => $dbitem->itemnumber_id, |
642 |
'itemnumber' => $dbitem->itemnumber_id, |
643 |
'frombranch' => $dbitem->itemnumber->homebranch, |
643 |
'frombranch' => $dbitem->item->homebranch, |
644 |
'tobranch' => $dbitem->stage->branchcode_id, |
644 |
'tobranch' => $dbitem->stage->branchcode_id, |
645 |
'datesent' => dt_from_string() - $sent_duration, |
645 |
'datesent' => dt_from_string() - $sent_duration, |
646 |
'datearrived' => dt_from_string() - $arrived_duration, |
646 |
'datearrived' => dt_from_string() - $arrived_duration, |
Lines 662-673
subtest "Tests for toggle_indemand" => sub {
Link Here
|
662 |
}); |
662 |
}); |
663 |
my $dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id}); |
663 |
my $dbitem = Koha::StockRotationItems->find($sritem->{itemnumber_id}); |
664 |
my $firstbranch = $dbitem->stage->branchcode_id; |
664 |
my $firstbranch = $dbitem->stage->branchcode_id; |
665 |
$dbitem->itemnumber->holdingbranch($firstbranch)->store; |
665 |
$dbitem->item->holdingbranch($firstbranch)->store; |
666 |
my $dbstage = $dbitem->stage; |
666 |
my $dbstage = $dbitem->stage; |
667 |
$dbstage->position(1)->duration(50)->store; # Configure stage. |
667 |
$dbstage->position(1)->duration(50)->store; # Configure stage. |
668 |
# Configure item |
668 |
# Configure item |
669 |
$dbitem->itemnumber->holdingbranch($firstbranch)->store; |
669 |
$dbitem->item->holdingbranch($firstbranch)->store; |
670 |
$dbitem->itemnumber->homebranch($firstbranch)->store; |
670 |
$dbitem->item->homebranch($firstbranch)->store; |
671 |
# Sanity check |
671 |
# Sanity check |
672 |
is($dbitem->stage->stage_id, $dbstage->stage_id, "Stage sanity check."); |
672 |
is($dbitem->stage->stage_id, $dbstage->stage_id, "Stage sanity check."); |
673 |
|
673 |
|
Lines 691-697
subtest "Tests for toggle_indemand" => sub {
Link Here
|
691 |
# Test an item in transfer, toggle cancels transfer and resets indemand. |
691 |
# Test an item in transfer, toggle cancels transfer and resets indemand. |
692 |
ok($dbitem->advance, "Advancement done."); |
692 |
ok($dbitem->advance, "Advancement done."); |
693 |
$dbitem->get_from_storage; |
693 |
$dbitem->get_from_storage; |
694 |
my $transfer = $dbitem->itemnumber->get_transfer; |
694 |
my $transfer = $dbitem->item->get_transfer; |
695 |
is(ref($transfer), 'Koha::Item::Transfer', 'Item set to in transfer as expected'); |
695 |
is(ref($transfer), 'Koha::Item::Transfer', 'Item set to in transfer as expected'); |
696 |
is($transfer->frombranch, $firstbranch, 'Transfer from set correctly'); |
696 |
is($transfer->frombranch, $firstbranch, 'Transfer from set correctly'); |
697 |
is($transfer->tobranch, $secondbranch, 'Transfer to set correctly'); |
697 |
is($transfer->tobranch, $secondbranch, 'Transfer to set correctly'); |
Lines 703-709
subtest "Tests for toggle_indemand" => sub {
Link Here
|
703 |
isnt($updated_transfer->datearrived, undef, 'Transfer datearrived set as expected'); |
703 |
isnt($updated_transfer->datearrived, undef, 'Transfer datearrived set as expected'); |
704 |
is($dbitem->indemand, 0, "Item retains indemand as expected."); |
704 |
is($dbitem->indemand, 0, "Item retains indemand as expected."); |
705 |
is($dbitem->stage_id, $dbstage->id, 'Item stage reset as expected.'); |
705 |
is($dbitem->stage_id, $dbstage->id, 'Item stage reset as expected.'); |
706 |
is($dbitem->itemnumber->homebranch, $firstbranch, 'Item homebranch reset as expected.'); |
706 |
is($dbitem->item->homebranch, $firstbranch, 'Item homebranch reset as expected.'); |
707 |
|
707 |
|
708 |
$schema->storage->txn_rollback; |
708 |
$schema->storage->txn_rollback; |
709 |
}; |
709 |
}; |
710 |
- |
|
|