View | Details | Raw Unified | Return to bug 28520
Collapse All | Expand All

(-)a/Koha/Hold.pm (-9 lines)
Lines 511-527 Cancel a hold: Link Here
511
511
512
sub cancel {
512
sub cancel {
513
    my ( $self, $params ) = @_;
513
    my ( $self, $params ) = @_;
514
515
    $self->_result->result_source->schema->txn_do(
514
    $self->_result->result_source->schema->txn_do(
516
        sub {
515
        sub {
517
            if ( $self->is_in_transit ) {
518
                my $transfer = $self->item->get_transfer;
519
                # NOTE: Transfers are well bound with Holds.. as such we have to check that there is actually a
520
                # transfer enqueued and in transit here prior to trying to cancel it.
521
                if ( $transfer && $transfer->in_transit ) {
522
                    $transfer->cancel({ reason => 'CancelReserve', force => 1 });
523
                }
524
            }
525
            $self->cancellationdate( dt_from_string->strftime( '%Y-%m-%d %H:%M:%S' ) );
516
            $self->cancellationdate( dt_from_string->strftime( '%Y-%m-%d %H:%M:%S' ) );
526
            $self->priority(0);
517
            $self->priority(0);
527
            $self->cancellation_reason( $params->{cancellation_reason} );
518
            $self->cancellation_reason( $params->{cancellation_reason} );
(-)a/Koha/Item/Transfer.pm (-21 / +4 lines)
Lines 52-71 sub item { Link Here
52
    return Koha::Item->_new_from_dbic($item_rs);
52
    return Koha::Item->_new_from_dbic($item_rs);
53
}
53
}
54
54
55
=head3 from_library
56
57
  my $from_library = $transfer->from_library;
58
59
Returns the associated from_library for this transfer.
60
61
=cut
62
63
sub from_library {
64
    my ($self) = @_;
65
    my $from_library_rs = $self->_result->frombranch;
66
    return Koha::Library->_new_from_dbic($from_library_rs);
67
}
68
69
=head3 to_library
55
=head3 to_library
70
56
71
  my $to_library = $transfer->to_library;
57
  my $to_library = $transfer->to_library;
Lines 173-187 sub cancel { Link Here
173
      ->store;
159
      ->store;
174
160
175
    # Set up return transfer if transfer was force cancelled whilst in transit
161
    # Set up return transfer if transfer was force cancelled whilst in transit
176
    # and we were not notified that the transfer is being replaced.
177
    # NOTE: We don't catch here, as we're happy to fail if there are already
162
    # NOTE: We don't catch here, as we're happy to fail if there are already
178
    # other transfers in the queue.
163
    # other transfers in the queue.
179
    if ($in_transit && !$params->{replace}) {
164
    try {
180
        try {
165
        $self->item->request_transfer(
181
            $self->item->request_transfer(
166
            { to => $self->from_library, reason => 'TransferCancellation' } );
182
                { to => $self->from_library, reason => 'TransferCancellation' } );
167
    };
183
        };
184
    }
185
168
186
    return $self;
169
    return $self;
187
}
170
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-3 lines)
Lines 134-141 Link Here
134
                                             [%- CASE 'Reserve' -%]Reserve
134
                                             [%- CASE 'Reserve' -%]Reserve
135
                                             [%- CASE 'LostReserve' -%]Lost reserve
135
                                             [%- CASE 'LostReserve' -%]Lost reserve
136
                                             [%- CASE 'CancelReserve' -%]Cancelled reserve
136
                                             [%- CASE 'CancelReserve' -%]Cancelled reserve
137
                                             [%- CASE 'TransferCancellation' -%]Transfer was cancelled whilst in transit
138
                                             [%- CASE -%][% trigger | html %]
139
                                         [%- END -%]
137
                                         [%- END -%]
140
                                     </p>
138
                                     </p>
141
                                 </div>
139
                                 </div>
142
- 

Return to bug 28520