Bug 24296: Update stockrotation process to use branchtransfers.reason

This patch updates all occurences of stockrotation related lookups of
branchtransfers status from using the 'comments' field to using the new
'reason' field.

Test plan:
1) Work through the process of creating a stock rotation plan and adding
   items to the plan.. no errors should be encoutered during this process.
2) Run the stockrotation cronjob to move some items on.. no errors
   should be encountered.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2020-01-16 09:52:20 +00:00
parent b43a4b2756
commit d06fbc124e
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
2 changed files with 10 additions and 9 deletions

View File

@ -119,7 +119,7 @@ sub needs_advancing {
return 0 if $self->itemnumber->get_transfer; # intransfer: don't advance.
return 1 if $self->fresh; # Just on rota: advance.
my $completed = $self->itemnumber->_result->branchtransfers->search(
{ 'comments' => "StockrotationAdvance" },
{ 'reason' => "StockrotationAdvance" },
{ order_by => { -desc => 'datearrived' } }
);
# Do maths on whether we need to be moved on.
@ -156,7 +156,8 @@ sub repatriate {
'frombranch' => $self->itemnumber->holdingbranch,
'tobranch' => $self->stage->branchcode_id,
'datesent' => DateTime->now,
'comments' => $msg || "StockrotationRepatriation",
'comments' => $msg,
'reason' => "StockrotationRepatriation"
})->store;
$self->itemnumber->homebranch($self->stage->branchcode_id)->store;
return $transfer_stored;
@ -185,7 +186,7 @@ sub advance {
'itemnumber' => $self->itemnumber_id,
'frombranch' => $item->holdingbranch,
'datesent' => DateTime->now,
'comments' => "StockrotationAdvance"
'reason' => "StockrotationAdvance"
});
if ( $self->indemand && !$self->fresh ) {

View File

@ -175,7 +175,7 @@ subtest "Tests for needs_advancing." => sub {
'tobranch' => $dbitem->stage->branchcode_id,
'datesent' => DateTime->now,
'datearrived' => undef,
'comments' => "StockrotationAdvance",
'reason' => "StockrotationAdvance",
})->store;
# Test item will not be advanced if in transit.
@ -307,7 +307,7 @@ subtest "Tests for investigate (singular)." => sub {
'tobranch' => $dbitem->itemnumber->homebranch,
'datesent' => DateTime->now,
'datearrived' => DateTime->now,
'comments' => "StockrotationAdvance",
'reason' => "StockrotationAdvance",
})->store;
is($dbitem->investigate->{reason}, 'repatriation', "older item repatriates.");
@ -323,7 +323,7 @@ subtest "Tests for investigate (singular)." => sub {
'tobranch' => $dbitem->stage->branchcode_id,
'datesent' => DateTime->now,
'datearrived' => DateTime->now,
'comments' => "StockrotationAdvance",
'reason' => "StockrotationAdvance",
})->store;
$dbitem->itemnumber->homebranch($dbitem->stage->branchcode_id)->store;
$dbitem->itemnumber->holdingbranch($dbitem->stage->branchcode_id)->store;
@ -342,7 +342,7 @@ subtest "Tests for investigate (singular)." => sub {
'tobranch' => $dbitem->stage->branchcode_id,
'datesent' => DateTime->now - $sent_duration,
'datearrived' => DateTime->now - $arrived_duration,
'comments' => "StockrotationAdvance",
'reason' => "StockrotationAdvance",
})->store;
$dbitem->itemnumber->homebranch($dbitem->stage->branchcode_id)->store;
$dbitem->itemnumber->holdingbranch($dbitem->stage->branchcode_id)->store;
@ -362,7 +362,7 @@ subtest "Tests for investigate (singular)." => sub {
'tobranch' => $dbitem->stage->branchcode_id,
'datesent' => DateTime->now - $sent_duration,
'datearrived' => DateTime->now - $arrived_duration,
'comments' => "StockrotationAdvance",
'reason' => "StockrotationAdvance",
})->store;
$dbitem->itemnumber->homebranch($dbitem->stage->branchcode_id)->store;
$dbitem->itemnumber->holdingbranch($dbitem->stage->branchcode_id)->store;
@ -382,7 +382,7 @@ subtest "Tests for investigate (singular)." => sub {
'tobranch' => $dbitem->stage->branchcode_id,
'datesent' => DateTime->now - $sent_duration,
'datearrived' => DateTime->now - $arrived_duration,
'comments' => "StockrotationAdvance",
'reason' => "StockrotationAdvance",
})->store;
is($dbitem->investigate->{reason}, 'repatriation',
"Item advances, but not at stage branch.");