Skip to content

Commit 3c83178

Browse files
author
Joonas Kylmälä
authored
Filter out cancelled transfers when checking whether item is in transit (#8)
In newer Koha versions it is possible to cancel a transfer by setting a timestamp to branchtransfers.datecancelled column. These transfer rows in the DB are not active transfers and should be filtered out when checking whether item is in transit or not.
1 parent 9374e3e commit 3c83178

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • Koha/Plugin/Fi/KohaSuomi/DI/Koha/Availability/Checks

Koha/Plugin/Fi/KohaSuomi/DI/Koha/Availability/Checks/Item.pm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use C4::Context;
2727
use C4::Reserves;
2828

2929
use Koha::AuthorisedValues;
30+
use Koha::Database;
3031
use Koha::DateUtils;
3132
use Koha::Holds;
3233
use Koha::ItemTypes;
@@ -427,10 +428,12 @@ Koha::Exceptions::Item::Transfer additional fields:
427428
sub transfer {
428429
my ($self) = @_;
429430

431+
my $is_cancellable = Koha::Database->new()->schema()->resultset('Branchtransfer')->result_source->has_column('datecancelled');
430432
my $transfer = Koha::Item::Transfers->search({
431433
itemnumber => $self->item->itemnumber,
432434
datesent => { '!=', undef },
433435
datearrived => undef,
436+
( $is_cancellable ? ( datecancelled => undef ) : () ),
434437
})->next;
435438
if ($transfer) {
436439
return Koha::Plugin::Fi::KohaSuomi::DI::Koha::Exceptions::Item::Transfer->new(

0 commit comments

Comments
 (0)