https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34756

--- Comment #23 from Tomás Cohen Arazi (tcohen) <[email protected]> ---
(In reply to Baptiste Wojtkowski (bwoj) from comment #22)
> (In reply to Tomás Cohen Arazi (tcohen) from comment #21)
> > Maybe I didn’t explain the whole idea well enough.
> > 
> > I think the cancel() method needs to be added a parameter controlling the
> > behavior. And the controller would pass it if conditions are met.
> 
> Oh.. I missread, very sorry.
> 
> I still don't get your point, I'm using transfer->cancel but I have no clue
> on how I would change it... Do you mean hold->cancel(), that would refuse
> cancelling if there is no explicit reference to the existing transfer ?

I mean something like

```
diff --git a/Koha/Hold.pm b/Koha/Hold.pm
index b3bf4a02b76..b4d185901e1 100644
--- a/Koha/Hold.pm
+++ b/Koha/Hold.pm
@@ -675,6 +675,8 @@ my $cancel_hold = $hold->cancel(
         [ charge_cancel_fee   => 1||0, ]
         [ cancellation_reason => $cancellation_reason, ]
         [ skip_holds_queue    => 1||0 ]
+        [ cancel_transfer     => 1||0 ]
+        [ cancel_transfer_reason => 'some valid transfer' ]
     }
 );

@@ -703,6 +705,14 @@ sub cancel {
             $self->cancellation_reason( $params->{cancellation_reason} );
             $self->store();

+            my $item = $self->item;
+
+            if ( $params->{cancel_transfer} ) {
+                my $transfer = $item->get_transfer();
+                $transfer->cancel( $params->{cancel_transfer_reason} //
'Manual' )
+                    if $transfer;
+            }
+
             my $dbh = $self->_result->result_source->schema->storage->dbh;
             $dbh->do(
                 q{
@@ -766,7 +776,6 @@ sub cancel {

             # and, if desired, charge a cancel fee
             if ( $params->{'charge_cancel_fee'} ) {
-                my $item   = $self->item;
                 my $charge =
Koha::CirculationRules->get_effective_expire_reserves_charge(
                     {
                         itemtype     => $item->effective_itemtype,

```

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to