Lines 129-135
sub needs_advancing {
Link Here
|
129 |
); |
129 |
); |
130 |
my $duration = DateTime::Duration |
130 |
my $duration = DateTime::Duration |
131 |
->new( days => $self->stage->duration ); |
131 |
->new( days => $self->stage->duration ); |
132 |
if ( $arrival + $duration le DateTime->now ) { |
132 |
if ( $arrival + $duration le dt_from_string() ) { |
133 |
return 1; |
133 |
return 1; |
134 |
} else { |
134 |
} else { |
135 |
return 0; |
135 |
return 0; |
Lines 155-161
sub repatriate {
Link Here
|
155 |
'itemnumber' => $self->itemnumber_id, |
155 |
'itemnumber' => $self->itemnumber_id, |
156 |
'frombranch' => $self->itemnumber->holdingbranch, |
156 |
'frombranch' => $self->itemnumber->holdingbranch, |
157 |
'tobranch' => $self->stage->branchcode_id, |
157 |
'tobranch' => $self->stage->branchcode_id, |
158 |
'datesent' => DateTime->now, |
158 |
'datesent' => dt_from_string(), |
159 |
'comments' => $msg, |
159 |
'comments' => $msg, |
160 |
'reason' => "StockrotationRepatriation" |
160 |
'reason' => "StockrotationRepatriation" |
161 |
})->store; |
161 |
})->store; |
Lines 185-198
sub advance {
Link Here
|
185 |
my $transfer = Koha::Item::Transfer->new({ |
185 |
my $transfer = Koha::Item::Transfer->new({ |
186 |
'itemnumber' => $self->itemnumber_id, |
186 |
'itemnumber' => $self->itemnumber_id, |
187 |
'frombranch' => $item->holdingbranch, |
187 |
'frombranch' => $item->holdingbranch, |
188 |
'datesent' => DateTime->now, |
188 |
'datesent' => dt_from_string(), |
189 |
'reason' => "StockrotationAdvance" |
189 |
'reason' => "StockrotationAdvance" |
190 |
}); |
190 |
}); |
191 |
|
191 |
|
192 |
if ( $self->indemand && !$self->fresh ) { |
192 |
if ( $self->indemand && !$self->fresh ) { |
193 |
$self->indemand(0)->store; # De-activate indemand |
193 |
$self->indemand(0)->store; # De-activate indemand |
194 |
$transfer->tobranch($self->stage->branchcode_id); |
194 |
$transfer->tobranch($self->stage->branchcode_id); |
195 |
$transfer->datearrived(DateTime->now); |
195 |
$transfer->datearrived(dt_from_string()); |
196 |
} else { |
196 |
} else { |
197 |
# Find and update our stage. |
197 |
# Find and update our stage. |
198 |
my $stage = $self->stage; |
198 |
my $stage = $self->stage; |
Lines 200-206
sub advance {
Link Here
|
200 |
if ( $self->fresh ) { # Just added to rota |
200 |
if ( $self->fresh ) { # Just added to rota |
201 |
$new_stage = $self->stage->first_sibling || $self->stage; |
201 |
$new_stage = $self->stage->first_sibling || $self->stage; |
202 |
$transfer->tobranch($new_stage->branchcode_id); |
202 |
$transfer->tobranch($new_stage->branchcode_id); |
203 |
$transfer->datearrived(DateTime->now) # Already at first branch |
203 |
$transfer->datearrived(dt_from_string()) # Already at first branch |
204 |
if $item->holdingbranch eq $new_stage->branchcode_id; |
204 |
if $item->holdingbranch eq $new_stage->branchcode_id; |
205 |
$self->fresh(0)->store; # Reset fresh |
205 |
$self->fresh(0)->store; # Reset fresh |
206 |
} elsif ( !$stage->last_sibling ) { # Last stage |
206 |
} elsif ( !$stage->last_sibling ) { # Last stage |
Lines 208-214
sub advance {
Link Here
|
208 |
# Revert to first stage. |
208 |
# Revert to first stage. |
209 |
$new_stage = $stage->first_sibling || $stage; |
209 |
$new_stage = $stage->first_sibling || $stage; |
210 |
$transfer->tobranch($new_stage->branchcode_id); |
210 |
$transfer->tobranch($new_stage->branchcode_id); |
211 |
$transfer->datearrived(DateTime->now); |
211 |
$transfer->datearrived(dt_from_string()); |
212 |
} else { |
212 |
} else { |
213 |
$self->delete; # StockRotationItem is done. |
213 |
$self->delete; # StockRotationItem is done. |
214 |
return 1; |
214 |
return 1; |